5 ms·
Totally non-opinionated tried and tested fact that all humanity knows: Anything that doesn't have discriminated unions cannot be used productively.
by patates 3y ago
Totally non-opinionated tried and tested fact that all humanity knows: Anything that doesn't have discriminated unions cannot be used productively.
- kayodelycaon 3y agoExcellent choice of term. 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.
- agentultra 3y ago"Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it." -- Djikstra. 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.
- TedDoesntTalk 3y agoYou could edit the wiki page.
- bentcorner 3y agoCare the elaborate? I'm not challenging you I'd just like to learn more. I recently transitioned from writing C++ to Typescript and probably haven't fully grokked the TS way.
- patates 3y agoOh, I'm so sorry, I was being (or trying to be) sarcastic. However, if you are curious, here is a deep dive: https://basarat.gitbook.io/typescript/type-system/discriminated-unions 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 :)
- bentcorner 3y agoHahaha no problem thanks for clarifying :)