This article discusses the difficulties of optimization arising from extremely dynamic languages ββsuch as JavaScript, and prototype inheritance.
In languages ββsuch as Ruby or JavaScript, the structure of the program may change at run time. Classes can get a new method, functions can be eval () 'ed into existence and much more. This makes code optimization difficult because the structure will never be guaranteed.
Prototype inheritance is more difficult to optimize than traditional class-based languages. I suspect this is due to the fact that many years of research and implementation experience for class-based virtual machines.
Interestingly, V8 (the JavaScript JavaScript engine) uses hidden classes as part of its optimization strategy. Of course, JS has no classes, so arranging objects in V8 is more complicated.
The layout of an object in V8 requires at least 3 words in the title. In contrast, Dart VM requires only 1 word in the title. The size and structure of the Dart object is known at compile time. This is very useful for VM developers.
Another example: Dart has real lists (aka arrays). You may have a fixed-length list that is easier to optimize than JavaScript, rather than arrays and always variable lengths.
More on compiling Dart (and JavaScript) for efficient code with this presentation: http://www.dartlang.org/slides/2013/04/compiling-dart-to-efficient-machine-code.pdf
Another performance parameter is startup time. As web applications become more complex, the number of lines of code increases. JavaScript design makes run optimization difficult because parsing and loading code also executes code. At Dart, the language was carefully designed to make it out quickly. Dart does not execute code when downloading and analyzing files.
It also means that Dart VMs can cache the binary representation of the analyzed files (the so-called snapshot) for even faster startup.
Seth ladd
source share