CHALLENGE TITLE: Embrace Clojure
CHALLENGE: Use Clojure to write any sort of application you like. Use it to write a web application, a desktop application, or anything in between. Use some of your existing Java code in Clojure, or create a clone of one of your Java apps in Clojure. Have fun.
Clojure is an amazing new language that was created two years ago by a man named Rich Hickey. It is not an implementation of an existing Lisp, but a whole new Lisp in itself. It isn't held back by the limitations of the Common Lisp standard. It embraces the JVM to offer direct and idiomatic interoperation with Java (or any other JVM language), so you can use any existing Java code in Clojure, without wrapping it in a Lispy wrapper.
Here is what is written on the front page of clojure.org:
"Clojure is a dynamic programming language that targets the Java Virtual Machine (and the CLR ). It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language - it compiles directly to JVM bytecode, yet remains completely dynamic. Every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.
Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.
I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use."
Clojure is the fastest growing language I've ever seen. It has gained a large following in just two years of development. The language has a book called Programming Clojure written about it, and three other books are in the works (one of them will be finished in February). If Clojure can do everything it has done in two years, I feel this language has an amazing future ahead of it.
There are lots of resources right at the homepage at http://clojure.org/, including API documentation, very good screencasts, a list of libraries, a cheatsheet, and various other general information about Clojure.
There is a relatively stable Eclipse plugin in active development, here: http://code.google.c...ounterclockwise, though it doesn't offer auto-indentation yet. I've been bugging Laurent about that lately, so it shouldn't be too long.
There is a stable and pretty feature-complete Netbeans plugin you can find information about here: http://www.enclojure.org/
There is also an IntelliJ plugin you should be able to google to find.
By far, most Clojure users use Emacs coupled with clojure-mode and swank-clojure and Slime as their development environment, including myself. You'll get the most out of Clojure by familiarizing yourself with Emacs a bit, and setting it up with Slime as detailed on the swank-clojure github page, but you don't have too. I do strongly recommend it.
There is a very comprehensive Clojure tutorial here that some say is on par with the Programming Clojure book: http://java.ociweb.c...re/article.html I've not read it, though I think I will when I get a chance. I'll point out that some things are probably a bit outdated, but as long as read changes and such after reading through the tutorial, you should be fine. Programming Clojure is a little outdated as well, but luckily, a ton of more books are being written. For instance, Clojure has protocols (which are like interfaces in OOP), and types which are kind of like C structs. Types created with deftype are making Clojure's struct-maps obsolete, so if you're using Clojure from it's master branch, where deftype and defprotocol now exist, remember to use deftype instead of structs. If you are going to use the last major release (Clojure 1.1), deftype and defprotocol don't exist and struct usage will be fine. Just a little tidbit of knowledge for yas!
I'll note with enthusiasm that you do not have to know Java in order to learn Clojure. Yes, it definitely helps, and it helps even more if you know your way around the Java API, but it isn't necessary. As a matter of fact, learning and using Clojure can expose you to Java a bit, and make it easier to find your way around if you learn Java in the future. Since Clojure can directly access Java code, you have the entire Java library at your disposal. Where Java isn't broke, Clojure doesn't fix it.
Beyond what I've explicitly mentioned, I encourage you to explore the Clojure website I linked first; it has tons of good information.
Oh yeah, and you're going to want this: http://github.com/te...mancy/leiningen
HOW TO GET STARTED:
This depends on what editor you decide to use. There is really no point in putting getting started information here. If you use Emacs with Leiningen (or maven) as your build tool, this will be self explanatory. Leiningen (or maven) will handle dependencies for you, even Clojure and the companion group of libraries, clojure-contrib. Otherwise, you'd just want to slap whatever Clojure version you want on the classpath (you probably know how to do this in the popular Java IDEs) and start coding.
- Write a tool you can use for your Java development.
- Plan to write something in Java? Write it in Clojure instead!
- For more advanced users: Think of a language feature you wish Clojure had, and then write that feature as a freakin' macro!