Clojure/Java Interop
Hello again.
I picked up the book Programming Clojure and have made my way through the first two chapters which were great.
Last night I started the 3rd chapter, on Java Interoperability.
I was hoping to toss together a single Java class that I could then try to rewrite in Clojure to help me learn. Following is what I came up with. (Note, I am not a Java ninja by any stretch so beware).
This is not intended as any sort of comparison of the languages per se. It’s simply, “Given X, I had to do Y to get the same functionality”.
My idea was to find a Java library for parsing rss and then parse out the rss for this site, prining the Title of the Post, as well as the link (this is the lieberry I used).
First the Java:
And next the Clojure:
While I am not sure the Clojure code is as succinct as it could be since I am still pretty new, I do like the looks of it. I agree with the notion that it’s an expressive language, and that one can do quite a bit with a minimum of fuss. I think that practically the syntax is idiomatic, I am not entirely sold on the dot form, and dot dot macro. I don’t think they are as visually appealing as would be a symbol in this context. But they do make sense.
Happy learning!
