3 ms·
I don't think so: TypeScript/JavaScript-Types are too coarse-grained for optimizations: For example number is a double in JS. For generating good machine code y
by readittwice 8y ago
I don't think so: TypeScript/JavaScript-Types are too coarse-grained for optimizations: For example number is a double in JS. For generating good machine code you really need to know whether the number is int or double. The same for string: Depending on the JS engine there are actually a lot of different string types.
Even if we consider that good enough or somehow solved, understanding type annotations only helps you reaching peak performance faster. It doesn't really make peak performance faster.
Also there are the PyPy and Dart devs that in theory could use type annotations, but both don't. For PyPy they even have an entry in the FAQ: http://doc.pypy.org/en/latest/faq.html#would-type-annotations-help-pypy-s-performance http://doc.pypy.org/en/latest/faq.html#would-type-annotation...
- dvlsg 8y agoAn int64 type is being added to Javascript in the near future, I believe. Of course it will take a while to be supported everywhere, but they are taking steps in that direction at least.
- masklinn 8y agoI think the type annotations themselves don't do anything, but the typing strongly pushes developers towards monomorphic (or at least non-megamorphic) calls sites; and having proper-ish data types may also encourages consistent order of initialisation. I don't really know about the details fo Pypy, but from what I gathered from performance talks about V8 between the hidden classes and inline caching it would strongly benefit from these behavioural changes. Basically, it doesn't preclude the runtime from having to do its analysis, but it makes the analysis & optimisations "hit" at higher rates than they would otherwise do.
- wruza 8y ago>For generating good machine code you really need to know whether the number is int or double Do you? I remember reading that LJ is able to infer ints for e.g. loops with no specific effort (neither performance hit).