It may sound like I'm asking to start a fiery war, but listen to me.
In some languages, laziness is expensive. For example, in Ruby, where I have the most recent experience, laziness is slow because it is achieved using fibers, so it is attractive only when:
- you should exchange the processor for memory (think of paging through a large data set)
- a performance penalty is worth hiding details (yielding to fibers is a great way to abstract complexity instead of skipping blocks to escape in mysterious places).
Otherwise, you will definitely want to use the usual, impatient methods.
My initial research suggests that the overhead for laziness at Elixir is much lower ( this thread on reddit supports me), so there seems little reason to ever use Enum instead of Stream for those things that Stream can do.
Is there something that I am missing, as I assume Enum exists for some reason and implements some of the same functions as Stream. What cases, if any, would I use Enum instead of Stream when I could use Stream?
source
share