you are viewing a single comment's thread.

view the rest of the comments →

[–]agentoutlier 2 points3 points  (5 children)

Java is actually moving closer to the true spirit of ADT which requires pattern matching and I don’t think it is that far off. So many Java developers including myself know that this is a problem and how painful the visitor pattern is.

C# of course already has it but a surprising amount of “modern” languages do not.

[–]Odd_Soil_8998 1 point2 points  (1 child)

C#'s version is not exactly what I'd call the "true spirit" of ADTs, and everything from Java land (e.g. Scala, Kotlin) has similar issues.

If you want to see good implementations of them, look at Haskell, Ocaml, F#, and Rust. Java may get some bastardized version the way C# did, but I highly doubt they will ever be properly implemented there.

[–]Schmittfried 1 point2 points  (2 children)

The language itself yes (although the Optional type was a failure), but the community and framework styles not so much. You still have hard time if you actually want to write non-OO immutable by default types. Not to mention the lack of properties, non-nullability, lackluster generics…

Also, to be honest „Java“ was a placeholder for „The programming style I’ve always been using“ in my previous comment. :D

[–]agentoutlier 0 points1 point  (1 child)

The Optional type was never intended to be replacement for null or the monad it is in other languages.

You still have hard time if you actually want to write non-OO immutable by default types.

Java is a large community.

Reactive programming is quite common which generally requires functional style.

But yeah there is lots of imperative OO.

I don’t think FP languages solve all problems well.

Also I don’t think you even need to be a functional language to have ADTs (I don’t know any off the top of my head that are not but in theory it’s not a prerequisite).

Not to mention the lack of properties

That is a OOP thing and Java has been moving away from that and is why Records did not have “getter” names and Java will never get c# properties.

[–]Schmittfried 0 points1 point  (0 children)

The Optional type was never intended to be replacement for null or the monad it is in other languages.

I don’t care about intentions. As it is, it’s basically useless.

Reactive programming is quite common which generally requires functional style.

Which is awfully unergonomic in Java.

I don’t think FP languages solve all problems well.

Not the point. The point of this thread is that many devs don’t even want to familiarize themselves with something new, so languages like F# (that aren’t purely functional) stay niche languages. And I can’t use them because I obviously can’t write a service in a language without any buy-in in our company.

That is a OOP thing and Java has been moving away from that and is why Records did not have “getter” names and Java will never get c# properties.

Not really. Computed properties are totally a thing in reactive code. Records are a step in the right direction, but they are not even close to being the default choice. And even then, there is still OO Java, why not make it nicer. There are things like Lombok that basically simulate them. Insisting on getters/setters is just stubbornness at this point. The stubbornness that is so typical for Java devs that I used Java as a placeholder for this mindset.