<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Boo</title>
        <link>http://www.ayende.com/Blog/category/498.aspx</link>
        <description>Boo</description>
        <language>en-US</language>
        <copyright>Ayende Rahien</copyright>
        <managingEditor>Ayende@ayende.com</managingEditor>
        <generator>Subtext Version 1.9.3.51</generator>
        <item>
            <title>Zero friction IoC: Auto registration is mandatory</title>
            <link>http://ayende.com/Blog/archive/2008/05/13/Zero-friction-IoC-Auto-registration-is-mandatory.aspx</link>
            <description>&lt;p&gt;This is the entire Binsor config file for a real application:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#0000ff"&gt;import&lt;/font&gt; Castle.MonoRail.Framework
&lt;font color="#0000ff"&gt;import&lt;/font&gt; Castle.MonoRail.WindsorExtension
&lt;font color="#0000ff"&gt;import&lt;/font&gt; Rhino.Commons.Facilities from Rhino.Commons.ActiveRecord

&lt;font color="#ff8000"&gt;facility&lt;/font&gt; MonoRailFacility
&lt;font color="#ff8000"&gt;facility&lt;/font&gt; RhinoTransactionFacility
&lt;font color="#ff8000"&gt;facility&lt;/font&gt; ActiveRecordUnitOfWorkFacility:
	assembly = "&lt;span style="color: #8b0000"&gt;HibernatingRhinos&lt;/span&gt;"

