Friday, September 03, 2010

Catching the train in J

My mini array engine in Clojure is coming on apace, and another day should give me the functionality I want to right now.

I've been checking my specification against the behaviour of J, and this has had an interesting side effect.

I've tried to learn J several times. Each time I quickly mastered the basics but then hit a brick wall in understanding.

This time around the wall has collapsed.

The concept I was missing was that of a train of verbs. A verb in J is another name for a function. A train is an isolated sequence of verbs. For some reason I couldn't grasp why these were needed or how they worked, but now the need and its solution seem obvious. As a result I can read (and write) programs in J which previously eluded me.

Wednesday, September 01, 2010

Old habits die hard, if ever

I've taken a bit of a break from electronics, and have been having great fun with Clojure.

In the distant past I spent about 19 years programming in a (fairly) functional programming language, so Closure feels very comfortable. The thing I miss most is a Romilly-friendly multi-dimensional array library.

There are high-performance numeric libraries in Java, and some of them have been wrapped in Clojure, but their authors don't think the way I do.What I want is a library that works like the array engines in APL or J wrapped in a Clojure API.

For now I value expressiveness more than performance, and it looks as if I can implement a useful subset of APL primitives in a couple of days.

When performance becomes an issue there are two tempting possibilities. Closure allows you to use native Java arrays performantly; and a Clojure wrapper for OpenGL looks as if it may allow easy access to a workstation's GPU. This might permit array operations that run faster than they would in Java or C++.