OSCON 2007: Building Domain Specific Languages in Perl, by Jesse Vincent
- Thu Jul 26 2007
- OSCON 2007
- Trackback URL
- comment feed
- digg this post
Domain specific languages are little languages built for specific programming tasks. You might want to use them because they’re easier to read, they’re expressive. SQL is an example of a DSL for dealing with relational datasets. Excel macros are a DSL for working with numbers and spreadsheets. XSLT is a DSL for transforming XML.
DSLs can be called by your host language, and they’re called “internal” DSLs. Most of everything in this talk will be an internal DSL. The Ruby community is big on DSLs and says that you can’t do them with Perl, but you can!
A DSL exists for declaring database schema, similar to Rails. One exists for web templating, one exists for dispatching HTTP requests, and one exists for making web testing easier.
Jifti::DBI::Schema is a very nice implementation of describing a schema.
Template::Declare is a pure Perl templating system. The two big Perl templating systems, Template:: and HTML::Mason, are either not Perl or are full of HTML. Why learn another language? Template::Declare looks very useful for prototyping HTML in Perl. There are a few little things it can’t do (like make a tr equivalent) (edit: yes, it can, it uses row, and also cell for td tags; see comment below), but all in all it’s very nice.
Test::WWW::Declare is a readable language for testing web interactions. You can do things like content should match qr{RT Essentials}i, which is pretty cool.
DSLs are tougher to debug. Errors can sometimes be confusing. But they make coding fun and can introduce programming to non-programmers.

One Response to “OSCON 2007: Building Domain Specific Languages in Perl, by Jesse Vincent”
Thu Jul 26 2007
2:18 pm
Template::Declare can do tr, it’s just spelled row (and td is spelled cell).
Leave a Reply