4 ms·
Being a Lisp dialect for the JVM Clojure has readability issues: https://tonsky.me/blog/readable-clojure/ https://tonsky.me/blog/readable-clojure/ That alone wi
by amai 3y ago
Being a Lisp dialect for the JVM Clojure has readability issues: https://tonsky.me/blog/readable-clojure/ https://tonsky.me/blog/readable-clojure/
That alone will make sure Clojure will always be a niche programming language and ensure job safety for the few ones who can read it.
But nowadays Clojure brings no advantages anymore over Java. I wouldn't start any new project using Clojure.
- j-pb 3y agoI'd consider your point more if you could actually write the name correctly.
- amai 3y agoFixed it. It seems the autocorrection on smartphones doesn’t like Clojure either.
- j-pb 3y agoYou're missing a/the crucial point about Clojure btw. It's not about the functional programming stuff, of which Java has added a lot in recent versions, but it's actually about the immutable/persistent data-structures, of which Java has added none afaik. Value types are simply not the same thing. The structural sharing you get with Clojure, means that you can have immutable data that contains billions of entries. This allows you to solve really hard problems that are almost impossible to get right any other way, undo-redo, search algorithms that exploit lattices, idempotent network operations.
- amai 3y ago"the core JDK package java.util.concurrent includes CopyOnWriteArrayList and CopyOnWriteArraySet which are persistent structures, implemented using copy-on-write techniques...Fully persistent collections are available in third-party libraries" https://en.m.wikipedia.org/wiki/Persistent_data_structure#Java https://en.m.wikipedia.org/wiki/Persistent_data_structure#Ja... So if you need that in Java you can simply use 3rd-party libraries like https://pcollections.org/ https://pcollections.org/ or https://github.com/GlenKPeterson/Paguro https://github.com/GlenKPeterson/Paguro. There is no need to completely change your programming language to Clojure and suffer from all that readability issues: https://softwareengineering.stackexchange.com/questions/197232/how-to-write-readable-clojure-code https://softwareengineering.stackexchange.com/questions/1972...
- j-pb 3y agoThere's a huge difference in friction between using a language that _also_ has a library for persistent data-structures, vs a language that was designed _around_ immutable datastructures. If you had brought up error messages in Clojure as your main concern, I'd think you'd have a point, but the "putting the paren before the function name confuses me" argument is as old as lisp and pretty moot imnsho. I did Clojure full-time for years, and now do Rust rust full-time, and I can definitely say that Rusts syntax is wayyy more complex and hard to read, despite technically being in the C style syntax family. Great minds discuss architecture, Average minds discuss semantics, Small minds discuss syntax It's also not like the example you posted is easier to read in e.g. javascript if you remove all indentation. (defn f [{x :x y :y z :z [a b c] :coll}] (print x " " y " " z " " a " " b " " c)) const f = ({x: x, y: y, z: z, coll: [a, b, c]}) => print(x, " ", y, " ", z, " ", a, " ", b, " ", c)
- amai 3y agoI compared Clojure with Java and see no advantages for using Clojure instead of Java on the JVM. Your examples comparing Clojure with Rust or Javascript are not of interest in that discussion. Both Rust and Javascript are used for completely different use cases than Clojure and Java.
- j-pb 3y ago(I) see no advantages for using Clojure instead of Java on the JVM To be blunt, I think that says more about you than it says about Clojure. A good engineer should always see the tradeoffs.
- fulafel 3y agoIndeed. There are also of course persistent data structure libraries for many other languages, but it's a huge difference when they are the core vocabulary of the language and its culture.
- iLemming 3y agoReadability? Every programming language suffers from "not enough readability". There doesn't exist any language that is always clear and easy to reason about. Writing is fundamentally a method of communication that involves the use of symbols to convey ideas, thoughts, stories, information, or messages. You can mess it up in any language. Clojure, being a Lisp dialect, does not have readability issues. Au contraire, I believe it is far more readable than any other general use, popular language. Once you grok the key features of any Lisp, you may find Lisps (especially Clojure) to be clear and direct, and here's why: 1. Uniformity: Lisp languages follow a consistent pattern. Functions and operators always come first, followed by operands. 2. Minimal syntax: The minimal syntax can also be seen as making the language cleaner and simpler, decreasing the chances of errors. 3. Expressiveness: Lisp allows you to accomplish more with less code, which leads to fewer lines of code and thus potentially easier maintenance and readability. 4. Macros and meta-programming: The ability to extend the language by defining new syntax or deriving new languages can lead to more readable and concise code. This one's pretty much up for debate, because as easily as you can improve the language, you can also make it much more confusing. You know what Spiderman's uncle says. People using non-lispy languages often get excited about certain things, to some of them I can only react with raising eyebrows. I always have a Clojure repl around. Even when I'm not programming in Clojure. Like for example, if I'm testing REST endpoints and sending data back and forth, I configure it in such a way that it always converts the responses to EDN. EDN is far more concise and much more readable than JSON. With the connected REPL I can quickly `filter, map, reduce, group-by, sort, remove`, dedup, slice, dice, and serve the data any way I like. It will take you longer to go through jq's documentation to perform the same data manipulation with JSON. It's an extremely powerful way of dealing with data. With large quantities of data. Clojure is the only language that can turn any impossible-to-navigate-through data and make it precisely readable for me. Readability? Really? Spend some more time using Clojure, you may get surprised how insanely readable it is.
- kazinator 3y agoNote that the nil/false issue he refers to in a real Lisp in which nil is the one and only false value. He's basically saying, in Clojure, don't use time-honored, clear idioms that are perfectly appropriate in some other Lisps.