1. 15

  2. 4

    (Haskell know-nothing here, but very curious, have ghci always open on a terminal, going through LYAH)

    When I see this, I’m tempted to run away from Haskell. If I want to implement laziness in Python I can write a bunch of iterators very simply and use something like Toolz. The Python code looks very elegant this way, though it can be slow.

    I see that if I want to go the opposite way and implement strictness in Haskell I have to do a lot of work and make things pretty messy code-wise, which is intimidating for me. On top of that, I see the note on how thunks can explode your memory usage and I worry even more.

    My question for experienced Haskell folks is whether, when dealing with real data sets you often face issues with laziness and memory consumption and when you have to make the code strict, does it make the code less elegant to deal with (read/understand)?


    1. 5

      Most of the time I don’t have to think about strictness at all. The GHC strictness analyser is pretty good. In some cases you know you need it and use foldl' or similar or a strict data field.

      1. 2

        When I see this, I’m tempted to run away from Haskell.

        You weren’t alone there. It looked really complicated and weird to do simple things. Fortunately, the article was good enough to show me it wasn’t that complicated for real as understanding came a step at a time. I think I followed most of what I read.

        1. 3

          So i’m at best at the “dangerous intermediate haskell” stage, and all I do is throw a Strict language pragma where I need to after profiling. I think this article is a bit more of the “when you need it” camp than needed to function.

          1. 2

            I think I understood it too. It just reminded me of a statement I read by someone saying that once you start doing “real” tasks with Haskell (e.g. worrying about memory and speed, because you have large data sets) the Haskell code becomes very messy and complicated, because the straightforward way is too slow/memory heavy. I didn’t understand that statement then, but this example code reminded me of that.

            1. 2

              Yeah, that seems to fit.