DSLs and the 90 percent

90%, 90%, 90%!!!


Windley on DSLs

Atwood on Languages Inside Languages (e.g.: Using multiple DSLs at the same time)

Rob Conery in defense of (his) ORM

Jeff, why the SubSonic hate? Rob, why the Regex hate? Why not use them where they're appropriate?

1) I want SubSonic to turn 90% of my Database needs into easy one-liners.

2) For everything else, I want SubSonic to get out of my way.

SubSonic does a pretty good job of both things.


Order o = Order.FetchByID(orderID);
foreach (Product p in order.Products)
  doSomeCoolThing(p.price, p.weight, p.title);

(plus intellisense and compile-time errors)


IDataReader rdr = QueryDb("SELECT * FROM Products WHERE OrderID = '" + " sqlEscaper(orderID) " + "');
while (reader.Read())


That right there is 90% of the SQL queries for 90% of DB applications out there. Look at how much more beautiful SubSonic can make the world.

Jeff is right though, people get their hands on a tool like SubSonic and suddenly think it will do their laundry and solve world hunger too. SubSonic's fluent interface doesn't cut it for complex data queries (and is often ugly when you try). But it shouldn't try to cut it, and it doesn't.

When you want to do complex data queries, drop down to SQL, or wrap your queries in Views, etc. Either way, you gotta know SQL, so don't try to hide it in a Kingdom of Nouns.

Jeff shouldn't be so down on SubSonic -- it is actually more of what he's talking about: It's a Domain Specific Language itself (for the most common queries a DB application makes). Why not let it play along with SQL & Regex too? Just don't try to use it for what it's not good at, just like with SQL & Regex.

Domain Specific Languages are fun and useful. SubSonic is fun and useful. They both need to stay out of each other's territories. Why the hate?

Last note on Regex's: When you want to parse something out of a string, use a short, concise Regex. People usually hate Regex because they get so excited by it that they try to write a single indecipherable Regex string that encapsulates the complete parsing structure of a entire programming language. Bad idea, but they blame it on Regex. You don't need an IDE for Regex's, you need to divide and conquer and separate your concerns, just like you approach every programming challenge in your favorite language: Wrap your whole program into one method and you will die. Period.