3 ms·
The previous article spoke about learning enough Haskell to write useful programs. It didn’t speak about learning enough Haskell to do performance optimization.
by runeks 7y ago
The previous article spoke about learning enough Haskell to write useful programs. It didn’t speak about learning enough Haskell to do performance optimization. I don’t think there exists a language where it’s enough to learn the surface language in order to write optimized code.
Also, the previous article recommends newcomers to use the “Strict” language extension, which would avoid the exploding memory usage of the second version (“simple-fold-wc”).
- xiphias2 7y agoRust is generally fast-by-default. My favourite example is the collections API, where you can do mapping/reducing/filtering operations only by inlining multiple operations and going through the collection only once. With Haskell these things are possible, but not efficient by default (the default Haskell library uses liked lists instead of vectors for example).
- roca 7y agoYou're implicitly assuming that there are only two classes of problems: ones where performance doesn't matter at all, no matter how awful, and ones where one is willing to expend unlimited amounts of wizard-level optimization effort to achieve maximum performance. On the contrary, in practice, it is important that the obvious code a programmer would write should be reasonably efficient (let's say, within an order of magnitude time and space of the optimal single-core solution). For this (very simple problem), this article makes it clear that is not true in Haskell. In contrast I believe it would be true in Rust and even Python (without having written the programs, but using BufReader::lines() and String::split() in Rust and the lines iterator and split() in Python). It's also a problem for Haskell that the first thing you do for performance is to disable one of the key features that distinguishes Haskell from other languages.
- Annatar 7y ago"I don’t think there exists a language where it’s enough to learn the surface language in order to write optimized code." Good news, there is indeed such a language: Fortran. Modern Fortran syntax is similar to Python (but without indentation restrictions) and the compiler generates wicked fast machine code.