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?
thanks
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?
thanks
Clojure is a dialect of LISP so, yes, it's as powerful as LISP.
For no other reason than we now have a good LISP tool for the JVM I like this language.
"Clojure has the potential to do for concurrency-oriented programming what Java did for object-oriented programming a decade ago: make it simpler to do properly using a language (or, in Clojure’s case, a “language environment”) that is similar to what programmers are already used to. " -- Bill Clementson
And people, LISP consists of a family of programming languages. There are Lisp dialects like Common Lisp and Clojure. And on top of that, there are many implementations of Common Lisp or Scheme.
what I mean by "is Clojure as powerful as LISP" is that i read someplace here on stackoverflow that Common Lisp is lisp-2 and Clojure is lisp-1? (I could easly be rambling here)...
as far as concurrency is concerned I really like the Erlang story since its so easy to distribute apps by writing them in the Actor model
from the creator of Clojure at http://groups.google.com/group/clojure/browse%5Fthread/thread/2a2b24ffef5d1631?pli=1
"Even with actors, Clojure will not yet have a distributed concurrency story, but I am considering just adopting Erlang's wholesale, using Jinterface for Clojure<->Clojure or even Clojure<->Erlang distributed processes. Maybe that will look like Termite when it is done. Stay tuned. "
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.
I like Common Lisp better than Clojure because the syntax is more regular and it's not tied to the horrible (IMHO) Java APIs.
For Common Lisp I also have the choice between several excellent and well-tested implementations and a mature standard to rely on.
But if I had to use Java for a job then I would definitely consider using Clojure. :)
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.
I use Clojure and not CL because:
:wq
Clojure is a Lisp-1, yes. Think of it as a nicer Common Lisp without all the historical baggage. It also has several modern concurrency features like STM and Agents (they decided not to implement Erlang's Actors model). The advantage of running on the JVM is simple- there are already SO many libraries written for it (mostly in Java).
Clojure in Clojure is an ongoing effort to rewrite the Clojure compiler in Clojure, to make it more portable and maintainable. Apart from core.clj, most of Clojure is written in Java presently. After this move, it'll be possible to port it to a LOT of VMs, including Parrot.