IlyaShpitser comments on I want to learn programming - Less Wrong

7 Post author: benelliott 26 March 2011 10:40AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (53)

You are viewing a single comment's thread. Show more comments above.

Comment author: IlyaShpitser 08 December 2012 11:08:19PM *  1 point [-]

sum [ i | i <- [1..999], mod i 3 == 0 || mod i 5 == 0 ]

:)

Haskell is amazing for Project Euler. Lots of these problems are one liners in Haskell. Actually I think Project Euler is excellent for learning Haskell tricks specifically, even if you know how to program already. For certain types of tasks, Haskell is an immense force multiplier.


Of course the difficulty with Haskell is that it is both functional and lazy, which means it explicitly hides the causal order of operations from you for other gains (expressiveness, parallelism, etc.) The problem with this is that in order to debug a Haskell program (or any computer program), a human brain needs to construct an accurate causal model of what's going on.

Debugging software is generally the act of repeated interventions into a malfunctioning system to figure out where the malfunction is. Languages like Haskell go against this grain by making it difficult to figure out what your intervention is doing due to the hidden causal order (try inserting a print statement into a Haskell program sometime). This is why, I believe, functional programming never caught on -- functional programs are very convenient for compiler programs to reason about, but very inconvenient for people.