Live data from Hacker News

Spinel: Ruby AOT Native Compiler

github.com

51–60 of 93 posts

Re: Spinel: Ruby AOT Native Compiler

#51
Antis: "If AI is so useful, where are the AI shovelwares? Where are the AI open source contributions? It's all hype" 6 months later: Matz used Claude and now Ruby runs 86 times faster after 1 month of work

At this point it's impossible to take antis seriously at all. Every claim is disproven simply by the passage of time. History will remember them just like the dot-com antis (that is, it won't)

Re: Spinel: Ruby AOT Native Compiler

#52
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…

It seems like a compiler from Ruby to Objective C could support all the Ruby features while still being more performant than interpreted Ruby.

there was MacRuby[0] which I seem to remember had an AoT compiler and was built on the ObjC foundation but was later abandoned.

[0] https://en.wikipedia.org/wiki/MacRuby

Re: Spinel: Ruby AOT Native Compiler

#53
post #10

For some context, just presented by Matz at RubyKaigi 2026. It’s experimental but he built it with help from Claude in about a month. Successful live demo. It’s named after his new cat, which is named after a cat in Card Captor Sakura, which is the partner to another character named Ruby.

oh, I thought it was about the mineral which is ruby-ish :)

https://en.wikipedia.org/wiki/Spinel

Re: Spinel: Ruby AOT Native Compiler

#54
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 This depends on the individual writing code. Some use it more than others. I can only give my use case. .send() I use a lot. I feel that it is simple to understand - you simply invoke a specific method here. Of course people can just use .method_name() instead (usually without the () in ruby), but sometimes you may…

I think you could work around send(). Not a Ruby person, but in most languages you could store functions in a hashmap, and write an implementation of send that does a lookup and invokes the method (passing the instance pointer through if need be).

Won’t work with actual class methods, but if you know ahead of time all the functions it will call are dynamic then it’s not a big deal.

Re: Spinel: Ruby AOT Native Compiler

#55
post #43

I will eat the downvotes to say what I actually think. Unless this gets back eval, metaprogramming and threads this isn't all that interesting as an actual language. There are plenty of compiled languages out there. Metaprogramming is what makes Ruby interesting and expressive. I know that this is just an experiment, but I've seen plenty of cases where stuff exactly like this gets forced into use in production becaus…

Spinel would be more interesting if this compiled subset could run side by side with interpreted Ruby, like Pallene does for (slightly modified) Lua.

Re: Spinel: Ruby AOT Native Compiler

#56

Earlier quoted context omitted.

Crystal is great and I think it nailed statically typing in a Ruby like language, but I've always been wary of day job use of the language because it doesn't have a significant user base.

This subset of Ruby doesn’t either.

If this stabilizes and gets networking support, there are definitely projects that I'll be able to use this for, and the buy-in will be easier than proposing Crystal.

Re: Spinel: Ruby AOT Native Compiler

#57
post #49

While obviously super-impressive, it is clearly not maintanable without AI agent. It has spinel_codegen.rb is 21k lines of code with up to 15 levels of nesting in some methods. Compilers code was never pretty, but even by those standard, I feel like it is a very-very hard to maintain code by humans.

spinel_codegen.rb is an eldritch horror. I always get spaghetti code like this when using Claude, and I've been wondering if I'm doing something wrong. Now I see an application that looks genuinely interesting (not trivial slop) written by someone I consider to be a top notch programmer, and the code quality is still pretty garbage in some places. For example infer_comparison_type() [1]. This is far from the worst of…

It's true that it's shorter, but I suspect that the if-return, if-return pattern compiles down to much faster code. Separately, this code was originally written in C then ported. There are reasonable explanations for why Matz has the code written this way besides the typical AI slop.

Re: Spinel: Ruby AOT Native Compiler

#58
post #49

Earlier quoted context omitted.

spinel_codegen.rb is an eldritch horror. I always get spaghetti code like this when using Claude, and I've been wondering if I'm doing something wrong. Now I see an application that looks genuinely interesting (not trivial slop) written by someone I consider to be a top notch programmer, and the code quality is still pretty garbage in some places. For example infer_comparison_type() [1]. This is far from the worst of…

It's true that it's shorter, but I suspect that the if-return, if-return pattern compiles down to much faster code. Separately, this code was originally written in C then ported. There are reasonable explanations for why Matz has the code written this way besides the typical AI slop.

I'm skeptical of that reasoning because the original C wasn't too clean or performant either. For example emit.c from an earlier commit [1]

It writes a separate call to emit_raw for each line, even though there many successive calls to emit_raw before it runs into any branching or other dynamic logic. What if you change this

    emit_raw(ctx, "#include \n");
    emit_raw(ctx, "#include \n");
    emit_raw(ctx, "#include \n");
    emit_raw(ctx, "#include \n");
    // And on for dozens more lines
to this

    emit_raw(ctx,
        "#include \n"
        "#include \n"
        "#include \n"
        "#include \n"
        // And on for dozens more lines
    );
That would leave you with code that is just as readable, but only calls the emit function once, leading to a smaller and faster binary. Again, this is a trivial change to the code, but Claude struggles to get there.

[1] https://github.com/matz/spinel/blob/aba17d8266d72fae3555ec91...

Re: Spinel: Ruby AOT Native Compiler

#59
post #51

Antis: "If AI is so useful, where are the AI shovelwares? Where are the AI open source contributions? It's all hype" 6 months later: Matz used Claude and now Ruby runs 86 times faster after 1 month of work At this point it's impossible to take antis seriously at all. Every claim is disproven simply by the passage of time. History will remember them just like the dot-com antis (that is, it won't)

This doesn't implement all of Ruby. It's easy to make a language that looks like Ruby run fast. It's hard to make a CRuby compatible Ruby fast (all the dynamic features add a ton of overhead).

Re: Spinel: Ruby AOT Native Compiler

#60
post #35
post #15

Earlier quoted context omitted.

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.

> It's a similar subset to mruby... This is what I've been wondering after only a cursory glance ("It...generates optimized C code" from the OP). Interesting that mruby itself got a major version update around the same time (in just the past few days) https://github.com/mruby/mruby/blob/master/doc/mruby4.0.md

Matz is behind both projects, unclear to me what this project is intended to accomplish over mruby.
Post reply on HN