Wow, Do We All Get a Language?
We’re all having a lot of fun this year making lovely hybrid languages from Ruby syntax, be it Rails models, Rake tasks, Dwemthy. Martin Fowler is knocking out a series of articles on domain-specific languages and language workbenches, the IDE and BDUF equivalent. All the surrounding essays are really interesting, including his IDE-based metaprogramming example, which gives you an idea of how parsing and code generation is being organized into these crazy point-and-click apps with IntelliSense and stuff.
Readers of this site will particularly love the early slant of the workbench article, since he attempts to hack some C# code in meta fashion, but it can’t hold a candle to his YAML-ish custom syntax:
mapping SVCL dsl.ServiceCall 4-18: CustomerName 19-23: CustomerID 24-27 : CallTypeCode 28-35 : DateOfCallString mapping USGE dsl.Usage 4-8 : CustomerID 9-22: CustomerName 30-30: Cycle 31-36: ReadDate
And, better yet, his subtle retooling into Ruby code:
mapping('SVCL', ServiceCall) do extract 4..18, 'customer_name' extract 19..23, 'customer_ID' extract 24..27, 'call_type_code' extract 28..35, 'date_of_call_string' end mapping('USGE', Usage) do extract 9..22, 'customer_name' extract 4..8, 'customer_ID' extract 30..30, 'cycle' extract 31..36, 'read_date' end
I found it almost bewildering that he links to Chapter Six of the (Poignant) Guide in his discussion of Ruby metaprogramming. I mean the reference to Rails is natural, but I would hate for this cartoon book to gain credibility. He knows that I have sketches of my sister’s clones quenching their thirst with jackal’s blood, right??