Is Haskell too abstract?

The Haskell programming language implements a lot of very cool ideas (many of which I want to liberate for my programming language). However, Haskell seems to have a reputation for being a very difficult language to learn. The IO monad seems to be one particular sticking point, but this didn't seem to be particularly difficult to me - it's just a clever little hack (I just read lots of "How I came to understand the IO monad" accounts until I got it).

Another sticking point seems to be there's a lot of stuff written about Haskell in the form of academic papers (with all the academic jargon that entails). That shouldn't be a surprise (since it's a language with origins in academia which seems to be only reluctantly escaping to industry), but it is kind of interesting that there's a sort of language barrier between academia and industry - what the former calls "deforestation hylomorphism" might be called "tree flattening" by the latter, for example.

But I think the real problem is something shared by other functional languages - it's just a different level of abstraction than we're used to thinking about. In imperative programming languages programmers can think "okay, what do I want the machine to do here?" and write that code. In functional programming languages one instead has to think about what the inputs and outputs are, write functions to perform those transformations and trust that the compiler will optimize it well (to a first approximation). It's much more like doing mathematics than imperative programming. Compilers will do all sorts of crazy things to turn those pure functions into high-performance imperative code. So when things are inevitably too slow, it's not obvious why (since the relationship between the generated code and the source code is very complicated) and it's difficult to understand how to make it faster.

Functional programming languages do have some interesting advantages over imperative languages, though - it's much easier to reason about pure functions than about imperative programs with all their attendant state, which means lots more interesting automatic optimizations are possible and (increasingly importantly) the code can be automatically parallelized so it takes maximum advantage of modern multi-core CPUs.

I'm not sure which side to place my money on. I suspect both imperative and functional paradigms will continue to exist for the foreseeable future. On the imperative side: the low-level OS and runtime components must can't be written using functional languages, and optimizations and multi-core abstractions for imperative languages will continue to improve. On the functional side, compilers will require less and less hand-holding to generate good code and will generate better code than imperative compilers for more and more situations.

4 Responses to “Is Haskell too abstract?”

  1. Andrew Stubbs says:

    I wonder if you've played with Scala at all?

  2. spiralofhope says:

    > (many of which I want to liberate for my programming language)

    You're working on a language? Have you written anything else on that topic?

    • Andrew says:

      Actually yes: https://www.reenigne.org/blog/category/computer/language/ is the category link for all my blog posts about language design.

      It's sort of like C++ but with no C compatibility and lots of new features, or like D with no garbage collection, but really it's just a playground for me to try out language features and compilation techniques I think of. I haven't got very far with it though - I tend to work it for a bit when I get frustrated with C++ and then get bored and switch to other projects. It was interpreting some very simple programs at one point but currently the code doesn't even compile.

      I've been calling it Unity but I'm in the process of renaming it to ALFE (A Language For Everything) as I've since learned of various other projects (including at least one other language) called Unity.

Leave a Reply