• Stars
    star
    530
  • Rank 83,660 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a unique Ruby implementation, compiled to C++ (WIP)

Natalie

github build status MIT License justforfunnoreally.dev badge

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.

demo screencast

There is much work left to do before this is useful. Please let me know if you want to help!

Helping Out

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!

Building

Natalie is tested on macOS, OpenBSD, and Ubuntu Linux. Windows is not yet supported.

Natalie requires a system Ruby (MRI) to host the compiler, for now.

Prerequisites:

  • git
  • autoconf
  • automake
  • libtool
  • GNU make
  • gcc or clang
  • Ruby 2.7 or higher with dev headers
    • Using rbenv to install Ruby is preferred.
    • Otherwise, you'll need the ruby and ruby-dev package from your system.
  • ccache (optional, but recommended)
  • compiledb (optional, but recommended)

Install the above prerequisites on your platform, then run:

git clone https://github.com/natalie-lang/natalie
cd natalie
rake

Troubleshooting Build Errors

  • Don't use sudo! If you already made that mistake, then you should sudo rm -rf build and try again.
  • If you get an error about file permissions, e.g. unable to write a file to somewhere like /usr/lib/ruby, or another path that would require root, then you have a couple options:
    • Use a tool like rbenv to install a Ruby verison in your home directory. Gems will also be installed there. Run rbenv version to see which version is currently selected. Run rbenv shell followed by a version to select that version.
    • Specify where to install gems with something like:
      mkdir -p ~/gems
      export GEM_HOME=~/gems
      
      You'll just have to remember to do that every time you open a new terminal tab.
  • If you get an error about missing bundler, then your operating system probably didn't install it alongside Ruby. You can run gem install bundler to get it.

NOTE: Currently, the default build is the "debug" build, since Nataile is in active development. But you can build in release mode with rake build_release.

Usage

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

Using With Docker

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

Running Tests

To run a test (or spec), you can run it like a normal Ruby script:

bin/natalie 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

What's the difference between the 'spec/' and 'test/' directories?

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/.

