3 ms·
No, but it saves you having to emit machine code that does type checking and dispatch at run-time. You need type information if you want inner-loop performance
by mbrubeck 16y ago
No, but it saves you having to emit machine code that does type checking and dispatch at run-time. You need type information if you want inner-loop performance that is competitive with languages (like C) that are designed for efficient compilation.
The generated code for something like "a = b + c" is very, very different if you know at compile-time whether b and c are strings or numbers or something else. Modern JavaScript VMs go to a lot of effort to guess or infer type information before JIT compilation.
- andraz 16y agoActually modern JavaScript engines depend on dynamic type discovery (via different forms of tracing) much more than on global static analysis.
- _delirium 16y agoIs there a good analysis anywhere on the pros/cons of that, and what languages it's most suited to? Lisp is also a dynamically typed (and otherwise quite dynamic) language, yet SBCL uses static type inference for its optimizations instead. Some difference in Lisp v. Javascript, or just different choices by the implementors?