Clojure's Core Features, Part 2

January 24, 2013

Let’s talk more about some of Clojure’s features.

Clojure is interoperable with Java. Clojure runs on the JVM, so Java libraries are accessible in your programs, allowing for easy extension through plugins or external libraries. Jay Fields has a wonderful post explaining this interoperability, complete with examples.

Clojure is dynamic. At any point, you can open a REPL (Read-Eval-Print-Loop) in a terminal to interact with your program or just the Clojure language. This gives you more flexibility during development, freeing you from the “compile > run > examine > repeat” cycle. As the official documentation puts it, “Clojure is not a language abstraction, but an environment, where almost all of the language constructs are reified, and thus can be examined and changed.”

Clojure utilizes runtime polymorphism, accomplished through Clojure’s multimethod. Multimethod is “free of the trappings of OO, types and inheritance”, allowing you to independently define functions that behave differently depending on the values supplied to it.

Overall, my experience with Clojure has been a positive one. Speclj made testing a breeze (especially for me, coming from Ruby’s RSpec) and Leiningen made it trivial to create and run applications and fire up REPLs. The only real trouble I had was training myself to write and read its Lisp-like syntax,  but after a few hours of tinkering I found this problem alleviated itself!

I’d encourage you to try out Clojure if you haven’t used it yet!