News for hackers. Stuff that matters.
Re:Announcing TypeScript 2.0 by rbanffy on Thursday September 22, 2016 @04:37PM (#12560163)
JITs help a lot with that.
Re:Announcing TypeScript 2.0 by vardump on Thursday September 22, 2016 @04:47PM (#12560239)
You got it exactly the opposite way.

Because JITs do type inference and compile specialized code with an assumption type doesn't change, they stop working when type(s) change(s) dynamically. When that happens, JITs need to deoptimize code, which leads to a dramatic slowdown.

In other words, changing type is the case where JITs don't help and their performance nosedives, because it breaks the underlying assumptions on type stability. Type stability is needed to generate compiled binary (x86, ARM, etc.) code.

Re:Announcing TypeScript 2.0 by rbanffy on Friday September 23, 2016 @04:30AM (#12563135)
No. Perhaps I wasn't clear.

The code running under a JIT will behave like the static typed code when the code (and data) allows it while the programmer didn't have the additional burden of doing the type analysis for the computer.

You may be confusing dynamic typing with weak types.

Also, it's perfectly fine for the JIT to generate multiple code paths that are invoked depending on runtime types even when the source code declares a single one that acts on multiple types.