ajeetdsouza/loxcraft

Language tooling for the Lox programming language.

Rust

366

102 commits

updated Aug 24, 2026

See the code

README

loxcraft

crates.io

Language tooling for the Lox programming language.

Installation

cargo install loxcraft --locked

Features

Screenshots

Screenshot of REPL

Screenshot of online playground

Benchmarks

Time taken to execute the benchmark suite (lower is better):

Benchmarkloxcraftcloxjlox
binary_tree8.29s8.13s26.41s
equality_17.17s7.73s10.01s
equality_28.39s9.66s14.30s
fib10.90s10.09s21.89s
instantiation10.83s12.84s14.24s
invocation9.93s8.93s15.77s
method_call11.01s9.12s62.03s
properties10.05s5.98s69.77s
string_equality_17.76s7.66s34.08s
string_equality_210.78s10.52s36.25s
trees9.97s8.72s72.87s
zoo10.67s6.18s100.10s

Benchmarks

Benchmarks were run with the following configuration:

  • Device: Apple MacBook Pro (16-inch, 2021)
  • Processor: M1 Pro
  • RAM: 16 GiB
  • OS: macOS Ventura 13.2
  • Rust: 1.66.1
  • Apple Clang: 14.0.0
  • Oracle JDK: 19.0.2

References

So you want to build your own programming language! Here's some extremely helpful resources I referred to when building loxcraft:

  • Crafting Interpreters 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.
  • Bob Nystrom also has a blog, and his articles are really well written (see his post on Pratt parsers / garbage collectors). I'd also recommend going through the source code for Wren, 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.
  • Writing an Interpreter in Go / Writing a Compiler in Go 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).
  • Make a Language by Luna Razzaghipour is a fantastic series. Notably, this book constructs its syntax tree using the same library used by rust-analyzer (rowan).
  • Simple but Powerful Pratt Parsing 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!
  • rust-langdev has a lot of libraries for building compilers in Rust. To start off, I'd suggest logos for lexing, LALRPOP / chumsky for parsing, and rust-gc for garbage collection.
  • Learning Rust with Entirely Too Many Linked Lists is a quick tutorial on unsafe Rust, which you'll need if you're building a garbage collector yourself.
  • If you want some inspiration for a production-grade language built in Rust, you might want to go through the source code of Starlark and Gluon.

Contributors

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

ajeetdsouza/loxcraft

Language tooling for the Lox programming language.

Rust

366

102 commits

updated Aug 24, 2026

See the code

README

loxcraft

crates.io

Language tooling for the Lox programming language.

Installation

cargo install loxcraft --locked

Features

Screenshots

Screenshot of REPL

Screenshot of online playground

Benchmarks

Time taken to execute the benchmark suite (lower is better):

Benchmarkloxcraftcloxjlox
binary_tree8.29s8.13s26.41s
equality_17.17s7.73s10.01s
equality_28.39s9.66s14.30s
fib10.90s10.09s21.89s
instantiation10.83s12.84s14.24s
invocation9.93s8.93s15.77s
method_call11.01s9.12s62.03s
properties10.05s5.98s69.77s
string_equality_17.76s7.66s34.08s
string_equality_210.78s10.52s36.25s
trees9.97s8.72s72.87s
zoo10.67s6.18s100.10s

Benchmarks

Benchmarks were run with the following configuration:

  • Device: Apple MacBook Pro (16-inch, 2021)
  • Processor: M1 Pro
  • RAM: 16 GiB
  • OS: macOS Ventura 13.2
  • Rust: 1.66.1
  • Apple Clang: 14.0.0
  • Oracle JDK: 19.0.2

References

So you want to build your own programming language! Here's some extremely helpful resources I referred to when building loxcraft:

  • Crafting Interpreters 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.
  • Bob Nystrom also has a blog, and his articles are really well written (see his post on Pratt parsers / garbage collectors). I'd also recommend going through the source code for Wren, 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.
  • Writing an Interpreter in Go / Writing a Compiler in Go 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).
  • Make a Language by Luna Razzaghipour is a fantastic series. Notably, this book constructs its syntax tree using the same library used by rust-analyzer (rowan).
  • Simple but Powerful Pratt Parsing 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!
  • rust-langdev has a lot of libraries for building compilers in Rust. To start off, I'd suggest logos for lexing, LALRPOP / chumsky for parsing, and rust-gc for garbage collection.
  • Learning Rust with Entirely Too Many Linked Lists is a quick tutorial on unsafe Rust, which you'll need if you're building a garbage collector yourself.
  • If you want some inspiration for a production-grade language built in Rust, you might want to go through the source code of Starlark and Gluon.

Contributors

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

Project health

crates.io

Latest release

0.1.1 · Apr 24, 2023

Releases this year

0

Significant stargazers

Bedis Nbiba

98 followers · starred Apr 2023

Bryant Biggs

654 followers · starred Jun 2024

Bob Nystrom

11,137 followers · starred Apr 2023

Vincent Prouillet

876 followers · starred Apr 2023