Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

[Functional Programming in Java] How has Java evolved towards functional programming?  RSS feed

 
Joris Renting
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Java having been an object oriented programming language for roughly 2 decades, how has it adapted towards the functional mindset which has been gaining popularity since the early days of programming? There are many other functional programming languages out there. And they are more often than not better at functional programming than Java is. Why will people use Java to do their functional programming?
 
Pierre-Yves Saumont
Author
Ranch Hand
Posts: 103
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joris,

Java has not evolved much toward functional programming. Lambdas are a great addition, but they are not specific to functional programming, although they make it much easier. Functions are useful too, but they are so simple to create that it does not count for much. Optional, Stream and CompletableFuture, although they are Monads, are not implemented in a way that makes them much useful for functional programming. But functional programming is not tied to any language. It's a programming paradigm. It's easier with functional friendly languages, but it is possible in any language.

But the most interesting part of you question is "Why will people use Java to do their functional programming?". This leads to another question: "Why would people have some functional programming to do?"  This means that you have some functional programming to do and must pick a language for that. Choosing Java to solve software problems is questionable. Generally, you chose the language you know. Otherwise, it can't be an educated choice. So you have to first learn a language in order to be able to make the choice of, eventually, using it (or not). But choosing Java to solve functional software problems would means that being functional is a goal, and not a mean. I can think about few use cases for this. For example if you are student in functional programming and are free to chose a language. But I would certainly not recommend Java for this.

Most often, the language is imposed, whether it is because of  environment requirements, or because you work in in team, or because you have to deal with legacy code, or all these reasons at the same time (as in my own case). So the choice is not which language for my functional programming, but which paradigm for my Java programming.
 
Joris Renting
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense. Thank you very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!