Just A Summary : Domain Specific Pidgin http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin.rss en-us 40 Piers Cawley Practices Punditry Comment on Domain Specific Pidgin by Ben <p>Interesting &#8211; I&#8217;ve been calling these (AR, RSpec, etc.) domain specific <strong>dialects</strong> for a while now. I think dialect might be a better term, given that the main distinguishing characteristic is the vocabulary, not the grammar (pidgins, as I recall, generally don&#8217;t take the grammar of one parent &#8211; they usually follow an extremely simplified grammar that is remarkably consistent regardless of the parent languages (which is often used as an argument for Universal Grammar, fwiw)).</p> Wed, 08 Aug 2007 11:48:07 -0500 urn:uuid:659029d3-89ae-4b27-91f2-3caa8f930177 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-513 Comment on Domain Specific Pidgin by Piers Cawley <p>We&#8217;re fast approaching &#8220;How many angels&#8230;?&#8221; territory here, but I&#8217;d be inclined to call ActiveRecord&#8217;s family of class methods taking hash arguments with meaningful keys a dialect, but reckon that RSpec is fast approaching a &#8216;real&#8217; language or pidgin.</p> Wed, 08 Aug 2007 12:25:42 -0500 urn:uuid:e1ab9840-e841-44d2-ba2f-395df8a42994 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-514 Comment on Domain Specific Pidgin by chromatic <p>&#8220;Dialect&#8221; reads better to me, but &#8220;pidgin&#8221; is catchy too.</p> Wed, 08 Aug 2007 14:47:12 -0500 urn:uuid:1c07506e-a9eb-43f7-8712-657f82c032d2 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-516 Comment on Domain Specific Pidgin by Aristotle Pagaltzis <p>I think Parse::RecDescent qualifies as an actual <span class="caps">DSL</span> – external one even. After all, it actually parses grammars itself. Granted, part of the grammar is code that’s passed thru straight to Perl, but you can write a perfectly useful P::RD grammar without any Perl in it.</p> <p>To stay in your image, it’s more like the speech of a second-generation immigrant who can speak the native tongues of both his parents and the locals – like me and the other Greek kids I knew while growing up in Germany. When in an audience that understands both languages, such speakers will tend to seamlessly flip-flop from one language to the other in mid-sentence depending on what rolls off the tongue easier in the moment.</p> <p>(And I know this is not limited to my crowd. The same tendency is apparent in second-gen’ers with all combinations of language; whether emigrating from Greece, Italy or Turkey to Germany, or from Greece to Germany, the US/Australia/Canada or France, or from Mexico to the US, it is always true. The immigrants’ kids know both languages almost equally well and switch between them casually in mid-sentence.)</p> Wed, 08 Aug 2007 18:43:50 -0500 urn:uuid:e18df721-cf28-460a-abfb-5e2b2c6fe6f4 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-517 Comment on Domain Specific Pidgin by Piers Cawley <p>Aristotle: You are, of course, correct. My memory was playing me false and Parse::RecDescent does indeed involve a parser. In my memory it was one more of those Conway modules which feel like another language but still parsed as Perl.</p> Thu, 09 Aug 2007 01:11:01 -0500 urn:uuid:bdc7a4ef-51b8-4817-b557-3772ba0222a4 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-518 Comment on Domain Specific Pidgin by David Romano <p>Piers: Do you think your pidgin might just actually be a <a href="http://en.wikipedia.org/wiki/Register_%28linguistics%29" rel="nofollow">register</a>? (I know, &#8220;register&#8221; isn&#8217;t as catchy as &#8220;pidgin&#8221; :-) It seems that most DSLs use vocabulary that simply expands the native language&#8217;s patterns of expression. This is no different than inventing mathematical jargon in English to express the problem domain of mathematics. How different is your embedded little language&#8217;s syntax/grammar from Ruby&#8217;s?</p> <p>Aristotle: Your description of flip-flopping back and forth between two languages mid-sentence is termed <a href="http://en.wikipedia.org/wiki/Code-switching" rel="nofollow">code switching</a> in linguistics. As you said, it&#8217;s a very common phenomenon, but it is not restricted to those who speak both languages fluently.</p> Thu, 16 Aug 2007 00:12:03 -0500 urn:uuid:c79babd5-f256-4fe3-a334-573ebe29b9d9 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-545 Comment on Domain Specific Pidgin by Piers Cawley <blockquote> <p>Do you think your pidgin might actually be a register?</p> </blockquote> <p>I don&#8217;t think so, mostly because it&#8217;s pretty much entirely declarative. It&#8217;s for attribute declaration and (currently) looks something like:</p> <pre><code>class Whatever attributes { foo.default = 42 bar.should.match /.../ baz.should.ensure {|val| val &gt; foo} quux { default = 90 should.ensure {|val| (val % 10).zero? } } end </code></pre> <p>The implementation leans heavily on evaluating the blocks involved in odd scopes and the semantics aren&#8217;t generally what you&#8217;d consider to be the usual ones for Ruby. For instance, the line <code>foo.default = 42</code> has the effect of generating code along the lines of</p> <pre><code>def foo @foo = 42 if instance_variable_defined? :@foo return @foo end </code></pre> <p>which isn&#8217;t really the normal semantics you&#8217;d expect for assignment. Meanwhile the block in <code>baz.should.ensure {|val| val &gt; foo}</code> gets evaluated in the context of an instance of the class before any assignment is made to <code>baz</code> via the accessor method.</p> <p>I&#8217;m not entirely sure pidgin is a particularly good word either; I&#8217;m just not sure I can think of a better one.</p> Thu, 16 Aug 2007 01:27:42 -0500 urn:uuid:2d847913-bf0b-47dc-aba4-87bca484f59c http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-546 Comment on Domain Specific Pidgin by David Romano <p>Thanks for showing me what it looks like and means. Now that I see it, it&#8217;s definitely not a register.</p> <blockquote> <p>I’m not entirely sure pidgin is a particularly good word either; I’m just not sure I can think of a better one.</p> </blockquote> <p>Me neither. :-/</p> Thu, 16 Aug 2007 04:09:40 -0500 urn:uuid:5ff739c7-4cda-47d8-af02-1666831384e9 http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-547 Comment on Domain Specific Pidgin by Warner Onstine <p>I&#8217;m not sure that pidgin is the right term here, specifically from a linguistic point of view. While Pidgin languages do come about because of one or more groups of people coming together and having to communicate with each other they are indeed &#8220;languages&#8221; in their own right. More specifically these languages evolve over time into their own full-blown language, where the words being used no longer mean what they did in either language.</p> <p>There was a really good story I either read or heard on Pidgin Languages (it might have come from the book &#8220;The Language Instinct&#8221; by Pinker &#8211; very good book).</p> <p>I&#8217;m going to be sticking with Internal DSLs for my own reference as I&#8217;m not very comfortable with labeling these as &#8220;Pidgin Languages&#8221; in my eyes they aren&#8217;t really. Just my .02.</p> Wed, 13 Feb 2008 14:05:45 -0600 urn:uuid:c2463f7e-4236-4836-897d-0c0ad5be8c3b http://www.bofh.org.uk/articles/2007/08/08/domain-specific-pidgin#comment-1311