Most Read Latest News Blog Resources

Integration Watch: So, you want to write a little language?




October 15, 2008 — 

Writing and implementing a language are nothing new to many computer geeks. University comp-sci curricula regularly require designing and implementing a toy language (complete with a compiler and, these days, a virtual machine).

This exercise often gives programmers a bug that lasts for years: the desire to write and implement their own language. The fantasy often wears off over time, however, diminished by the complexity of the task; the low likelihood that the resultant language would find adoption beyond the developer and a few acquaintances; and, most important, the fact that, aside from a narrow set of personal needs, new languages tend to mimic existing, established ones.

Industry and commerce, however, are a different world altogether. Most large software packages need some kind of little language, or domain-specific language (DSL), to be used for commands, macros and scripting. Regrettably, many DSLs today are designed to use XML syntax in order to facilitate the language parsing. Use of a data interchange format as the defining grammar makes many human-oriented DSLs, such as Ant’s syntax, very unpleasant.

Good DSLs are naturally expressive; that is, their language reflects the problem domain they address. Once such a language is learned, it is easy to remember. A good example is the data and text manipulation language awk. Its syntax is so simple that you can return to it years after you last looked at it and be productive in a few minutes with just a reference card. Of course, awk’s advanced capabilities involve a larger, fuller syntax, but even that retains a remarkable ease of use.

Designing good DSLs or full, expressive languages is no easy job. And yet, it is the design stage that frequently will determine a language’s appeal. For example, a substantial part of Ruby’s attraction is what users describe as its intuitive syntax, pleasant expressiveness and brevity. (Compare those sentiments with your experience writing Ant files.)

The challenge of good language design is that it is little taught and rarely discussed. It remains tucked away as though it were the province of a cabal of specialists with Ph.Ds who scare the uninitiated with terms such as “monads” and “lambda calculus.”

In truth, it is not so rarefied a skill—and it’s one from which almost all large IT organizations can benefit, since nearly all such organizations have complex programmable in-house apps that represent part of the company’s unique competitive advantage. Writing a good language can be a huge contribution to getting things done better, faster, cheaper.

There are several landmark books that can help a new language designer do the job right. Unfortunately, they’re textbooks. But they do offer a deep understanding of the features that languages can have—in essence, providing the designer with a palette of many colors.

Two of the books are established classics: R.D. Tennet’s “Principles of Programming Languages” and Michael Scott’s “Programming Language Pragmatics.” While the former work was published in 1981, its content is still highly relevant and it is frequently cited in today’s discussions of the implementation of Java closures. The latter book focuses on pragmatics, which are the implementation aspects of a language. (The three principal phases of language implementation are syntax, semantics and pragmatics.) It discusses such topics as data type selection, object lifetimes and parameter processing.

Together, the two books cover the basics that good designers and implementers need. Tennet’s book, however, is a slim volume that does not cover all modern concepts.

To update the area completely, there’s the just-released “Design Concepts in Programming Languages,” by F. Turbak and D. Gifford. The book is comprehensive (at 1,300-plus pages) and presents numerous little languages to illustrate key concepts. One caveat: The material is dense and relies heavily on mathematical explanations, formal logic and Lisp-like language examples; in other words, it has a strongly academic feel. That will be forbidding to some readers, but the remarkably lucid style compensates well. And unlike the two other books, this one is so comprehensive as to be usable as an encyclopedic resource. Readers who use it as a reference volume can skip the math and symbols without much loss.

If you’re thinking of designing a language—large or small—spend extra time working on the design. You’ll attract more users, and they’ll be happier for the help you give them. If your view of what features a language should have is limited to the programming languages you’ve used, then start with Tennet’s book, follow up with Scott’s, and use Turbak and Gifford for updates and for reference. You’ll be pleased with the results.

Andrew Binstock is the principal analyst at Pacific Data Works. Read his blog at binstock.blogspot.com.


Related Search Term(s): software development


Share this link: http://www.sdtimes.com/link/32964
 

Add comment


Name*
Email*  
Country     


  • Comment
  • Preview
Loading



 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 
Download Current Issue
ISSUE 3/15/2010 PDF

Need Back Issues?
DOWNLOAD HERE

Receive the print Edition?


 
blogs tab
Google Code turns 5
Google Code Turns 5, and adds a Paxos Algorithm to make the system more stable and reliable.
03/17/2010 11:16 AM EST

Test your Visual Studio 2010 know-how
Microsoft is offering free beta certification exams for Visual Studio 2010.
03/17/2010 11:08 AM EST

Microsoft lifts the hood on IE9
Microsoft is previewing IE9.
03/16/2010 01:10 PM EST

 

Events calendar tab
3/22/2010 to 3/25/2010
Santa Clara, Calif.
The Eclipse Foundation

4/12/2010 to 4/14/2010
Las Vegas
Penton Media

4/12/2010 to 4/15/2010
Santa Clara, Calif.
O'Reilly Media

4/19/2010
New York City
Flagg Management

4/25/2010 to 4/28/2010
Overland Park, Kans.
IIUG