4 ms·
Honestly the TC39 is the best case scenario. https://tc39.es/proposal-type-annotations/ https://tc39.es/proposal-type-annotations/ Forget runtime type validati
by javier123454321 3y ago
Honestly the TC39 is the best case scenario. https://tc39.es/proposal-type-annotations/ https://tc39.es/proposal-type-annotations/
Forget runtime type validation, TS is really for preventing bugs at development time as well as IDE integration.
- josephg 3y agoIf types were added to javascript it could also dramatically improve the performance of javascript virtual machines (V8 and friends). It seems so silly to me that I write typescript, then the types are erased from my code, sent to the browser, and then the browser tries to infer them as part of its own optimization process. Adding types to javascript proper would be fantastic.
- bazoom42 3y ago> If types were added to javascript it could also dramatically improve the performance of javascript virtual machines Are you sure? In my understanding modern JS engines basically makes type inference on the code anyway, and in the rare case when types are observed to change at runtime, it is special-cased. So static types might simplify this but I dont see how it would dramatically improve performance.
- IshKebab 3y agoThis is a good read: https://medium.com/dartlang/dart-and-the-performance-benefits-of-sound-types https://medium.com/dartlang/dart-and-the-performance-benefit... That said I really doubt JS will actually get sound static types ever. Typescript is not sound.
- auscompgeek 3y agoThat Medium link 404s for me.
- homarp 3y agohttps://medium.com/dartlang/dart-and-the-performance-benefits-of-sound-types-6ceedd5b6cdc https://medium.com/dartlang/dart-and-the-performance-benefit... works for me or https://web.archive.org/web/20210310020311/https://medium.com/dartlang/dart-and-the-performance-benefits-of-sound-types-6ceedd5b6cdc https://web.archive.org/web/20210310020311/https://medium.co...
- olejorgenb 3y agoAnd chances are(?) typescript code are to a larger degree monomorphic than javascript making the JIT more efficient(?). At least typescript discourage writing functions where the parameters can have wildly different types since this is un-ergonomic and/or hard to type.
- vbezhenar 3y agoThis proposal is not about adding types to JavaScript. This proposal is about new syntax for comments in JavaScript. Virtual machine will not use this information.