Streams, Map and Filter

  • the map and filter operations ← this is the main thing to learn here
  • internal iteration
  • pipelining
  • intermediate vs. terminal operations in a pipeline

This reading uses the term “declarative programming” to describe Java stream. I would quibble with that terminology. To be truly “declarative,” code must describe only what results it should produce, and nothing about how to get them. While Java streams do have some of this flavor — one might be able to argue that they have a “more declarative style than loops” — Java code that uses streams still does describe a specific algorithm. A truly declarative language, like SQL or Prolog, says nothing about how the computer gets the result.

Like many terms in computer science, this seemingly precise term is in fact quite fuzzy. Others certainly would quibble with my quibble. My own opinion is that the book overreaches by using this term.

A better, more widely understood term for this style of programming is “functional pipeline” or “function pipeline.” (And I’m sure somebody would quibble with that!)

  • Consider the dishes example in CH 4.
    • How are the dishes in the menu represented?
    • What are some possible operations on this collection?
  • What are some advantages of using Streams?
  • What are some disadvantages?

What was particularly interesting, confusing, or exciting to you in this reading?