• 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

97 Things Every Java Programmer Should Know: Future of OOP?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kevlin & Trisha!

I want to push my Java skills to the next level, hence my interest in your book!

My questions for you: what does the future of OOP look like? Will OOP and FP blend in Java?

Background: I've read some articles regarding the 'broken promise' of OOP, and as somebody who plays with Clojure and Rust as well I wonder if functional programming makes for better maintainable software.

Sander

edit: found this very interesting thread after posting: https://coderanch.com/t/673880/paradigms/FP-design-flexibility-Pierre-Yves
 
Author
Posts: 49
18
IntelliJ IDE Java
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sander,

That's a great question and you're not alone in asking it. Of course, you know the answer is "it depends" Functional languages like Clojure are really great at solving particular types of problems, and I don't mean that these problems are a small niche either. I love functional programming because it can feel simpler to reason about, I particularly like side-effect-free functions and immutability.

As a long-time Java programmer, and a veteran of the kind of enterprises that generally like using Java, I think the introduction of functional-style programming in Java 8 (e.g. lambdas and streams) and the movement towards immutability has created a nice blend that allows Java to be used in a wide range of business domains, solving a range of technical problems. Java is continuing to adopt some things we commonly see in functional languages where it makes sense.

For me, it doesn't have to be OO vs FP. I like OO, because you can model the business domain (I'm a big fan of Domain Driven Design). There were some OO concepts missing in early versions of Java that perhaps made early Java's OO a little clumsy. I think the introduction of concepts like Records (a preview feature in Java 14 and 15) is a very modern-Java approach - records are a lightweight object that could model a business concept, but they are immutable by design and lend themselves well to (for example) being a payload in a message. This feels like the right direction for an Object Oriented language.

Trisha
 
Sander Hollaar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your extensive reply! And for your insight on OO and FP from your long-time experience.

Totally agree with your view on Records: I've played with it and it feels so natural! This new feature, and others (Loom  comes to mind) give me trust in the future of Java.

Still so much to learn ..

Thanks again Trisha!
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you cover records in the book?
 
Trisha Gee
Author
Posts: 49
18
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Do you cover records in the book?



Not explicitly. When the book was being put together at the end of last year it was barely on the radar. However Steve Freeman's piece "Simple Value Objects" talks about one of the use-cases for records, and at the end mentions Records within this context.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paradigms are not strictly disjoint and the paradigm landscape is richer and more varied than many people expect. For example, Java's OO paradigm is very different to, say, Python's, and Excel's expression of functional programming is very different to Haskell's. There is a lot of variety and range!

So to add to Trisha's "It depends" we need to understand that Java has a number of features that better support OO than FP. It is unlikely Java will ever be a functional programming language and there is a lot in the existing language that works against functional programming. For example, by default Java is imperative in how it treats its data. Changing such a default is like changing the laws of physics. It would break everything, and for minimal value. Java also doesn't support functions! This is the most basic construct in functional programming, but Java only permits classes and interfaces as top-level constructs.

Certainly, Java can be programmed in a way that is influenced by FP, and Java 8+ makes this easier. Adding lambdas and streams brings Java closer to FP, but neither streams nor lambdas are specific and unique to FP. If you look at blocks and collection pipelines in languages such as Smalltalk and Ruby, it looks more like Java is becoming more OO!
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...but doesn't a λ become an object, and aren't objects first class citizens?
 
Kevlin Henney
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly! When Java 8 added lambdas, Java did not be come functional; it became more object oriented. See my talk, Lambda? You Keep Using that Letter: https://www.youtube.com/watch?v=orcSUE0Jjdc
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I might have to listen to that talk again. I noticed the similarity to how my old COD defines “two”: “one more than one”. And “three” is “one more than two”. So it should be easy to guess how “four” is defined. But you can't define “one” as “one more than none”, because there is circular logic there, so the dictionary has to use 1‑based numbers.

COD = Concise Oxford Dictionary (1978 edition).

That is different from Eric Hehner in A Practical Theory of Programming. He calls the first chapter “Chapter 0”, and defines number theory in terms of succ(i) (short for successor). 1 is succ(0) and 2 is succ(1), and when you write that out in long, you get the same formula as you showed for natural numbers. In fact, Hehner defines the bunch ℕ as 0, succ(ℕ). Of course it includes 0 as a natural number; Hehner is sceptical about any numbering system without 0s.
I see that λs do and don't appear in various languages. Do they appear in Eiffel? In the days when I did some work with Eiffel, I don't remember λs ever being mentioned.
 
Kevlin Henney
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The idea of starting from 0 and then defining a successor function is the basis of Peano numbering. Interestingly, the original λ paper did not use 0, but it is consistent with (and included in) most presentations of Church numerals. I find myself agreeing about being suspicious of number systems without 0... although, that said, I have a soft spot for Roman numerals 😉

Eiffel did not originally include any lambda/block/closure kind of object and, if anything, appeared stylistically opposed to anything that might smack of brevity and convenience! It was a language that made Pascal look compact. It did later (Eiffel 3 onwards?) adopt a number of conveniences, including lambda-style constructs.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevlin Henney wrote: . . . Eiffel . . . appeared stylistically opposed to anything that might smack of brevity and convenience! . . .

Hahahahahahahahaha!
 
reply
    Bookmark Topic Watch Topic
  • New Topic