{"id":13838482,"url":"https://github.com/ajeetdsouza/loxcraft","last_synced_at":"2025-05-15T16:02:19.822Z","repository":{"id":65539198,"uuid":"215614449","full_name":"ajeetdsouza/loxcraft","owner":"ajeetdsouza","description":"Language tooling for the Lox programming language.","archived":false,"fork":false,"pushed_at":"2025-02-25T04:14:12.000Z","size":788,"stargazers_count":298,"open_issues_count":1,"forks_count":13,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-31T21:43:46.918Z","etag":null,"topics":["bytecode","bytecode-interpreter","compiler","compiler-construction","compiler-design","crafting-interpreters","hacktoberfest","interpreter","lalrpop","language-server-protocol","lox","lox-language","programming-language","repl","rust","scripting-language","tree-sitter","virtual-machine","webassembly"],"latest_commit_sha":null,"homepage":"https://ajeetdsouza.github.io/loxcraft/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajeetdsouza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-16T18:14:35.000Z","updated_at":"2025-03-30T20:02:00.000Z","dependencies_parsed_at":"2024-01-12T18:39:43.764Z","dependency_job_id":"2e977ca2-753f-4763-a00a-92992a241b74","html_url":"https://github.com/ajeetdsouza/loxcraft","commit_stats":{"total_commits":82,"total_committers":2,"mean_commits":41.0,"dds":0.04878048780487809,"last_synced_commit":"6aa74cf221d5c6d6a52324f74f721c074f23800f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajeetdsouza%2Floxcraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajeetdsouza%2Floxcraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajeetdsouza%2Floxcraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajeetdsouza%2Floxcraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajeetdsouza","download_url":"https://codeload.github.com/ajeetdsouza/loxcraft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615479,"owners_count":20967183,"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":["bytecode","bytecode-interpreter","compiler","compiler-construction","compiler-design","crafting-interpreters","hacktoberfest","interpreter","lalrpop","language-server-protocol","lox","lox-language","programming-language","repl","rust","scripting-language","tree-sitter","virtual-machine","webassembly"],"created_at":"2024-08-04T15:01:59.119Z","updated_at":"2025-04-07T22:04:42.997Z","avatar_url":"https://github.com/ajeetdsouza.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003c!-- markdownlint-configure-file {\n  \"MD033\": false,\n  \"MD041\": false\n} --\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n# loxcraft\n\n[![crates.io](https://img.shields.io/crates/v/loxcraft)](https://crates.io/crates/loxcraft)\n\n**Language tooling** for the **[Lox programming language](http://craftinginterpreters.com/)**.\n\n\u003c/div\u003e\n\n## Installation\n\n```sh\ncargo install loxcraft --locked\n```\n\n## Features\n\n- [x] Bytecode compiler + garbage collected runtime\n- [x] Online playground, via WebAssembly ([try it out!](https://ajeetdsouza.github.io/loxcraft/))\n- [x] REPL\n- [x] Syntax highlighting, via [tree-sitter-lox](https://github.com/ajeetdsouza/tree-sitter-lox)\n- [x] IDE integration, via the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/)\n\n## Screenshots\n\n![Screenshot of REPL](https://user-images.githubusercontent.com/1777663/216910834-4ea40427-34d7-43e0-8ba0-06638dfb0fa2.png)\n\n![Screenshot of online playground](https://user-images.githubusercontent.com/1777663/201918922-39b567fe-9375-4990-8224-e540cf3266bc.png)\n\n## Benchmarks\n\nTime taken to execute the [benchmark suite](https://github.com/ajeetdsouza/loxcraft/tree/main/res/benchmarks) (lower is better):\n\n| Benchmark         | loxcraft | clox   | jlox    |\n| ----------------- | -------- | ------ | ------- |\n| binary_tree       | 8.29s    | 8.13s  | 26.41s  |\n| equality_1        | 7.17s    | 7.73s  | 10.01s  |\n| equality_2        | 8.39s    | 9.66s  | 14.30s  |\n| fib               | 10.90s   | 10.09s | 21.89s  |\n| instantiation     | 10.83s   | 12.84s | 14.24s  |\n| invocation        | 9.93s    | 8.93s  | 15.77s  |\n| method_call       | 11.01s   | 9.12s  | 62.03s  |\n| properties        | 10.05s   | 5.98s  | 69.77s  |\n| string_equality_1 | 7.76s    | 7.66s  | 34.08s  |\n| string_equality_2 | 10.78s   | 10.52s | 36.25s  |\n| trees             | 9.97s    | 8.72s  | 72.87s  |\n| zoo               | 10.67s   | 6.18s  | 100.10s |\n\n![Benchmarks](https://user-images.githubusercontent.com/1777663/216903842-5d626770-e599-491e-8e09-83b2f956cf34.svg)\n\nBenchmarks were run with the following configuration:\n\n- Device: Apple MacBook Pro (16-inch, 2021)\n- Processor: M1 Pro\n- RAM: 16 GiB\n- OS: macOS Ventura 13.2\n- Rust: 1.66.1\n- Apple Clang: 14.0.0\n- Oracle JDK: 19.0.2\n\n## References\n\nSo you want to build your own programming language! Here's some extremely helpful resources I referred to when building `loxcraft`:\n\n- [Crafting Interpreters](https://craftinginterpreters.com/) by Bob Nystrom: this book introduces you to a teaching programming language named Lox, walks you through implementing a full-featured tree walking interpreter for in in Java, and then shows you how to build a bytecode compiler + VM for it in C. I cannot recommend this book enough.\n- Bob Nystrom also has a [blog](https://journal.stuffwithstuff.com/), and his articles are really well written (see his post on [Pratt parsers](https://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/) / [garbage collectors](https://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/)). I'd also recommend going through the source code for [Wren](https://wren.io/), it shares a lot of code with Lox. Despite the deceptive simplicity of the implementation, it (like Lox) is incredibly fast - it's a great way to learn how to build production grade compilers in general.\n- [Writing an Interpreter in Go](https://interpreterbook.com/) / [Writing a Compiler in Go](https://compilerbook.com/) by Thorsten Ball is a great set of books. Since it uses Go, it piggybacks on Go's garbage collector instead of building one of its own. This simplifies the implementation, making this book a lot easier to grok - but it also means that you may have trouble porting it to a non-GC language (like Rust).\n- [Make a Language](https://lunacookies.github.io/lang/) by Luna Razzaghipour is a fantastic series. Notably, this book constructs its syntax tree using the same library used by [rust-analyzer](https://rust-analyzer.github.io/) ([rowan](https://github.com/rust-analyzer/rowan)).\n- [Simple but Powerful Pratt Parsing](https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html) by Alex Kladov (one of the main authors behind rust-analyzer) is a great tutorial on building a parser in Rust. The rest of his blog is incredible too!\n- [rust-langdev](https://github.com/Kixiron/rust-langdev) has a lot of libraries for building compilers in Rust. To start off, I'd suggest [logos](https://github.com/maciejhirsz/logos) for lexing, [LALRPOP](https://lalrpop.github.io/lalrpop/) / [chumsky](https://github.com/zesterer/chumsky) for parsing, and [rust-gc](https://github.com/Manishearth/rust-gc) for garbage collection.\n- [Learning Rust with Entirely Too Many Linked Lists](https://rust-unofficial.github.io/too-many-lists/) is a quick tutorial on unsafe Rust, which you'll need if you're building a garbage collector yourself.\n- If you want some inspiration for a production-grade language built in Rust, you might want to go through the source code of [Starlark](https://github.com/facebook/starlark-rust) and [Gluon](https://github.com/gluon-lang/gluon).\n\n## Contributors\n\n- [Ajeet D'Souza](https://github.com/ajeetdsouza)\n- [Kartik Sharma](https://github.com/crazystylus)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajeetdsouza%2Floxcraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajeetdsouza%2Floxcraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajeetdsouza%2Floxcraft/lists"}