• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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
 
Author
Posts: 160
31
  • 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
 
Marshal
Posts: 69813
277
  • 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.
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic