Over a million developers have joined DZone.

Day 6 - Clojure

DZone's Guide to

Day 6 - Clojure

· Java Zone
Free Resource

The single app analytics solutions to take your web and mobile apps to the next level.  Try today!  Brought to you in partnership with CA Technologies

Today I'm reviewing the discussion of Clojure from Bruce Tate's Seven Languages in Seven Weeks. Clojure is Lisp on the Java virtual machine. Lisp is another language that, despite being around a long time, I have yet to investigate, so this is another new experience. Bruce starts with a brief review of Lisp itself, then a quick discussion of the link between Clojure and the JVM. A discussion of Lisp functions and datatypes is followed by a view of Clojure lists, sets, maps and vectors (in Clojure, lists are typically used for data, while vectors are used for data).

Still on Day 1 of Clojure, we discuss functions, including how to pass parameters, deconstruction using bindings, and then anonymous functions. The day ends with an interview with Rich Hickey, the creator of Clojure. One interesting revelation from this interview is that a concerted effort was made to reduce the use of parentheses, to make the language more accessible to the rest of us!

Day 2 discusses recursion, including interesting syntax Clojure uses to support tail recursion (required because of the fact that Clojure runs on the JVM). Next, Bruce discusses Clojure sequences, which can be used to wrap all the Clojure collection classes (plus a few more), and functions available to operate on sequences. He discusses lazy evaluation, used to create infinite sequences. A little discussion on Java interoperability is followed by an overview of macros, used to extend the Clojure language.

Bruce's Day 3 discusses concurrency. Unlike any of the other languages discussed so far in the book, Clojure supports concurrency with an approach that is called software transactional memory, a strategy that uses multiple versions of data to avoid issues surrounding simultaneous mutation. To use this strategy, Clojure requires that all references be changed within a transaction. Following are discussions of working with atoms, agents, and futures. Bruce ends Day 3 with a list of some features of Clojure which were not covered in the book, then ends with the expected discussion of Clojure's strengths and weaknesses. 

From http://wayne-adams.blogspot.com/2011/04/day-6-clojure.html

CA App Experience Analytics, a whole new level of visibility. Learn more. Brought to you in partnership with CA Technologies.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}