Monthly Archives: January 2009

DSLs: Definitely a bad idea!

Last Friday Rocky posted an entry on his weblog entitled “DSLs – fun, cool, but maybe a bad idea?” and my reaction was:

Maybe a bad idea? Maybe a bad idea? Of course they’re a bad idea!

This may seem strange coming from someone who’s working on the heart of Oslo/M’s DSL capabilities, but stick with me here.

To begin with, writing a new language, domain-specific or not, is a lot like opening a restaurant: everyone thinks they can do it because they’ve eaten at one and it looks like fun. But the truth is that something like 50% of restaurants fail in the first year, and probably 90% fail over the long haul. It’s incredibly difficult, time consuming, and hard to keep a restaurant as a going concern-but doing that while actually coming up with something people want to eat is nearly impossible. I’m amazed new restaurants open up at all, given the odds.

Languages are the same way. It’s mind-bendingly, stupendously difficult to build a new language, even one that’s largely based on an existing one. Yet many programmers think, “hey, I use languages, how hard can this be?” and go at it. Like restaurants, probably over 98% of them fail to ever gain any traction at all, but god bless the optimists because without them we’d never get the 2% of languages that succeed. I’m personally willing to sacrifice the millions of dollars and hours wasted on languages that never make it just so that we can get languages like C# and Java and Ruby and Python and so on. (One language omitted to preserve at least the appearance of humility.)

So the fact that coming up with a new language is a bad idea shouldn’t dissuade people from developing new DSLs, it should just give them pause and hopefully a little humility. The key, I think, is to start small and to stay small. A domain-specific language needs to stay, well, domain-specific and not try and branch out to become a general purpose programming language. The problem is that it’s really, really hard to resist the temptation to do that. You just have to keep in mind that all the really successful DSLs have remained little languages, and repeat that to yourself every day. If you do that, you’ll be fine. Or, put another way:

Remember kids, DSLs don’t kill people, people kill people.

I am not a theorist…

As I’m sure regular followers of my blog are aware, I have a weakness for disclaimers. As I’ve starting thinking about how I want to talk in more detail about how the MGrammar parser generator works, I felt compelled to make yet another disclaimer: I am not a computer science theorist.

The field of parser generation is an old and storied one (at least, relative to a lot of other things having to do with computers) and there’s a lot of theory that’s built up around it. I simply ask my readers to keep in mind that I am but a humble practitioner, same as they are, and I make no great claims to deep insight or great knowledge of the full theory of parsers. I can not hope to even touch the hem of the garment of those who have gone before me, particularly these guys:

Book Cover

So if you really want to understand the difference between a LL(k) and a LALR(1) parser, go buy the book. Otherwise, you’re stuck with my simplistic explanations.