|
|
|
|
|
by 7thaccount
2086 days ago
|
|
Not OP and don't use JS, but generally speaking, a lot of these languages that transpile one language into another (or compile one language to another for those that insist transpile is the wrong word), it comes up with a less efficient result than if I had just used the original language. Or at least a different program. So if I use Type Script that gets converted to JavaScript, the end result will be different than if I had done it like that to begin with (not necessarily slower either). Also...I guess there are situations where using something (Ex: C) could lead to faster code than me using Assembly by myself if the compiler is smarter than me (GCC knows a lot more about hardware than I do). |
|
This isn't true for Typescript. TypeScript is a superset of JavaScript, and running JavaScript through the TypeScript compiler will produce identical output code[1]. If you add type annotations to that JavaScript to make it fully pass the strictest type checking settings, that will still be true provided you didn't otherwise rearrange or modify your program.
This makes me doubt their methodology on TypeScript at least, or wonder if they're running a tool like `ts-node` which compiles and runs at the same time, thus counting compile time in their execution time and energy.
1. As long as you're targeting the same language version as the original code was written for. For instance the compiler will downlevel async/await into slower async generators if you're targeting a version of JavaScript which doesn't support it yet.