&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypesBased of IController("&lt;span style="color: #8b0000"&gt;HibernatingRhinos&lt;/span&gt;"):
	&lt;font color="#ff8000"&gt;component&lt;/font&gt; type.Name, type
	
&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypes("&lt;span style="color: #8b0000"&gt;HibernatingRhinos&lt;/span&gt;").WhereNamespaceEq("&lt;span style="color: #8b0000"&gt;HibernatingRhinos.Services&lt;/span&gt;"):
	&lt;font color="#ff8000"&gt;component&lt;/font&gt; type.GetServiceInterface(), type&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I am pretty confident that I am not going to have to do much in the future with those.&lt;/p&gt;

&lt;p&gt;And yes, you can do it with the fluent registration API as well. &lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10220.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/13/Zero-friction-IoC-Auto-registration-is-mandatory.aspx</guid>
            <pubDate>Tue, 13 May 2008 13:08:57 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10220.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/13/Zero-friction-IoC-Auto-registration-is-mandatory.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10220.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Binsor &amp;amp; Auto Registration - Making it even simpler</title>
            <link>http://ayende.com/Blog/archive/2008/05/13/Binsor-amp-Auto-Registration--Making-it-even-simpler.aspx</link>
            <description>&lt;p&gt;Here is the syntax that I am getting at...&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypesBased of IView("&lt;span style="color: #8b0000"&gt;Rhino.Commons.Test&lt;/span&gt;"):
	component type
	
&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypesWithAttribute of ControllerAttribute("&lt;span style="color: #8b0000"&gt;Rhino.Commons.Test&lt;/span&gt;"):
	component type
	
&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypes("&lt;span style="color: #8b0000"&gt;Rhino.Commons.Test&lt;/span&gt;") \
	.WhereNamespaceEq("&lt;span style="color: #8b0000"&gt;Rhino.Commons.Test.Binsor&lt;/span&gt;"):
	component type

&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypes("&lt;span style="color: #8b0000"&gt;Rhino.Commons.NHibernate&lt;/span&gt;") \
	.Where({ t &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; System.Type | t.Name.Contains("&lt;span style="color: #8b0000"&gt;NHRepository&lt;/span&gt;") }):
	component "&lt;span style="color: #8b0000"&gt;nh.repos&lt;/span&gt;", type.GetSeriveInterface(), type&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;And this seems to cover just about any scenario that I can think of. Combine that with Binsor's extend facility, and we are more or less done.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10219.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/13/Binsor-amp-Auto-Registration--Making-it-even-simpler.aspx</guid>
            <pubDate>Tue, 13 May 2008 05:21:51 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10219.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/13/Binsor-amp-Auto-Registration--Making-it-even-simpler.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10219.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Setting up MonoRail Windsor Integration with Binsor</title>
            <link>http://ayende.com/Blog/archive/2008/05/13/Setting-up-MonoRail-Windsor-Integration-with-Binsor.aspx</link>
            <description>&lt;p&gt;I think I'll let it stand on its own:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#ff8000"&gt;facility&lt;/font&gt; Castle.MonoRail.WindsorExtension.MonoRailFacility 
&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; type &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; AllTypesBased of Controller("&lt;span style="color: #8b0000"&gt;HibernatingRhinos&lt;/span&gt;"):
	&lt;font color="#ff8000"&gt;component&lt;/font&gt; type.Name, type&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Done.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I&lt;/em&gt; didn't believe it, to be fair. &lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10218.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/13/Setting-up-MonoRail-Windsor-Integration-with-Binsor.aspx</guid>
            <pubDate>Tue, 13 May 2008 04:17:17 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10218.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/13/Setting-up-MonoRail-Windsor-Integration-with-Binsor.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10218.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Course: Building Domain Specific Languages in Boo</title>
            <link>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx</link>
            <description>&lt;p&gt;You can &lt;a href="http://ayende.eventbrite.com/"&gt;register here&lt;/a&gt; for a two days course in building DSL with Boo.&lt;/p&gt;
&lt;p&gt;It is going to take place two weeks from today, in Austin. (19 - 20 May)&lt;/p&gt;
&lt;p&gt;I know that this is short notice, but it wasn't something that was planned well in advance. It came out of the ALT.Net conference.&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;&lt;strong&gt;Topics&lt;/strong&gt;:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Creating Domain Specific Languages&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;The Boo Language&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Flexible compiler and malleable language&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Creating applications with embedded DSL&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Management, tracing and debugging&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Tooling support&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Testing and maintainability concerns&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;There are ten seats open for that.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;I hope we would have fun.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;I would also like to thank &lt;a href="http://codebetter.com/blogs/jeffrey.palermo/"&gt;Jeffrey Palermo&lt;/a&gt; and &lt;a href="http://www.headspringsystems.com/"&gt;Headspring&lt;/a&gt; for hosting the course.&lt;/span&gt;&lt;/p&gt;
&lt;img src="http://ayende.com/Blog/aggbug/10210.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx</guid>
            <pubDate>Tue, 06 May 2008 01:33:54 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10210.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10210.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DSL Article on InfoQ</title>
            <link>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx</link>
            <description>&lt;p&gt;&lt;img src="http://www.infoq.com/resource/articles/dsl-on-the-clr/en/smallimage/image_boo.jpg" width="100" height="100" alt="image_boo.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;My DSL article has been published on InfoQ!&lt;/p&gt;
&lt;p&gt;You can get it &lt;a href="http://www.infoq.com/articles/dsl-on-the-clr"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://ayende.com/Blog/aggbug/10189.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx</guid>
            <pubDate>Mon, 21 Apr 2008 16:10:20 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10189.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10189.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Loop unrolling in Boo</title>
            <link>http://ayende.com/Blog/archive/2008/04/02/Loop-unrolling-in-Boo.aspx</link>
            <description>&lt;pre&gt;&lt;span style="color: #008000"&gt;// We create a class for the macro, the class name is&lt;/span&gt;
&lt;span style="color: #008000"&gt;// meaningful, [macro name]Macro allows us to later refer&lt;/span&gt;
&lt;span style="color: #008000"&gt;// to the macro using just [macro name].&lt;/span&gt;
&lt;span style="color: #008000"&gt;// Note that we inherit from AbstractAstMacro&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; UnrollMacro(AbstractAstMacro):

	&lt;span style="color: #008000"&gt;// Here we perform the actual compiler manipulation&lt;/span&gt;
	&lt;span style="color: #008000"&gt;// the compiler hands us a macro statement, and we have&lt;/span&gt;
	&lt;span style="color: #008000"&gt;// to return a statement back, which will replace it.&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;override&lt;/span&gt; def Expand(macro &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; MacroStatement) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; Statement:
	
		&lt;span style="color: #008000"&gt;// define a block of code&lt;/span&gt;
		block = Block()
		
		&lt;span style="color: #008000"&gt;// extract the second parameter value&lt;/span&gt;
		end = cast(IntegerLiteralExpression, macro.Arguments[1]).Value
		
		&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; range(end):
			&lt;span style="color: #008000"&gt;// create assignment statement, using the block: trick &lt;/span&gt;
			&lt;span style="color: #008000"&gt;// and add it to the output&lt;/span&gt;
			statements = [|
				block:
					$(macro.Arguments[0]) = $i
			|].Block
			block.Add(statements)
			
			&lt;span style="color: #008000"&gt;// add the original contents of the macro&lt;/span&gt;
			&lt;span style="color: #008000"&gt;// to the output&lt;/span&gt;
			block.Add(macro.Block)
			
		&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; block&lt;/pre&gt;

&lt;pre&gt;And usage:&lt;/pre&gt;

&lt;blockquote&gt;
  &lt;pre&gt;unroll i, 5:
	print i&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;font face="Courier New"&gt;Which will produce:&lt;/font&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;i = 0
print i
i = 1
print i
i = 2
print i
i = 3
print i
i = 4
print i&lt;/pre&gt;&lt;/blockquote&gt;&lt;img src="http://ayende.com/Blog/aggbug/10155.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/04/02/Loop-unrolling-in-Boo.aspx</guid>
            <pubDate>Wed, 02 Apr 2008 10:05:58 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10155.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/04/02/Loop-unrolling-in-Boo.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10155.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The quote generation DSL</title>
            <link>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx</link>
            <description>&lt;p&gt;I am doing some work on the DSL book right now, and I run into this example, which is simple too delicious not to post about.&lt;/p&gt;  &lt;p&gt;Assume that you have the following UI, which you use to let a salesperson generate a quote for your system. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ThequotegenerationDSL_1A0C/image_2.png"&gt;&lt;img height="278" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ThequotegenerationDSL_1A0C/image_thumb.png" width="299" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is much more than just a UI issue, to be clear. You have fully fledged logic system here. Calculating the total cost is the easy part, first you have to understand what you need.&lt;/p&gt;  &lt;p&gt;Let us define a set of rules for the application, is will be clearer when we have the list in front of us:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The Salary module requires a machine per every 150 users. &lt;/li&gt;    &lt;li&gt;The Taxes module requires a machine per 50 users.&lt;/li&gt;    &lt;li&gt;The Vacations module requires the Scheduling Work module.&lt;/li&gt;    &lt;li&gt;The Vacations module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Pension Plans module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Pension Plans module must be on the same machine as the Health Insurance module.&lt;/li&gt;    &lt;li&gt;The Health Insurance module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Recruiting module requires a connection to the internet, and therefore requires a fire wall of the recommended list.&lt;/li&gt;    &lt;li&gt;The Employee Monitoring module requires the CompMonitor component&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Of course, this fictitious sample is still too simple, we can probably sit down and come up with fifty or so more rules that we need to handle. Just handling the second level dependencies (External Connections, CompMonitor, etc) would be a big task, for example.&lt;/p&gt;  &lt;p&gt;Assume that you have not a single such system, but 50 of them. I know of a company that spent 10 years and has 100,000 lines of C++ code (that implements a poorly performing Lisp machine, of course) to solve this issue.&lt;/p&gt;  &lt;p&gt;My solution?&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @vacations:
	&lt;font color="#800000"&gt;requires&lt;/font&gt; @scheduling_work
	&lt;font color="#800000"&gt;requires&lt;/font&gt; @external_connections
	
&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @salary:
	&lt;font color="#800000"&gt;users_per_machine&lt;/font&gt; 150
	
&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @taxes:
	&lt;font color="#800000"&gt;users_per_machine&lt;/font&gt; 50

&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @pension:
	&lt;font color="#800000"&gt;same_machine_as&lt;/font&gt; @health_insurance&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why do we need a DSL for this? Isn’t this a good candidate for data storage system? It seems to me that we could have expressed the same ideas with XML (or a database, etc) just as easily. Here is the same concept, now express in XML.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"vacation"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requires&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"scheduling_work"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requires&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"external_connections"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"salary"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;users&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_per_machine&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"150"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"taxes"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;users&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_per_machine&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"50"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"pension"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;same&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_machine_as&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"health_insurance"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a one to one translation of the two, why do I need a DSL here?&lt;/p&gt;

&lt;p&gt;Personally, I think that the DSL syntax is nicer, and the amount of work to get from a DSL to the object model is very small compared to the work required to translate to the same object model from XML.&lt;/p&gt;

&lt;p&gt;That is mostly a personal opinion, however. For pure declarative DSL, we are comparable with XML in almost all things. It gets interesting when we decide that we don’t want this purity. Let us add a new rule to the mix, shall we?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Pension Plans module must be on the same machine as the Health Insurance module, if the user count is less than 500.&lt;/li&gt;

  &lt;li&gt;The Pension Plans module requires distributed messaging backend, if the user count is great than 500.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trying to express that in XML can be a real pain. In fact, it means that we are trying to shove programming concepts into the XML, which is always a bad idea. We could try to put this logic in the quote generation engine, but that is complicating it with no good reason, tying it to the specific application that we are using, and in general making a mess.&lt;/p&gt;

&lt;p&gt;Using our DSL (with no modification needed), we can write it:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @pension: 
	&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; information.UserCount &amp;lt; 500: 
		&lt;font color="#800000"&gt;same_machine_as&lt;/font&gt; @health_insurance 
	&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;: 	
		&lt;font color="#800000"&gt;requires&lt;/font&gt; @distributed_messaging_backend&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can imagine, once you have run all the rules in the DSL, you are left with a very simple problem to solve, with all the parameters well known.&lt;/p&gt;

&lt;p&gt;In fact, &lt;em&gt;throughout the process&lt;/em&gt;, there isn't a single place of overwhelming complexity.&lt;/p&gt;

&lt;p&gt;I like that.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10143.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx</guid>
            <pubDate>Sun, 30 Mar 2008 22:51:21 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10143.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10143.aspx</wfw:commentRss>
        </item>
        <item>
            <title>A web server in 30 lines of code</title>
            <link>http://ayende.com/Blog/archive/2008/03/30/A-web-server-in-30-lines-of-code.aspx</link>
            <description>&lt;p&gt;Just found myself writing that, and it was amusing.&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;span style="color: #0000ff"&gt;import&lt;/span&gt; System.Net
&lt;span style="color: #0000ff"&gt;import&lt;/span&gt; System.IO

&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; argv.Length != 2:
	&lt;span style="color: #0000ff"&gt;print&lt;/span&gt; "&lt;span style="color: #8b0000"&gt;You must pass [prefix] [path] as parameters&lt;/span&gt;"
	&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;prefix&lt;/span&gt; = argv[0]
&lt;span style="color: #0000ff"&gt;path&lt;/span&gt; = argv[1]

&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; not Directory.Exists(&lt;span style="color: #0000ff"&gt;path&lt;/span&gt;):
	&lt;span style="color: #0000ff"&gt;print&lt;/span&gt; "&lt;span style="color: #8b0000"&gt;Could not find ${path}&lt;/span&gt;"
	&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;

listener = HttpListener()
listener.Prefixes.Add(&lt;span style="color: #0000ff"&gt;prefix&lt;/span&gt;)
listener.Start()

while true:
	context = listener.GetContext()
	file = Path.GetFileName(context.Request.RawUrl)
	fullPath = Path.Combine(&lt;span style="color: #0000ff"&gt;path&lt;/span&gt;, file)
	&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; File.Exists(fullPath):
		context.Response.AddHeader("&lt;span style="color: #8b0000"&gt;Content-Disposition&lt;/span&gt;","&lt;span style="color: #8b0000"&gt;attachment; filename=${file}&lt;/span&gt;")
		bytes = File.ReadAllBytes(fullPath)
		context.Response.OutputStream.Write(bytes, 0, bytes.Length)
		context.Response.OutputStream.Flush()
		context.Response.Close()
	&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;:
		context.Response.StatusCode = 404
		context.Response.Close()&lt;/pre&gt;&lt;/blockquote&gt;&lt;img src="http://ayende.com/Blog/aggbug/10141.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/30/A-web-server-in-30-lines-of-code.aspx</guid>
            <pubDate>Sun, 30 Mar 2008 19:35:15 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10141.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/03/30/A-web-server-in-30-lines-of-code.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10141.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Short yet interesting: in search of a sample</title>
            <link>http://ayende.com/Blog/archive/2008/03/06/Short-yet-interesting-in-search-of-a-sample.aspx</link>
            <description>&lt;p&gt;One of the feedback points that I got about the book was that there need to be a fully working Boo program, before we start to introduce the DSL ones. The problem? I can't think of anything that will be both interesting and short enough to put into a book.&lt;/p&gt;  &lt;p&gt;My limit is at about two pages, and I don't want a tedious example. Any suggestions?&lt;/p&gt;  &lt;p&gt;One major point, it should have as little background assumptions as possible. &lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10086.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/06/Short-yet-interesting-in-search-of-a-sample.aspx</guid>
            <pubDate>Thu, 06 Mar 2008 16:38:43 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/03/06/Short-yet-interesting-in-search-of-a-sample.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10086.aspx</wfw:commentRss>
        </item>
        <item>
            <title>From BooBS to Bake</title>
            <link>http://ayende.com/Blog/archive/2008/01/26/From-BooBS-to-Bake.aspx</link>
            <description>&lt;p&gt;Okay, I renamed Boo Build System to Bake. Now you can cut the jokes and actually integrate it into a PC environment. &lt;/p&gt; &lt;p&gt;The repository is &lt;a href="http://boo-build-system.googlecode.com/svn/trunk/"&gt;here&lt;/a&gt;, although you can just grab the &lt;a href="http://boo-build-system.googlecode.com/svn/trunk/bin"&gt;binaries&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/FromBooBStoBake_14636/image_2.png"&gt;&lt;img height="236" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/FromBooBStoBake_14636/image_thumb.png" width="489" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10026.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/01/26/From-BooBS-to-Bake.aspx</guid>
            <pubDate>Sat, 26 Jan 2008 21:11:48 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/01/26/From-BooBS-to-Bake.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10026.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>