News for hackers. Stuff that matters.
Re:Against SQL by thom on Saturday July 10, 2021 @04:30AM (#27792003)
In most languages where unions are a first class concept, are they not generally warned against?
Re:Against SQL by ebingdom on Saturday July 10, 2021 @05:31AM (#27792245)
The author uses the term "union", but unfortunately they picked the one wrong term against a long list of correct alternatives: sum type, tagged union, discriminated union, coproduct, disjoint union, variant, algebraic data type, ...

"Union" does not imply disjointness (which is the source of many problems), whereas all those other terms do.

Re:Against SQL by valenterry on Saturday July 10, 2021 @07:37AM (#27792684)
Correct, I just continued to use the term of OP. Sum types r coproducts are what I mean.
Re:Against SQL by ebingdom on Saturday July 10, 2021 @08:52AM (#27793035)
By the "author", I meant the author of the article. I figured you were just being consistent with them.
Re:Against SQL by OskarS on Saturday July 10, 2021 @04:42AM (#27792059)
You’re probably thinking of C/C++ unions, and they do indeed have quite tricky semantics and are difficult to use correctly. What the article and the other commentators are talking about is more properly called a “sum type”, like Rust’s enums, for instance. Those are different things from C unions. In languages with first class support for sum types, they are used everywhere, it’s an incredibly useful concept.
Re:Against SQL by thom on Saturday July 10, 2021 @04:45AM (#27792067)
Gotcha, ta. That becomes a tricky problem when we're talking about something that's primarily a storage engine though, right?
Re:Against SQL by paavohtl on Saturday July 10, 2021 @10:30AM (#27793557)
Well, sum types are not magic - they must be stored in the memory somehow. Rust's enums tend to use a simple approach: there's a large enough integer tag (usually an 8-bit integer), followed by enough space to store any of the variants. The same exact encoding could be used with a database storage engine too.
Re:Against SQL by valenterry on Saturday July 10, 2021 @07:39AM (#27792687)
Not sure - because in the end, a programming language also has to store this concept in memory. I don't think there is a fundamental difference.
Re:Against SQL by bccdee on Saturday July 10, 2021 @04:37AM (#27792042)
Not at all. Untagged unions, sure, but no decent modern language has first-class support for untagged unions. First-class tagged unions are a real treat to use.