{"id":13678722,"url":"https://github.com/zesterer/forge","last_synced_at":"2025-06-13T23:41:16.394Z","repository":{"id":66134585,"uuid":"172063134","full_name":"zesterer/forge","owner":"zesterer","description":"A lightweight, elegant scripting language with built-in Rust-FFI.","archived":false,"fork":false,"pushed_at":"2019-11-01T12:37:24.000Z","size":99,"stargazers_count":163,"open_issues_count":4,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-02T04:35:13.378Z","etag":null,"topics":["compiler","interpreter","language","parser"],"latest_commit_sha":null,"homepage":"https://forge.jsbarretto.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zesterer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-22T12:31:33.000Z","updated_at":"2025-02-05T23:45:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"336e43d4-3088-49cc-b46d-da3a36857d1a","html_url":"https://github.com/zesterer/forge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zesterer/forge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fforge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fforge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fforge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fforge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zesterer","download_url":"https://codeload.github.com/zesterer/forge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fforge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259737638,"owners_count":22903843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","interpreter","language","parser"],"created_at":"2024-08-02T13:00:57.491Z","updated_at":"2025-06-13T23:41:16.353Z","avatar_url":"https://github.com/zesterer.png","language":"Rust","readme":"# Forge\n\nForge is a dynamically-typed language written in Rust. It is inspired by JavaScript, Rust, Python and [Rhai](https://github.com/jonathandturner/rhai).\nIn the future, you'll be able to use Forge as a general-purpose lightweight scripting language in your applications.\n\n[**You can try out Forge in your browser here!**](https://forge.jsbarretto.com)\n\n## Example\n\n```py\n# A function to square numbers\nvar square = |x| {\n\treturn x * x;\n};\n\nvar n = input \"How many squares? \";\n\n# Create a list of squares\nvar squares = [];\nfor x in 1..n + 1 {\n\tsquares += square(x);\n}\n\n# Iterate and print squares\nfor square in squares {\n\tprint square;\n}\n```\n\n## Goals\n\n- Simple, familiar syntax\n- Lightweight, quick to parse\n- Moderately fast execution speeds\n- Well-considered, 'common-sense' design\n- Useful, informative error messages\n- Easy to build into an existing codebase\n- Python-like REPL prompt\n\n## Usage\n\nUsing Forge is similar in principle to using Python.\nOnce compiled, running the shell or executing scripts with the interpreter is trivial.\nYou'll need to compile the `cli/` crate to gain access to the interpreter binary.\n\nTo access the REPL shell, run:\n\n```\n$ forge\n```\n\nTo execute a script, run:\n\n```\n$ forge my_script.fg\n```\n\n## Roadmap\n\n- [x] Numbers, strings and booleans\n- [x] Arithmetic operators *`+`, `-`, `*`, `/`, `%`*\n- [x] Logical operators *`and`, `or`, `xor`, `==`, `!=`, `!`, `\u003c`, `\u003c=`, `\u003e`, `\u003e=`*\n- [x] `if`/`else` statements\n- [x] `while` and `for` statements\n- [x] Assignment operators *`=`, `+=`, `-=`, `*=`, `/=`, `%=`*\n- [x] Scoped variable declaration\n- [x] Function objects\n- [x] Function calling\n- [x] Rust-to-Forge object interface\n- [x] Rust-to-Forge type coercion\n- [x] Rust callbacks *Only Rust closures with no arguments or functions are currently supported*\n- [x] Iterators\n- [x] Rust-to-Forge iterators\n- [x] Lists\n- [x] List splicing\n- [x] Indexing and ranges\n- [x] `clone` and `mirror` operators\n- [x] Lvalues vs rvalues\n- [x] Maps\n- [x] Map construction\n- [ ] Map iteration\n- [ ] Immutability by default\n- [ ] Structures\n- [ ] Enums\n- [ ] Objects\n- [ ] Modules as objects\n- [ ] Scoped constants\n- [ ] C-based FFI for non-Rust integration\n- [ ] AST optimisation\n- [ ] Bytecode generation\n- [ ] Bytecode interpretation\n- [ ] LLVM-driven recompilation\n\n## Some Syntax Examples\n\nList splicing\n\n```\n\u003e\u003e var my_list = [0, 1, 2, 3];\n\u003e\u003e my_list[1..2]\n[1]\n\u003e\u003e my_list[1..3] = [\"this\", \"is\", \"a\", \"list\", \"splice\"];\n\u003e\u003e my_list\n[0, this, is, a, list, splice, 3]\n```\n\nString splicing\n\n```\n\u003e\u003e \"Hello, world!\"[7..12]\nworld\n\u003e\u003e var test = \"An apple is what I am eating\";\n\u003e\u003e test[3..8] = \"pear\";\n\u003e\u003e test\nAn pear is what I am eating\n\u003e\u003e\n```\n\n## Design\n\n### Types\n\nForge has several distinct types:\n\n- Number *64-bit, floating-point*\n- String *unicode-compliant*\n- Char *unicode-compliant*\n- Boolean\n- Range\n- Function\n- List\n- Map\n- Object *Currently unimplemented*\n- Custom *Used to call to and from Rust*\n- Null\n\n### Things To Do\n\n- Investigate design features that would make the dynamic type system easier to optimise\n\n### Interpreter\n\nCurrently, Forge is only implemented as an AST-walking interpreter.\nIn the future, I aim to generate more efficient low-level bytecode for the language.\nI also aim to implement many a variety of optimisations throughout the compilation process.\n\n### Error Messages\n\nForge aims to produce the most useful, informative and intelligence error messages it can.\nErrors can be emitted at compile-time or run-time. Below are a few examples.\n\nParser errors:\n\n```\n[ERROR] Parsing error at 1:45...\n   ...while parsing if-else statement...\n   ...while parsing print statement...\n        1| var x = 1; if x \u003e 2 { print \"Hello, world!\" oops; }\n         |                                             ^^^^\n   Expected ';', found identifier 'oops'.\n```\n\nRuntime errors:\n\n```\n[ERROR] Runtime error at 1:21...\n        1| var p = true; while p { print \"On the next iteration, p will be null\"; p = null; }\n         |                     ^\n   Cannot determine the truthiness of value of type 'null'. Did you mean for this to be a bool?\n```\n\nRuntime errors that produce error messages that reference code written during the previous declaration of a function object:\n\n```\n[ERROR] Runtime error at 1:10...\n        1| var say_hello = || { print \"Hello, world!\"; };\n         |                 ^^\n        1| say_hello(1); # Wrong number of parameters\n         |          ^^^\n   Tried to call a function with the wrong number of parameters. Expected 0, found 1.\n```\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzesterer%2Fforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fforge/lists"}