Hacker News new | past | comments | ask | show | jobs | submit login
Artichoke Ruby Architecture (github.com/artichoke)
114 points by ibraheemdev on Feb 13, 2021 | hide | past | favorite | 14 comments



This looks really neat for the ruby community. It being modular I imagine the target is for Embedding when you know you only need X features of ruby so you get smaller and hopefully more performing builds? At least if I understand this correctly.

As an aside: is ruby easier to implement than other languages? It’s syntax and features seems more complex than say Python but I’ve heard from others that implementing a new Python distribution in say Rust is a real PITA


Code size in an embedded context is one use case for the modularity here. Another is limiting access of Ruby code to the host system.

For example, one may wish to use Artichoke in a game engine for scene scripting. It’s probably undesirable for Ruby code run in this context to modify the host environment, so `ENV` can be disabled at compile time. But maybe you have existing code that uses `ENV`. Toggle a compile time flag and you can get a compatible `ENV` implementation that is backed by a hash map.


Ruby’s syntax is definitely more complex than Python’s (which until recently was LL(1)), but it wouldn’t surprise me if Ruby as a whole was a simpler language. For example, Ruby’s object model is much simpler and more elegant than Python’s.


Ruby is hell to implement. To quote Matz:

> Ruby is simple in appearance, but is very complex inside, just like our human body


I believe it is actually much harder to implement than many other languages because the syntax is so complex. You have so many edge cases to account for that it is rather difficult to consider all scenarios.


Parsing is hard, but that’s only a small part of writing an interpreter.


For now Artichoke leans on mruby’s parser, but I’m looking forward to using https://github.com/lib-ruby-parser/lib-ruby-parser which is a Rust port of MRI’s parse.y.


One can already embed Ruby in any C-compatible project with mruby, which this project uses as a default backend. mruby itself is extremely modular.

I’m not too sure this is for embedding related to size, but more as an abstraction layer to have the ability to switch backend, as well as embedding (as in inside a larger app, not as on embedded-class devices) but aimed at Rust projects.

I find the description a bit misleading:

> Artichoke is a Ruby implementation written in Rust and Ruby

The arch doc seems to indicate this is an implementation in C and Ruby (mruby) with a frontend/backend layer written in Rust, and packaged as crates for ease of use in Rust. Maybe the desc is about the endgame, gradually eating the C part with Rust?


> It being modular I imagine the target is for Embedding

That may be a motivating use case, but it also seems to serve their desire to manage complexity of implementing Ruby by using the strangler pattern and working up from mruby-based to MRI-based to full-Ruby-in-pure-Rust.

> As an aside: is ruby easier to implement than other languages?

From everything I've seen and heard, both from Marx and alternative Ruby implementations, no.


I hope so. I would love to use Ruby embedded one day


mruby is embeddable today.


thanks, didn't know about that


What's the tool used to make this diagram?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: