Starting with Haskell

haskell-logo-nobg

Around ten years ago I learned to program in Lisp, Common Lisp to be more precise. And since then I believe I never actually learned a new language that impressed me, and excited me, so much as was the experience of learning Lisp.

Well, yesterday I started to learn more seriously Haskell. For quite some time my interest in the language has been increasing. From several blogs posts, comments and discussions on the web, it is almost impossible not to be curious. Yes, I’ve heard of Haskell for a very long time but it seems the buzz on my ears raised a lot recently. And so, I’ve decided to take a look. In the worst case scenario, it would a be just a few hours of playing around with a new language.

Up until now, I didn’t do much. Installed the Haskell platform, haskell-mode in Emacs (although I ended up using Vim too to code) and searched for some basic tutorial. My starting choice is “Learn You a Haskell for Great Good!”. It looks nice. Seems suitable for a beginner and starts in a simple way. The first real chapter is the second one, which I just did yesterday. I was very impressed with it. And perhaps more important, very happy with the experience. To be honest, I don’t remember a similar feeling with other languages… except Lisp! Although this “Starting Out” chapter introduces just some very basic Haskell stuff, it is already a lot to feel the language and the potential of it. The last example was very cool. Suppose you want to find the right triangle that has integers equal or smaller than 10 for all sides and has a perimeter of 24. With tuples, list comprehensions it’s just a matter of writing:

[(a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2, a + b + c == 24]

Simple, concise and very neat! I still didn’t do anything proper with Haskell. I am just in the very very very beginning but it looks promising. I could be wrong about it sure, but the feeling is nice.

Also, recently, I started to take a look at Clojure, another Lisp. I had some hopes that would be a very nice experience. Unfortunately, it was not. For some reason, I am unable to appreciate the “beauty” of a JVM language. But let’s see how Haskell will fare when I start to try it with the kind of stuff I’m interested in.

5 thoughts on “Starting with Haskell

  1. yitz

    Thanks for the nice post. It was featured today on the Haskell Reddit (http://www.reddit.com/r/haskell/).

    Enjoy your journey into Haskell. Don’t forget to visit us on the
    #haskell Freenode IRC channel, and on the haskell-cafe mailing list at haskell.org.

    1. Thanks for the visit and the submission. Just started exploring Haskell but so far I am enjoying it very much. Today I did four more chapters in the tutorial and now it’s time to code a bit more to consolidate what I’ve learned. I’ll try to keep it posted :-)

      I’ve just subscribed haskell-cafe and haskell-beginners as well as the feeds for planet haskell and reddit. I guess it will be a little overwhelming now but let’s see.

      Cheers!

  2. sriram srinivasan

    I was curious about what you didn’t like about Clojure. It seems to me one of the cleanest and most functional (as in with most functionality) lisps I have seen.

    How does the fact that it runs on a JVM affect your experience? Is it speed? Portability? Bare-metal executables?

    1. It’s a good question you make since there are lots of things I like about Clojure too. I must say my experience with it is limited. Perhaps I didn’t give it enough time.

      To keep it short, the points I don’t enjoy so much in Clojure are, above all, more subjective than technical. For example, it has too much syntax; it feels “unlispy” sometimes. It “forces” you to know and use Java to gain the most from the language. Using libraries (Java ones) does not seem natural in a certain way – it looks ugly.

      Things like this make me feel a bit uncomfortable while programming with Clojure. Like I said, it’s more of a personal thing than technical.

      To conclude, in my mind, a Lisp is a language that adapts itself to the problem you want to solve and not the other way around, i.e., you adapt your problem to the language. And Clojure, in my opinion, is the least successful Lisp in this regard.

      Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: