I am coming from a mixed software development background. Starting with VB.net, when I was a child, over to Java for a long time, ending with Ruby, Javascript / Typescript.
On my whole journey, I did not get in touch with functional programming a lot. I furthermore did not spend a lot of my years with declarative programming. That's something I have been up to for the past few years.
Difference between imperative and declarative
const arr = [1, 2, 3, 4, 5];
// imperative
let itemsArr = [];
for (const item of arr) {
itemsArr.push(`Item-#${item}`);
}
// declarative
let itemsArr = arr.map((item) => `Item-#${item}`);
What is Clojure anyways?
It's a Lisp-like functional programming language. It runs on top of the Java Virtual Machine. Key features include:
all variables are immutable by default. You can use so-called
atoms
to get the chance to manipulate variables"It's just data" is a key concept that for example also states: even function calls are just a list. The first element of the list is the function name, followed by the parameters
Concurrency in mind.
What does it look like?
(def arr [1, 2, 3, 4, 5])
(map #(str "Item-#" %1) arr) ;; Same example as in javascript
Why did I do this to me?
Good question. I still haven't found a good answer to that one. I was heavily interested in whole new paradigms, that are outside of my horizons:
declarative programming (correct use of reduce, map, etc.)
functional programming (bye, bye
let
. Helloconst
)
I have furthermore seen an amazingly funny presentation about Clojure.
Who is using Clojure
Nubank.com.br. A Brazilian bank runs fully on Clojure microservices. They state they have over 1000 microservices in use.
Was it worth it?
Somehow, yes. It taught me new ways to approach a problem and showed me, how f*cked I am once possible solutions get a new requirement: immutability.
Conclusion
Would I recommend getting your head around Clojure? Well if you have some spare time and want to learn a new language, then it has served me well.
I highly recommend you, to watch the talk mentioned above.