What is your opinion on Clojure? [closed]

What do you guys think about Clojure? I'm thinking of learning it next, currently using Erlang and in general happy with it except the records fiasco... Is Clojure as powerful as LISP?


Solution 1:

Consider learning it. If for no other reason then because you can actually use it in a real project.

You : Can I use this small Java library called Clojure?
Boss: Why do you need it?
You : For some concurrency improvements.
Boss: Ok.

Solution 2:

What you're refering to by Lisp-1 vs Lisp-2 is the question of whether functions and variables share the same name space. In Lisp-1 Lisps, like Scheme and Clojure, they do. In Lisp-2 Lisps, like Common Lisp, they do not. This is mostly a matter of taste and/or convenience - it doesn't affect the power of the programming language.

As an example, in Clojure you can do this:

(defn my-apply [func arg1 arg2]
  (func arg1 arg2))

This is a function that takes a function and two values and applies the function to the values. For example:

user=> (my-apply + 1 2)
3

In Common Lisp, you'd have to write this as

(defun my-apply (func arg1 arg2)
  (funcall func arg1 arg2))

The reason you need "funcall" is that, since "func" is in the name space of variables, you cannot directly use it as a function, like you can in Clojure, which does not make this distinction. So you have to tell Common Lisp "please interpret this variable as a function and call it with these arguments". Another consequence of this is that to get the same result you must call "my-apply" like this:

=> (my-apply #'+ 1 2)
3

Here the problem is reversed: "+" is a function, but you want to pass it as a variable, so you have to "convert" it. "#'+" is short for "(function +)", btw.

Solution 3:

I use Clojure and not CL because:

  • It communicates well with Java, so I can outsource my coding
  • It has access to the zillions of java libraries that do all sorts of things, including Swing and Weka
  • Since it runs on the JVM, you can more safely assume that your problem will work everywhere
  • If you can show the same libraries being used with much less code, you can convert Java programmers to the lambda way
  • And, most importantly, I don't get tied to Emacs

:wq