|
|
|
|
|
by tikhonj
5341 days ago
|
|
Several things jump out immediately: - Haskell has exceptionally thorough type inference (almost all type declarations are optional).
- anything impure (e.g. involving an I/O) is typed as such
- the types are easier to read and tend to give a good idea of what the function in question is doing
- much more complicated types are readable
- idioms like Monads lead to a lot of code that is much more abstract and generic than anything I've seen in Java. There are tons of library functions that can work on lists, or IO things, or parsers, or random values...
Some things that I found particularly cool in Haskell:
- functions (and even constants!) can be polymorphic on their return type. The function read, for example, always takes in a String but returns whatever type you happen to need.
- You can easily express things like a "list of list": [[a]]. I don't even know how to begin writing a function like join in Java. (On lists, join takes a list of lists of something and flattens it.)Overall, I've found Haskell's type system to be much more useful, and much less of a burden, than Java's. That said, I'm just a college student with limited experience with either language. I've used Java more than Haskell but I've been using the latter more recently; I've never used C#. |
|
So I think to like Haskell, you have to truly believe that more abstraction is better. It's very much a mathematician's language.
The thing is, when writing code, I don't want to write a math paper. When I'm done, I want it to be as smooth and easy to read and as obvious as an article in the New Yorker.