
How Laziness Works - ScottWRobinson
http://two-wrongs.com/how-laziness-works
======
anon4downvotes
Reading this has only further convinced me that Haskell is unsuitable for
production due to the difficulties laziness posses to correctly reasoning
about the performance characteristics of code. Idris is not only strict by
default, but has an even more advanced type system, and because of that it
will probably overtake Haskell eventually.

~~~
batou
I'll second this.

We've had similar problems with Task<> based code in C# (futures/async) when
it comes to performance analysis.

I will say this only becomes apparent when you really push it hard, but we do
that. Determinism is really important for predictable performance.

~~~
jeremyjh
Laziness doesn't take away determinism. I agree you may have some surprises
but they all make sense when you understand them. I've only ever had one
really baffling problem due to un-evaluated thunks building up and it did not
take long to find the root of it using the profiler.

~~~
eloisant
What becomes non-deterministic with async is the order in which operations are
executed (depending on how long the previous processes took) possibly creating
race conditions that can sometimes become very hard to debug.

However if you work with immutable objects like Scala or Haskell encourages
you to do, this shouldn't become much a problem.

------
tel
There's a rather extensive series of blog posts by Edward Yang, a GHC
contributor, that cutely and obliquely describe the STG machine that gives
semantics to STG code. Highly recommended for anyone who found this
interesting!

    
    
        * http://blog.ezyang.com/2011/04/the-haskell-heap/
        * http://blog.ezyang.com/2011/04/evaluation-on-the-haskell-heap/
        * http://blog.ezyang.com/2011/04/io-evaluates-the-haskell-heap/
        * http://blog.ezyang.com/2011/04/implementing-the-haskell-heap-in-python-v1/
        * http://blog.ezyang.com/2011/04/functions-produce-the-haskell-heap/
        * http://blog.ezyang.com/2011/04/how-the-grinch-stole-the-haskell-heap/
        * http://blog.ezyang.com/2011/05/bindings-and-cafs-on-the-haskell-heap/
    

Also, C-- has updated from its spec as the author noted and... as far as I'm
aware there aren't actually any updated specs or documentation. Perhaps a few
papers? C-- was originally marketed as a new, designed intermediary language
for compiling functional programs but it never quite took off as far as I
understand. My understanding is that GHC is also moving toward using LLVM
instead.

------
nraynaud
There is a functional language called Mercury. I don't care about the
language, but on the website there are incredibly insightful documents, and
reduction order is explained in a very clear way:
[https://mercurylang.org/documentation/papers.html](https://mercurylang.org/documentation/papers.html)
(The oldest stuff)

------
cpursley
To get lazy in Ruby, I've been using the rspec-style rlet gem:
[https://github.com/hosh/rlet](https://github.com/hosh/rlet)

For example, in Rail, instead of setting up a variable in a private method for
a before_action, you write:

`let(:ar_model) { ArModel.ar_scoping_stuff }`

This defines a method (where the values are memoized) that can be shared
across multiple objects.

