Hacker News new | ask | show | jobs
by dllthomas 4011 days ago
"Be prepared to be much less productive in Haskell[.]"

Likely to be the case, but mostly because there's a lot to learn before you can be effective as an intermediate or senior level Haskeller.

"[Y]ou can't just get into it and start writing code. Everything must be well thought out before you start to write a line (and yes, that's how it's supposed to be but sometimes it's easier to just hack something together to see what issues might arise, and then make it beautiful)."

This is not the case at all. You can write Haskell that way, but remember that 1) with type inference, you don't need to specify the types of most things up front; and 2) you can change your types as you go. You can totally just start coding, and then later peel out this tuple into a named type and such. I find I'm most productive somewhere between the two extremes - start from the few types that I know must be fixed (by the fact that I'm interfacing with other code expecting them), then continue sketching in both types and code and let each guide the other.

"On the other hand, the beauty of Haskell is that the code is much cleaner and modular."

When you're doing it right, absolutely.

"Don't be fooled, though: Even in Haskell you can write very ugly code."

Also very much the case - I've done it!

1 comments

> "Don't be fooled, though: Even in Haskell you can write very ugly code."

> Also very much the case - I've done it!

On the bright side, refactoring ugly code into not ugly code is substantially easier in Haskell than many other languages! ;)

It can be. It depends on the reasons your code is ugly. Meaningful refactors are much easier in Haskell. Small, local improvements in clarity aren't going to be substantially different between Haskell and other languages.

Also, it's worth noting that Haskell has a couple ways it can get ugly that are less of an issue in other languages.

First, point-free programming can be incredibly clear when you've got a simple series of transformations of relatively simple data. Sometimes it winds up over-applied, in situations where it would be clearer to break things apart.

Second, most languages enforce a distinction between expression and statement. That Haskell doesn't gives more flexibility about how one breaks up expressions. This flexibility means that sometimes ideas can be expressed more clearly, but it's an additional thing to learn on the path to writing readable Haskell.