<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Composing DSLs in JavaScript</title>
	<atom:link href="http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/</link>
	<description>This dirt was a building before</description>
	<pubDate>Sat, 26 Jul 2008 02:05:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1-alpha</generator>
		<item>
		<title>By: James</title>
		<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3122</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 02 Apr 2008 00:25:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3122</guid>
		<description>Russel, DSLs of the style demonstrated above do have a certain aptitude to writing descriptions -- I like to think of them as executable specs. Typically, writing rules for a system is a good candidate for DSL writing. The concept of 'rules' does not need to be as narrow as controlling access to methods, though.

As regards breaking encapsulation, externalising the rules is often the whole point of APIs like the above. People frequently find that they end up scattering the rules for a system all over the different classes, making the system hard to modify and to add and remove rules easily. Separating the rules out of the classes lets you apply and revoke sets of rules at runtime, which is useful.

Sometimes, the best approach to designing a system is to get all the objects to implement the available actions, and put all the decision-making logic in a set of rules. I suppose the closest familiar OO concept for all this would be the mediator pattern, in which all the objects in a system communicate through a centralised resource. JavaScript's extreme maleability means this pattern does not need a formalised mediator object but can simply involve directly modifying objects and classes.</description>
		<content:encoded><![CDATA[<p>Russel, DSLs of the style demonstrated above do have a certain aptitude to writing descriptions &#8212; I like to think of them as executable specs. Typically, writing rules for a system is a good candidate for DSL writing. The concept of &#8216;rules&#8217; does not need to be as narrow as controlling access to methods, though.</p>
<p>As regards breaking encapsulation, externalising the rules is often the whole point of APIs like the above. People frequently find that they end up scattering the rules for a system all over the different classes, making the system hard to modify and to add and remove rules easily. Separating the rules out of the classes lets you apply and revoke sets of rules at runtime, which is useful.</p>
<p>Sometimes, the best approach to designing a system is to get all the objects to implement the available actions, and put all the decision-making logic in a set of rules. I suppose the closest familiar OO concept for all this would be the mediator pattern, in which all the objects in a system communicate through a centralised resource. JavaScript&#8217;s extreme maleability means this pattern does not need a formalised mediator object but can simply involve directly modifying objects and classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3121</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 02 Apr 2008 00:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3121</guid>
		<description>Jim, I would love a method_missing equivalent in JavaScript, but I don't think that its absense really limits what you can do with the language. You can still do a lot of metaprogramming by generating functions dynamically and using reflection.</description>
		<content:encoded><![CDATA[<p>Jim, I would love a method_missing equivalent in JavaScript, but I don&#8217;t think that its absense really limits what you can do with the language. You can still do a lot of metaprogramming by generating functions dynamically and using reflection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell Allen</title>
		<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3120</link>
		<dc:creator>Russell Allen</dc:creator>
		<pubDate>Mon, 31 Mar 2008 00:24:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3120</guid>
		<description>Interesting...  Do you see this 'natural language' approach as limited to the expression of rules which control access to object methods?  How do you reconcile the externalizing of those rules with the traditional OO view that an object is an island...  In other words, doesn't this violate encapsulation?  (I can see some cases where it does and it doesn't.)

Have you seen: http://livepipe.net/projects/event_behavior/

It's a very nice lib for 'glue' code...  Looks like this:
with(Event.Behavior){  
     show('state_field').when('country').is('United States');
     show('province_field').when('country').is('Canada');
}</description>
		<content:encoded><![CDATA[<p>Interesting&#8230;  Do you see this &#8216;natural language&#8217; approach as limited to the expression of rules which control access to object methods?  How do you reconcile the externalizing of those rules with the traditional OO view that an object is an island&#8230;  In other words, doesn&#8217;t this violate encapsulation?  (I can see some cases where it does and it doesn&#8217;t.)</p>
<p>Have you seen: <a href="http://livepipe.net/projects/event_behavior/" rel="nofollow">http://livepipe.net/projects/event_behavior/</a></p>
<p>It&#8217;s a very nice lib for &#8216;glue&#8217; code&#8230;  Looks like this:<br />
with(Event.Behavior){<br />
     show(&#8217;state_field&#8217;).when(&#8217;country&#8217;).is(&#8217;United States&#8217;);<br />
     show(&#8217;province_field&#8217;).when(&#8217;country&#8217;).is(&#8217;Canada&#8217;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim LoVerde</title>
		<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3118</link>
		<dc:creator>Jim LoVerde</dc:creator>
		<pubDate>Sat, 29 Mar 2008 05:39:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3118</guid>
		<description>Without an equivalent to "method missing", you are severely limited in what you can do with a Javascript DSL.  However, this is a good example of about the best you can expect to get with today's Javascript.

We'll have to see what becomes of it, but Javascript 2 as currently drafted up might make it possible to improve the readability (and it has method missing support).</description>
		<content:encoded><![CDATA[<p>Without an equivalent to &#8220;method missing&#8221;, you are severely limited in what you can do with a Javascript DSL.  However, this is a good example of about the best you can expect to get with today&#8217;s Javascript.</p>
<p>We&#8217;ll have to see what becomes of it, but Javascript 2 as currently drafted up might make it possible to improve the readability (and it has method missing support).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allain</title>
		<link>http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3111</link>
		<dc:creator>Allain</dc:creator>
		<pubDate>Fri, 28 Mar 2008 20:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jcoglan.com/2008/03/21/composing-dsls-in-javascript/#comment-3111</guid>
		<description>The idea's neat, but the syntax of this DSL is... difficult.

I'll give you this much: This is the first time I've seen someone doing something like this.</description>
		<content:encoded><![CDATA[<p>The idea&#8217;s neat, but the syntax of this DSL is&#8230; difficult.</p>
<p>I&#8217;ll give you this much: This is the first time I&#8217;ve seen someone doing something like this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
