Live data from Hacker News

Spinel: Ruby AOT Native Compiler

github.com

11–20 of 93 posts

Re: Spinel: Ruby AOT Native Compiler

#11
As someone who spent a few years working on a compiler in this space — it’s tough, but are the results of instant startup and immediately decent performance without warm-up satisfying to use in practice. I really hope this takes off and yet another language can break free from dominant interpreter + jit compiler monoculture that we currently have for higher-level programming languages.

Re: Spinel: Ruby AOT Native Compiler

#13
post #2

If it wasn't built by Matz I'd have severe doubts, but it's clearly defined and I presume he knows all limitations of the Ruby semantics well. My thesis work (back when EcmaScript 5 was new) was an AOT JS compiler, it worked but there was limitations with regards to input data that made me abandon it after that since JS developers overall didn't seem to aware of how to restrict oneself properly (JSON.parse is inheren…

> If it wasn't built by Matz I'd have severe doubts, but it's clearly defined and I presume he knows all limitations of the Ruby semantics well.

It's a very pragmatic design: Uses Prism - parsing Ruby is almost harder than the actual translation - and generates C. Basic Ruby semantics are not all that hard to implement.

On the other extreme, I have a long-languishing, buggy, pure-Ruby AOT compiler for Ruby, and I made things massively harder for myself (on purpose) by insisting on it being written to be self-hosting, and using its own parser. It'll get there one day (maybe...).

But one of the things I learned early on from that is that you can half-ass the first 80% and a lot of Ruby code will run. The "second 80%" are largely in things Matz has omitted from this (and from Mruby), like encodings, and all kinds of fringe features (I wish Ruby would deprecate some of them - there are quite a few things in Ruby I've never, ever seen in the wild).

> eval, send, method_missing, define_method , as a non-rubyist how common are these in real-world code? And how is untyped parsing done (ie JSON ingestion?).

They are pervasive. The limitations are similar to those of mruby, though, which has its uses.

Supporting send, method_missing, and define_method is pretty easy.

Supporting eval() is a massive, massive pain, but with the giant caveat that a huge proportion of eval() use in Ruby can be statically reduced to the block version of instance_eval, which can be AOT compiled relatively easily. E.g. if you can statically determine the string eval() is called with, or can split it up, as a lot of the uses are unnecessary or workaround for relatively simple introspection that you can statically check for and handle. For my own compiler, if/when I get to a point where that is a blocking issue, that's my intended first step.

Re: Spinel: Ruby AOT Native Compiler

#14
post #2

If it wasn't built by Matz I'd have severe doubts, but it's clearly defined and I presume he knows all limitations of the Ruby semantics well. My thesis work (back when EcmaScript 5 was new) was an AOT JS compiler, it worked but there was limitations with regards to input data that made me abandon it after that since JS developers overall didn't seem to aware of how to restrict oneself properly (JSON.parse is inheren…

> eval, send, method_missing, define_method , as a non-rubyist how common are these in real-world code?

Quite a lot, that's what allows you to build something like Rails with magic sprinkled all around. I'm not 100% sure, but probably the untyped JSON ingestion example uses those.

Remove that, and you have a very compact and readable language that is less strongly typed than Crystal but less metaprogrammable than official Ruby. So I think it has quite a lot of potential but time will tell.

Re: Spinel: Ruby AOT Native Compiler

#15
post #7
post #4

Given it's built by Matz, how realistic is it that this becomes a core part of Ruby? And if so, how threatening is that for Crystal?

Crystal has an explicit static type system and is actually optimized at the language level for AOT compilation. These features are pretty much required for compiling and maintaining large programs. This is for a limited subset of Ruby - almost no popular Ruby gems would run under it. It's more like PreScheme [1] (ie. a subset of a language oriented at C compilation). I don't think these compete in the same niches rig…

It's a similar subset to mruby, and it might well end up influencing mruby, which does have its users. But it's almost a different language in some ways.

Re: Spinel: Ruby AOT Native Compiler

#17
post #12

Wow, written in just over a month. Say what you will about AI, but it has enabled serious speedups in the hands of a talented coder.

Rest of industry: OK we need to set up our agent harness, write our SOUL.md, config permissions, skills, mcps, hooks, env...

Matz: gem env|info and find should do

Re: Spinel: Ruby AOT Native Compiler

#18
post #16

Even Matz now uses claude code...

He has been using it for quite a long time for mruby already.

For Ruby and c development it’s the best llm we got right now, the others lag behind by a lot sadly.

With openAI it’s so bad for my usecase it’s basically unusable.

Re: Spinel: Ruby AOT Native Compiler

#19

I find the current documentation difficult to understand. This is a problem I see with many ruby projects. How would I reword this? Well, first thing, after stating what spinel is, I would show a simple example. Ideally a standalone .rb file or something like that, that can be downloaded (or whatever other format). Yes, the README shows this, but believe it or not, I have realised that I am usually below average when…

Maybe AI generated? I mostly suffer to read AI generated documentation.

Re: Spinel: Ruby AOT Native Compiler

#20
post #17
post #12

Wow, written in just over a month. Say what you will about AI, but it has enabled serious speedups in the hands of a talented coder.

Rest of industry: OK we need to set up our agent harness, write our SOUL.md, config permissions, skills, mcps, hooks, env... Matz: gem env|info and find should do

"plansturbation" is a real industry, there are tons of successful YouTubers that sell millions of dollars in tutorials, courses, books, etc on how to setup your productivity harness
Post reply on HN