I gave a talk at the 2003 International Ruby Conference this week. I think the talk went over pretty well. I gave my presentation on the first day and the two days following we talked on and off about CG approaches to various problems.
The other CG approaches that were presented were very interesting. One of the unique attributes of Ruby is how literate the code is. It looks and reads in a very simple and structured form. So people were using Ruby code to build the model in memory and then using generator code to use the in-memory form of the model when generating the code. It looked and worked really nicely. I'll have to think about the advantages and disadvantages of this apporach. Hopefully I will be able to interview some of the other presenters and put those up on the site for some feedback.
One of the more intruiging uses was using a code generator to build an adapter layer between Ruby and Java's Debug Wire Protocol which allows you to connect to a running JVM and debug the code over the wire. It was really cool to see a running Java process was then started and stopped by an external Ruby process.
The author had hand written the JDWP spec as Ruby code which was, in effecft, a model in memory. This model was then traversed by a generator which build Ruby classes on disk to do the marshalling for each of the various binary packet types in JDWP. The binary marshalling stuff was ugly, but it is in every scripting language. I don't think there is an elegant way to do that. The cool thing was that all of the code was documented with the spec itself, so once the code was generated you could use RDoc (Ruby's equivalent of JavaDoc) and create HTML pages which had the entire JDWP specification as well as the Ruby methods to make the calls.
One of the great things about Ruby is it's users. These are some clever, intelligent and resourceful people that come up with extremely elegant solutions to difficult problems.