Clojure Gazette 1.6

Clojure 1.4 Spectacular

Clojure Gazette

Issue 1.6 - April 18, 2012

editorial

Clojure 1.4 Released

Clojure 1.4 does not bring with it the fanfare of a huge list of new features. Yet we can see some important trends in the changelog. For one, we see a movement toward compatibility with Clojurescript. There is obviously a healthy interchange between the two platforms. We see a few new "utility" functions, such as mapv, which is just like map except it returns a vector. Rich has always shown a tendency toward reducing parentheses and (vec (map f l))is a pretty common pattern. And there is still ongoing discussion and experimentation with Java interop and numbers. Finally, we see the introduction of Reader Literals, likely the main reason for incrementing the version number.Reader Literals will make it easier to serialize data inside and between systems.

Remember to update the dependencies in your projects to 1.4.

Eric Normand

group hug

The Release Announcement on Google Groups

The Clojure Google Group is chock full of discussions and announcements. There are people of all Clojure knowledge levels.

ch-ch-ch-changes

Clojure 1.4 Changelog

This file is worth a read when you flip the switch to 1.4. There are a few small gotchas to watch out for. The document is not long and it is well-written. However, I do go over some of the items in this issue.

boxing with numbers

Why ints now get boxed as Integers

One of the gotcha changes in 1.4 is that ints get boxed to Integers. In 1.3, ints got boxed to Longs. The reason ints got boxed to Longs before was that Integers are not equal to Longs in Java. This broke the Clojure semantics of numerical equality. Concomitant with the boxing change, Clojure now uses its own hash function (clojure.lang.Util.hasheq) which is the hashing function now used by the PersistentHashMap. The new hash function is consistent with = under the Clojure semantics.

exception that proves the rule

clojure.core/ex-info and clojure.core/ex-data

The first is a utility for creating a RuntimeException with a String and a Clojure map. The second gives you the data value given the exception. This is good to know because you might see it appearing in code.

reading, literally

Reader Literals

The new biggie in Clojure 1.4 is Reader Literals. It makes the reader extensible. It also decomplects the syntax of data from its semantics. These are hoped to supplant the use of JSON and XML. Clojure as a data language is superior to JSON because it allows arbitrary data values as keys of maps. And now it has the extensibility of XML.

Toplevel literal tags are reserved for the Clojure hegemon but you can create your own namespaced tags.

literally from the source

Rich Hickey: Keynote

In this keynote speech at the last Clojure Conj, Rich Hickey discusses Reader Literals and why they are important, among other things.

reader literal example

Coding a transactional database using Clojure's 'reader literals'

Check out one of the first examples I have come across using reader literals. It shows one of its main advantages: human readability!

release frenzy

Leiningen 2 preview 3

Speaking of releases: Leiningen is almost at 2.0. Check out this extensive list of small changes.

community support

Light Table on Kickstarter

I am probably preaching to the choir, but Light Table is liquid expressiveness in a bottle. Chris Granger is developing his Light Table from prototype to full-blown IDE. The project is well on its way to being funded on Kickstarter. Please check it out, even just to see the great video. Click on a larger view for better viewing.

extra-clojure

Julia

Julia looks like a pretty cool language. It is meant to be a mathematical/scientific platform, but takes lots of cues from Lisp. Be sure to check out Why We Created Juliafor a manifesto and an online repl.