by ithrow · 6y ago · 0 comments
I stop using it because the lack of Clojure libraries pushed me to use Java libraries, and that was a life-sucking experience. Java is fine as language but you cannot say the same about the APIs of many of its libraries. I also started sensing that new open source libraries are not being created in Java which worsens the story for Clojure.
So I mostly do frontend development at the time and I know Clojure since before. Because of those two variables, I've chosen to use ClojureScript so now I 99% of my professional time write only ClojureScript, with the remaining time being 1% JS when needed. Otherwise the only time I see JS is when I have to understand how a library works.
So I agree with you on the Java side, I'm not a Java developer and I want to stay far away from it, but I love Clojure and I need to be close to it, any other language feels inefficient and slows me down. But there are other hosts you can use, if needed.
A piece of crap unsuitable for production use could be a Lisp. Lisp 1.5 is Lisp; I wouldn't use it today. Lisp or not is not about quality, but semantics. Clojure lacks or changes numerous semantics which define Lisp. That's not statement about quality, just otherness.
Clojure doesn't call itself a Lisp; though the main website claims it is a Lisp dialect. Dialects are defined by mutual intelligibility. An Osaka man speaks a dialect which is understood in Tokyo. The mutual intelligibility between Lisp dialects and Clojure does not extend very far beyond (+ 2 2).
But once you want to spread between multiple computers or operate on data larger than what comfortably fits in memory, you end up coding just like you would in C#.
I started working on some versions of persistent data structures that serialize to a KV store, which lets you send a hash map to another machine, have save that machine add a key, then send it back. It seemed to work pretty well, but there's a ~10x performance penalty over Clojure's inbuilt data types (which are themselves not lighting the world on fire speed wise).
That's a pretty harsh price to pay - you can use 100 machines to simulate single address space Clojure on a 10x machine. Awesome, but likely impractical. If you need the persistence between program runs or would like to run incremental computation on large data I could see it working well, though.
I didn't use special data structures (except when the problem called for it), with a clear separation using nippy serialization (in place of pr-str/read-string) at the edges of my app.
[0] https://github.com/jkk/honeysql
This is no accident, as Clojure's STM was built around the premise of emulating the MVCC provided by databases to provide ACI (minus the D) guarantees to program against. If you're already getting those guarantees elsewhere, doubling up does no good.
Similarly, code that operates on streams is generally not where you get bogged down by state and multithreading in something like C#.
I say this as somebody that believes Clojure is a powerful addition to the toolbox. I even use refs in production code...
Add to that the fact that the language shepards you into using immutable datastructures and writing pure code, I still think Clojure is a significant advantage when writing distributed applications.
Clojure's HoneySQL is the best way to programatically interact with a database I have found, and it's not particularly close. It provides nice data structures to work with (that can even be schemed or speced) and combined with clojure makes writing complicated logic a breeze. It is easily extensible to new SQL functions, clauses, and operators, even vendor-specific stuff (we used a lot of PostgreSQL specific features around function-based indexing). LINQ doesn't compare to the flexibility here provided by data structures and a potentially just in time SQL compiler. No ORM does. As an example, the user might be submitting ajax requests to my backend, filtering some data by adding more filters or other clauses to my query. What I store in the session or in the database is fundamentally just (pr-str my-query). When the user comes back and wants to continue modifying it, I (read-string my-query-str) from my store. Then I just keep assoc'ing, filtering, and manipulating the data. If they decide this is a nice query, I just save it. It can become an alert, a report, etc. The only machinery is basic clojure data structure manipulation, basic print/reading, and the power of compiling data structures to SQL.
As far as operating on streaming data via Kafka (raw) or with Kafka + Onyx, I suspect you've never actually done this in Clojure. It's a breeze, quick to write and performant. I've yet to meet someone who has worked with Onyx who wasn't blown away by how simple it is to use and how quickly you can evolve very complicated data flow graphs. It provides reasonably low latency, customizable batching, and I can still write straight-forward and simple Clojure. You don't really deal with state or multithreading when dealing with Onyx (Onyx handles that for you and you can declare the parallelism behavior you're looking for). When I consumed Kafka directly, I didn't have many problems that get bogged down by state. We'd keep some local state, but the system was designed to either run in batch to consume some entire time interval or to be able to be kill -9'd at any point, in which case the data was designed with idempotence in mind (such that we can handle/detect processing data more than once).
I selected and championed Clojure because it was a dynamic language (very similar to python or ruby) that had access to battle-tested JVM libraries. I selected it over python and ruby, because it made choices that resulted in simpler programs that have far better locality when I or a co-worker must understand and modify a program in the future. The emphasis on immutable data and functional programming allows nice straight line programming where all I need to know to reason about the code is in the function arguments. There aren't as many surprises. The reason I've stayed with Clojure is the community focus on simplicity and the stability of my code. The code I wrote 8-9 years ago works just fine today. That's not a huge brag (cough Fortran cough Common Lisp), but it's refreshing when I'm looking at how quickly evolving languages like Rust and Python.
If you started to struggle with fitting everything in one node due to CPU or memory constraints, but still felt like you were writing Clojure in a half way idiomatic style when moving to a cluster, I'd love to hear from you.
I think I could do better starting from scratch given what I've learned.
Don’t think to hard about it, they don’t either.
personally, I believe they should have used BEAM originally and stayed as far away from the jvm as they could, but that is my own opinion, and everyone has their own opinions.
At its core, Clojure attempts to be practical. Running on the JVM was a practical decision.
I have never used it, but it seems to still be actively developed / maintained.
(I can’t actually downvote)