As the post nicely demonstrates, TypeScript is definitely not OK for compilers (and not surprising at all!) It doesn't even have destructuring pattern matching! At this point, even Java is better [1]. [1] https://github.com/tomprimozic/caya/blob/master/src/caya/Int...
Pattern matching is definitely not a requirement for a language to be good for writing compilers in.
TypeScript is surprisingly ok for compilers
61–70 of 245 posts
Re: TypeScript is surprisingly ok for compilers
#62Is that really suprising? Typescript is yet another language that has, kicking and screaming, picked up most of the ML featureset. I'd expect it to be, well, fine; the lack of real pattern matching is a pain, so it's going to be inferior to OCaml, but fine, no different from using C# or Swift or Dart or Kotlin or something of that ilk.
I've done a bit of typescript and kotlin-js. It always strikes me how close those two languages are. Yes there are lots of differences but they aren't that different and you can transition from one to the other pretty easily. I have my preferences (kotlin) but I can work with both. IMHO typescript could just cut loose from its javascript compatibility. Why not compile it to wasm instead of transpiling it to javascrip…
Re: TypeScript is surprisingly ok for compilers
#63Is that really suprising? Typescript is yet another language that has, kicking and screaming, picked up most of the ML featureset. I'd expect it to be, well, fine; the lack of real pattern matching is a pain, so it's going to be inferior to OCaml, but fine, no different from using C# or Swift or Dart or Kotlin or something of that ilk.
I've done a bit of typescript and kotlin-js. It always strikes me how close those two languages are. Yes there are lots of differences but they aren't that different and you can transition from one to the other pretty easily. I have my preferences (kotlin) but I can work with both. IMHO typescript could just cut loose from its javascript compatibility. Why not compile it to wasm instead of transpiling it to javascrip…
Re: TypeScript is surprisingly ok for compilers
#64Is that really suprising? Typescript is yet another language that has, kicking and screaming, picked up most of the ML featureset. I'd expect it to be, well, fine; the lack of real pattern matching is a pain, so it's going to be inferior to OCaml, but fine, no different from using C# or Swift or Dart or Kotlin or something of that ilk.
Re: TypeScript is surprisingly ok for compilers
#65TS's type system is fun but a part of me always wonders how much faster TS's compiler would be if it was written in a compiled language (assuming "good implementation", which is a big assumption!)
Written in Rust by the (lead?) dev of SWC
---
SWC (speedy web compiler) compiles TS to JS
STC (speedy type checker) checks TS types
Re: TypeScript is surprisingly ok for compilers
#66Is that really suprising? Typescript is yet another language that has, kicking and screaming, picked up most of the ML featureset. I'd expect it to be, well, fine; the lack of real pattern matching is a pain, so it's going to be inferior to OCaml, but fine, no different from using C# or Swift or Dart or Kotlin or something of that ilk.
The biggest expressivity pain point in practice for me is try/catch not being an expression, so I can’t do const c = try { … }
Re: TypeScript is surprisingly ok for compilers
#67As the post nicely demonstrates, TypeScript is definitely not OK for compilers (and not surprising at all!) It doesn't even have destructuring pattern matching! At this point, even Java is better [1]. [1] https://github.com/tomprimozic/caya/blob/master/src/caya/Int...
Re: TypeScript is surprisingly ok for compilers
#68Earlier quoted context omitted.
That's some very high level view - in reality even tough those languages are in similar categories the experience would be vastly different : TypeScript - powerful type system but shit underlying stdlib and language (no pattern matching/switch expressions) Dart - worse than TS because the object model is closed - so no dynamic freedom, but the type system and expressions are weaker then the rest. Also 0 meta programm…
> no pattern matching/switch expressions They're still waiting on the do expression proposal for that ( https://github.com/tc39/proposal-do-expressions ), which has been in the bikeshedding stage for the past five years.
And the React example makes no sense, you can use a ternary and it is even shorter.
``` return ( {loggedIn ? : } ) ```
Re: TypeScript is surprisingly ok for compilers
#69Earlier quoted context omitted.
I've done a bit of typescript and kotlin-js. It always strikes me how close those two languages are. Yes there are lots of differences but they aren't that different and you can transition from one to the other pretty easily. I have my preferences (kotlin) but I can work with both. IMHO typescript could just cut loose from its javascript compatibility. Why not compile it to wasm instead of transpiling it to javascrip…
"Modern" Javascript essentially is Typescript without the type hints (e.g. if you ignore the historical baggage, JS is actually a fairly decent language).
People wanted a different language, they should have gotten more scripting languages in the browser. Not changing JavaScript so much that it's no longer JavaScript.
Re: TypeScript is surprisingly ok for compilers
#70Is that really suprising? Typescript is yet another language that has, kicking and screaming, picked up most of the ML featureset. I'd expect it to be, well, fine; the lack of real pattern matching is a pain, so it's going to be inferior to OCaml, but fine, no different from using C# or Swift or Dart or Kotlin or something of that ilk.
I've done a bit of typescript and kotlin-js. It always strikes me how close those two languages are. Yes there are lots of differences but they aren't that different and you can transition from one to the other pretty easily. I have my preferences (kotlin) but I can work with both. IMHO typescript could just cut loose from its javascript compatibility. Why not compile it to wasm instead of transpiling it to javascrip…
In browsers the Wasm runtime doesn't have access to the DOM APIs. So that's wishful thinking ATM.