Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Trying Clojure (netzhansa.blogspot.com)
58 points by gruseom on Oct 4, 2008 | hide | past | favorite | 8 comments


I've written a moderate amount of Clojure code (probably about 3000-4000 lines) so I'll try and address some of the bad stuff the author is talking about.

The error messages that the compiler produces are mostly useless.

This has improved substantially in recent versions. Clojure release tarballs are almost instantly out of date, tracking svn HEAD is effectively required. (and very rarely causes breakage)

Debugging is hard, as no tracing facility and no breakpoints are available

The Clojure compiler emits full debug information, so you can debug with a Java debugger; I've used JSwat succesfully, although I very rarely have found the need.

One thing that has struck me while using Clojure is the hackability of the language and its built-in functions and macros. Although comments in the Java code are few and far between, it's very readable, concise code. A significant part of the built-in functionality is bootstrapped in Clojure itself, which is even easier to read and hack. (yes, I've submitted patches)

I'm currently taking Rhino (JVM JavaScript) for a spin, as I occasionally have a hard enough time coming up with a decent algorithm for a problem, and my brain hasn't yet fully adjusted to purely functional programming, so I sometimes yearn for something more imperative. Since they're both in the JVM, mixing the two languages ought to be pretty simple. Famous last words...


would you use clojure again?

Also - how do you deal with mixed source (eg clojure and java or whatever) in one project ?


Yes, definitely. I'm gradually scaling up to bigger and bigger projects with it. (I'm about to release a small open source disk snapshot backup utility that I've been writing with it for the last week or so)

As for dealing with mixed source: your or whatever is the key, to some extent.

Interop with Java itself (classes, class instances, static methods) is trivial, you can also easily subclass Java classes, typically to implement interfaces. The syntax for java calls is pretty straightforward, e.g:

   (. System/out (println "foo"))
There are a few variations on the above that are also permitted; of course, you've got a CL-style macro system at your disposal should the need for more syntactic sugar arise. I tend to just wrap frequently used Java calls in a function.

Because of the excellent Java integration, other JVM languages are at least as easy to work with as they are from Java. I've recently been playing with integrating Rhino with Clojure, which on the most basic level involves implementing Clojure's IFn interface for Rhino functions and Rhino's Callable interface for Clojure functions so you don't need to use the Java syntax. Syntactic integration of the data structures, etc. would of course also be nice, so it's not 100% trivial.

I can't really talk much about other JVM languages as I haven't used any others. I suspect Groovy is easy to work with as it's so close to Java itself.

One big side of the Clojure language that I haven't worked with at all is the concurrency support, which seems extremely solid.


I guess you have to avoid circular dependencies between the different languages, then its doable.


Not really; Java (the platform) can handle circular dependencies.


Can anyone comment on the Slime support for Clojure? Is it as awesome as it is for CL? I'm deciding on a language for a robotics based project and the exploratory programming features of Slime are looking very tempting...


I use clojure-mode and http://github.com/jochu/swank-clojure/. They work for local or remote Clojure repl, compile files, look up code, auto-complete, display args and docs help, etc. It's not as complete as CL. It doesn't have debugging because clojure's debugging info is in the JVM, so something like Enclojure/Netbeans has full debug support.


A interesting writeup from a CL user point of view.




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

Search: