Skip to Content
Functional Programming in Java
book

Functional Programming in Java

by Venkat Subramaniam
February 2014
Intermediate to advanced
160 pages
4h 59m
English
Pragmatic Bookshelf
Content preview from Functional Programming in Java

The Big Gains of Functional-Style Code

Functional-style code has a higher signal-to-noise ratio; we write fewer lines of code, but each line or expression achieves more. We gained quite a bit from the functional-style version, compared with the imperative-style version:

  • We avoided explicit mutation or reassignment of variables, which are often sources of bugs and result in code that’s hard to make concurrent. In the imperative version we repeatedly set the totalOfDiscountedPrices variable within the loop. In the functional-style version, there is no explicit mutation in our code. Fewer mutations leads to fewer errors in code.

  • The functional version can easily be parallelized. If the computation was time consuming, we can easily run it concurrently ...

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.
Start your free trial

You might also like

Functional Programming in Java

Functional Programming in Java

Pierre-Yves Saumont

Publisher Resources

ISBN: 9781941222690Errata Page