Since then, I have more or less tried again and again (with different sets of sources, books, courses…). I got this bug during my maths degree: if I struggle learning something, it means there is some knowledge/ability there I lack. Then I need to acquire it.
At last, though, this book did it. First, let me clarify what I mean by learning a programming language. For me, this would be the first set of required steps in any language. Having them, you can just keep it as a side toy or go on to mastery on your own. They are:
You have interacted with the compiler/interpreter enough to know the basics (basic flags, basic “magic commands”).
You have a good enough idea of folder layout for a basic project.
You have used the package/build tooling enough to be able to create new projects and add libraries to them.
You have written enough code to have a personal set of examples of basic tools and idioms you can go back to.
You feel confident to go check documentation/Google/Stack Overflow on your own
As you can see, I don’t put the bar very high, but it’s the first bump in any language. My experience has shown that once I have the first 4 bullets, the fifth comes for granted. From there, sky’s the limit.
To be fair, the success of Finding Success may not be its own doing. I suspect there was a form of externality in play here as well: I got ghcide working on Visual Studio Code pretty quickly. It is a LSP powered type-completion/code-exploration/you-know engine for Haskell. Having it means good error detection, type inference, signature completion… many goodies that make code writing really enjoyable, particularly if it is Haskell (this will be material for another post, possibly). Having ghcide working properly was the final push to make me go through the whole book.
Note: Why Visual Studio and not Emacs? Emacs can be tricky when setting up LSP (I know from experience with Python and Scala) so I didn’t want to make the process harder than necessary. Also, VS Code is not a bad editor. If only it had good keybindings!
The ideal setup to go through this book is to have a multi-window layout with your editor, the book and possibly a terminal window to run commands from ghci, the interactive Haskell environment.
You will need around 7 or 8 hours to go through the book, typing the code as it comes and solving the exercises. They are not particularly hard, and most remind me of when I was learning German. Every time you learnt new phrase structures (the forms of Konjunktiv is the one I remember more vividly), you’d get a set of Sagen Sie es anders exercises, Say it in another way. Most of the exercises in this book follow this same pattern: making you rewrite your code in another way using a new idiom.
In the book you are going to write very simple (and understandable) code to:
Get input from the user (a username and a password)
Validate it with a couple of rules
Print out the errors in validation or a welcome message.
As easy as that, but on the way you’ll learn fundamental Haskell concepts and write enough code to think “this wasn’t as hard”. You will learn about monads, applicatives and lenses (and a few other things, but I would single these). The book is structured to introduce concepts slowly. Not as slowly as a Haskell version of The Little Lisper would, but slow enough. Side note, The Little Haskeller would be a terrific book, but probably several thousand pages long.
Some things worth noting are:
The exercises should be done, but shouldn’t be done conundrum. In my experience, solving the exercises on this book and typing along has been what made the difference. But most exercises are “rewrite this method you wrote in the last chapter using this new abstraction/tool/helper”. Then, in follow-up chapters the edits in the code to add functionality depend on the pre-exercise code (or at least in most cases) which makes it a not great experience (in particular the NonEmpty exercise, which made most changes further down the book too tricky for a newbie). Keep this in mind: when you rewrite your methods in an exercise use a different name and keep the old ones as well.
The last two chapters (Coercible and Generalizing Further) look significantly more rushed than the rest of the book. Before these, all concepts (more or less) were introduced in a very slow and smooth way (with some exceptions and some hiccups). These two cram a lot of content to “get to the end”. Or at least that’s the feeling you get when you make it there. I have the suspicion I will be going over these two chapters again once I have written a bit more Haskell for personal projects to see if I understand them better.
All in all, I give this book 4.5 stars. Half a star can be attributed to it actually making me pass that invisible wall, the rest to the book, which I think makes for good teaching material.
I would love to see a follow-up book that built on this by creating some real-world application, even if simple, like a web-server with a to-do. Classic initial project material.
Note: just after writing this review I found out they have a book in the works, writing an HTTP server from scratch, from the specification. I did that a really long time ago in Lisp (for HTTP 1.0) and it was quite fun. I bought early access after finding this out.
Ruben BerenguelFinding Success (and Failure) in Haskell4.5