What is Clojure's main selling point?
It is hard to go back to other languages once you appreciate its simplicity.
21–30 of 43 posts
What is Clojure's main selling point?
It is hard to go back to other languages once you appreciate its simplicity.
I got a good laugh out of that one. Honestly that final paragraph should just be deleted. It's just a giant, indefensible claim.
I'm not sure I agree here. There's not too much value in testing these two or three lines of code in the get-article handler. And the passing around of compositions of higher order functions can get confusing. There are cases where an approach like this is warranted but I would say that there needs to be a significant level of complexity before this makes sense. Having a protocol for your data layer and an in memory…
Pervasive use of protocols and custom, user-defined higher-order functions I would argue is unidiomatic Clojure and creates long-term pain as you end up with opaque functions being passed around that can't be inspected at the REPL and a lot of tricky "fitting functions together" that is made difficult without a static type system. You sometimes need them, but you should reach for them very judiciously.
There's a reason Clojure emphasizes data over functions (and both over macros).
"Software design is a well researched and understood problem..." I got a good laugh out of that one. Honestly that final paragraph should just be deleted. It's just a giant, indefensible claim.
I also recommend the book "Grokking Simplicity" by Eric Normand for a longer exploration of functional software design (not Clojure-specific). The linked blog post uses Clojure examples, but this approach to software design is universally applicable (especially in functional programming!).
Thank you for this rec, been thirsty for knowledge in this domain.
What is Clojure's main selling point?
Not writing Java (although you do have to do lots of interop with Java).
Many options exists to not having to touch Java when you use Clojure, but I guess it's hard to kill old memes?
That's not true that the approach is more OO.
People get confused because a lot of OO languages like Java eventually added support for something protocol-like, in Java it was interfaces for example, but for a long time Java, an OO language, didn't have interfaces, you only had Classes and Objects and inheritance.
Protocols and polymorphism is not an OO concept, and doesn't even need to involve Objects at all.
In Clojure for example, you can dispatch the protocol over a map, given two maps based on their metadata the protocol will pick a different implementation for the called protocol function. There are no Objects and Classes involved.
All you need for polymorphism is a sort of metadata over a datatype, it could be type information or it could be something else, like attached metadata like in Clojure.
In an OO language, and in Clojure by virtue of running on the JVM, user datatypes are defined using Classes and Objects, but in a language like Haskell they're not.
So basically you can implement protocol-like polymorphism, basically the idea that you dispatch based on meta-information about the arguments passed to the function with or without object constructs.
I'm pointing this out because it is an argument against OO. The fact that even in most OO language people have over time preferred to use such polymorphism over object inheritance hierarchies is a sign that Objects aren't as useful as ounce thought.
What is very useful though is to be able to define alternate function implementations based on some metainfo about a given argument, such as their type. So much so that all languages, OO and Functional will tend to have such feature.
> The protocol is another form of abstraction we can use to decouple modules, the approach is more object-oriented than functional That's not true that the approach is more OO. People get confused because a lot of OO languages like Java eventually added support for something protocol-like, in Java it was interfaces for example, but for a long time Java, an OO language, didn't have interfaces, you only had Classes and…