I love domain specific languages (DSL). The idea is that instead of programming at a low level (i.e. tedious and error-prone), you program at a higher level of abstraction. This means coding with a language (or even class library) that closely maps to the problem domain. For example, here are several domain specific languages. While you could try to do without, it just becomes so much easier with them:
DSL | Purpose | Example | Manually doing without: |
Regular Expressions | Find and replace patterns in text | Find all numeric decimals in a file | You could use core string methods like SubString and IndexOf |
SQL | Manage database data | Select all employees that meet a certain criteria | You could do selects by getting the entire dataset and cycling through the object model |
XPath | Query xml data | Get the custom order xml nodes where price is less than $100 | You could step through the xml with a reader, or loop through an XmlDocument |
MSBuild | Microsoft's build engine to automate your processes | Compile your application on a build server, run unit tests, and then produce MSI outputs | You could use System.Diagnostics to manually run a bunch of commands, and keep track of error conditions and logging output yourself. |
String Format Expressions | Format a string using var.ToString("myPattern") | Format the number 12.3456 to only two decimal places | You could use core string methods, and pick apart the variable, and re-assemble it. |
The point is that while someone could get by without knowing the appropriate domain language, it's just not practical to tackle the domain without it. Each of these has tons of tutorials and quickstarts, so there's no reason to avoid them. An application developer should probably be comfortable with most of these.
So, what's your favorite domain specific language?
No comments:
Post a Comment