3 ms·
In fact I've implemented precisely that first tradeoff in a library and it isn't too bad. It's still much slower than machine words though. In Dart this become
by wbhart 15y ago
In fact I've implemented precisely that first tradeoff in a library and it isn't too bad. It's still much slower than machine words though.
In Dart this becomes more constrained as it uses dynamic typing. Apparently the types specified by the programmer will be thrown away when it is compiled down to VM instructions. They are only used to specify/check interfaces.
What this means is that those tags become quite large in the implementation. You can try any Common Lisp or Scheme R6RS without type inference to see how fast or slow this is in practice.
I don't completely understand the second trick. Where are the bignums?
- Peaker 15y agoHe's basically saying: If the integer is tagged in its static type to be within the range of some array -- then that is proof that it is not a "bignum" and can be stored as a machine word.
- wbhart 15y agoOh yeah. That's an optimisation more languages should use. But he clearly doesn't do much mathematics if he thinks most integers are array indices. His point is doubtlessly right in his problem domain though and maybe even for a large sector of the programming community.