Natalie is a very early-stage work-in-progress Ruby implementation.
It provides an ahead-of-time compiler using C++ and gcc/clang as the backend. 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!
Contributions are welcome! You can learn more about how I work on Natalie via the hacking session videos on YouTube.
The easiest way to get started right now would be to find a method on an object that is not yet implemented and make it yourself! Also take a look at good first issues. (See the 'Building' and 'Running Tests' sections below for some helpful steps.)
We have a very quiet Discord server -- come and hang out!
Natalie is tested on macOS, OpenBSD, and Ubuntu Linux. Windows is not yet supported.
Natalie requires a system Ruby (MRI) to host the compiler.
Install the above prerequisites on your platform, then run:
git clone https://github.com/natalie-lang/natalie cd natalie rake
NOTE: Currently, the default build is the "debug" build, since Nataile is in active development.
But you can build in release mode with
Run a Ruby script:
Compile a file to an executable:
bin/natalie examples/hello.rb -c hello ./hello
docker build -t natalie . # build image docker run -it --rm natalie # repl docker run -it --rm natalie -e "p 2 * 3" # immediate docker run -it --rm -v$(pwd)/myfile.rb:/myfile.rb natalie /myfile.rb # execute a local rb file docker run -it --rm --entrypoint bash natalie # bash prompt
To run a test (or spec), you can run it like a normal Ruby script:
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:
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
Intepreter) does. We copy specs over as we implement the part of the language
that they cover.
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
Natalie is copyright 2021, 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:
||David M. Gay, Lucent Technologies||custom permissive|
||Syed Faheel Ahmad||MIT|
||Engine Yard, Inc.||MIT|
||Engine Yard, Inc.||MIT|
See each file above for full copyright and license text.