No mention of Ruby or smalltalk in this post, which i think of as "true" OO languages, down to the runtime. The ruby object model has its merits! Sandi Metz's POODR is a fantastic intro into OO _and_ a compositional approach to design.
FP vs OO is always a false dichotomy for sure. Actors and messaging appear in FP languages. Inheritance surely has nothing to do with OO. Inheritance means nothing for data, and it's almost a bug to extend Record types.
In short, this post seems to rage against inheritance and blind use of design patterns, not the spirit of OO. But the post also qualifies that "that is what an OO advocate would say".
Consider Typescript. The same program can be written with `class`es, or as a module of "loose" types and functions. Really, lets pick a mix that best represents the problem we're solving? I think OO can be a _useful complement_ to FP and other paradigms.
It is really weird in 2020 we are still seeing those largely ideological essays against OOP.
The solution is simple, there are tons of languages to use today in a single service/application. Just create your own and put it on the market for validation, if OOP or not is really at the center of productivity then it will be addressed.
Otherwise, I really don't understand the point of such rant posts, feels like marketing and personal flexing.
I only played with Small talk in school as it was before my time but it was great. As I am working at a large Ruby shop currently, Ruby is a lovely language. Ruby really does solve many of the issues I had with Java. Its a very elegant language. I think the behavior of any object taking messages is great, though thats not used much in professional code it seems. I think more people should give ruby a shot.
I do wish it were a bit faster ,but hopefully truffle ruby, sorbet, yjit, etc. can put in the work to fix that.
Would you have any resource on functional Java?
My experience with 8 and onward is better for sure.
I find myself writing more robust filtering / map-reduce logic. But that’s kind of it.
For instance I don’t feel like function are first class citizen still. ( I almost never user higher order function in Java, even if it’s possible )
Effective Java [0] is the single most important book I can recommend for any Java programmer. This article [1] gives an overview of some of the primitives you can use for writing functional Java. Lombok [2] is a very common library that makes writing functional Java much more ergonomic with its `@Value` annotation, but that might not be needed anymore with Java 14's Record types [3].
The book Clean Code [4] helped me a lot to really learn how to write clean Java, and many of these ideas directly translate into writing good functional code. One of the key takeaways was just how small functions should be which incidentally is a great thing to learn when functions are your main unit of composition.
Java isn't a purely functional language, so you obviously will always have some impurity regarding state/mutation. I personally try to do the following:
1. Keep all state in some top-level class and let everything else be immutable
2. Nearly every class I write is immutable
3. Follow common OOP principles like SOLID
4. Write reactive code with heavy use of Optional and Streams
Here's [5] an example repo of board game written using those ideas.
Thanks for your answer, I think I’m stuck with Java for the time being but I least I now cater to a modern codebase. I think it’s … alright. But I miss the function being truly a first class citizen.
Those advice ring familiar or interesting. I need to give effective Java a second look. It’s been year and I’m a different dev now.
God. Those example how to archive currying or composition are painful to read. Not wonder why I never write code this way in Java. Still. I want to be more diligent in that domain because I know it pays off down the line.
No mention of Ruby or smalltalk in this post, which i think of as "true" OO languages, down to the runtime. The ruby object model has its merits! Sandi Metz's POODR is a fantastic intro into OO _and_ a compositional approach to design.
FP vs OO is always a false dichotomy for sure. Actors and messaging appear in FP languages. Inheritance surely has nothing to do with OO. Inheritance means nothing for data, and it's almost a bug to extend Record types.
In short, this post seems to rage against inheritance and blind use of design patterns, not the spirit of OO. But the post also qualifies that "that is what an OO advocate would say".
Consider Typescript. The same program can be written with `class`es, or as a module of "loose" types and functions. Really, lets pick a mix that best represents the problem we're solving? I think OO can be a _useful complement_ to FP and other paradigms.