|
|
|
|
|
by slavapestov
2924 days ago
|
|
> Suppose everything - even every int - is heap-allocated. You now need a very sophisticated JIT compiler (as in, better than any we have today), or it's going to run dog slow. Most dynamic language implementations (JavaScript, Lisp, Smalltalk, even Ruby) use a tagged pointer representation allowing integers (and sometimes floats) to be encoded directly in the reference, avoiding heap allocation in this common case. Another alternate model is to pass the type of a value separately from the value itself, and allow the value to be of variable size. Java simply made the wrong tradeoff, and while it wasn't fully apparent at the time, there's no good defense of that decision today. |
|
Code that deals with a lot of values which are small but larger than a machine word can be made a lot more efficient if there is a way to treat those values as not objects.