Tuesday 29 March 2005 — This is over 19 years old. Be careful.
Cullen O’Neil wrote to tell me that he liked Cog enough to re-implement it in Ruby. The result is Argent. Now you can use Ruby for code generation:
// This is my C++ file.
...
/*[[$argent
['DoSomething', 'DoAnotherThing', 'DoLastThing'].each do |fn|
$argent.outl("void #{fn}();")
end
$]]*/
//[[$end$]]
...
Reading the Argent code was an interesting experience: I don’t really know Ruby, but I’m familiar with how Cog is implemented, so I “knew” the code without knowing the language. It helped me understand more about Ruby.
Also cool: Cullen uses Argent to manage its own Makefile. He generates test classes and Makefile entries for them using Argent itself.
Comments
I think eventually we'll see Cog like functionality and support right in the IDE (whatever IDE that may be. I'm rhyming, wheee!). My feeling is some vendor is going to do a slick job integrating that functionality and then more vendors and projects will follow suit. Eventually it will be like "intellisense" and people will take it for granted.
Unrealistic predictions perhaps, but I'm really sold on the Cog approach.
Actually there is probably no point and then that would add the painful requirement of the command-line script having to know how to delegate to another interpreter if it came across another language block.
Alternatively, the Bean Scripting Framework (BSF) could be used. Only caveat is that it's written in Java. so it would require Jython and JRuby.
That said, either approach may be overkill. Cog is a simple and powerful idea that isn't tied to Python or Ruby. I think the idea is more important than the specifics of the implementation. This is analogous to how Ant inspired a .NET version called Nant and JUnit inspired a .NET version called NUnit. Good ideas are portable.
Add a comment: