2 ms·
The methods are not constant: def foo Array.send(:define_method, :sort) do; [100, 200]; end end puts eval([1, 2, 3].inspect).sort[1] * 2
by pron 8y ago
The methods are not constant:
def foo
Array.send(:define_method, :sort) do; [100, 200]; end
end
puts eval([1, 2, 3].inspect).sort[1] * 2
foo
puts eval([1, 2, 3].inspect).sort[1] * 2
But, anyway, my points isn't about partial-evaluation of values specifically (although JITs can and do do that); instead of int and 2 you can consider a type with 4 billion subtypes. JITs do specializations that an AOT simply cannot possibly do (not without code explosion).
Now, as I wrote in the original comment, I'm definitely not saying that JIT compilation is "better" than AOT. I am saying that the "zero-cost abstraction" philosophy of C++/Rust and the "zero-cost use" philosophy of JITs are two extremes that are each perfectly suited to two very different software domains.