Functional Programming In Java

Author: Pierre-Yves Saumont
Publisher: Manning Publications
Pages: 472
ISBN: 978-1617292736
Print: 1617292737
Audience: Fairly advanced Java programmers.
Rating: 5
Reviewer: Mike James

Functional programming is increasingly popular and Java is popular so a book on both topics is a good idea.

I'm not a functional programming user, but I am interested in the approach. I find some of the ideas of functional programming persuasive, but so far I haven't been converted hook, line and sinker. I'm like the majority of programmers - I use some aspects of functional programming when I think it results in simpler code. But functional programming in Java is not something I've considered before, hence my interest in this book.


The first chapter explains what functional programming is all about. It isn't overly academic and discusses the advantages of no-side effect functions and concepts such as immutability briefly. You won't find a reference to monads or category theory here, it's all practical - although monads do get an appendix all to themselves.

Chapter 2 moves on to consider functions in Java and this is the first place you start to get a feel for what is wrong with this book - it's Java. It is not a good choice for a functional approach. This is where the author begins his fight against Java to implement functional approaches to solving problems.

Chapters 3 and 4 are about alternatives to iteration. Chapter 3 explains functional ways of applying functions to data so that the iteration is hidden and chapter 4 is about recursion. Of course Java doesn't support tail recursion so you have to struggle against it yet again.

Chapter 5 picks up the data driven programming elements again with a look at Lists with Lisp just below the surface. Chapter 6 is an examination of the null problem and how not to use it to signify optional data. Chapter 7 is about exceptions and error handling, which is about the most difficult problem functional programming has to solve. Errors by their very nature break the neat perfect flow of functional composition with no side effects - errors are side effects you can't avoid but would like to.

At this point the book starts to consider more advanced topics.Chapter 8 is about advanced list handling including parallel processing. Chapter 9 is about the role of laziness in functional programming. That's lazy evaluation, not sloth on behalf of the programmer. Chapter 10 deals with trees, another perfectly recursive data structure. This goes further than you might expect and included balanced trees. The next chapter gives examples of how you can solve real problems with trees.

The remaining chapters are about practical problems - state mutation, input/output, sharing state and solving common problems.




You might think that I didn't enjoy this book because of its constant fight with Java to implement functional programming. In fact the reverse is the case. It was a lot of fun finding ways to bend Java to make it do what was required.

As an advanced Java book it rates very highly. It is well written and easy to read and nearly all of the time the explanations are down to earth and attempt to convince you that functional programming is a good way to work.

Unfortunately the evidence is that in Java at least things are not so good for functional approaches. You might not agree with me but I wouldn't use functional programming in Java for fear of producing code that was simply confusing to the average Java programmer.

This is a good book but an essentially misguided one as functional programming in Java doesn't seem to be a good idea. I would, however, encourage you to read it if you have an interest in advanced Java and want to apply some, but not all, of the functional programming techniques in your own programs. You will be a better Java programmer after reading it, even if you might not be a better functional Java programmer.

Because of this strange situation the book deserves a rating of 5 even though I don't really think it achieves what it sets out to.

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.


Machine Learning For Dummies, 2e (Wiley)

Author: John Paul Mueller
Publisher: For Dummies
Date: January 2021
Pages: 464
ISBN: 978-1119724018
Print: 1119724015
Kindle: B08SZHJGJW
Audience: General, but not too dumb
Rating: 4
Reviewer: Mike James
Dummies probably need machine learning to cope...

Securing SQL Server

Author: Peter Carter
Publisher: Apress
ISBN: 978-1484241608
Print: 1484241606
Kindle: B07KLW99YM
Audience: DBAs
Rating: 5
Reviewer: Kay Ewbank

As a developer, you're probably well versed in how to write a secure app that won't be vulnerable to attack, but the database component is a whole dif [ ... ]

More Reviews

Last Updated ( Thursday, 24 August 2017 )