

A Year of Clojure - puredanger
http://tech.puredanger.com/2010/12/31/a-year-of-clojure/

======
aduric
Great post Alex. I've recently started to experiment with Clojure on SemWeb
apps, RDF, SPARQL, etc. In your post you talk about how Clojure enables you to
abstract better than Java. I was just hoping you would discuss a specific
example (maybe even in a production environment) instead of how many LOCs you
saved.

~~~
puredanger
I did write one blog post earlier this year but it's a pretty trivial example.
The zipper/tree stuff I'm writing up will go into quite a bit more detail.
That article will be in the new Code Quarterly journal sometime this year.

------
wwkeyboard
Great post, I really want to play with Clojure, but when I looked into it last
year it was very apparent that it was built on Java. Not just the JVM, but the
Java ecosystem, you were expected to use Maven or Ant for building, jdbc for
database connectivity, things like that. I'm sure this is great for someone
coming from Java who knows how all of these libraries and tools work, but it
felt like I'd have to remember Java just to understand their documentation.
Has this changed? Is Clojure standing on it's own now feet now?

~~~
lukev
There is a fairly nice Clojure build/dependency tool called Leiningen. It uses
maven repositories under the hood but you usually don't have to worry about
that.

There are libraries in contrib that wrap JDBC database access so you don't
have to interface with any of the Java classes.

clojuredocs.org documents core and contrib very well in a non-javadoc style.

So by and large, yes. Of course Java still shines through from time to time -
I'm not sure that can be helped. But overall things have improved and are
still getting better.

------
zck
>What macros? I’m a bit embarrassed to say I’ve not yet written a single
macro. Partially I tend to think the function version should exist regardless
in most cases and partly I work with three other Clojure gurus that can
satisfy my macro whims faster than I can state the need. Let’s call it a goal
for 2011.

Heh, he hasn't completely grokked macros yet; they should _only_ be written if
the goal couldn't be done as a function.

~~~
thurn
Or, perhaps, if it gets you nicer syntax. The classic macro example "unless"
could be written with a function, but then you'd need to write

(unless (< 1 2) #(println "hi"))

every time.

~~~
zck
Arguably, that's not the same, as long as you define "unless" as not having
the hash there.

I'm not quite familiar with the hash -- is that just making a vector with
_println "hi"_ as its elements? How does the unless work with multiple
statments? I'm sure you know that unless has an implicit _progn_ in it -- does
this? What's the code to implement this? I tried, but couldn't really figure
out what to do with the vector.

~~~
ataggart
The hash is the anonymous function form. In the example, presumably the unless
function calls and returns the value of the passed-in function when the test
is logical true, otherwise returns nil.

~~~
zck
Ah, interesting. At least in clisp -- the Lisp I fired up to test this -- the
hash is syntax for vectors:

> (type-of #(+ 1 2)) (SIMPLE-VECTOR 3)

