Clojure DSP Longing

I often find myself longing to be able to use Clojure, a very enticing lispy language that runs on the JVM.

I could possibly be using it right now in my dissertation research. It has the promise of dynamic languages, functional programming, almost-as-cool-as-Erlang concurrency, JVM performance, and Java library soup. It could be so awesome. A few months ago I started briefly down this road, unaware that…

Clojure sucks. Not generally, but it sucks for DSP. More specifically, Java and therefore Clojure has no real support for complex numbers. In order to do serious DSP, you need native syntactic, semantic, and performance support for complex numbers. Java has none of the above. Older versions of C didn’t have syntactic or semantic support, but the performance of using arrays was plenty fast. Not so in Java, at least not to the extent necessary to override the lack of syntactic and semantic.

So someday, when I’m writing general purpose code again and not high performance DSP code, I will have an opportunity to use Clojure, and I think that will make me very happy. By then the book will be out of beta. The community will be in full swing. There will be awesome libraries. Children will play in pristine parks with formerly-ravenous ravens.

In the meantime, if anyone sees the scene change, do let me know.


3 Responses to “Clojure DSP Longing”

  • what do lispers think of clojure? - Page 2 | keyongtech Says:

    [...] Re: what do lispers think of clojure? Nice post here on the topic. I feel EXACTLY the same way :) http://hans.fugal.net/blog/2008/11/1…re-dsp-longing [...]

  • Hans Says:

    keyongtech visitors welcome. If I may weigh in on your discussion without going to the trouble of creating an account on your forum…

    Complex number support is important for a nontrivial niche, but it is nevertheless a niche. Good complex number support is rare, and really it’s only recently that even a few of the more mainstream languages have gotten decent support (e.g. C99). Usually you can work around it, but in the case of Java it’s just not worth it unless you have other motivations for using Java.

    If Clojure could have complex number support with nice syntax and semantics that used Java Arrays underneath, it would not be blindingly fast but it would perhaps be sufficient. I don’t hold my breath though, because it’s not really Clojure’s fault. Complex numbers really need to be supported by the math library for this to be really useful, so functions like `exp()` would need to support it for it to work really well.

    Incidentally, I’m using Octave for my research. MATLAB is as funky a language as you could ever dream up, but it has all the right stuff for DSP and a lot of other mathematics, which many other languages (and most GP languages) simply don’t.

    That said, it’s likely that the vast majority of DSP code in the real world (which is primarily on embedded systems) is written in assembly and C, and have been for years.

  • Hans Says:

    Oh, and I can verify that Ruby has native support for complex numbers, but it’s no less clunky than all other things mathematical in Ruby—mathematical syntax is not one if its strong suits (though it scores quite well in mathematical semantics).

Leave a Reply