<p>I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen <a href="http://ayende.com/blog/tags/domain-specific-languages" rel="noreferrer">Ayende's blog posts</a> and things, but I've never really gotten exactly why I would take my business logic away from the methods and situations I'm using in my provider.</p>

<p>If you've got some background using these things, any chance you could put it in real laymans terms:</p>

<ul>
<li>What exactly building DSLs means?</li>
<li>What languages are you using?</li>
<li>Where using a DSL makes sense?</li>
<li>What is the benefit of using DSLs?</li>
</ul>

[{'answer_id': 41735, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 4, 'selected': False, 'text': "<p><strong>DSL</strong> stands for <em>Domain Specific Language</em> i.e. language designed specifically for solving problems in given area.<br>\nFor example, Markdown (markup language used to edit posts on SO) can be considered as a DSL.</p>\n\n<p>Personally I find a place for DSL almost in every large project I'm working on. Most often I need some kind of SQL-like query language. Another common usage is rule-based systems, you need some kind of language to specify rules\\conditions.</p>\n\n<p>DSL makes sense in context where it's difficult to describe\\solve problem by traditional means.</p>\n"}, {'answer_id': 41742, 'author': 'Staale', 'author_id': 3355, 'author_profile': 'https://Stackoverflow.com/users/3355', 'pm_score': 1, 'selected': False, 'text': '<p>DSL is basically creating your own small sublanguage to solve a specific domain problem. This is solved using method chaining. Languages where dots and parentheses are optional help make these expression seem more natural. It can also be similar to a builder pattern.\nDSL aren\'t languages themselves, but rather a pattern that you apply to your API to make the calls be more self explanatory.</p>\n\n<p>One example is Guice, <a href="http://docs.google.com/View?docid=dd2fhx4z_5df5hw8" rel="nofollow noreferrer">Guice Users Guide http://docs.google.com/View?docid=dd2fhx4z_5df5hw8</a> has some description further down of how interfaces are bound to implementations, and in what contexts.</p>\n\n<p>Another common example is for query languages. For example:</p>\n\n<pre><code>NewsDAO.writtenBy("someUser").before("someDate").updateStatus("Deleted")\n</code></pre>\n\n<p>In the implementation, imagine each method returning either a new Query object, or just this updating itself internally. At any point you can terminate the chain by using for example rows() to get all the rows, or updateSomeField as I have done above here. Both will return a result object.</p>\n\n<p>I would recommend taking a look at the Guice example above as well, as each call there returns a new type with new options on them. A good IDE will allow you to complete, making it clear which options you have at each point. </p>\n\n<p>Edit: seems many consider DSLs as new, simple, single purpose languages with their own parsers. I always associate DSL as using method chaining as a convention to express operations.</p>\n'}, {'answer_id': 41743, 'author': 'Tim Howland', 'author_id': 4276, 'author_profile': 'https://Stackoverflow.com/users/4276', 'pm_score': 5, 'selected': True, 'text': "<p>DSL's are good in situations where you need to give some aspect of the system's control over to someone else. I've used them in Rules Engines, where you create a simple language that is easier for less-technical folks to use to express themselves- particularly in workflows.</p>\n\n<p>In other words, instead of making them learn java:</p>\n\n<pre><code>DocumentDAO myDocumentDAO = ServiceLocator.getDocumentDAO();\nfor (int id : documentIDS) {\nDocument myDoc = MyDocumentDAO.loadDoc(id);\nif (myDoc.getDocumentStatus().equals(DocumentStatus.UNREAD)) {\n    ReminderService.sendUnreadReminder(myDoc)\n}\n</code></pre>\n\n<p>I can write a DSL that lets me say:</p>\n\n<pre><code>for (document : documents) {\nif (document is unread) {\n document.sendReminder\n}\n</code></pre>\n\n<p>There are other situations, but basically, anywhere you might want to use a macro language, script a workflow, or allow after-market customization- these are all candidates for DSL's.</p>\n"}, {'answer_id': 41751, 'author': 'Daren Thomas', 'author_id': 2260, 'author_profile': 'https://Stackoverflow.com/users/2260', 'pm_score': 2, 'selected': False, 'text': '<p>DSL is just a fancy name and can mean different things:</p>\n\n<ul>\n<li><p>Rails (the Ruby thing) is sometimes called a DSL because it adds special methods (and overwrites some built-in ones too) for talking about web applications</p></li>\n<li><p>ANT, Makefile syntax etc. are also DSLs, but have their own syntax. This is what I would call a DSL.</p></li>\n</ul>\n\n<p>One important aspect of this hype: It does make sense to think of your application in terms of a language. What do you want to talk about in your app? These should then be your classes and methods:</p>\n\n<ol>\n<li>Define a "language" (either a real syntax as proposed by others on this page or a class hierarchy for your favorite language) that is capable of expressing your problem. </li>\n<li>Solve your problem in terms of that language.</li>\n</ol>\n'}, {'answer_id': 41759, 'author': 'Guy Starbuck', 'author_id': 2194, 'author_profile': 'https://Stackoverflow.com/users/2194', 'pm_score': 3, 'selected': False, 'text': '<p>If you use Microsoft Visual Studio, you are already using multiple DSLs -- the design surface for web forms, winforms, etc. is a DSL. The Class Designer is another example.</p>\n\n<p>A DSL is just a set of tools that (at least in theory) make development in a specific "domain" (i.e. visual layout) easier, more intuitive, and more productive.</p>\n\n<p>As far as building a DSL, some of the stuff people like Ayende have written about is related to "text parsing" dsls, letting developers (or end users) enter "natural text" into an application, which parses the text and generates some sort of code or output based on it.</p>\n\n<p>You could use any language to build your own DSL. Microsoft Visual Studio has a lot of extensibility points, and the patterns &amp; practices <a href="http://www.microsoft.com/downloads/details.aspx?familyid=E3D101DB-6EE1-4EC5-884E-97B27E49EAAE&amp;displaylang=en" rel="nofollow noreferrer">"Guidance Automation Toolkit"</a> and <a href="http://msdn.microsoft.com/en-us/vsx/default.aspx" rel="nofollow noreferrer">Visual Studio SDK</a> can assist you in adding DSL functionality to Visual Studio.</p>\n'}, {'answer_id': 41768, 'author': 'kenny', 'author_id': 3225, 'author_profile': 'https://Stackoverflow.com/users/3225', 'pm_score': 2, 'selected': False, 'text': '<p>DSL are basic compilers for custom languages. A good \'free and open\' tool to develop them is available at <a href="http://antlr.org/" rel="nofollow noreferrer">ANTLR</a>. Recently, I\'ve been looking at this DSL for a <a href="http://www.codeplex.com/SimpleStateMachine/SourceControl/DownloadSourceCode.aspx?changeSetId=10958" rel="nofollow noreferrer">state machine language</a> use on a new project . I agree with Tim Howland above, that they can be a good way to let someone else customize your application. </p>\n'}, {'answer_id': 41861, 'author': 'toolkit', 'author_id': 3295, 'author_profile': 'https://Stackoverflow.com/users/3295', 'pm_score': 2, 'selected': False, 'text': '<p>FYI, a book on DSLs is in the pipeline as part of Martin Fowler\'s signature series.</p>\n\n<p>If its of the same standard as the other books in the series, it should be a good read.</p>\n\n<p>More information <a href="http://martinfowler.com/dslwip/" rel="nofollow noreferrer">here</a></p>\n'}]
['https://Stackoverflow.com/questions/41724', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3717/']