Side Effects in Functional Pipelines
A common mistake many programmers make is mutating shared variables from the functional pipeline. That’s a big no-no.
Purely functional programming languages, like Haskell, don’t permit mutability. The compilers of such languages will disallow writing code, let alone lambda expressions that mutate data. Java is a hybrid language and the functional programming capabilities were added almost two decades after the language was created. Thus, the compiler for the most part won’t complain if it finds impure lambda expressions—but we should.
A programmer once emailed me a snippet of code that had been working fine, but its behavior had become rather unpredictable after the most recent change they had made. They ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access