What critical features Clojure has, which don't exist in other platforms/languages?
What critical features Clojure has, which don't exist in other platforms/languages?
Editing JSX is a pain in comparison to the Hiccup syntax used more often in CLJS, e.g. [:div {:class shiny} "some stuff" [:button "OK"]] - with the structural editing in any good Clojure editor you can cut, paste, entire blocks of tags, or slurp a tag from outside your div into it, or spit one out, all with a few keystrokes, never stopping to find some closing </div> tag.. I guess some JSX IDEs might do this, but it's really nice that the HTML is represented as just another piece of data, not some weird chimerical syntax bolt on.
With Figwheel or ShadowCLJS hot reloading is instantaneous and doesn't even interrupt your webapp. If they're written properly, functions and the app state are not conflated at all, so you can modify any function in your app's rendering or behavior and as long as they aren't incompatible with the runtime state, it will just pop right into your browser. Illustrated well in this video where the author is interactively re-implementing Flappy Bird: https://youtu.be/KZjFVdU8VLI?t=277
I feel particularly strongly about this having started out doing front end work primarily in cljs but recently being falling into using React/Redux for a contract and being REALLY strung out by the tedium of working with them.
Besides, experienced clojure devs just see things differently and end up writing lots of nice libs that capture the essence of the feature the lib is providing. Think datomic (immutable database), reagent (interface to react), honeysql (data-as-sql), "dependency injection" (mount/component & others), pull/query-based UIs (om.next and its spiritual successor, fulcro) and so on.
A few other high points:
- macro-based metaprogramming, familiar to any Lisp-er; macros are essentially functions which write code for you, which allow one to create extremely concise constructs to reduce repetition in code;
- functional programming: probably the hardest thing to get one's head around if coming from a more mainstream language, FP reduces mutable state to a minimum, eliminating one of the biggest source of programming defects and making programs significantly easier to reason about. Additional concurrency-safe state primitives in Clojure makes concurrency a trivial addition to many programs;
- hosted on the JVM, giving interoperability with Java libraries and significant ease of deployment compared to other dynamic languages (I recently went back to Python to roll out a small web service and was amazed at how much more painful the deployment/devops story was compared to our Clojure services).
These are some of the benefits we leverage; other people here more qualified than me have enumerated others. (Plus Datomic, whose philosophy aligns fully with Clojure, though I have yet to use it in production.)
On a personal note, one final attribute I appreciate is structural editing: as a Lisp, Clojure code is data, a feature which one's editor can make use of to allow operations that would be alien to non-Lispers, such as: absorbing nearby expressions or expelling them; splitting them; sorting and reordering; and writing your own automated refactorings without having to write parsers for the language in question. Treating code as data structures rather than strings of characters allows for speed in writing and refactoring code that is hard to give up once you get used to it.
Have you seen Lumen, a Beam implementation in Rust that targets Wasm?
I hope at least some of those languages get enough adoption to become viable production choices. I feel, apart from Elixir, Gleam has the most “popularity potential” right now.
It's similar with Clojure. Are transducers "critical" or revolutionary? Not at all. And yet they facilitate building composable and reusable pipelines, which helps me with modeling a complex problem domain. Is core.async "critical"? Hardly. And yet it allows me to build reliable asynchronous data flows.
Clojure is a practical language, designed by someone with decades of experience in building complex systems.