Why learn Haskell programming language

Amin A.
By Amin Ariana — December 2010

If you find it isn't your thing, then 30 minutes wasted. But Haskell is the prettiest programming language under the Sun, for what that's worth.

Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry.
Wikipedia

When I was at Microsoft, I met Sean E. Johnson, a high school intern. The mere fact that a high schooler was working inside the walls of the most successful company in the world at the time should illustrate why he's a genius. He introduced me to a world of new things before I ever got the startup fever, including Boba Tea, Stargate SG-1 and dynamic programming.

We had one of those discussions with him one day during which I knew he was arguing something that I would fully comprehend many years later (five years to be exact). He was arguing the merits of beauty in a language, which eventually became one of the many forces leading me down the path of becoming a Rubyist.

I kept his passionate email about the Haskell Language in my archives for retrospective analysis. Here it is, with all the virtues of its young author beaming between the lines:

----

"Hey Amin,

I mentioned Haskell while I was over at your place, but I did a poor job extolling its virtues.

Basically it is a purely functional, lazy programming language. This means that the order that you write things in doesn't matter. A few practical consequences of this are that there are no "if" statements or "while" or "for" loops. These loops are instead replaced by map, filter, fold, and recursion. Also, the laziness of the language means that handling infinite lists is quite easy. For example, if you want a function that returns all the prime numbers, its return type should be an infinite list of integers. This is ugly to do in most languages. In C# it would require the "yield" statement and iterators. Or the more traditional way would be to pass in a max value, and stop computation once you reach it. This is of course flawed because what if you do not know the max number without processing the list of primes.

Here is an simple (but inefficient) way to get the list of all primes in Haskell (primes is an infinite, ascending list of all the prime numbers):

primes :: [Integer]
primes = filter isPrime [2..]

isPrime :: Integer -> Bool
isPrime n = null (filter (\x -> x `mod` n == 0) [2..n-1])

You know everything in the code example above. The "mod" is the modulus operator (sometimes written as %).

Anyway, even though I didn't make a good case of Haskell while I was at your place, if you are interested, you should do the following tutorial: learnyouahaskell.com

If you find it isn't your thing, then 30 minutes wasted, oh well. But I did manage to convince (edited: one of our skeptical former colleagues) that Haskell is the prettiest programming language under the Sun, for what that's worth.

Enjoy,

Sean"

----

Last time I checked, Sean had left the software industry and was out somewhere with more smart people building rockets. Yes. Rockets.

He's the kind of person I love to work with.


Amin Ariana is a software entrepreneur in San Francisco.

Subscribe to AA
free sneak peak of book chapters


This was a draft of Chapter 5.2 from the book:
Entrepreneurial Story Series

Comments

Readers shared their thoughts on this essay:

Be the first person to make a comment.

Add comment