• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles

 
Ranch Hand
Posts: 56
  • Number of slices to send:
    Optional 'thank-you' note:
A very warm welcome to you, Ben Weidig, in this forum.

My question is more on the semantics of the language of Java. When I started learning functional programming constructs that were added to Java, I personally felt that it feels forced because obviously, it was designed with the object oriented approach in mind.

So when compared to other pure functional languages, how do you see Java's functional constructs faring against them?

Also, do you think if this limits Java's ability to allow developers to fully realize the potential of achieving the benefits of functional programming?

Thanks & Regards
Dinkar
 
Author
Posts: 28
9
  • Number of slices to send:
    Optional 'thank-you' note:
Hi Dinkar,

thanks for the warm welcome!

Dinkar Chaturvedi wrote:So when compared to other pure functional languages, how do you see Java's functional constructs faring against them?



That's a tricky question... if I say Java's not good for FP, no one will buy my book

Jokes aside, Java's functional support can feel quite constrained or forced compared to a "pure" functional language, but I think that's to be expected in a multi-paradigm language without such support from the ground up.
But for me, that isn't the issue or the eventual deciding factor to use it.

As I see it, the Java team did a fantastic job integrating the possibility of functional programming in a way that works without breaking the language and is quite close to how Java devs would expect it..
Naturally, this is a trade-off and affects how "pure" the functional support or how good the constructs are compared to other languages that don't focus on compatibility, or don't need to integrate it 12 years after the language's inception.

For example, backing each lambda with a concrete type as a functional interface makes them first-class citizens without breaking Java, as there are no dynamic types.
Pre-Java 8 interfaces even become usable for lambdas automagically if the comply with the "single-abstract method" requirement of functional interfaces.
However, enforcing concrete types can create incompatibility between identical lambdas that are represented by different types.
I talk about this in the book, and usually, type inference or bridging the gap with a method reference is enough to make it work.
From a pure FP point of view, that might feel subpar, and it is, but from a Java devs view, you still have access to many of the benefits of FP without needing to go fully functional.

Also, do you think if this limits Java's ability to allow developers to fully realize the potential of achieving the benefits of functional programming?



If a developer only checks out a single language trying to realize the potential of a paradigm's ability, then I'd say yes.
But I wouldn't recommend Java as the language to learn/use if you want to be exposed to the full potential of FP.
Just as you wouldn't start/use F# for being exposed to the full potential of OOP, either.
Sure, you can use either language for both paradigms, but software development is about choosing the right tools for the job.

For me, Java's functional support is a great way to get your feet wet and see the tip of the FP iceberg.
That's why I called my book "A Functional Approach to Java" and not "Functional Programming with Java".
Being able to introduce FP into your Java code base gradually is the real benefit of Java's functional support, in my opinion.
 
Rancher
Posts: 379
22
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:

Ben Weidig wrote:
need to integrate it 12 years after the language's inception.



This made me curious about the timeline...

  • Java 1.0 came out in early 1996
  • Java 8 added lambdas and came out in the spring of 2014


  • So that's about 18 years -- which makes what the language's designers did even more amazing, in my opinion. Java is 27 years old and has had 20 major releases so far (with another due in three months) and yet it has retained backward compatibility in nearly all cases, while still changing in some fairly radical ways.

    Language design and stewardship are hard! Brian Goetz (who was the spec lead for lambda expressions) gave a great talk about this, the year Java 8 was released, at Clojure/conj (of all places!). Definitely worth watching: https://www.youtube.com/watch?v=2y5Pv4yN0b0
     
    Ben Weidig
    Author
    Posts: 28
    9
    • Number of slices to send:
      Optional 'thank-you' note:

    Sean Corfield wrote:So that's about 18 years



    Looks like it's time for the weekend when I can't do such simple math anymore


    Exactly, the language design, good stewardship, and preservation of backward compatibility to the vast ecosystem IS the main selling point for Java IMHO.
    If that means there are trade-offs in areas of how well certain features can be integrated, I'm ok with that.
    There's still a lot to gain from such features.

    Looking at my other most-used language, Swift, I see quite a different approach to a programming language.
    It's an interestingly designed language with many features done right.
    But the price was the lack of ABI stability before version 5 and multiple changes to the syntax over the years.

    So each yearly iOS release brought a new Swift version that broke your code and dependencies.
    Combined with the fact that Apple forces you to recompile and re-upload the app every other year, that's quite a nuisance!
     
    Marshal
    Posts: 79422
    377
    • 1
    • Number of slices to send:
      Optional 'thank-you' note:

    Ben Weidig wrote:. . . time for the weekend . . .

    Hahahahah!
    You have put no end of effort into answering the many questions you have been asked: thank you
     
    Ben Weidig
    Author
    Posts: 28
    9
    • Number of slices to send:
      Optional 'thank-you' note:
    It was my pleasure!

    Getting critical questions and being confronted with different views and backgrounds is always a good way to re-evaluate and re-adjust your own point of view.

    Thanks to all of you for the interesting and sometimes not so easy to answer questions!
     
    Dinkar Chaturvedi
    Ranch Hand
    Posts: 56
    • Number of slices to send:
      Optional 'thank-you' note:
    Thank you Ben Weidig for the insightful responses. This was helpful.

    Also thanks to the members who ensured that I took away accurate information about the quick lesson on Java's history.

    Thanks again!

    Regards,
    Dinkar
    reply
      Bookmark Topic Watch Topic
    • New Topic
    vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
    http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |