3 ms·
I'm still fairly removed from clojure. Most of what I do read doesn't convince me it is worth it over common lisp. That said, the idea of conj bring an extend
by taeric 6y ago
I'm still fairly removed from clojure. Most of what I do read doesn't convince me it is worth it over common lisp.
That said, the idea of conj bring an extended cons sounds really nice. Are there examples where the "you can change the fundamental data structure and the algo still works" pans out?
I fear this will be a lot like our industry's love of tries. Mostly impractical and more likely to cause bugs. :(
- YuriNiyazov 6y agoIf your bar is "Common Lisp" and you already get to use Common Lisp regularly, then you are right, Clojure will never be good enough for you. Clojure was designed to, as seamlessly as possible, Trojan a Lisp into the enterprise world where the JVM rules. It succeeded at that narrow task.
- justinhj 6y agoI used CL as a hobbiest for years but never in code I would get paid for. Clojure is a different story. That you can run it on the JVM is a game changer when you want to introduce the code to a production environment. The massive amount of Java libraries and tooling plus the operational knowledge that organizations have make it a much easier sell even with "all those rackets". More language related reasons I prefer it to Common Lisp are things the syntax for vectors, maps and sets that give those data structures a more first class feel (CL users will probably disagree), persistent data structures and overall a fresh feel to the language.
- kazinator 6y agoI recently ran into a situation in the TXR Lisp compiler where it would have been useful to have immutable hash tables with conj. http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/compiler.tl?h=txr-254#n175 http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/compil... Notice how there is a method to take a snapshot of the compiler state, which includes making copies of several hash tables, and a corresponding restore method to put it back. Hey, isn't there some GoF Design Pattern for this? Memento or something. The thing is, if hash tables and objects were immutable, the whole code would be a shitshow, and perform badly too. It would just not have that one problem: it would never have to copy a hash table in order to have a copy of the old one. Immutable HAMT hash tables that I could conj to and then assign back into the original location would be a reasonable middle ground. Then I would still need he snapshot method; but it wouldn't have to do anything beyond returning (copy me). It occurs to me I could implement a shallow hash table copy function, such that the original and new table share chains. Mutating either table (overwriting an existing key/value pair with a new value) would show up in the other, but deletions and insertions would not.
- slifin 6y agoInternally those are "persistent data structures" in Clojure which don't duplicate the data but instead mutate a underlying tree that links both the old state and the new state Then as a developer you are looking into a certain piece of that tree depending on what bit of the "mutated value" you are viewing I assume this is to help ensure memory usage doesn't balloon but if you need to do mutation there are non-default features for doing that: https://clojure.org/reference/transients https://clojure.org/reference/transients with all the pros and cons of mutation
- raspasov 6y ago"you can change the fundamental data structure and the algo still works" - it doesn't really pan out, and it's not important in my experience of using Clojure for about ~8 years. What makes Clojure worth it is the pervasive reduction of mutable state across your program without the cost and rigidity of creating types everywhere. Also great sharing of code across Clojure and ClojureScript: - You want your dates to behave the same on client and server? You got it: https://github.com/juxt/tick https://github.com/juxt/tick - You want your logging/debugging code to be the same? You got it: https://github.com/ptaoussanis/timbre https://github.com/ptaoussanis/timbre - You want good async primitives? No problem: https://github.com/clojure/core.async https://github.com/clojure/core.async - And many more... I haven't seen another language that is as good as Clojure(Script) at this. Nowadays .cljc (.clj + .cljs) files really rock.