13 ms·
The article seems to be not-so-subtly hinting that Java is an anti-math programming language, and I agree. The language encourages each developer to reinvent an
by kyllo 12y ago
The article seems to be not-so-subtly hinting that Java is an anti-math programming language, and I agree. The language encourages each developer to reinvent and reimplement key concepts in terms of "classes" that are much more succinctly described in languages that embrace abstract algebra. The example of using inheritance and dynamic dispatch to represent a union type, is a perfect example.
- Klockan 12y agoUnion types is not a key concept in abstract algebra, I bet that most mathematicians have never even heard of it. I'd like to hear about its use in abstract algebra, how would you define the union type of the simplest of simple objects without breaking its operation: a group with a group?
- throwaway283719 12y agoThat would be a groupoid - http://en.wikipedia.org/wiki/Groupoid http://en.wikipedia.org/wiki/Groupoid
- Klockan 12y agoNo, groupoids breaks the group operation and thus behaves like neither of the groups. Do type systems allow operations between union types? If not then it is just a simple interface in OO. If they do then you are no longer working with pure functions.
- kyllo 12y agoI didn't say that union types are a key concept in abstract algebra, and I'm not a mathematician by any means, although I vaguely understand that a disjoint union is a thing in set theory. What I'm saying is that languages that do embrace concepts from abstract algebra, are much more expressive than languages that eschew these concepts (like Java).
- j2kun 12y agoThe concept is called a coproduct. The coproduct of two sets is the disjoint union. The coproduct of two abelian groups is also called the direct sum [edited], and the category of general groups does not have coproducts. The coproduct of two types in the category of types is exactly the union type. The idea of an Abelian category (basically, a "nice" category) requires the existence of coproducts, which I think is widely used enough in universal algebra to be considered a key concept. I wrote a long (and unfinished) series about how to interpret category theory with programs on my blog [0], and in [1] I cover universal properties and the coproduct, which describes how you would formulate a "union type" in any category. [0]: http://jeremykun.com/ http://jeremykun.com/ [1]: http://jeremykun.com/2013/05/24/universal-properties/ http://jeremykun.com/2013/05/24/universal-properties/