
Artichoke – A Ruby made with Rust - ashton314
https://github.com/artichoke/artichoke
======
samatman
This is a great idea but why would it be called anything other than Jasper:
[https://en.wikipedia.org/wiki/Jasper](https://en.wikipedia.org/wiki/Jasper)

It doesn't get closer to a Ruby made with Rust than that...

~~~
iovrthoughtthis
That would literally make my year, as a Jasper.

------
_hardwaregeek
While I think this is great, Ruby implementations are notorious for being
tricky to implement 100%. Rewriting Ruby in Rust is great and all but even
TruffleRuby isn't at the point where the authors recommend running a Rails app
on it.

I wonder if there's a way to add some Rust into MRI. Perhaps someone could
write a YARV VM or a version of the JIT in Rust. It'd complicate the build
pipeline, but it'd be iterative and improve the main implementation of Ruby.

~~~
p4lindromica
Hi, I'm the author of Artichoke.

Ruby has a great black box testing suite called ruby/spec [0] that is shared
among multiple Ruby implementations. Artichoke has a custom runner [1] to
track progress on implementation completeness.

If Artichoke passes ruby/spec and is not compatible with MRI, that's a bug in
the specs.

re: adding Rust to MRI, I'm working on extracting the mruby backend from the
core VM infra + core/stdlib impls [3] which would let us use MRI as the
backing VM via rutie. When the Artichoke core and stdlib is complete, this
would mean that the MRI runtime could be implemented entirely in Rust [2].

[0] [https://github.com/ruby/spec](https://github.com/ruby/spec) [1]
[https://github.com/artichoke/artichoke/tree/master/spec-
runn...](https://github.com/artichoke/artichoke/tree/master/spec-runner) [2]
[https://github.com/artichoke/artichoke/issues/92](https://github.com/artichoke/artichoke/issues/92)
[3]
[https://artichoke.github.io/artichoke/artichoke_core/](https://artichoke.github.io/artichoke/artichoke_core/)

~~~
chrisseaton
So what is the current pass rate for language and core specs? I didn’t see a
number in any of those links or did I miss it? Do I have to build and run it
myself to find out?

If you can run mspec at all then that’s pretty good to be honest.

~~~
p4lindromica
I can run MSpec to completion for language, core, and library specs. Thank you
for the encouragement :D.

I've implemented a runner that can skip known things that cause the spec to
hang (e.g. Mutex specs since Artichoke has a single-threaded implementation of
Mutex that deadlocks during the specs).

    
    
        $ pushd spec-runner/vendor/ruby/language
        $ cargo run --bin spec-runner **/*.rb
        Passed 1078, skipped 35, not implemented 2, failed 476 specs.
        $ popd; pushd spec-runner/vendor/ruby/core
        $ cargo run --bin spec-runner **/*.rb
        Passed 5412, skipped 998, not implemented 201, failed 8629 specs.
        $ popd; pushd spec-runner/vendor/ruby/library
        $ cargo run --bin spec-runner **/*.rb
        Passed 0, skipped 22, not implemented 16, failed 3276 specs.
    

The library specs pass number is a bug in my spec runner. All packages added
to Artichoke pass ruby/spec. Those packages are : delegate, forwardable, json,
monitor, ostruct, set, srscan, and uri.

------
subroutine
A little oxidation and this would make the perfect logo:

[https://www.amazon.com/dp/B00IK9F9F4](https://www.amazon.com/dp/B00IK9F9F4)

------
judofyr
I love seeing more Ruby implementations! Looking forward to seeing how it will
progress. Are there any details on how it’s implemented? How does it execute
Ruby? Does it have its own bytecode? Does it compile to machine code on the
fly? What will make it faster than MRI?

~~~
p4lindromica
Thank you for your kind words.

Growing pains of blowing up on HN lol, I do not have this written down yet,
but I have a ticket to start documenting this [0].

The idea is to have a core set of traits [1] that when implemented allow an
implementation to load an interpreter agnostic Ruby core and Ruby Standard
Library.

There is currently only one interpreter that implements these traits, and it
is backed by mruby. My ultimate goal is to move off of mruby to either an MRI-
backed interpeter via rutie or a native Rust-implemented backend + VM +
parser.

[0]
[https://github.com/artichoke/artichoke/issues/102](https://github.com/artichoke/artichoke/issues/102)
[1]
[https://artichoke.github.io/artichoke/artichoke_core/](https://artichoke.github.io/artichoke/artichoke_core/)

------
ultrarunner
No c extensions? So most popular gems won’t work? Does that make this
essentially an intellectual pursuit without practical application?

~~~
untog
No reason it can't be added in the future.

~~~
msbarnett
Without a GIL it would be incredibly difficult, would it not? AFAIK C
extensions to MRI are not thread safe.

This could, of course, expose a different C API that allows for thread safe
extensions, but I think the original comment is complaining about lack of
compatibility with all of the important gems that depend on the existing MRI C
API.

This has always been an issue that held back JRuby.

~~~
pjmlp
JRuby does not have a GIL.

~~~
y4mi
My personal experience with Ruby is extremely shallow, but a casual glance at
the search results wrt the GIL in Ruby seems to say it actually does have one.
I could be wrong, as I'm not an experienced Ruby developer, however.

I.e. [https://thoughtbot.com/blog/untangling-ruby-
threads](https://thoughtbot.com/blog/untangling-ruby-threads)

~~~
yorwba
From your link: "Note that this is not the case for JRuby or Rubinius which do
not have a GIL and offer true multi-threading."

------
rishav_sharan
Once this language is more mature, comparing it with Crystal would be great.
Artichoke will have the added benefit of having Ruby's entire ecosystem as its
behest.

------
Exuma
I wonder how much this would change the performance of ruby... that's all kind
of cool except no c extensions, that basically makes all the gems I use
unusable.

~~~
dymk
They're going to have to spend an immense amount of time implementing all the
performance optimizations present in mri/yarv bytecode engine before they
achieve performance parity.

The amount of engineering effort to remove the GIL _and_ simultaniously make C
extensions work is probably not worth simply choosing a multi-process w/
shared memory solution for true parallelism.

------
pankajdoharey
I actually like the idea, being a Rust illiterate i have way of reading it. I
like the tone of it "No GIL". I hope it does come to fruition. But i would
love ruby programs to eventually be able produce machine code, like tons of
lisp and scheme implementations do. Even Smalltalk did. I hope with "No GIL"
that should be somewhere in the pipeline.

------
mkorfmann
Is it possible to install ruby gems in the browser playground? So, Does ruby
gem install via web assembly runtime work?

~~~
p4lindromica
Not yet, but you can track progress here:
[https://github.com/artichoke/artichoke/issues/105](https://github.com/artichoke/artichoke/issues/105)

