<?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: Can You XML a DSL, And Would You Want To?</title>
	<atom:link href="http://www.blog.dannynet.net/archives/59/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dannynet.net/archives/59</link>
	<description>Pondering Programming and Poetry</description>
	<pubDate>Sat, 04 Feb 2012 22:06:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Ravi Mohan</title>
		<link>http://www.blog.dannynet.net/archives/59#comment-668</link>
		<dc:creator>Ravi Mohan</dc:creator>
		<pubDate>Tue, 18 Apr 2006 10:33:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/archives/59#comment-668</guid>
		<description>"He describes how his team created a DSL that describes a data model. Depending on its context, the DSL code will either create a table creation script, a script for creating stored procedures, or XHTML code for display in a browser. His description is not all too elaborate, I must say, so maybe I’m missing some interesting feature here. But it sounded to me like nothing more than doing some data transformations."

Your instinct is correct. It *is* just a transformation, though there are few subtleties.

This is how (all) language processing works. Here is  a simplified explanation.

A string is transformed  into a data structure. This process is called parsing. Various traversals can be performed on the resulting data structure("abstract syntax tree") to give different effects. 

e.g: (pseudocode)  
aString = " 2 + 3 " 

ast  = parse(aString)
// results in a datatructure like {operator:"+" , operand1= "2"  
 , operand2 ="3" }

def print(anAst) { puts anAst.operand1, anAst.operator. ast.operand2}

def evaluate(ast) { return ast.operand1 + ast.operand2} 

def generate_html(ast) ...

def generate_sql(ast) ..
def  whatever_you_want(ast) { ... }

print(ast) =&#62; 2+3

evaluate(ast) =&#62; 5

etc.


So in Obie's case , the "dsl" code is transformed into a data structure , either explicitly, or implicitly by the ruby parser.

 Then various transformations (which are traversals on the data structure, either explicit or implicit) generate different results.

Yes, for any dsl (or any programming language) you can write an equivalent xml (representing the data structure)  and xsl (representing the transform) . This might be a *lot* more work than just writing it in ruby (or lisp or whatever), but the concept is the same.

 Having said that, John's comment is right on the mark. Though there is nothing particulary new or tough about ruby dsl s, the ideas that "code == data" , and that given a powerful enough language, one could use the same language to represent code and data is strange to  many developers. 

Hope that helped.</description>
		<content:encoded><![CDATA[<p>&#8220;He describes how his team created a DSL that describes a data model. Depending on its context, the DSL code will either create a table creation script, a script for creating stored procedures, or XHTML code for display in a browser. His description is not all too elaborate, I must say, so maybe I’m missing some interesting feature here. But it sounded to me like nothing more than doing some data transformations.&#8221;</p>
<p>Your instinct is correct. It *is* just a transformation, though there are few subtleties.</p>
<p>This is how (all) language processing works. Here is  a simplified explanation.</p>
<p>A string is transformed  into a data structure. This process is called parsing. Various traversals can be performed on the resulting data structure(&#8221;abstract syntax tree&#8221;) to give different effects. </p>
<p>e.g: (pseudocode)<br />
aString = &#8221; 2 + 3 &#8221; </p>
<p>ast  = parse(aString)<br />
// results in a datatructure like {operator:&#8221;+&#8221; , operand1= &#8220;2&#8243;<br />
 , operand2 =&#8221;3&#8243; }</p>
<p>def print(anAst) { puts anAst.operand1, anAst.operator. ast.operand2}</p>
<p>def evaluate(ast) { return ast.operand1 + ast.operand2} </p>
<p>def generate_html(ast) &#8230;</p>
<p>def generate_sql(ast) ..<br />
def  whatever_you_want(ast) { &#8230; }</p>
<p>print(ast) =&gt; 2+3</p>
<p>evaluate(ast) =&gt; 5</p>
<p>etc.</p>
<p>So in Obie&#8217;s case , the &#8220;dsl&#8221; code is transformed into a data structure , either explicitly, or implicitly by the ruby parser.</p>
<p> Then various transformations (which are traversals on the data structure, either explicit or implicit) generate different results.</p>
<p>Yes, for any dsl (or any programming language) you can write an equivalent xml (representing the data structure)  and xsl (representing the transform) . This might be a *lot* more work than just writing it in ruby (or lisp or whatever), but the concept is the same.</p>
<p> Having said that, John&#8217;s comment is right on the mark. Though there is nothing particulary new or tough about ruby dsl s, the ideas that &#8220;code == data&#8221; , and that given a powerful enough language, one could use the same language to represent code and data is strange to  many developers. </p>
<p>Hope that helped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Lam</title>
		<link>http://www.blog.dannynet.net/archives/59#comment-502</link>
		<dc:creator>John Lam</dc:creator>
		<pubDate>Mon, 03 Apr 2006 03:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/archives/59#comment-502</guid>
		<description>Many folks (myself included) started out going down the XML path that you're at now. Sometime in the future, I suspect you will get the epiphany that code and data aren't really meant to as separate as your current implementation languages make them out to be. At that point, I think you'll start looking for confirmation of your epiphany, and you'll likely find it in strange places (at least from where you're sitting right now). It's a very old idea. But it's a very powerful idea.</description>
		<content:encoded><![CDATA[<p>Many folks (myself included) started out going down the XML path that you&#8217;re at now. Sometime in the future, I suspect you will get the epiphany that code and data aren&#8217;t really meant to as separate as your current implementation languages make them out to be. At that point, I think you&#8217;ll start looking for confirmation of your epiphany, and you&#8217;ll likely find it in strange places (at least from where you&#8217;re sitting right now). It&#8217;s a very old idea. But it&#8217;s a very powerful idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Obie Fernandez</title>
		<link>http://www.blog.dannynet.net/archives/59#comment-474</link>
		<dc:creator>Obie Fernandez</dc:creator>
		<pubDate>Mon, 27 Mar 2006 04:55:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.dannynet.net/archives/59#comment-474</guid>
		<description>&lt;strong&gt;More on Business DSLs in Ruby...&lt;/strong&gt;

This entry is mainly in response to  Danny, who
is pondering my description of writing DSLs in Ruby ... 
 He refers to some  questions
he left me as comments , asking how writing DSLs in Ruby
different from using XML/XSLT. It's really different ac...</description>
		<content:encoded><![CDATA[<p><strong>More on Business DSLs in Ruby&#8230;</strong></p>
<p>This entry is mainly in response to  Danny, who<br />
is pondering my description of writing DSLs in Ruby &#8230;<br />
 He refers to some  questions<br />
he left me as comments , asking how writing DSLs in Ruby<br />
different from using XML/XSLT. It&#8217;s really different ac&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

