tags:

views:

3928

answers:

10

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

+4  A: 

I think the name is clever.

Bill Echo
+12  A: 

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.

Allain Lalonde
Not all Lisp dialects are equally powerful. Unless by A being at least as powerful as B you mean that B is implementable in A. In which case all Turing-complete programming languages are equally powerful, and the question becomes nonsensical.
Mark Probst
The old well trained flock of pigeons argument.
Allain Lalonde
I think he just felt like typing something, because his comment was rather redundant.
Rayne
@Rayne: That's because it was implemented in English.
intuited
+11  A: 

"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.

Berlin Brown
+2  A: 

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. "

deepblue
Lisp-1 vs. Lisp-2 refers to whether functions live in the same namespace as everything else, or whether functions have their own namespace. It doesn't have anything to do with power. It means Scheme has to use "lst" as a variable name instead of "list", and CL has to use "funcall" a lot.
Brian Carper
so in the Scheme example u're saying that because variables of the object are in the same namespace as its methods?
deepblue
yes. (Clojure avoids Lisp-1's problem with symbol capture in macros by qualifying all symbols with their namespace: http://en.wikipedia.org/wiki/Clojure#Macros)
Nathan Sanders
Seconded: Clojure's nice use of namespaces largely solves the issues with a lisp-1. None: you probably don't care too much about lisp-1 vs. lisp-2 unless you're writing a lot of macros. That said, macros are greatly simplified this way.
twopoint718
thank you very much for the insightful answers
deepblue
+39  A: 

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.
Dev er dev
I asked righ hickey about this post at a bar after Java One and i paraphrase his response "sure sneak Clojure in any way you can!"
Arthur Ulfeldt
+1 for making me LOL.
ShaChris23
+1  A: 

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. :)

skypher
I don't see how the syntax is harmed by Java APIs. :\
Rayne
you are expected to use them
dunkyp
+11  A: 

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.

Mark Probst
The interesting consequence: in Common Lisp as a Lisp-2 you know that in (foo 2) FOO will be a function. There is no way to bring, say, a number in function space. This means, you never have to check this at runtime other than in FUNCALL.
Rainer Joswig
Certainly. But then again, Clojure makes maps and vectors callable. I'm not saying it's terribly useful, just that there might be some point to it.
Mark Probst
+3  A: 
Arthur Ulfeldt
+7  A: 

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

konr
Have you tried Armed Bear Common Lisp, full blown CL implementation on the JVM. It's development seems pretty active.
Dev er dev
+3  A: 

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.

Ramkumar Ramachandra