r/Clojure • u/fredoverflow • Aug 12 '21
Java language architect Brian Goetz: "Mutability is greatly overused and overrated. Records is a language feature that recognizes the importance of immutability. We want to model data coming in as XML or JSON as ordinary data."
https://blogs.oracle.com/javamagazine/java-architects-loom-panama-valhalla23
u/lgstein Aug 12 '21 edited Aug 12 '21
I really like experimental languages, but for now I'll stick with Clojure.
8
u/agumonkey Aug 12 '21
I got into college at peak java vomit, j2ee and full setFoo spaghetti.. what a waste
20
u/CodeFarmer Aug 12 '21 edited Aug 12 '21
I was reading this article this morning and thinking similarly.
My Clojure and (before that) Scala experiences have basically caused me to now write Java in a way that causes Java-identifying devs' eyes to roll back into their heads, which in turn makes me basically unemployable as a Java Writing Guy. (It's lucky that's not what I do nowadays eh.)
I wonder if future Javas as imagined by Brian and co might bring me back into the mainstream :D
5
u/NaiveRound Aug 12 '21 edited Aug 12 '21
Yeah, I hear ya! I've been using https://immutables.github.io/ on any new Java projects to give me that good, immutable stuff I've come to know and love in Clojure.
It gives me a
toString(),hashCode(),equals(), and copy. Even supportsjava.util.Lists.It also provides a builder-type pattern, so you can do
assoc/disassoctype operation via the builder.1
u/lordmyd Aug 16 '21
But are these implemented with structural sharing as in Clojure?
1
u/NaiveRound Aug 16 '21
Nah, just basic POJO stuff. Nothing that fancy ;)
2
u/lordmyd Aug 17 '21
So not really the most efficient implementation. Rich Hickey spent a lot of time making Clojure's persistent data structures performant based on the earlier work of Phil Bagwell.
9
u/agumonkey Aug 12 '21
being unemployable as a java writing guy probably sucks financially wise but existentially seems like bliss
1
u/CodeFarmer Aug 13 '21
You know, I don't really mind Java... it doesn't spark joy exactly, but then neither do most languages and it was a huge improvement over what I was doing before (C++ and Perl, mostly). I wrote code for about 35 years, about 20 professionally, and now am employed to mostly not write code at all, and that's fine. Honestly I've reached an age where I don't have the focus and attention span to do it well enough to be satisfied. But my experience can still be valuable to others!
Clojure is nice though. If I had to program for a living again it would be a mostly pleasant choice.
1
u/agumonkey Aug 13 '21
I lost drive to code mostly because of the gritty details, I prefer combinatorics now. In any case I wonder if with age most of us simply don't go meta and are skilled in emotional and organizational aspects.
1
u/CodeFarmer Aug 13 '21 edited Aug 13 '21
Don't know about most, but yeah, quite a few. Me, certainly. Maybe it's not just that my coding output has worsened, but that my other skills have gotten better too.
1
u/agumonkey Aug 13 '21
I think it's a shift, we care less about indivual performance but group's performance (and happiness) .. something like that
2
u/UseHerMane Aug 13 '21
My ex boss wrote Java for 15 years and spent nearly every day trashing it while working in Clojure together.
4
u/CurtainDog Aug 13 '21
“Because of these conventions, mutability is greatly overused and overrated,”
Eh, no. The problem is not the conventions but that nobody stopped to think about whether what they were doing actually made sense. This is the thing that attracts me to Clojure - it doesn't claim to do your thinking for you.
5
u/SimonGray Aug 13 '21
I took a class in my final year of uni that was specifically about OOP design patterns (it wasn't my first time learning about design patterns, of course). I thought that maybe this time I would finally "get it". I did my best all semester, got the highest grade possible, and that was when I finally gave up trying to understand what the fuss was about. It made me disillusioned to think that the entire software industry was mindlessly making software in this way.
Watching Rich Hickey's talks (especially "Are We There Yet" and "Simple Made Easy") was a revelation.
3
u/elliotbarlas Aug 13 '21
This is a deceptive citation since you omitted the beginning of the first sentence: "Because of these conventions, ..."
The quote is specifically with respect to the JavaBeans conventions, which encourage mutability. It's not a broad statement about Java as presented. Folks on this thread are reading it as such.
In any case, immutable classes have been a central design pattern in Java for decades. The brilliant Doug Lea devoted a chapter of Concurrent Programming in Java to immutability. First published in 1996.
11
u/cbleslie Aug 12 '21 edited Sep 12 '25
governor reminiscent grey steer towering coordinated divide paltry boat correct
This post was mass deleted and anonymized with Redact