HN2new | past | comments | ask | show | jobs | submitlogin
A Year of Clojure (puredanger.com)
51 points by puredanger on Dec 31, 2010 | hide | past | favorite | 11 comments


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.


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.


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?


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.


Clojure does depend heavily on Java and it is often beneficial to be familiar with Java tools, Java libs, the JDK, etc. I consider that a strength (mostly) but that's really just part of the package for the forseeable future.


>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.


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.


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.


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.


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)


Yeah, I get it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: