3 ms·
> As someone who has breathed Clojure for the past three years, I very rarely come across code that is truly difficult to understand. I'm not really arguing th
by weareconvo 14y ago
> As someone who has breathed Clojure for the past three years, I very rarely come across code that is truly difficult to understand.
I'm not really arguing that Clojure code is "truly" difficult to understand, if that is taken to mean reasoning about its performance and effects. Rather, I'm talking about the fact that idiomatic Clojure code encourages writing functions upon functions upon functions, which continually builds up layers of abstraction that inherently make code more and more difficult to read. Example:
console.log("Hiya.");
console.log("How's it ");
console.log("going?");
vs.
printFirstString();
printSecondString();
printThirdString();
function printFirstString() { ...etc }
- lukev 14y agoI don't know anyone who writes code like that. Unnecessary wrapping of functions is an antipattern. Idomatic Clojure for what you just wrote is: (println "Hiya.") (println "How's it ") (println "going?") If a Clojureist wanted to get fancy and build an abstraction (as they probably would) they'd probably write a debug function instead of using 'println' directly: (log/debug "Hiya.") (log/debug "How's it ") Which is, granted, an abstraction, but isn't any harder to read.
- rayiner 14y agoI could say the same thing about Java. Clojure/Lisp code just tends to have functions that do mostly what their names indicate. Java code tends to be broken up into billions of classes, and understanding an algorithm tends to involve trying to collect together all the pieces of it that are spread out as methods in a bunch of classes. Take something like code generation from an AST. In Clojure, you might do it in a single file with multimethods. In Java, the code generation algorithm would be spread out over dozens of different AST classes, each with a visitor method.