Does the book talk about Scala and/or mentions differences between Java and Scala? If I understand correctly, Scala was the way to go for functional programming on JVM - is Functional programming in Java changing that?
Scala is not the only option for FP on the JVM e.g. Clojure (based on Lisp) is also gaining popularity, but Scala seems to be more widely used. Scala is a hybrid OO/FP language, so you can choose to write Scala like a "better Java" i.e. mainly in OOP style, or you can program in a strictly FP style. Some people see this as an advantage, because it can help Java developers transition gradually to Scala (many companies take this approach to introducing Scala), but others point out that this duality can make Scala more complicated and harder to learn: every problem has at least two solutions!
Now Java is starting to provide more FP features, you have more options within Java as well. FWIW (and with respect to Venkat), I prefer to use Scala because FP is built in to the language, rather than bolted on as in Java. But it will depend on your project and your developers - YMMV as always!
Thanks, Chris. But I guess Java has the advantage of not having to learn another programming language Can you get the same functionality as in Scala in Java 8, or is Scala still worth learning?
David Starina wrote:Thanks, Chris. But I guess Java has the advantage of not having to learn another programming language Can you get the same functionality as in Scala in Java 8, or is Scala still worth learning?
I'm not using Java 8, so you'd need to ask Venkat for a more informed opinion! But I would assume you can do pretty much everything in Java that you can do in Scala (they're both VM languages and compile down to the same bytecode underneath), but you will probably find that many things can be achieved more easily and concisely in Scala. That's one of the first things you notice if you start writing Scala as a "better Java". When it comes to FP, I think Scala is probably the better choice purely in language terms, because FP is baked into the language from the ground up, and Scala has very powerful libraries that take advantage of FP as well. My guess is that Java still has a long way to catch up on the FP side of things.
Anyway, it's always good to learn a new language, so go try it out for yourself and see what you think!
David, no in this book I focus only on Java 8. I've written books on Scala and Groovy, and also use quite a few other languages on the JVM on a regular basis. I do not see a reason to compare with one and not the other languages in a book like this. My objective for writing this book is to help Java programmers get up to speed on this newer facilities and so have kept it topics spot on that.