238 points · by simongray · 4y ago · 69 comments
My favorite things about using Clojure: 1. Runs on the JVM. Battle tested, tons of libraries, and well engineered. 2. Immutable Data Structures. I wouldn't want to live without this safety ever again. 3. LISP syntax - so simple to remember and just basically code functions! I also find reading Clojure code very simple vs other procedural languages. 4. REPL development. 5. Transducers - not unique to Clojure, but just love them so listed it.
Great language.
The choice of default meanings is good too, lists/application, indexed sequences and k/v mappings are useful widely used primitive constructs (clojure makes sets (the math meaning, unordered collection, no dupes) with #{} which is handy).
It cleans up the code nicely, having these literals, and now I find non-clojure styles to be a bit annoying to read with the extra noise from contructor function calls.
And when describing data/DSLs using these literals people generally carry the general meanings over, so things can be a bit more intuitive. And in a lot of places just using ('s and ['s in a way that makes it easy to disambiguate them when reading some DSL or literal value also makes for nicer reading of code (just in terms of a bit less mental parsing effort).
I'm the type to not be immediately a fan of extra syntax added to a lisp, but I've been convinced that edn notation is pretty wonderful and I've been converted.
That's not a feature of Scheme. It must be a feature of the implementation you use. (Which one?) E.g. in R7RS, [ ] and { } are explicitly reserved for future language extensions.
1. https://docs.racket-lang.org/collections/index.html 2. https://docs.racket-lang.org/seq/index.html 3. https://docs.racket-lang.org/threading/index.html
1. https://github.com/racket/rhombus-prototype/blob/master/reso...
2. http://programming-puzzler.blogspot.com/2010/08/racket-vs-cl...
[1] https://github.com/oracle/graal
[2] https://github.com/babashka/babashka
[3] https://arnoldgalovics.com/java-cold-start-aws-lambda-graalv... (large proj - dynamoDB)
[4] https://dev.to/wololock/groovy-script-startup-time-from-2-1s... (small proj)
For a one-liner scripting I still use Bash but for a larger script I now use Clojure.
Whìch happens to be the favourite alternative JVM language from Brian Goetz,
I'm particularly happy with the new keyword args semantics, which solves a long standing pain point.
How does it compares to the likes of other statically typed Lisp dialects such as Rackett?
I've always wanted to read "Clojure for the brave and true" but there's just enough lisp books (my favorite being "Structure and Interpretation of Computer Programs") I can read without actually wanting to use the language.
Its always contentious topic, there are no answers.
- compile to small binaries that run fast. I get what the langage gets from the JVM, but those 5,10 seconds I get before _anything_ runs, even after I had everything compiled ?
- show me an example of how having 'spec' is going to help me refactor the code that I got wrong the first time, as easily as what a proto-ML-like static type checker does. It's not a question of "types are bad vs types are good thing". It's a question of "this property was called 'name', but now I need it to be 'names', and I really need to know every possible place of my code base that uses it so that I can recursively change all code paths to handle the fact that it's a list, now." I read the spec doc a dozen times, and I don't think it does help in this simplest of simple case.
Also, I make typos all the time, and caml / typescript / rust catch them before I waste a run cycle. Dynamic langages can't know if 'names' and 'name' coexist - Let me tell the compiler what I mean once.
- promote an "obvious" gui lib. It's not obvious what I need to use to do an hello world window (but that's really not specific to clojure, in all fairness...)
For this, I think the way to go is to use `fdef` to annotate the arguments to each function. This is a lot more explicit keyboard-typing on the programmer's part, but then so is a statically-typed language.
Where I think Clojure will still come up short is in tooling to support finding each reference in a better way than grepping your project for `:user/name`. All the information you need is in there, as you can see from this proof-of-concept tool[0], but it's not implemented seamlessly into the workflow.
What are you finding that is breaking? Backwards compatibility is pretty stellar in the language
In general, Clojure still has poor documentation compared to more popular languages.
My unit (just like many other Clojure teams) has been building numerous solutions for many years now. Our employer loves us very much. As long as we keep making money; maintain our codebase aiming for expansion rather than [quartely] renovation - investors won't care what we use to achieve the results. If other companies prefer hiring new devs and rebuilding everything every two years - well, that's their money.
But from my experience working with it on real projects:
- Good tutorials, combined with library and build tooling integration for usage with GraalVM. Startup times make it a horrible fit for anything other than long-lived daemons.
- Speaking of build systems: more ecosystem coalescing around tools.deps, there's a lot of resources around Leiningen, not too many around the blessed native tooling (I know, I know, it's fairly new for Clojure standards, but it is a problem).
- More and better linters for popular libraries. Without good types, you need something to guide you when you're misusing an API; the team where I worked with Clojure lost a lot of time getting Reagent patterns wrong.
My final complaint is something that I don't think can't ever be fixed without undoing what makes Clojure, Clojure:
REPL-driven development combined with dynamic typing, in the same way as its cousin: debugger-driven development, often leads to write-only code that works but good luck using it or modifying it if you don't have good automated tests to tell you how it's supposed to be used and more importantly how it's not.
It doesn't help that tests are de-emphasized by the community precisely because of REPL-driven development. "Just put it on the REPL and see what it does" is not a good way of reasoning about code, and makes it easy and convenient to just pile on more hacks that may or may not break something instead of promoting understanding. "Just write good code and have discipline, you're doomed if you can't do that anyway" does not excuse that other languages have radically different tools and practices that lead to far fewer footguns.
Can you share any examples of these different tools and practices?
They can be used not only as a way to let the compiler help you out in not making mistakes but also as an exploratory tool to test out many edge cases with quick feedback and as an informational aid to help quickly introduce new developers into a codebase with its own business domain explained in a language that allows conveying "this is possible" and "this isn't possible" much more quickly than reading tons of procedural code until the reader comprehends all the implicit rules laid down by the program's behavior.
If it's true that engineers leave after one/two years then I can't blame them. Whatever cost static typing brings, it's worth it to them. Just look at how typescript usage has exploded.
I love Clojure and would use it for small projects if given the chance but I think there are diminishing returns when you scale up, specially if you deal with a complex data structures which get encoded and decoded to JSON (messes up things like keywords).
I am so happy to see that not one but a couple of those names are my colleagues. They send patches to clojure.core. I send comments to HN :). I'm proud of them, I hope they proud of me too.