5 ms·
Given the number of codebases littered with 'any', and the fact that TS is known to produce app bundles that perform slower than handwritten JS code, I'm in two
by dynamite-ready 4y ago
Given the number of codebases littered with 'any', and the fact that TS is known to produce app bundles that perform slower than handwritten JS code, I'm in two minds about celebrating those ten years... But it is strange to think it's been ten years.
- mumphster 4y agoDo you have examples of slower code generated by typescript? TS is a superset of JS so it changing anything that has a large performance impact seems odd, but maybe I’m missing something here. The types aren’t even available at runtime, what’s the biggest slow down you’ve seen?
- redox99 4y agoMost likely polyfills because he's targeting some old ES version.
- dynamite-ready 4y agohttps://thenewstack.io/which-programming-languages-use-the-least-electricity/ https://thenewstack.io/which-programming-languages-use-the-l...
- int_19h 4y agoThis claims that TypeScript is an order of magnitude slower than JavaScript, which is obvious nonsense if you know how TypeScript works, unless they counted transpiling in execution time.
- jmull 4y ago> TS is known to produce app bundles that perform slower than handwritten JS code I’m curious about this, and runs counter to my understanding of typescript. Do you have any sources on this? I’m googling a bit but not really finding anything.
- laundermaf 4y ago> TS is known to produce app bundles that perform slower than handwritten JS code Wrong. TS doesn’t bundle files. TS doesn’t produce code unless you target an earlier ES version than what you write, in which case there’s no way around it: native for-of loops and await/async will always be faster regardless of what you use to transpile it. I think you’re confusing the tool with something else.
- mirekrusin 4y agoTs does produce code, ie. for enums, modules/namespaces.
- ksbrooksjr 4y agoConst enums get completely erased by the compiler, and modules are a native js feature. Non-const enums and namespaces are probably the only aspects of typescript that actually have any significance at runtime, but they get compiled into simple objects. The compiler output is very close to what you'd write by hand. Take a look at this compiler output here [1]. Unless you're constantly recreating enums and namespaces inside of a loop (which you'd never do in real life code), I can't imagine there'd be any performance penalty. [1] https://www.typescriptlang.org/play?target=99#code/HYQwtgpgzgDiDGEAEBlA9pAcuadFIG8AoJJCADxjQCcAXJeNYKegMzTSQF4kByAIxDVeRAL5EJEYAFcwqDBACiMucVKl2nHgKEjxRAPQGktABYBLKAyYsyKpAHdzAG2dJ+yCNRBQIAE3cATxNTZEYwGBcvIkZmeilZeUgAYRtaZUS1dQBHaXJuPlzyPSA https://www.typescriptlang.org/play?target=99#code/HYQwtgpgz...
- mirekrusin 4y agoSo ts does produce code.
- ksbrooksjr 4y agoIt can (depending on which features you're using), but the comment that started this thread claimed that the produced code was much slower than handwritten js. I was just pointing out that the examples you gave (enums and namespaces), don't change the performance of your code.