Piers Cawley picked up on a rant I had elsewhere in DSLs, Fluent Interfaces, and how to tell the difference. An API that uses Ruby symbols isn’t automatically a DSL, nor did Ruby invent or even popularize the concept (though it seems to have taken the “How to Draw a Horse!” concept right out of matchbook covers)–I credit lex and yacc as ancestors.
Once I simplified and unified almost all of the language-specific test harnesses in Parrot to a single line per language implementation:
use Parrot::Test::Harness language => 'pheme', compiler => 'pheme.pbc';
API or DSL? Does it really matter? Maybe. It can be difficult to talk about closures when Luddites from the Java world claim that they’re the same thing as anonymous inner classes, and I still consider Python’s use of the word
lambda as misleading.
Then again, there’s no reason that code has to look anything like valid Perl. It only needs to be a list of strings, and
Parrot::Test::Harness could do anything. Consider also P5NCI::Declare which extends the concept:
use P5NCI::Declare library => 'shared_library'; sub perl_function :NCI( c_function => 'vii' ); perl_function( 101, 77 );
Maybe a language with richer syntactic elements–and the possibility to change their behavior–allows greater potential to create a true DSL modeled after the domain.
Either way, the possibilities for API simplification are hard to ignore.