3 ms·
With interfaces, it's pretty simple to replicate patterns like a Container<Comparable> or Channel<Reader>, to borrow common Java syntax. Personally, I like how
by johnpmayer 15y ago
With interfaces, it's pretty simple to replicate patterns like a Container<Comparable> or Channel<Reader>, to borrow common Java syntax. Personally, I like how it forces you to think about parametricity whenever you want polymorphism, like most functional languages.
- TylerE 15y agoBut, unless I'm missing something, it's missing the supporting bits you get in a nice functional language, like algebraic datatypes and pattern matching, which make that style much more pleasant. Of course, most of the functional language DO have generics, and full type inference to boot, also.
- EdiX 15y agoThe ML language family does, other functional languages (the LISP family, Erlang) don't.
- TylerE 15y agoArguably lisp doesn't NEED generics since unless you go around setting lots of type pragmas, the typing system generally doesn't intrude. So, in other words, Lisp doesn't have generics in the same way Python doesn't have generics.
- deleted 15y ago[deleted]
- ootachi 15y agoUp until the point you want to return an object from your container, sure. Then you have to return a Comparable and the user has to downcast it into the right object. Plus, you pay the overhead of boxing.