Re:What I Learned Making My Own JIT Language
by arghwhat on Wednesday June 27, 2018 @06:16PM
(#17412326)
Ah yes, I had forgotten about Typed Arrays, which is a terrible name for what is in fact a buffer view. The entire arraybuffer/typedarray system was a later (≥IE10 if I am not mistaken?) hack added to make up for the fact that Array and Number are super inefficient for data processing.
But regardless of them being a bandaid, you are correct that it is an exception. ArrayBuffer and all its views count 10 types in total, so were they the only exception? If so, I believe my point still stands.
Re:What I Learned Making My Own JIT Language
by squeaky-clean on Wednesday June 27, 2018 @06:03PM
(#17412227)
That's just how it optimizes their usage under-the-hood, but as far as JS is concerned they are all hash maps.
For example, try this:
var foo = [1,2,3]; // or `foo = new Array(1,2,3)` also works
foo['bar'] = 'test';
console.log(foo);
and you get: 0:1
1:2
2:3
bar:"test"
I can see at least 10 types which are not hash maps. Including all the flavors of Typed Arrays.