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.
It seems that there is already a language with similar syntax to Grace that compiles down to JS (as well as most of the other large platforms): Haxe (http://haxe.org/ref)
It is largely focused on OOP, but also provides support for anonymous functions & objects, enums with pattern matching that can act as algebraic data types. They have also thought through their type system (i.e. they deal with issues like variance explicitly http://haxe.org/manual/variance) and have a nice type inference system set up.
As far as I can understand, the nominal motivations for Grace are:
* to be a simple, objecct-oriented language ‘designed for novices’ (whatever that means)
* specifically to avoid the many features and ‘scars of Java’s evolution over the last 20 years’
Looking at what seems to be the current Grace spec (http://gracelang.org/documents/grace-spec0353.pdf), Haxe appears to be much more of a lingua franca/common denominator between today’s popular languages than Grace. The big differences seem to be
* Grace’s blocks (a la Ruby) vs. Haxe’s anonymous functions (a la Javascript)
* Grace’s functions with multiple slots in them (a la ???) vs. Haxe’s standard syntax
Although I do like Grace’s more extensive case pattern matching.
But I think the biggest draw to Haxe is that it’s already implemented, already compiles to JS, Java, etc., and has a nice ‘batteries-included’ library, making it possible to write real applications in it.
Hi Maksym –
thanks for the pointer to Haxe – it looks cool, and certainly is a rather more mature language than Grace – which we’re not really done designing yet, let alone implementing!
I’ve added Haxe to our list of 25-odd languages that are doing somewhat similar things to Grace. I’m certainly interested in other languages the design decisions that they make.
In that case you’ll also be interested in Dart — a similarly styled language by Google. See http://www.dartlang.org/docs/language-tour for details
🙂
Yep – we know about Dart. Indeed Dart is a lot closer to Grace than Haxe is, from my perspective.