r/Clojure • • 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-valhalla
97 Upvotes

20 comments sorted by

View all comments

Show parent comments

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 supports java.util.Lists.

It also provides a builder-type pattern, so you can do assoc / disassoc type 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.