November 20th, 2007
I’m a big fan of domain-specific programming languages when developing for a very specific domain. Game development is a nice example, because you have a lot of rules and details to present do the player, that influence the game flow and game play. You could write these rules directly in the game engine, but you would lose flexibility.
A better approach could be to write a more generic game engine that knows how to handle the game rules via a DSL. There are games that use a scripting language to add flexibility to the game engine. But I still prefer some kind of DSL that maps directly to XML (or vice-versa), because of the following advantages:
- Forcing all the rules to be in a DSL is great to enforce loosely coupled systems. The game rules will often change and we want no impact on the other modules
- You can use a language specially created to represent the application logic, instead of using a general purpose language - you gain in software quality, readability and maintenance
- You can give this language to the business guys; you can have the application logic written by the people that really know the business rules. Note that the DSL can be visually represented with some modeling tool, that transforms it to XML
Given these advantages, I think that DSLs should get way more attention.