what’s a good persistent collections framework for use in java?

Just use the ones in Clojure directly. While obviously you might not want to use the language it’s self, you can still use the persistent collections directly as they are all just Java classes.

import clojure.lang.PersistentHashMap;
import clojure.lang.IPersistentMap;

IPersistentMap map = PersistentHashMap.create("key1", "value1");

assert map.get("key1").equals("value1");
IPersistentMap map2 = map.assoc("key1", "value1");

assert map2 != map;
assert map2.get("key1").equals("value1");

(disclaimer: I haven’t actually compiled that code 🙂

the down side is that the collections aren’t typed, i.e. there are no generics with them.

Leave a Comment