Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Thus, even Java has product types.

Even C has product types. Which is why I'm always bothered when people claim language X lacks algebraic data types.

They probably lack sum types, but are very unlikely to lack product types.



Product types without sum types and pattern matching are basically useless for expressing ADTs. That's what people mean.


> Product types without sum types and pattern matching are basically useless for expressing ADTs.

That makes no sense. Algebraic data types are not expressed, they're a concrete thing, a classification of composite types (by multiplication (hence product types) or addition (hence sum types)).


Sure it does, languages allow you to express things.

Some shitty languages don't have a concise way for you to express particular things (like sum types), so you have to rely on idioms or "patterns".


C also has sum types with unions (though without any indication of which of the alternatives is actually present).


They are mix types then.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: