a work-in-progress Ruby compiler, written in Ruby and Rust
Natalie is a work-in-progress Ruby implementation.
It provides an ahead-of-time compiler, written in Ruby, using LLVM with a Rust runtime. Also, the language has a REPL that performs incremental compilation.

There is much work left to do before this is useful. Please let me know if you want to help!
Natalie is tested on macOS and Ubuntu Linux. Windows is not yet supported.
Install Nix, then enter the development shell (or let direnv enter it for you) and build:
nix develop
bundle install
rake
REPL:
bin/natalie
Run a Ruby script:
bin/natalie examples/hello.rb
Compile a file to an executable:
bin/natalie -c hello examples/hello.rb
./hello
Natalie runs ruby/spec and its own spec-style tests with MSpec. Initialize
ext/mspec with git submodule update --init ext/mspec if it is missing.
To run a single spec:
bin/natalie -Itest/support -rspec spec/core/string/strip_spec.rb
This will run the tests and tell you if there are any failures.
If you want to run all the tests that we expect to pass, you can run:
rake test
Lastly, if you need to run a handful of tests locally, you can use the
test/runner.rb helper script:
bin/natalie test/runner.rb test/natalie/if_test.rb test/natalie/loop_test.rb
The files in spec/ come from the excellent ruby/spec
project, which is a community-curated repo of test files that any Ruby
implementation can use to compare its conformance to what MRI (Matz's Ruby
Interpreter) does. We copy specs over as we implement the part of the language
that they cover.
Everything in test/ is stuff we wrote while working on Natalie. These are
tests that helped us bootstrap certain parts of the language and/or weren't
covered as much as we would like by the official Ruby specs. We use this
to supplement the specs in spec/.
Natalie is copyright 2025, Tim Morgan and contributors. Natalie is licensed
under the MIT License; see the LICENSE file in this directory for the full text.
Some parts of this program are copied from other sources, and the copyright
belongs to the respective owner. Such copyright notices are either at the top of
the respective file, in the same directory with a name like LICENSE, or both.
| file(s) | copyright | license |
|---|---|---|
abbrev.rb | Akinori Musha | BSD |
benchmark.rb | Gotoken | BSD |
bigint.{h,c} | 983 | Unlicense |
cgi.rb/cgi/* | Wakou Aoyama | BSD |
crypt.{h,c} | The Regents of the Univ. of Cali. | BSD |
delegate.rb | Yukihiro Matsumoto | BSD |
dtoa.c | David M. Gay, Lucent Technologies | custom permissive |
erb/util.rb | Masatoshi SEKI | BSD |
ipaddr.rb | Hajimu Umemoto and Akinori Musha | BSD |
find.rb | Kazuki Tsujimoto | BSD |
formatter.rb | Yukihiro Matsumoto | BSD |
linenoise | S. Sanfilippo and P. Noordhuis | BSD |
matrix.rb/matrix/* | Marc-Andre Lafortune | BSD |
minicoro.h | Eduardo Bart | MIT |
net/ftp.rb | Shugo Maeda | BSD |
net/http*/net/protocol.rb | Yukihiro Matsumoto and Minero Aoki | BSD |
pp.rb | Yukihiro Matsumoto | BSD |
prettyprint.rb | Yukihiro Matsumoto | BSD |
resolv.rb | Tanaka Akira | BSD |
shellwords.rb | Akinori MUSHA | BSD |
spec/* | Engine Yard, Inc. | MIT |
timeout.rb | Yukihiro Matsumoto | BSD |
unicode_normalize/* | Ayumu Nojima and Martin J. Dürst | BSD |
uri.rb/uri/* | Akira Yamada | BSD |
version.rb | Engine Yard, Inc. | MIT |
zlib | Jean-loup Gailly and Mark Adler | zlib license |
See each file above for full copyright and license text.
Improve handling of arguments forwarding info
https://github.com/natalie-lang/natalie/issues/2896
Labels: enhancement
Status of interpreted mode
https://github.com/natalie-lang/natalie/issues/2855
Labels: None
LocalJumpError can only be caught with this exact exception class
https://github.com/natalie-lang/natalie/issues/2745
Labels: bug
Multiple uses of argument forwarding
https://github.com/natalie-lang/natalie/issues/2705
Labels: None
Fix Rakefile dependencies for something in build/generated
https://github.com/natalie-lang/natalie/issues/2701
Labels: None
Determining the encoding when concatenating strings
https://github.com/natalie-lang/natalie/issues/2633
Labels: None
Add flag to raise SyntaxErrors in eval at runtime
https://github.com/natalie-lang/natalie/issues/2310
Labels: None
Add NATUNRELIABLE to the spec helpers
https://github.com/natalie-lang/natalie/issues/2308
Labels: None
Make the Onigmo patch obsolete
https://github.com/natalie-lang/natalie/issues/2051
Labels: enhancement
Everyone is welcome to contribute to Natalie!
We are building a kind of Ruby implementation, following as closely as possible to what Matz's Ruby Interpreter (MRI) does. Where this is not possible, we do the best we can.
When contributing to Natalie, make sure that the changes you make are in line with the project direction. If you are not sure about this, open an issue first so we can discuss it.
clang-format to automatically format C files, rustfmt for Rust files, and syntax_tree for Ruby files. You can run rake format; the Nix development shell pins all three, matching CI.Enable the repository's hook once per checkout:
git config core.hooksPath .githooks
The hook rejects commits when staged Ruby, C, or Rust files would change under
Syntax Tree, clang-format, or rustfmt. It checks a temporary copy of the index, including
staged formatter settings, without modifying your working tree or staged files.
Ruby exclusions in .streerc, bundled dependencies in ext/, build output, and
generated encoding tables are skipped.
The hook uses nix develop when Nix is installed. Otherwise, put stree (Syntax
Tree), clang-format, and rustfmt on PATH. Fix formatting with
rake format, then stage the files again.
Run the check manually with ruby tools/check_staged_format.rb in your development
shell.
NATFIXME helper to do this,
which is defined in test/support/spec.rb.
(We usually don't comment out failing tests.)tests/ directory, especially if such tests are specific to a Natalie
feature or quirk.