When you hear “Haskell performance”, what comes to your mind? I was never really interested in Haskell since I had Clojure, and I thought Haskell might be slow.

Haskell with GHC is actually as fast as C or even faster. Haskell runs right on your hardware, no VM or interpreter.

When a program is small, the performance is comparable to C. Sometimes it’s quicker, sometimes not. But when a program is large, Haskell implementation would be faster if you’re not a robot that generates perfect C code.

It’s both very high-order AND very fast. You don’t need math to code in Haskell.

Too bad there are no kewl libraries.

  • 1
    Haskell is generally regarded as being slow compared to other similarly high level languages. It's focus isn't performance as much as it is safety and surety. It's like without the crabs.
  • 0
    @SortOfTested but it’s fast
  • 1
    @SortOfTested I know you can’t really say “slow” or “fast” and it depends but Haskell is darn fast, much faster than python under any circumstances
  • 2
    Python is pretty slow in general. It has fast startup time, and that's about it.

    Haskell vs ocaml or f#, the latter two usually win.

    I love haskell, it's just middle of the pack in terms of perf.
  • 2
    Oh yeah, it's a heck of a lot faster than most people realise. (Not as fast as C though.) A lot of it has to do with the fact the GC can be stupidly quick and deterministic because of the guarantees you can make about short lived evaluations in a purely functional environment. That's not an advantage you can really leverage as much with the less pure functional langs like OCaml, Scala, Clojure etc.

    The real disadvantage is that, despite the noise functional people make to the contrary, pure functional isn't suitable for everything - and Haskell doesn't really offer a "way out" of it. That being said, while that would make it wholly unsuitable for a monolith, I'm surprised it hasn't been used more in a microservice environment.
  • 0
    @SortOfTested python has awfully slow startup time. Maybe we’re talking about different pythons somehow? 🤔
  • 0
    Is there any benchmarks to show that it performs like you described? I have only seen ones that strengthen C's case. Also wouldn't the immutable nature of haskell still make for much less performant code for some simple things mutability solves quickly and easily?
  • 0
    @matt-jd immutability done via persistent structures is usually much quicker than copying shit. So much quicker in fact than a clojurescript react wrapper powered by persistent data structures outperformed the react itself by a huge margin
  • 0
    @uyouthe yeah sure how does this relate to the haskell, C performance? I'm just curious if you know of any info at hand one could look at
  • 0
    @matt-jd do I look like google front page?
  • 0
    @uyouthe no but you claimed that it has comparable performance and even better for larger code bases. Thus my original question was if you have seen/done any benchmarks to support it
  • 3
    Program performance depends on a lot more than just number crunching (look up a metric called arithmetic intensity for example).

    Haskell is great at expressing computation logic, but where it loses to systems stuff like Rust/C/C++ is memory management and data structure control. It's also hard to optimize for caches and stuff, and Haskell code can have unexpected bottlenecks because of its complex programming and execution model. Basically, very hard to express your computation in terms of how hardware (or a higher abstraction, like concurrent processes) actually works.

    In most high performance applications, managing data transfers and stuff is a much bigger bottleneck than computation.

    It really depends on what you want performance for. Eg. in an Erlang application, compute is usually crap. But that's because in the kind of thing Erlang is meant for, compute isn't the bottleneck, it's more about managing data in a massively distributed system. So Erlang is "slow" in the traditional sense, but not really.

    If you're talking about general performance, in my experience Haskell does about the same on average as Java.
Add Comment