[HN Gopher] Natalie - a work-in-progress Ruby compiler, written ...
       ___________________________________________________________________
        
       Natalie - a work-in-progress Ruby compiler, written in Ruby and C++
        
       Author : ciconia
       Score  : 58 points
       Date   : 2023-09-24 07:40 UTC (15 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | BasedAnon wrote:
       | Wouldn't it be easier to have it transpile to Crystal? The
       | languages are already extremely similar
        
         | woodruffw wrote:
         | Crystal's syntax is somewhat similar to Ruby's, but its actual
         | semantics (and type system) are fundamentally different.
         | 
         | In particular, `method_missing` and other fundamentally dynamic
         | things that make Ruby feel like Ruby can't be done in Crystal,
         | at least not without extensive runtime support.
         | 
         | (I haven't looked at this implementation, but I suspect that
         | they end up doing similar things in C++ for the same reason.)
        
       | faitswulff wrote:
       | Andreas Kling (of SerenityOS and Ladybird fame) streamed
       | contributing a performance improvement to this compiler that was
       | pretty interesting to watch:
       | https://www.youtube.com/watch?v=b4PZgvPYkP4
        
       | ufmace wrote:
       | It's a cool project, but I'm not really sure what the point is.
       | I'm doubtful that you could ever match the full expressiveness of
       | Ruby in C++ or any compiled language. If you wanna play with it
       | because it's fun, that's fine, but I doubt that it would ever be
       | able to do much with most of the Ruby code out there.
        
         | Tao3300 wrote:
         | Never underestimate the power of doing it for fun.
        
       | egonschiele wrote:
       | What's the goal of the project? It's not clear from the Github
       | repo or the site (natalie-lang.org).
        
         | mk89 wrote:
         | I think:
         | 
         | > It provides an ahead-of-time compiler using C++ and gcc/clang
         | as the backend
         | 
         | Which is kind of the new "in" lately.
         | 
         | EDIT: If you see the the animation in the GitHub repo, you'll
         | see at a certain point a file named "bs" (which is a binary
         | file). I guess the standard Ruby compiler doesn't allow you to
         | spit out binaries out of the box (?).
        
           | ricardobeat wrote:
           | > I guess the standard Ruby compiler doesn't allow you to
           | spit out binaries
           | 
           | Ruby is an interpreted language, programs are not compiled
           | (except for the JIT compiler).
           | 
           | I wonder what makes this different from mruby[1] which seems
           | to be very well supported for many years.
           | 
           | [1] https://mruby.org/
        
             | deaddodo wrote:
             | If we're being honest, the only thing that differentiates
             | an interpreted and compiled language is intention (design
             | decisions that make one implementation versus the other
             | easier) and what you choose to run the language through.
             | 
             | You can make almost any general purpose language
             | "compiled", depending on how fat you're willing to make the
             | runtime. And you can certainly create an interpreter/JIT VM
             | for C/C++. It's not a question of possibility, but one of "
             | _why?_ ".
        
           | egonschiele wrote:
           | Cool, that was my read as well. Just making sure I wasn't
           | missing something!
        
           | e12e wrote:
           | Still think that crystal might be more interesting in a
           | similar niche?
           | 
           | https://crystal-lang.org/
        
             | dragonwriter wrote:
             | No, a compiler for Ruby is more interesting than a compiler
             | for a vaguely Ruby-like language with feature alterations
             | specifically for ease of implementing compilation.
             | 
             | Even if it only ends up compiling a subset of Ruby, it
             | could be a foundation for a Ruby equivalent of one of the
             | several tools for accelerating Python by compiling a subset
             | and allowing it to interface with regular interpreted code.
        
       | emmanueloga_ wrote:
       | For those asking what's the point, check the author's GitHub
       | profile: "I'm also making my own Ruby called Natalie. You know,
       | for fun!".
        
       | dang wrote:
       | Related:
       | 
       |  _Natalie: An early-stage Ruby implementation that compiles to
       | C++_ - https://news.ycombinator.com/item?id=29660883 - Dec 2021
       | (50 comments)
       | 
       |  _Natalie: A work-in-progress Ruby implementation, compiled to
       | C++_ - https://news.ycombinator.com/item?id=28207921 - Aug 2021
       | (2 comments)
        
       ___________________________________________________________________
       (page generated 2023-09-24 23:01 UTC)