3 ms·
Can you share some links?
by koloron 11y ago
Can you share some links?
- contravariant 11y agoOne 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' https://wiki.haskell.org/Foldr_Foldl_Foldl'
- hellofunk 11y agoAdding 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.
- hellofunk 11y agoAnother discussion today: https://news.ycombinator.com/item?id=11060257 https://news.ycombinator.com/item?id=11060257 for example: https://news.ycombinator.com/item?id=11060566 https://news.ycombinator.com/item?id=11060566