• Post Reply Bookmark Topic Watch Topic
  • New Topic

Functional Programming in Java: Scala Vs Java:Both JVM language  RSS feed

 
Kerim Kara
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think java can provide same functionality with Scala ?

or do you think java is going to become fully functional language not just adding one feature

Thanks
 
Pierre-Yves Saumont
Author
Ranch Hand
Posts: 156
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think Java can provide same functionality with Scala?


If you mean Java 8, the answer is clearly no. Scala has much much more functional features that Java 8. But most of the classes that are missing may be written in Java. Java is missing Tail Call Elimination, but it can be simulated in Java. Java is missing tuples, but they may be created. (After all, most Java objects are, indeed tuples!) Java is missing pattern matching, but we can do without (but it is tedious). Java is missing for comprehensions, but we do not need them. (This is only useful to make functional programming look like imperative!) Java is missing value types, but we also can do without, although the performance cost is quite high. But there is no way to implement variance or higher kinded types in Java 8.

or do you think Java is going to become fully functional language not just adding one feature


Sadly, I don't. First, there are many Java programmers not wanting this to happen, because they would lose part of there expertise. Of course, they do not say it like that. They rather say "This is not the way Java was intended to be used", or "You can't write functional programs in Java because Java is not a functional language", or even "lambdas are dangerous". This, of course, makes no sense.

Regarding the future of Java, I found a post by Brian Goetz one year ago where he said that value types could be added to Java 10. This would clearly be good news, but nothing is certain. What is quite sure is that Java 9 will not bring us much in terms of functional programming.

Link to the post by Brian Goetz: http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html
 
Kerim Kara
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you !!!
very detailed and clear
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking forward to seeing value types.

I hadn't noticed how bad primitives were before Java8, but when I start mixing arrays of primitives with Streams etc., I start wishing I had never seen arrays of primitives.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!