A Path Less Travelled

homepostsaboutfamilyresumes
04
Mar 2014

Haskell My Destination

Sadly, people around me, even programmers, don't read much science fiction, so in case you don't recognize, the title is an allusion to Alfred Bester's book (find it out and read it!).

Well, I come to realize that Haskell may be my last language. Well, I'd like to learn Clojure when I'm free and play with it, but I will always come back to write things in Haskell if possible. I've had such realizations before. Over time, Smalltalk, Ruby, Common Lisp, have all been my last language for some time, but Haskell is going to stick, I think.

You may have noticed that I prefer simple languages. Not easy ones, mind you, because Common Lisp, and especially Haskell, are both beyond easy, which contributes to the fact that they're rarely used these days. However, they're all simple, and powerful, like a bomb of antimatter, with a small core in the middle, but can produce so much.

In Smalltalk and Ruby, everything is an object. In Common Lisp, everything is a list. In Haskell, everything is a function. Even a variable is a function with no argument. You know, since a function with no argument always does the same thing, they'd better be called constants rather than variables. Even better, all functions, except the constants, are not only functions, but also unary functions. That is, they take only 1 argument, and return something. Then how do Haskellers add 1 to 2? you would ask. Well, (+) is an unary function too! It takes 1 and returns... (1+)! It's another function! and you can apply it to 2, giving 3.

Simple as that. Sure, there must be something else. You have types, but they seldom play a significant role in the program logic (not saying that they will be out of your way when you're trying to implement that logic), as they change even less. And there're kinds and even sorts (what a marvelous language English is! I can't to see how these concepts get translated into Chinese). I don't think present day mainstream languages go this far to strain the natural language, and there is a reason people stay away from Haskell & other functional languages: to stay (mostly) sane.

I have stayed away from kinds, let alone sorts, this far, and this fact is bothering me even if learning these things may make me crazy. Not being able to use or understand Boost MPL has not bothered me at all. That's not for common people. Even masters don't often use them. I don't remember hearing MPL mentioned anywhere other than inside the Boost libraries. (Sure, I have not seen a lot of C++ libraries either. Who knows, other than monolithic, everything included frameworks like Qt, Gtk, etc, there're few C++ libraries to talk about in the first place. People tend to write libs in C rather than C++, and then write a C++ wrapper, which is not very C++-ish.) But in Haskell, everybody seems to know everything about everything. What is endomorphism? Hom sets? Profunctors? (Disclaimer: I don't know what they mean.) Really? And you have to write papers with math formulas all over the place to show people how to do something in Haskell? Have you ever read "Howto"s in, say Python? or Ruby? or even C++ or Lisp? To show mortal people how to do something, you show them the code, and explain the logic, and the tricks. To show Haskellers, you show them math, strange symbols and formulas above and under long lines. As if it were easily understandable for us sipping our coffee after a long hour of breathless typing. Sure, I know I'm talking like showing code to us is easier for us, but it's not. You have to think really hard to make types fit together, before you even get to the meaning.

But damn I'm attracted. Like a moth attracted to fire, I cannot help but want to write in Haskell. To challenge it and see how far I can get before burning myself. I don't hope to get to know everything, no, I don't even want to learn much math (category theory, eh? The Chinese translation always eludes me when I want to talk about it.) I don't want to be a scientist. I just want to be a pragmatic engineer, taming some part of the dragon's power, and ride it to the stars.

comments powered by