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: Differences between functional programming in Java and Scala  RSS feed

 
Salil Wadnerkar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any significant differences between the two approaches these two languages took towards functional programming? The obvious one is collections in Java need to be converted to Stream before using functional programming goodies. Are there any others?
 
Pierre-Yves Saumont
Author
Ranch Hand
Posts: 103
17
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many differences. Java is missing nearly all functional elements that Scala offers. Scala has pattern matching, for comprehensions, lazy values, tail call elimination, data types, higher kinded types, and much much more. Plus it has many functional types such as Option, Try, immutable collections... They should not be compared from the functional programming point of view. If you want to learn functional programming and you have the choice of the language, my advice would be to select Haskell if you don't need the JVM, and Scala otherwise.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!