Log in


An interesting thing has happened lately...

in the world of perl.

I think it all started in ruby, but may be traced back even farther, and I'll try. Ruby is another scripting language that has a lot in common with perl (take a look at some of the methods available on String such as chop, chomp, etc.). But Matz, the creator of ruby, stated once that a lot of the inspiration came from lisp.

Now lisp (and its children) is interesting because it has these things called macros. No, nothing like the watered down, dangerous macros of C. These macros are an important part of the language because they let you essentially define new language. The macros have been used in lisp for many, many years to create libraries of essentially new *language* features (not just libraries) which has caused some to say that lisp programmers don't write programs, they write programs that write programs.

All of this language changing has been taking on a name lately and been getting called "Domain Specific Languages." These DSLs, as the name implies, are little languages put together to better express the domain you are working in than a general purpose programming language can.

Sometimes a DSL is external to the language (you see them quite often in Java land as XML) a good example of that is YAML (YAML Ain't Markup Language) which is a language for defining data in data-structures:

	name: Bob Marley
	age: 30
	children: [Mary-Sue, Moonbeam]
	name: Jay Leno
	age: 55 

Sometimes it is internal to the language (written in the syntax of the language itself). Ruby on Rails uses this quite often for things like dispatching responses based on what was requested:

	respond_to do |format|
		format.xml { render :xml => @recipe.to_xml }

These kinds of mini-languages are not really new (lisp did them, ATT Bell Labs had a philosophy for them along the lines of "Library design is Language Design"), but they are getting a lot more attention now. Mostly because as systems get bigger and bigger and become their own large worlds unto themselves the *general* purpose languages are just too general to express clearly what is happening. Think of it as the technical jargon of a specialty being formalized so that a computer can understand it (in fact I would say that that is a major part of what software engineering is).

What does this have to do with perl? We'll for a while perl has been a bit of a languishing language. Many malodorous features of five (perl version 5) have cause confusion and contempt among possible perl programmers. But lo! Language laxness is the perl prime! Raucous ruby wranglers poo-pooed perl's packages, obfuscated objects, and odious operators.

Perl has a new vigor in perl 5 now. Many of the techniques that formed in ruby for creating these languages are now crossing over into perl. Much more use of blocks, thick-commas, and objects is taking hold. The Moose system is giving perl a nicer syntax (and semantic) for objects. Interestingly it is happening in a very similar manner as it did in lisp (no objects in the language and then language features were used to create a system). I'm also starting to see several modules that work by creating mini-language declarative style interfaces.

We'll see how far this goes...and what it will do for perl 6.



December 2007

Powered by LiveJournal.com