Copyright & License

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. 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
big_int.* Syed Faheel Ahmad MIT
dtoa.c David M. Gay, Lucent Technologies custom permissive
fiber_object.* Evan Jones MIT
spec/* Engine Yard, Inc. MIT
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.

More Repositories

1

30-days-of-elixir

A walk through the Elixir language in 30 exercises.
Elixir
3,029
star
2

onebody

private member portal for churches, built with Ruby on Rails
Ruby
1,398
star
3

do-install-button

NO LONGER MAINTAINED
HTML
609
star
4

bible_api

Ruby web app that serves JSON API for open and public domain bibles
Ruby
524
star
5

open-bibles

Repository of public domain and freely (libre) licensed bible translations in some standard XML formats.
Python
272
star
6

justforfunnoreally.dev

A little website to explain that sometimes we just like to have fun!
HTML
95
star
7

bible_parser

parse different bible formats with Ruby
Ruby
51
star
8

malcc

Mal (Make A Lisp) Compiler in C
C
51
star
9

sooner.io

NO LONGER MAINTAINED - a distributed job scheduling engine and web-based management app
CoffeeScript
39
star
10

old-churchio-website

The website of Church.IO
HTML
23
star
11

hackernews

Ruby library for scripting the Hacker News website (http://news.ycombinator.com).
Ruby
22
star
12

rpi-clock

very simple clock and weather page for raspberry pi - NO LONGER MAINTAINED
CSS
21
star
13

wuparty

Lightweight Ruby wrapper for Wufoo REST API v3 over HTTP using HTTParty
Ruby
19
star
14

dymo-printer-agent

print label XML to a Dymo printer on Linux (or any platform)
Ruby
19
star
15

load_and_authorize_resource

Auto-loads and authorizes resources in your Rails controllers
Ruby
18
star
16

mini

Tim's [VERY OLD] Mini JavaScript Library
JavaScript
18
star
17

checkin-printer

This is a tiny bit of software that allows the Church.IO Checkin System to print remotely to a DYMO LabelWriter controlled by a Raspberry Pi.
JavaScript
18
star
18

bible_ref

Parser for bible passage/ranges
Ruby
16
star
19

sidekiq-clutch

An ergonomic wrapper API for Sidekiq Pro Batches
Ruby
16
star
20

mal-rust

My own Rust implementation of Mal (Make a Lisp)
Rust
14
star
21

rpi-check-in-printer

Set up a Raspberry Pi as a Planning Center Check-ins Printer Station for Dymo label printers
Shell
12
star
22

sinatra-appengine-example

Example of a Sinatra app for Google AppEngine (JRuby) from http://blog.bigcurl.de/2009/04/running-sinatra-apps-on-google.html
Ruby
12
star
23

mya

WIP statically-typed subset of Ruby (maybe)
Ruby
10
star
24

simple_restful_openid

Rails plugin that generates an uber simple, restful openid login controller.
Ruby
10
star
25

scheme-vm

a work-in-progress R7RS scheme implementation
Ruby
9
star
26

cascading_rubies

Ruby DSL for generating CSS. THIS IS NO LONGER MAINTAINED
Ruby
8
star
27

image_hash_ruby

a simple perceptual image hashing library
Ruby
7
star
28

type_inference_experiment

A little toy compiler so I can play with type inference
Ruby
7
star
29

flickr_party

Wrapper for the Flickr API, with real application authentication, using HTTParty
Ruby
6
star
30

froman

Run Sidekiq/Resque workers for multiple apps only when there is work to be done.
Rust
6
star
31

lydia

an interpreted functional language for learning
C
6
star
32

trac_wiki_to_github

A rough start of a Ruby script to help convert Trac wiki syntax to GitHub friendly syntax. DOES NOT SUPPORT NEW GIT-BACKED WIKIS.
Ruby
6
star
33

has_one_photo

Super simple photo support for AR models using MiniMagick - THIS IS NO LONGER MAINTAINED
Ruby
5
star
34

flickr-upload-set

Browse your computer hard drive for photos that are not yet on your Flickr account.
Ruby
5
star
35

onebody-sync

scripts to export data from other Church Management System databases to OneBody
Ruby
4
star
36

.emacs.d

My Emacs configs, and a live blog of my experience switching from Vim to Emacs
Emacs Lisp
4
star
37

quine

Some Ruby Quines
Ruby
4
star
38

facebook_party

Lightweight wrapper for Facebook API using HTTParty.
Ruby
4
star
39

prawn_template_handler

Uber simple template handler for Prawn PDF views in Rails. THIS IS NO LONGER MAINTAINED; please check out https://github.com/Volundr/prawn-rails
Ruby
4
star
40

openwar

turn-based strategy game written in SVG and JavaScript
CoffeeScript
3
star
41

onebody-mobile

A mobile app for OneBody
CSS
3
star
42

jqtal

jQuery Template Attribute Language
JavaScript
3
star
43

honcho

Sidekiq- and Resque-aware process manager for your dev environment (alternative to Foreman)
Ruby
3
star
44

crk

Corkboard App built with Node.js, Backbone.js, and Socket.io
JavaScript
3
star
45

ragchew.app

A website for amateur radio operators to find and participate in on-the-air gatherings
Ruby
3
star
46

simple_sinatra_openid

example Sinatra app with OpenID authentication
Ruby
3
star
47

whiteboard_icons

Icons with a certain fat, hand-drawn marker look. Actually drawn on my whiteboard.
Ruby
3
star
48

onebody-mobile-old

WebView wrapper for OneBody
Objective-C
2
star
49

tulsarb.org

Old website of the Tulsa Ruby User Group
Ruby
2
star
50

path-download

Download your entire feed from Path before they disappear on Oct 18, 2018
JavaScript
2
star
51

tm

Some basic data structures for C++ projects
C++
2
star
52

snake-term

A simple ASCII "snake" game in the terminal, written in < 100 lines of Ruby
Ruby
2
star
53

attr_accessible_if

Pass an :if Proc to the attr_accessible class method to change what attributes are accessible depending on, for example, who is logged in.
Ruby
2
star
54

usfx

Ruby SAX stream parser for Unified Scripture Format XML (USFX)
Ruby
2
star
55

my_snippets

I was fed up with dzone snippets, and decided to write my own. ABANDONED -- just use GitHub Gists. :-)
Ruby
2
star
56

natalie-lang.org

Just a simple website for Natalie
JavaScript
2
star
57

lisp200

200 LOC Lisp implementation in Ruby
Ruby
2
star
58

hook.io-fswatcher

filesystem watcher for Hook.io (supports inotify on Linux)
CoffeeScript
2
star
59

exceptioncollection

My first AppEngine app. It collects exceptions in Rails apps, ala Hoptoad and Exceptional, but has about 10% of the features.
2
star
60

adventofcode

Advent of Code exercises
Ruby
1
star
61

html5-todo-app

demo app for presentation at September 2011 meeting of TulsaWebDevs
JavaScript
1
star
62

snake-gosu

Snake game written in Ruby and Gosu
Ruby
1
star
63

dlopen_test

Just testing dlopen, dlsym, et al
C
1
star
64

onebody-help

Help Guides - NO LONGER MAINTAINED
1
star
65

natalie-spec-stats-api

a tiny sinatra app for tracking our ruby/spec stats
Ruby
1
star
66

plusone-test

Just testing the plusone bot
1
star
67

monkey

working thru 'Writing an Interpreter in Go' in Ruby :-)
Ruby
1
star
68

bulk_bundler

Install dependencies for multiple Gemfile.lock files in one go. Or maybe don't.
Ruby
1
star
69

boardslam-c

Classical Conversations Board Slam math game calculator
C
1
star
70

microbit-services-live

Control Planning Center Services LIVE with a micro:bit
JavaScript
1
star
71

pco_giving_labels

Set labels on donations in Planning Center Giving based on campus in Planning Center People.
Ruby
1
star
72

rust-ruby-wrap-data

set a pointer to a Rust heap-allocated value on your Ruby object and get it back out again
Rust
1
star
73

nvim

my neovim config
Lua
1
star
74

robots-chatting-with-other-robots

Simple Node.js chat server based on Socket.io, with Robot avatars thanks to robohash.org
JavaScript
1
star