Streams are a staple of functional programming. They were invented for the Scheme programming language, and then adopted and used heavily by Haskell. In fact, they are used so heavily in Haskell that all Lists in Haskell are really Streams. Streams offer a number of advantages for certain kinds of programming tasks, but due to differences between Scala and Scheme or Haskell, and for reasons that we will get into, in order to avoid exhausting the heap, more care has to be taken when using Streams in Scala than you would have to in either Scheme or Haskell.
(Read more...)