by obblekk · 3y ago · 0 comments
Personally, I find direct Typescript interpretation to be one of the best features. Typescript is not necessarily a simple type system, but it is an expressive one:
- It has great type inference avoiding Java style codespam
- It has gradual typing, enabling "risky" type casts
- It has fully functional types, enabling the productivity and readability improvements from functions as data
- It is 10 seconds away from having dependent types
Typescript took most of the best programming language research from the past 20 years and popularized it in a way that actually makes js hackers more productive without getting too much in the way.
The only hard thing has been that js interpreters don't understand typescript, requiring an awkward transpilation step with weird symlinks and other hidden complexity that works 99% of the time, but wastes a lot of time when it doesn't work just right.
If Deno could just solve that, it would be a great improvement. If it's also faster (as claimed) that's even better. This article shows a lot of other ways in which small, simple improvements add up to a much better product.
Can't wait until it's production ready.
If you don’t need systems language type performance, and don’t need true parallelism, it’s a pretty terrific choice. Starts out productive/simple in the early days of a project, stays productive/simple as it grows. Plus, if you’re doing “mobile apps + web app + RESTful services”, pretty nice that you can do it all in one language (assuming React Native on mobile), and that there’s no JSON related boilerplate.
I have the impression that many of us programmers have a hard time really accepting that different applications of programming require vastly different skillsets, so we often underestimate how hard things can be.
For example, a software developer of 15 years probably doesn't have almost any of the necessary skills to make a new database server.
A lot less would be a lot more, because as of now Typescript lures otherwise entirely competent programmers into writing complex 'type system puzzles' which are entirely obscure to everybody except the person who wrote that code, and it takes a lot of discipline and experience to reist the lure and keep things simple.
I want a type system that embraces the correct way to to do things instead of allowing anything you want no matter how bad it actually is. I want my type system to inform me that my code is really bad for performance and should be redone.
Instead, I constantly deal with people who think their code is fine just because the TS checker doesn't complain.
Excessive typing is very costly and should be left to popular libraries that solve generic problems. This is where you get best bang for buck.
It should not be present in your business code, high level business logic is rarely prone to type errors anyway.
Static typing was always a means to an end, but unfortunately it was recently sold as a virtue and many people have bought it.
They are the most natural way to encode structural information, especially across language/system boundaries.
- Clojure’s multimethods (multiple dispatch)
- Clojure spec’s “or”
- JSON schema’s “anyOf”
There’s likely more features and tools that are not strictly/statically discriminated/tagged unions, but in practice they help you to code that way.
In TS this is IMO the best feature. In a sense it just adds tooling support on top of a coding style that is very close to dynamic typing.
My favourite use-case for discriminated unions is to represent all possible client events as a DU, as well as the entirety of the application state. This allows you to efficiently communicate with a backend over websockets via a very thin transport layer that only needs to handle one message type.