by ithrow · 4y ago · 0 comments
Keep in mind that they have to juggle between almost four different languages, Java, Javascript, Clojure and Clojurescript, almost because there are differences between Clojure and Clojurescript. Instead of for example just using one language: JS.
ClojureScript is one of the main reasons why Clojure makes sense in my business. I can use the same language and share the same business logic code between the server and the browser app. That's huge!
Also, I avoid a load of problems related to communication and serialization, because the native serialization format is EDN, e.g. Clojure data structures. There is no need to adapt your data structures to the limitations of, say, JSON.
Also, what are the limitations of JSON that EDN handles better?
* Can represent sets `#{1 2 3 4 "foo" "bar" true false}` (JSON only supports arrays)
* Maps/sets can contain arbitrary EDN as keys/values. `{[1 2] "foo", 5 :a, "5" :b, true -1, false 5}` or `#{[1 2] #{3 4} (5 6)}` (JSON only supports string keys on "objects")
* Supports clojure types like keywords (`:foo`, `:bar/baz`) and symbols (`foo`, `bar/baz`), and can be extended to support other values as well
2. JS has Map/Set which allow other composite types as keys and can be converted to objects for JSON serialization then deserialize back to Map/Set.
Because Clojure is better designed. As are many other languages.
Nodejs competes with Java in single threaded performance, I'll say normal JS code is faster than normal Java code. For web services that are IO bound, nodejs still competes with Java unless you go with all the batshit crazy complex reactive stuff in the Java world, supposedly is going to get better with the new green threads implementation.
As for JSON, others have replied, but my point was perhaps not very well made. It's not just the limitations of JSON itself. By using the same language on both sides, I can avoid adapting to the limitations of any transit format. In other words, I can (pretty much) pass native data structures through and get them out on the other side. In my case, that means not just maps and vectors, but also sets, keywords, or UUIDs. Can this be done with JSON? Sure! But then I'd have an entirely new bug area to deal with (encoding/decoding, forgetting to coerce, etc).