The latest “James Bond” release of minigrace (version 0.0.7.1010, thus James Bond) includes experimental support, written by Tim Jones, for generating Java code and calling Processing. Unfortunately this support really is very experimental, and will probably go away in the next release.
The main things we learned from the experiment is that while we can just about compile Grace to Java as a prototype, anything more serious either needs a global analysis to map Grace’s structural types to Java’s nominal types (a nice PhD thesis) or to generate byte codes and use invokedynamic to build Grace’s calling conventions (an MSc at least), or perhaps a mixture of the two.
Tim’s current plan – unless anyone volunteers to take over the Java side of things – is to concentrate on the JavaScript backend. Compiling to a dynamically typed substrate will be so much easier, and as a consequence, perhaps quicker too. Since Processing has a JavaScript implementation, if we can bind to that, we hope to be able to port Grace code calling the Processing API over to JavaScript without any change on the Grace side.
While playing with the experimental Java-backend I revisited some examples that was all the rage when I was starting out, fractal graphics done in Logo style. Stealing shamelessly from motivate.maths.org, all the images in this post were generated in Grace via the Processing API hosted on top of Java, running on a Mac OS 10.7.4. If you download the tarballs and install the files, you could play with something like this too – I mean, this is an example of Grace code that might actually be used, someday, to teach programming.
123456789 method gasket(size : Number, limit : Number) -> Void {if (size < limit) then {return}repeat 3 times {gasket(size/2, limit)forward(size/2)right(120)}}
This article is translated to Serbo-Croatian language by Jovana Milutinovich from Webhostinggeeks.com.