Hacker News new | past | comments | ask | show | jobs | submit login

This complaint comes up enough that I'm surprised nobody's created the Ruby equivalent of GraalVM, to compile a Ruby script, all its deps, and a WPOed subset of the Ruby runtime, into a native executable.



Given Ruby's lackluster type system, the amount of assumptions a compiler can take is significantly reduced. Moreover, analyzing that at a simple IR level would prevent it from understanding of what is actually referenced vs what isn't without making compile times take eternity and performing complex flow analysis with simulation.

Even with a good type system, a trimmer/linker has to be enlightened of many special idioms and patterns and perform flow analysis, and in the case of dynamically typed languages or languages with reflection - to analyze reachability of reflectable members and trim otherwise spaceous metadata. It took significant amount of work in .NET's ILLink in order for it to be able to produce as compact binaries/libraries as it does today with .NET's AOT build target, and it still required a degree of metdata compression and dehydration of pointer-rich data structures (something which, funnily enough, Go doesn't do, resulting in worse binary size).


It's not quite what you're describing, but TruffleRuby is Ruby on GraalVM:

https://github.com/oracle/truffleruby

Unlike GraalVM Java, as far as I can tell TruffleRuby doesn't provide a bundler that can create a single executable out of everything, but in principle I don't see why it couldn't.


Worth noting that the GraalPython implementation does support creating a single binary.

https://www.graalvm.org/latest/reference-manual/python/stand...

I'm not sure I'd try replacing shell scripts with natively compiled Python binaries. That said, I use a Kotlin Scripting based bash replacement in my own work that has many useful features for shell scripting and is generally much more pleasant. You have to "install" it in the sense of having it extracted somewhere, but it runs on Win/Mac/Linux and can be used without root etc.


I wasn't so much imagining each shell script being replaced with a binary, as I was imagining deploying a single static binary "sysadmin-DSL interpreter binary" — where that "interpreter" is just "Ruby with a custom prelude, all packed together" — such that I could then name that interpreter in the shebang line for my admin scripts written in that DSL.


Graal can create an executable from a ruby program as well with TruffleRuby and native image (both part of the general graal project).


WPO?


While Program Optimization, in this case mostly meaning dead-code elimination for any runtime code not called by the Ruby code.


I think you mean Whole Program Optimization.




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

Search: