3 ms·
> Clojure is a immutable, functional language, It is so not. Clojure is to immutable-functional as Prolog is to logic: a procedural language with fancy syntax
by wizzwizz4 3y ago
> Clojure is a immutable, functional language,
It is so not. Clojure is to immutable-functional as Prolog is to logic: a procedural language with fancy syntax and funny execution order, masquerading as the other thing.
=> (def globalX 0) (defn getX [] globalX) (getX)
0
=> (def globalX 1) (getX)
1
=> (while (< globalX 10) (def globalX (+ globalX 1))) (getX)
10
It's built on the JVM. How could it be otherwise? Sure, you can program in the immutable-functional style in Clojure, but under the hood, it's procedural. You have to deal with all the same procedural issues: the compiler doesn't really smooth anything over for you.
> This sounds very bitter.
This is bitter. But I thought what you replied to praised Clojure.
- askonomm 3y agoThe examples you just created are unidiomatic Clojure. Is that supposed to somehow convince me? I have yet to see anyone actually use `while` in Clojure, and redeclaring `def`'s is also not something I've actually ever seen, despite yes, it being possible to write horrible code if you really set your mind to it.
- wizzwizz4 3y ago> The examples you just created are unidiomatic Clojure. Assuredly. Yet, in an immutable-functional language, the examples I gave are unrepresentable. Clojure has nice syntax, like recur, to make it easy to write pure functional programs, but ultimately it's a procedural language full of side-effects, with a fairly simple mapping to JVM semantics. Clojure is often the right tool for the job, and I'm sure the Clojure programmers reading this are thinking things like “a simple mapping to JVM semantics is not a bad thing!”. But mere usefulness doesn't make it Agda.