Pimp My Programming Language

By Darryl K. Taft  |  Posted 2008-11-13

Pimp My Programming Language

Should high-end programmers be allowed to modify or add extensions to the programming languages they use?

That issue was among the points up for debate by a panel of programming language experts at the Microsoft PDC (Professional Developers Conference) in October. The issue was whether programmers should be allowed to extend a language to get around constraints or to do things they typically might not be able to do with the language in its standard form.

"You should be able to extend the syntax [of a language] as a programmer," said Jeremy Siek, an assistant professor at the University of Colorado.

Adding syntax or tweaking the syntax of a language could be somewhat akin to the idea of DSLs (domain-specific languages), in that a programmer could customize a language for specific tasks. There has always been tension between general-purpose language design and specific application requirements-usually developers have to compromise or work around language features. Adding syntax may be like adding macros in Excel, allowing a way to use language to represent common routines or to group multiple steps.

Erik Meijer, a Microsoft software architect and language expert who moderated the panel, asked, "But isn't it dangerous to have amateurs 'pimping' the language?"

Meijer was referring to the slang for glamorizing an object, as in the MTV show "Pimp My Ride," on which the goal is to find a car in poor condition and restore it, adding glitz and ostentation to the vehicle. Thus the "pimp" reference. In this case, Meijer wondered whether developers should be allowed to add "bling" to their programming language of choice.

Siek responded to Meijer by saying his question represented "fear, uncertainty and doubt. As humans we're coming up with new mutations and languages all the time ... and it's wrong to limit that." So programming languages should allow adding syntax extensions, Siek said.

Douglas Crockford, a senior JavaScript architect at Yahoo, said he didn't think it was a good idea, however. And Gilad Bracha, the creator of the Newspeak programming language and a distinguished engineer at Cadence Design Systems, said, "What will come out of inexperienced people making syntax extensions is that you probably won't be happy with the results."

Wolfram Schulte, a senior researcher at Microsoft, said, "One of the funny things is that we struggle with DSLs because of our inability to do parsing very well." However, "we could allow extensions to a limited degree," he said.

Bracha added that "having a less noisy syntax makes it easier to make a language that is like a DSL."

The Importance of Syntax


Meanwhile, Siek, who started the tangent, said, "We don't have to 'open' the language to do that sort of thing." He said as long as he can do compilation at compile time and manage chunks of code that is "pretty much as powerful as I would want."

Meanwhile, Meijer also asked if syntax was the reason a language succeeds or not-basically how important syntax is. Anders Hejlsberg, a Microsoft technical fellow and creator of C#, said, "I think it [syntax] matters a lot. Our brain is a pattern recognizer and syntax helps us think in certain ways."

Well, "it does and it doesn't," Bracha said, "because people are trained to certain syntax, but they're not geared to learn a new syntax. I think Parkinson's Law of Triviality applies here: 'The smaller an issue, the more people will discuss it.' Where you put a semicolon shouldn't matter."

For his part, Crockford said he believes the whole thing comes down to fashion.

"We like to imagine the process of programming language design is a scientific process, but it's actually all about fashion," Crockford said. "I think the process of language design has more to do with fashion than the question of the ideas behind them, and I think that's unfortunate."

On a different note, Hejlsberg said metaprogramming is "high on my list of things to attack in C#-to make it a better metaprogramming system. To open up the black box ... Enterprise applications live and die by metaprogramming. There's code generation everywhere. And the tools for doing this are terrible; we need a modern approach to that."

However, Schulte said, "I think metaprogramming at the syntax level is a really bad idea. You don't want to open up the box."

Metaprogramming is the writing of programs that write or manipulate other programs-or even themselves-as their data, or that do part of the work at compile time that is otherwise done at run-time.

Indeed, that is what Bracha reflects on. "It's really about reflection," he said. "Metaprogramming is just about one program manipulating another; reflection is about a program manipulating itself."

Rocket Fuel