Live data from Hacker News

Spinel: Ruby AOT Native Compiler

github.com

41–50 of 93 posts

Re: Spinel: Ruby AOT Native Compiler

#41
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.

Re: Spinel: Ruby AOT Native Compiler

#42
i have wanted to be able to compile ruby to a binary for some time – and have dreamed of poking at this problem with claude – so this is pretty cool.

if you can get a Rack compatible web server to build… i'd waste some serious time playing with this.

Re: Spinel: Ruby AOT Native Compiler

#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 because someone established in the company thinks some new experimental tool is "cool" and "the future".

---

Also, I would like to direct people to take a look at Factor programming language that both compiles into fairly efficient binaries and has amazing metaprogramming features inspired by Lisp and Smalltalk. It doesn't have real threads either, though, which is extremely unfortunate.

https://factorcode.org/

Re: Spinel: Ruby AOT Native Compiler

#44

Curious why "no threads" when the ruby scheduler and underlying pthread implementation should work fine in C land. I guess to be "zero dependency"? Seems an odd trade-off to me, unless optional "extensions" are planned / omitted for later implementation etc.

I don’t see anywhere that it’s something they specifically decided not to support. Probably they just haven’t gotten around to it yet? Multithreading is notoriously difficult to get right.

Re: Spinel: Ruby AOT Native Compiler

#45
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.

The most recent cartoon Spinel in my mind is from Steven Universe, so I hadn't noticed the Spinel/Ruby (Moon) pun, that made my day.

Re: Spinel: Ruby AOT Native Compiler

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

Why do you say HashWithIndifferentAccess shows a lack of understanding? Like many Rails features, it's a convenience that abstracts away details that some find unpleasant to work with. Rails sometimes takes "magic" to the extreme through meta-programming. However, looking at the source [1], HashWithIndifferentAccess doesn't use eval, send, method_missing, or define_method. So I'm not sure how it seems weird to someone who works more with plain Ruby.

1. https://github.com/rails/rails/blob/fa8f0812160665bff083a089...

Re: Spinel: Ruby AOT Native Compiler

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

I'm one of those who use eval often. Could I avoid it, possibly, but it seems more ergonomic for me.

Re: Spinel: Ruby AOT Native Compiler

#48
post #25

Limitations - No eval: eval, instance_eval, class_eval - No metaprogramming: send, method_missing, define_method (dynamic) - No threads: Thread, Mutex (Fiber is supported) - No encoding: assumes UTF-8/ASCII - No general lambda calculus: deeply nested -> x { } with [] calls Assuming UTF-8/ASCII isn’t, IMO, a huge limitation, but some of the others likely are, for quite a few programs. Removing them also will require s…

This removes a large portion of the magic of Ruby.

Re: Spinel: Ruby AOT Native Compiler

#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 offender - it's not that hard to read - but what's striking here that there is a better implementation that's so simple and obvious and Claude still fails to get there. Why not replace this with

    COMPARISON_TYPES = Set.new(["", "=", "==", "!=", "!"])

    def infer_comparison_type(mname)
      if COMPARISON_TYPES.include?(mname)
          "bool"
      else 
        ""
      end
      # Or even better, strip the else case
      # (Which would return nil for anything not in the set)
    end
This would be shorter, faster, more readable, and more easily maintainable, but Claude always defaults to an if-return, if-return, if-return pattern. (Even if-else seems to be somewhat alien to Claude.) My own Claude codebases are full of that if-return crap, and now I know I'm not alone.

Other files have much better code quality though. For example, most of the lib directory, which seems to correspond to the ext directory in the mainline Ruby repo. The API is clearly inspired by MRI ruby, even though the implementation differs substantially. I would guess that Matz prompted Claude to mirror parts of the original API and this had a bit of a regularizing effect on the output.

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

Re: Spinel: Ruby AOT Native Compiler

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

I've never even heard of Factor. thanks for sharing.
Post reply on HN