Learn Functional Programming The Hard Way?

It doesn’t need to be done with a purely functional language like Haskell. If you still plan on a Rust book, then that might be a great opportunity to explore functional programming as Rust is heavily influenced by functional programming languages like OCaml.

Having the ability to think using a functional programming paradigm can only make one a more well-rounded programmer. What do you think?

So I actually do want to do a book on some form of recent functional programming language, but nearly all of them are in constant flux or too difficult to write a book for. In the “too in flux” camp we have things like Rust, Nim, etc. and in the “too difficult” camp we have things like Haskell and Agda.

I’ve got a new author who’s working on a clojure (or maybe clojurescript) book which I think will actually serve this purpose. The other language I’ve considered is F#, which seems to be easy to use, have the modern FP ideas, and also very practical at the same time.

1 Like

That makes a lot of sense. Clojure is a really nice language to learn, it’s a neat way to exploit the great Java libraries without having to actually code in Java. F# is also good for the same reason.

BTW, any update on Learn Unix the Hard Way? Really excited for a beta release.

Apologies for bumping this old thread, but I came across this and I’m wondering: Why do you think that Haskell is too difficult to write a book about?

I’m currently learning C (with LCTHW) and Haskell at the same time and it’s a very rewarding experience. They’re different enough to not get muddled in my brain, and they nicely complement each other. I’m not finding Haskell overly difficult. It’s just different, beautifully different.

It’s my belief that the Haskell community is more interested in pursuing their own “purity” than in any intellectual honesty about their pursuit. They frequently declare their language the best and perfect, and then secretly change fundamental things about it and pretend it was never broken. For example:


Search around for “improving haskell gc” and you’ll find loads of articles like this where people improve the GC performance, and eventually have to dump the assembly language output to figure out the problem. It’s become so bad that now there’s a very quiet movement in Haskell to “fix” it, but they aren’t admitting it was broken, they’re “improving” it. It’s like Apple’s new keyboards. They don’t say the previous keyboards were actually defective, or that they just went to the original keyboards, or admit that the broken keyboards were a bad idea, they just go back to the old keyboard and pretend like it’s a new better keyboard.

I found the exact same behavior with Python 3. Python 3 was slow as dog snot for most of its life, and is still slower, but they didn’t admit that. Instead they kept telling everyone it was “ready for prime time” and “everyone should switch” then “everyone must manually rewrite all of their code now!” Then they quietly fix little things like performance and GC and the standard library but never admit that these were broken the whole time and nobody should have used Py3 until they were fixed.

Why does this matter for a guy like me trying to write a book? This kind of intellectual dishonesty makes it nearly impossible to write a book that’s up to date. I’ll write the book using the current version of Haskell or Python, then they secretly change something, and my book stops working. Now, I’m not a crazy person and I’m a very solid coder, so I know they “fixed” something. But, rather than admit they had to fix something and coordinate, what they do is bluster, and deny, and accuse me of being stupid in a vast gaslighting operation Orwell would be proud of.

I now only focus on languages where I see things being fixed and they admit they were bad designs. JavaScript has finally been doing this and it’s wonderful. Just look at what’s being done to ES6 and beyond to improve programmer usability and you’ll see what I mean. Before ES6, they were the same kind of obnoxious blowhards pretending their “events over threads” code was great when it was impossible to use, and pretending that JS didn’t have serious issues with var vs. globals and terrible for-loops structures.

Now, they fully admit it was a bad design and are fixing it, and I’m confident that I can keep up because it’s a full standards body running the show with a published specification. Vs. Python and Haskell which are secret cabals of insecure narcissists who are more interested in pretending they’re geniuses than making something that regular people can actually use.

1 Like

Thanks for this too.
I guess it’s kind of hard for a beginner not to get dazzled by all that “talking big”.
Do you think it’s worth learning Haskell? Or would you recommend another language? I do enjoy the functional approach…

If you are interested in browser front-end development I suggest having a look at Elm.

Another functional language that crossed my path is Elixir. Might be worth a look.
I’m interested on @zedshaw’s opinion about this to languages.

1 Like

Thanks, @DidierCH. I had a look at Elm some time ago and it’s on the list… front-end development is not really something I’m into at this point. Elixir looks interesting, too.

Yeah, I’m also very interested in @zedshaw’s opinion.

See, the term “functional” seems to have changed over the years. To me functional meant “doing everything with function application”, then later it was coopted to mean “doing everything with types”. I’d say, learning Lisp would be a good step toward learnign the first kind, and it teaches you a lot. If you want to work with Types then, I kind of like Typescript because you can work with normal JavaScript then slowly add types and that version of functional programming. If you want to expand your mind then sure, learn Haskell, or OCaml, but remember that most of their claims that it decreases defects are mostly unfounded. You’ll also struggle with error messages a lot, as the general usability is very low for both languages. OCaml is the more usable and practical of the two though.

Elixir and Elm are both really interesting, but kind of very specialized for specific purposes.

Now, why are you into the functional style of programming? Can you possibly drop me some quotes from literature that are motivating you?

My currently client opted for Scala as a language to bring two separate merging companies together, one Java based, the other C#.

Some guys presented the other day on a little
Community they have going that is all about ‘functional programming’. I assumed it was in terms of functional/OOP but actually it’s was heavily statistically/mathematically based and totally over my head I must admit.

So is ‘functional’ becoming a buzz or am I just tuning into it a bit more as I tiptoe around the edge of programming communities?

Thank you, Zed! Will do tonight.

I may very well be a victim of propaganda. But it’s actually not so much about anything I read. It’s more the refreshing experience of learning a completely different approach and mindset. Not telling the computer the steps to follow, but sort of defining the mathematical relations between things. It feels much more abstract. And it’s a wonderful supplement to learning C.

I think I fell in love when I saw this one-line definition of the fibonacci sequence:

fs = 1 : 2 : zipWith (+) fs (tail fs)

We are producing an infinite sequence by combining that very sequence with itself. Compared to the sheer elegance of this formulation, everything I could come up with in Python feels clunky. And indeed, I find that my Haskell ‘programs’ are usually half the size of the same thing in Python. (Mind you, I’m still far from writing real programs.)

But yes, the error messages are rather cryptic. I haven’t even started to try and figure out what they mean. Thank god I’m quite self-confident… they won’t make me believe I’m not smart enough anytime soon. :smiley:

1 Like

First of all thank you for writing all these great books.
The wax on, wax off approach really works for me for some reason.
When I read other gentle introductions to programming I feel like an idiot (maybe I am),
but LPTHW progresses at just the right pace so I feel challenged but not overwhelmed.
That being said I read your comment above about certain languages development being too dynamic and hidden so I wanted to make a suggestion. What do you think instead of writing a physical or a static digital book, to change the format to something like private membership book that’s hosted on the website in html and instead of relying on publishers to release updated editions, to have something like Arch’s rolling-release update method. This will allow you to be very flexible and correct for “hidden developments” and for members it will be similar to buying a video game that occasionally releases patches and fixes. The members could pay for a one-time life time license or an annual subscription. This way the book will always be up to date. A possible analogy is a text-based Lynda, because text is faster to read than watching a video and the cost of editing text is orders of magnitude lower than that of video. See this book for example: https://elmprogramming.com/

A free service run by Zed A. Shaw for learncodethehardway.org.