Software engineers are irrepressibly creative. For generations, they have devised programming languages to boldly explore new ways of expressing ideas.
But does it matter? Do the new languages help us? While I grew to appreciate certain innovations, I found I profited most from ignoring trends and following well-worn paths established by Lisp programmers decades ago. Weary and wary, I tend to dismiss the latest programming paradigm as a passing fad.
I was astonished when I found an exception: Haskell.
Haskell is compelling for profound reasons as well as profane ones. We focus on the latter on this page.
What do I look for in a practical programming language? First of all:
Programs should be easy to express.
Writing code should be comparable to writing prose. A plain text editor with 80-character columns should suffice. Coding should feel like writing an email or a novel. If instead it feels like filling out a tax return, then the language is poorly designed.
I have encountered languages that flaunt this law, none of which I will utter here. I have seen languages that practically force the programmer to run a heavyweight specialized IDE, and that require 14 words to print 2 words.
Haskell adheres to the zeroth law. Programs are so easy to express that interactive Haskell interpreters are practical. For example, to print "Hello, World!" in a Haskell session (online even!), just type:
To turn this into a complete program that can be compiled:
Though really, a short "Hello, World!" program is unimpressive; it’s merely a basic requirement of a well-designed language.
Let us now dispel a common misconception, one which I once believed:
In other words, I used to think functional programming languages were only of theoretical interest because they frowned upon side effects. Rob Pike notes that they have a “problem with I/O”. Even Simon Peyton Jones himself jokingly derides earlier incarnations of the language as “useless”.
But times have changed. Modern Haskell handles side effects beautifully. Our “Hello, World!” program above proves this, and we shall see many other examples.
Moreover, it has become clear that:
Side effects are important and therefore should be easy to express.