by spekcular · 6y ago · 0 comments
If I could suggest just one, it would be lazy evaluation by default, which makes it exceedingly hard to reason about time and space complexity.
Also relevant is the author's article on problems using Haskell on Arch Linux: https://dixonary.co.uk/cabal-2020
Hopefully Idris will become production-ready and I'll have the best of all worlds, but that's a way away.
It's also a surprise to me that you seem to say that OCaml is Haskell without the lazy eval being the default, mind expanding on that? Quite interesting.
* Haskell is pure whereas Ocaml is not
* Haskell has a great story for parallelism whereas Ocaml does not
* Haskell has ad-hoc polymorphism (via typeclasses) whereas Ocaml does not
* Ocaml has an exceptionally powerful module system whereas Haskell does not
That said, the notion of purity is a bit BS. At some point in your program you are definitely going to invoke the world-at-large. Whether you do it through IO(), tap your nose and call it "pure" or you do it other way is all down to semantics (not in the PLT sense of the word - the PLT term to use would be "pragmatics"). The core of both Ocaml and Haskell are pure functions.
Also, Ocaml doesn't really need typeclasses. Modules. Modules are everything
But algebraic data types, exhaustive pattern matching, and modules make it the next best thing, I think.
See also the insightful comment of plinkplonk on that thread.
FTFY
In what scenarios does it make hard to reason about those complexities?
I find GHCs profiler statistics clear and meaningful[1], I lack the efficiency of its reports in other environments I work with, namely Python.
[1] https://downloads.haskell.org/~ghc/latest/docs/html/users_gu...
I’m guessing OP is referring to reasoning about time/space usage by reading code, rather than by running the program.
l = list(range(N))
for _ in range(M):
x = list(l)
CPython will have MxN iterations (allocations?), whereas other languages/libraries where data is immutable may decide to optimise the list() constructor and return a reference to the same object when the input is an instance of a list.In lazy-by-default languages I can at least rely on normal evaluation order.
Laziness gets a lot of flak for being hard to reason about. I disagree - it's just different.
But I never hear anyone acknowledge that laziness can bring compositional performance benefits no other language can sniff.
You are completely right about laziness being a big plus for composing functions.