I'm working on techniques to optimise through the core library in Ruby, and it's requiring novel research techniques that clearly weren't needed in LuaJIT, as it was done without them, so there must be something extra in Ruby.
I'm working on techniques to optimise through the core library in Ruby, and it's requiring novel research techniques that clearly weren't needed in LuaJIT, as it was done without them, so there must be something extra in Ruby.
So it can be done.
And to quote Mike Pall again
"" tl;dr: The reason why X is slow, is because X's implementation is slow, unoptimized or untuned. Language design just influences how hard it is to make up for it. There are no excuses. "
Knowing Ruby only superficially I fail to see why the former three managed to have AOT and JIT compilers, while Ruby still requires novel research techniques as you say.
Thinking of Smalltalk, become: is probably one of the best ways to kill anything a JIT knows about an object.
I use a Ruby library called psd.rb as an example. It's for handling Photoshop files. It represents pixels as a hash (map) of r, g and b values, and it parameterises the kind of filter in your image by making reflective method calls with dynamically created strings instead of using a function object of some kind.
So to compile that to tight machine code that looks like something a C compiler would output, you are going to have to completely optimise away the pixel hash and the reflective method call.
You could probably write that kind of code in the languages you mentioned, but people usually don't. In Ruby, that's how a lot of the code is written, starting with the standard library itself.
Maybe I could restate it by saying that optimising typical idiomatic Ruby code is more difficult than optimising typical idiomatic Smalltalk, Lisp, Lua etc.
More here: http://chrisseaton.com/rubytruffle/pushing-pixels/. Look half-way down at 'Acid Test'. My implementation of Ruby can compile that whole program to a constant.
I remembered you mentioned that example in some Graal talks I've watched.
As much as I reach for more performant languages, I still need to work with Ruby on a daily basis. I really appreciate the ongoing work done by you and others to keep the ecosystem alive and prosperous.