Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a problem in Haskell as well, from everything I've read.


Can you share some links?


One particular example that I recall was that if you calculate something like

    foldl (+) 0 [1..1000000]
(i.e. calculate the sum of the first 1000000 natural numbers)

Then the obvious way to do it is to simply keep a running total, but haskell doesn't do that, it constructs the expression:

    (...((1+2)+3)+4)+5)+...)+1000000)
And tries to evaluate that, which tends to cause stack overflows, and is just generally slow. To fix it you have to use the following expression instead:

    foldl' (+) 0 [1..1000000]
This problem is described in more detail here: https://wiki.haskell.org/Foldr_Foldl_Foldl'


Adding just a single tick mark to make a big difference in performance is one of many areas in Haskell that make performance-minded development a pain. With these high-level languages, you really have to understand the implementation of the language to get anything fast written.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: