by azakai · 14y ago · 0 comments
> That's what I thought, too. The VM designers say that in practice, type guarantees really don't help them nearly as much as you might think, because type checks are not a major drain on performance.
If this is the case, what is supposed to make Dart faster than JavaScript? It sounds like they will end up around the same speed.
In JavaScript, I can write this:
var dog = new Animal();
dog.name = "Fido";
... adding a new field to the "dog" object, even though other objects of the same class may have no such field. Objects that share common sets of fields are the famous "hidden classes" that V8 is able to optimize.You can't write the above example in Dart. Dart doesn't have to work as hard as V8 to discover and cache hidden classes, because the shape of an object is statically fixed to be the same as its class.