Since Typescript is just a superset of javascript (every javascript program is also a typescript program), I've got this idea - why doesn't v8 support typescript? or anything statically typed compatible with JS? This way it could do some real big performance hacks and suit a much wider range of programmers who require static typing... For me it sounds like a very good idea. Why hasn't anyone done this yet? (so the Q is: are there some visible downsides of this solution? I don't see anything but I'm sure there may be something...)
closed as too broad by Steven Burnap, GlenH7, gnat, MichaelT, MainMa Mar 8 at 16:42There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question. |
|||||||||||||||||
|
For starters, v8 predates (public knowledge of) TypeScript by several years, TypeScript isn't from Google, Google isn't invested in it, TypeScript is far from an industry standard, and Google has its own language trying to fill a similar niche (Dart). And then there's the problem that nobody deploys TypeScript to websites, it's designed to be compiled to JavaScript and that's what everyone does. But let's assume none of this matters. I don't believe that there are any performance gains to be had. Precisely because it is interoperable with JavaScript, TypeScript's type system provides virtually no hard guarantees. Sure, it allows workable autocomplete in most circumstances, but it does not guarantee that the types are all 100% correct. With type assertions ( JIT compilers can already figure out all information they need for optimization with runtime instrumentation. TypeScript can't statically eliminate the need for those checks, so it provides no extra value. Maybe the types could give the baseline compiler an initial guess for speculative optimizations (which would be overridden by runtime profiling data in later stages), but:
|
|||||
|