Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I got a personal question for you guys out there: what's your reason for learning Clojure ?

(For me, it's the same thing as it was with Java over C, it promises a better programming experience)

share|improve this question

closed as not constructive by ChrisF Feb 10 '12 at 15:47

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Oh no, a LISP variant, run... :D –  Tom Wijsman Sep 19 '10 at 11:16
3  
there seem to be lots of people excited if not overexcited about clojure... maybe you outta give it a try :) –  Belun Sep 19 '10 at 18:36
    
Funny, a 'not constructive' question is so popular. Simpleton programmers, or snobs for moderators? –  CMR May 6 at 14:24
add comment

7 Answers

up vote 13 down vote accepted

I was looking for a language to really learn and tried a few but non really clicked. Almost bought a book an Scala but then I saw one of Rich Hickys Videos on http://clojure.blip.tv/ and then all the rest of them and then basically everything else I could find on the web.

Clojure has me hooked and I tell you why ....

Clojure is like a chair it has four legs and i am going to say somethings about every leg.

Functional Programming, Lisp, Java and Concurrency.

First of I think Functional Languages are superior to imperative Languages (note that its not about OO vs FP its about FP vs imperative you can do OO in Clojure, depending on you view of OO of course) because FP allow you to reason about (almost) every function without context. It much (much!) easier to reason about the code. A other thing that you avoid a lot of errors if you don't let things change until you start with a FP Language you don't even notice how much time you waste witch such things. There is more to be said about FP but I will leave it at that.

Now look at Lisp. Lisp like languages have lots of great features that are disagreeable. Lisp languages allow a really fast feedback-cycle because you can work with the REPL. The killer feature you get you of being a lisp is the macro system. There is no greater power you can have in programming languages. You have the same power as the language designer to change the language to your need and it allows for some nice DSLs. This of course works because Data is Code and Code is Data. Thats not just good for macros its good for other things too. Lets make a example.

Clojure Code is represented in Clojure Data Structures. Clojure Data is represented in Clojure Data Structures. Clojure Meta Data is represented in Clojure Data Structures.

Know Java

Java Code is a string. Java Data is in Java Arrays or Java Collections. Java Meta Data is represented with annotations.

This gives you a great uniformity. I leave it at that but lisp brings more to the table but I leave that to you to explore.

Lets talk Java :)

Java as a language sucks (in my opinion) but there is a lot of good stuff going on with the Ecosystem. The Hotspot JIT and the GC are GREAT. Java today is very very fast. Its just consider slow because it was slow 5-10 Years ago and most people will NEVER change there opinion. So Clojure can get to the speed of Java in conclusion this means that Clojure is a very fast dynamic Language. Way faster then most other dynamic languages. Then there are all this Java Libraries. The Interop Story to Java is just fantastic in Clojure probably the best there is (maybe Groovy or Scala are better its subjective). So you don't have to write Rappers but often people write to make it more clojurey to work with the libraries.

So the last thing to talk is Concurrency. Today with have multi core blablabla .... you know the talk. Clojure has a great Concurrency story. Everything you do in Clojure is Threadsafe that means even if you go in to your single core code you wrote and add thread you are going to be safe. Then there is the agent model (yes agent not actor). They are like actors in the scene that the allow asynchronous concurrency, but there are differences too, check it out yourself. Last but not least we should look at the STM. Its great if you can do everything without shred memory but sometimes things just change but if the get changed from more then one thread you have control that somehow. A TM System allows you to do that safely without to much work on your part.

Now some meta stuff. The Clojure mailing list (and IRC too) is really great, no flamewars like in other lisp groups. It's really beginner friendly.

The IDE support is not Java like but its quite ok, there are plugins for all the big IDEs but most people (me included) work with emacs. I just started learning it too and its not that hard. There is great Clojure support for Vim too if you are a vim guy.

Last but not least we should talk about the build tool. Because of Java you have to work with maven or ant but because nobody wants to do that there is a great project called leiningen (there are others too) which allows you to manage your dependencies, compile your code and more. It's really really easy and no XML crap like in the Java tools.

Come to the IRC if you have more questions.

share|improve this answer
1  
can you pack all that in a phrase ? if it all come down to a phrase, what would it be: "it's much better than everything else"? or "i enjoy it mostly"? –  Belun Sep 19 '10 at 18:33
1  
I never had that mutch fun in programming befor and you get things done too. –  nickik Sep 22 '10 at 8:34
    
"until you start with a FP Language you don't even notice how much time you waste with such things": True!! –  Giorgio Nov 11 '12 at 21:00
add comment

It will make you a better programmer

share|improve this answer
add comment

The major reason for going Lisp instead of staying with Java is the ability to generate and compile code on the fly.

Remember that Lisp deals with XML-like tree structures as the internal data format. This includes the Lisp programs itself, so it is trivially simple to generate new, and manipulate existing programs inside a running program. This as opposed to either run javac or manipulate bytecodes inside Java which is somewhat above the "trivially simple" level.

share|improve this answer
add comment

Two main things:

  • Functional programming paradigm -> expand your way of thinking.
  • Useful in the real world, real projects, out of the box.

Many languages offer one of the two above. Clojure offers both. Additionally it's:

  • Simple, beautiful.
  • Concurrency support superior.
  • Interoperable with existing languages (Java) & libraries.
  • Multi-paradigm.
share|improve this answer
add comment

The power of Lisp on the most popular and successful virtual platform there is, the JVM. Add to that good support for concurrency and transactional memory (and less parenthesis than other, more lispey dialects), what's there not to like!?!? :)

share|improve this answer
1  
to many. answer discarded :P –  Belun Oct 18 '10 at 20:35
add comment

Clojure (and lisp in general) is a different way of think about programming that the mainstream programming languages (I'm not talking about history, I know that lisp is one of the older pl, but that isn't the point), and that is a very good reason to learned it.

share|improve this answer
    
so for the challenge. nice –  Belun Sep 23 '10 at 10:30
add comment

I can think of at least two major aspects of your question: Why learn a Lisp? and, Why learn this Lisp dialect, Clojure?

Lisp is worth learning because it is elegant, powerful, and supports multiple paradigms (functional, OO, declarative). I won't try to repeat badly and too briefly what others have written more eloquently, as über-hackers - people at the very top of CS and software - have long advocated for learning and using Lisp:

As for the second part, Why learn this Lisp dialect called Clojure? Well besides having all the goodness of the Lisp approach, Clojure is functional in philosophy (immutable data structures, lazy evaluation), was specifically designed to handle concurrency nicely (software transactional memory, agents) in an increasingly multicore world, and has access to all Java libraries. That combination packs quite a lot of power, and makes it an exciting language to learn and develop with.

share|improve this answer
1  
so, you find it exciting to have all those things ? –  Belun Sep 19 '10 at 18:34
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.