{"id":166,"date":"2006-05-22T22:07:08","date_gmt":"2006-05-22T22:07:08","guid":{"rendered":"http:\/\/localhost:8000\/?p=166"},"modified":"2006-05-22T22:07:08","modified_gmt":"2006-05-22T22:07:08","slug":"libraries-vs-dsls","status":"publish","type":"post","link":"https:\/\/blog.gwadej.org\/programmer-musings\/2006\/05\/libraries-vs-dsls\/","title":{"rendered":"Libraries vs. DSLs"},"content":{"rendered":"<p>Many years ago, I was working on application software that we configured and shipped to nearly a hundred clients. Although we did the first installation on a machine that we provided, the customer had to install updates a few times a year. (This was before most people knew about the Internet.)<\/p>\n<p>A few of us tried to convince the president of the company that we could make good use of a professional installation program. But, he could not see the point. He pointed out that we were already working in C, and C could do everything that the installer could do. So he concluded we could just write our own. He could not see the use of a specialized language for installation, what we would now call a Domain Specific Language (DSL).<\/p>\n<p>Amusingly enough, we were already using a <abbr title=\"Domain Specific Language\">DSL<\/abbr> to build all of the software. This guy was a big fan of <code>make<\/code>. We used a reasonably complex build system based around <code>make<\/code> to generate over twenty different variants of the program.<\/p>\n<p>His question is actually a valid one, although at the time I didn&#8217;t have the terminology to make my point. Everything I can do with a <abbr title=\"Domain Specific Language\">DSL<\/abbr>, I can do in a general purpose language. In fact, I can package up the functionality for the <abbr title=\"Domain Specific Language\">DSL<\/abbr> in libraries or classes and even make calling it almost as easy as using a <abbr title=\"Domain Specific Language\">DSL<\/abbr>. So, why would a <abbr title=\"Domain Specific Language\">DSL<\/abbr> be a advantage? I believe the answer is <em>notation<\/em>. The <abbr title=\"Domain Specific Language\">DSL<\/abbr> provides no increase in functionality. But what it does do is provide a better notation for working in the domain.<\/p>\n<p>Let&#8217;s take <code>make<\/code> as an example. Even though almost everyone complains about the tab thing in Makefiles and the reliance on the shell, <code>make<\/code> is still in wide use. Anything you can do with <code>make<\/code> can be done with any general purpose language. It would even be possible to build libraries for common functionality needed by build tools. Yet, we still use make or other tools similar to them. Why? Despite its flaws, the make DSL is very effective for specifying dependencies and tasks needed to build one set of resources from another set of resources.<\/p>\n<p><abbr title=\"Structured Query Language\">SQL<\/abbr> is another good example of a <abbr title=\"Domain Specific Language\">DSL<\/abbr>, I remember accessing databases before <abbr title=\"Structured Query Language\">SQL<\/abbr> was wide-spread. Every database <abbr title=\"Application Programming Interface\">API<\/abbr> was slightly different. They all provided the same basic functionality, but there were differences. You also needed to write quite a bit of common code in every place you used a particular database&#8217;s <abbr title=\"Application Programming Interface\">API<\/abbr>. Then <abbr title=\"Structured Query Language\">SQL<\/abbr> came along, and things changed. No, it was not a <em>complete<\/em> language, but it did allow you to talk to the database at a higher level. In the beginning, <abbr title=\"Structured Query Language\">SQL<\/abbr> libraries were not any faster (and were often slower) than the native <abbr title=\"Application Programming Interface\">API<\/abbr>s. Nevertheless, the notation was more convenient for the kinds of operations that you need to perform on a relational database.<\/p>\n<p>In many domains, a library is enough to allow you to get your work done. When the domain is understood well enough that we can really talk about it at a high level, it becomes possible to make a <abbr title=\"Domain Specific Language\">DSL<\/abbr>. There seems to be a large difference in usability when a <abbr title=\"Domain Specific Language\">DSL<\/abbr> is designed well. Even if a <abbr title=\"Domain Specific Language\">DSL<\/abbr> is not perfect (like make), it may be enough better than the alternatives that still use it&#8230;even if we still reserve the right to complain.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many years ago, I was working on application software that we configured and shipped to nearly a hundred clients. Although we did the first installation on a machine that we provided, the customer had to install updates a few times a year. (This was before most people knew about the Internet.) A few of us\u2026 <span class=\"read-more\"><a href=\"https:\/\/blog.gwadej.org\/programmer-musings\/2006\/05\/libraries-vs-dsls\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[77,116,193,225],"_links":{"self":[{"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/posts\/166"}],"collection":[{"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":0,"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gwadej.org\/programmer-musings\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}