
 Haskell comprehension measured through WTF/min - nickb
http://ripplingbrainwaves.blogspot.com/2009/02/haskell-comprehension-measured-through.html
======
swombat
You know, funnily, that's one of the things I enjoyed about Ruby most from the
get-go: there's a very low incidence of "WTF?"

In Ruby, most concepts that you haven't met before are still intuitive enough
to be able to grasp them without being told what they are explicitly. Of
course, there are exceptions (inject takes a little getting used to, as do
some edge cases with code blocks and lambdas), but take the following example:

    
    
      puts Project.find_all_by_created_at(1.month.ago..Time.now).collect(&:name).join(", ")
    

This uses a few "medium-advanced" ruby concepts, like ORM, ranges of dates,
and iterating through a collection and mapping the results of the iteration,
and yet even someone who knows zero programming has a chance of figuring out
what it does.

Or:

    
    
      recent_joiners = project.all_users.select { |user| user.joined_at(project) > 1.month.ago }
    

All very obvious. I like obvious code. As they say, code should be written for
people to read, and only incidentally for machines to execute. Whatever other
flaws it may have, Ruby is written for clear, easy reading.

On the other hand, after the Erlang 'discussion' ("Why OO Sucks") Dale Harvey
pointed me to this erlang file:
[http://github.com/daleharvey/erlang_util/blob/e9057208f88ba5...](http://github.com/daleharvey/erlang_util/blob/e9057208f88ba5e16f9d2f396248782144e7db41/dh_date.erl)

The density of WTF's in this file is huge. Who can make sense of the following
lines without any explanation?

    
    
      format([$M|T], {{_,M,_},_}=Dt, Acc) ->
          format(T, Dt, [smonth(M)|Acc]);
    

Beyond "It's something to do with formatting a date of some sort", it's hard
to tell what it does or how. And yet, this piece of code is probably trivial
when compared to the ruby code I pasted above.

Personally, I really prefer languages with a low WTF/minute rate right from
the start. Then I can measure progress in that language based on what I
achieve with it, rather than based on how many hurdles I've jumped to get to
square one.

~~~
jrockway
> Personally, I really prefer languages with a low WTF/minute rate right from
> the start.

I think you are missing the point of the article. The idea is that Haskell
taught the author new ways of thinking. It allowed him to see computation in a
way that he had never seen before.

This is a good thing. Language features are restricted to one language. New
ways of thinking are useful everywhere.

~~~
swombat
So your point is that these ways of thinking are unachievable without a syntax
filled with WTFs? I'm no expert on functional languages like Haskell or
Erlang, but somehow that doesn't ring true to me. There's gotta be a way to
create languages that provide new ways of thinking while maintaining a clear
syntax. Ruby (sorry, that language again), for example, provides a number of
functional language features with a very clear syntax.

~~~
jrockway
I don't think any of Haskell's syntax is intrinsically unclear.

If you read the article, you'll notice that most of the WTFs are things like
"oh, I never though of abstractions like monads, functors, etc." There is one
about the indentation thing, but honestly, braces are probably a WTF to people
that only know Python.

~~~
jimbokun
I have a hard time figuring out precedence relations when looking at Haskell
code. I can't always figure out which are the functions, which are the
arguments, and which are the functions passed as argument. The fact that
Haskell does not have any punctuation to denote function application obviously
has something to do with this.

~~~
brl
You don't need syntax for that. Regular function application has the highest
precedence and functions always have exactly one argument.

