Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,007 | Comments: 44,760

filter by tags archive

DSL Support for Brail

time to read 4 min | 732 words

First things first, Harris Boyce III has done all the work, my sum contribution to this feature has included some wild cheering from the side lines.

That said, this is one cool feature. Let us explore it.

There are a lot of people who consider anything resembling <html> tags to be a mess, associate them with ASP Classic mistakes, and reject them out of hand. I think that this is a mistake, but I gave up changing the whole world overnight, now I have busy formulating three steps plans that takes a week...

At any rate, consider this output:


How would we generate this output using Brail? The classic approach is:

                       component Grid, {"source": names}:
                         	section header:
                                    output "<tr><th>Names</th><tr>"
                             	section item:
                        	    output "<tr><td>${item}</td><tr>"
?> </body> </html>

This works, but it not really Jump-Up-And-Down-All-Excited code. And, of course, some people faint dead away from having to deal with raw HTML, "Give me my components or give me death!"

Now, here is the DSL way of doing it:

dsl Html:
		component GridComponent, {"source" : names}:
			section header:
						text "Names"
			section item:
					text item

And this baby produces the same output as the previous one.

Now, you are probably aware that I am not really fond of raising the abstraction level needlessly, so why is this a good thing? Well, because it means that you can now do stuff like this:

               text "some content"

And it will be able to produce semantically correct ATOM feed. (To be exact, it would be if we had an AtomExtension implementation to the new IDslLanguageExtension interface, which we currently don't have).

There are some quirks in the implementation, but it is a very cool direction to go to.



Nice! And I see it is already in the trunk, I will have to play with that later today!

Dave Newman

Still not as nice as haml:


If i worked in monorail i would definitely create a haml view engine. And sass too

Markus Zywitza

Given the fact, that html and body tags are usually part of the layout and not of the view itself, the first example is rather strange, as the bulk HTML generation is already done in a component (Grid).

Second, when I remember how much pain it is to generate a simple link with MonoRails helper, I'm fine with HTML most of the time, but as you said, there are people who start shivering when their eyes catch angled brackets...

Ayende Rahien

You can use it with the layout as well, and the tests has a sample of using that.

I just wanted to show a complete example

El Guapo

I want to like Monorail / Brail / Boo, but I just don't see the value.

I don't want to spend another n cycles learning a new programming language that is off the beaten path and seems to be champtioned by rebellious malcontents. Especially when new things that I am burning valuable time learning seem to obsolete the whole rationale behind Boo itself anyway. Things like inferred delegates, things like type inference, I'm reading the "Boo Manifesto" and it seems like this stuff has already been address by MS in .NET 3.5

Please convince me I'm wrong? I must be missing something, but what?

Ayende Rahien

rebellious malcontents

I take offense at that, to tell you the truth.

If you think that .Net 3.5 gives you all of that, feel free to use that, I have looked at that, and I am not seeing the option to make it work with the flexibility that I need to have. C# 3.0 has a few crumbles of this stuff, Boo has boat loads of it, and it is a significant difference.

El Guapo

Sorry, no offense intended at all and I didn't mean that to be written that way. I was just trying to make an observation (using the observer pattern) and didnt express myself well (I will try expression blend)


I think the main fun of this is on xml generation. I agree with Ayende that in most cases HTML does not require such hassle. But in generating hierarchical document like xml, dsl like this has a lot of value. The fact is such script is way more easy to understand and use than using XmlWriter stuff.

By the way, El, have you seen rxml from RoR? I think if you read that before you would pick up what Ayende said easier on this particular example.

Chris Ortman

My magic 8-ball says I will create a FormBuilder dsl with this.

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Speaking (3):
    23 Sep 2015 - Build Stuff 2015 (Lithuania & Ukraine), Nov 18 - 24
  2. Production postmortem (11):
    22 Sep 2015 - The case of the Unicode Poo
  3. Technical observations from my wife (2):
    15 Sep 2015 - Disk speeds
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats