Re:Building a data compression utility in Haskell using Huff...
by GrantMoyer on Thursday July 04, 2024 @11:48AM
(#40875817)
> The reality is that for any language, including C, compiler optimized code will never be as fast as hand optimized code
That's not strictly true; sometimes a C compiler can optimize away my whole program.
Re:Building a data compression utility in Haskell using Huff...
by wyager on Thursday July 04, 2024 @05:14PM
(#40878104)
You're doing extremely simple constant arithmetic here. GHC can optimize this type of thing away to nothing as well. Are we talking about contrived examples or real numerical bottlenecks?
To answer your question directly, The GHC compiler is very good. High level code will perform very well, and for most realistic applications, performance bottlenecks are architectural, not e.g. the use of single width versus SIMD, and the "architectural asymptotics" of haskell are very favorable. I think GHC has/is getting SIMD support but that's not what I would focus on when evaluating perf.
I wouldn't write a matrix multiplication algorithm in Haskell, but I also wouldn't write one in rust or C if I was serious about speed.
Many focus on number crunching as a performance metric, but almost no one is ever actually bottlenecked on that, and if they are it doesn't really matter what high level language they're using.