Remix.run Logo
soraminazuki a day ago

Whoa, that's a core building block of programming and computer science that you're dismissing as "niche" without explanation.

mistrial9 19 hours ago | parent [-]

yes types are a core building block of programming and computer science, but not using UNION ? this casual dismissal of "criticisms of UNION" here seems superficial and un-wise to me.

soraminazuki 14 hours ago | parent [-]

Sum types, not C unions. Different concepts.

A sum type is a concept from type theory. Like unions, it expresses a type that can be either one of multiple types. But unlike unions, it retains information about which type it is.

Properly implemented sum types are completely type safe. I can't be 100% sure what your particular "criticisms" of C unions precisely are, but assuming they all relate to type safety, they don't apply to sum types.

Sum types are important because any real world project has to deal with data that's either A or B. There's nothing controversial here.

In C, a union is a way to implement that. Yes, it's unsafe. But can you eliminate the use of unsafe features from C projects? No, if they deal with memory.

Also, it's rich and quite frankly rude to brush off my comment as "casual dismissals," "superficial," and "unwise" when it's a direct response to this.

> your niche feature "sum types"

That's pure unprovoked smugness right there that contains no substance of what your criticisms actually are, let alone the reason.