In any other situation I firmly believe the benefits Typescript brings very quickly outweigh the small amount of added complexity.
I also enjoy piling on Rust fanboys,but those of us who had to go through late night troubleshooting sessions to track issues that were ultimately caused by use-after-free issues do tend to be vulnerable to Rust's memory safety siren's song
I've been a full-stack web developer for over a decade across multiple companies and this is the first time I've seen the phrase "discriminated unions".
And the wikipedia article is horrendous. It starts with the following sentence and gets worse from there.
> In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types.
It uses lots and lots of words to explain something that's very simple. If you don't already know what it is, you can't figure out which words are important.
Then after all of the theory, it dives into a binary tree example which has to be the worst possible way to explain it. If you haven't implemented a binary tree before, you don't know any idea what you're looking at. It didn't help that I implemented a linked list in college.
Also, the choice of language ensures you have no idea what the types are. I completely missed the first example was self-referential.
It's like parody of a function programmer writing an explanation for anyone who isn't a functional programmer.
I've been programming in some form or another since the late-80s. I've been paid to write code for other people for over twenty years. I haven't gone to university.
Maybe it's because I started back in BASIC, assembler, and later C that I know what that term is and have encountered it in various languages and forms several times since?
The problem with wikipedia definitions is that they have to be the definition. Some one like me would expect a link to the definition and not a tutorial. They're not written to take into account that you've been a professional programmer and have never been exposed to a computer science curriculum nor are they written for laypersons who don't know anything about programming.
It's a similar problem for functional programmers trying to explain functors, monoids, and monads: these are not terribly complicated abstractions but catering your explanation to the various audiences out there is incredibly difficult. The definitions sounds like gibberish... but with effort and education it is possible to understand and appreciate it.
https://basarat.gitbook.io/typescript/type-system/discrimina...
I'm sincerely sorry for confusing you! Discriminated unions are nice but above I was exaggerating excessively to make a point :)
10 DEFINT A-Z