Ayende @ Rahien

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

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 18 | Comments: 82

filter by tags archive

Domain Specific Language: Losing the original language

time to read 1 min | 183 words

Here is an interesting question, at what point you drive away so far from the original language that you lose the benefits of an internal DSL?

The following examples are several ways to represent the same thing, going from the extreme DSL to the no DSL to C#. I think that they all have value, and neither cross that line, but I believe that they will help make the point. The example here is a a simple MonoRail Controller:

#1:

controller Field:
    action Tag:
           @defaultTags = [ "green", "trees", "growth" ]

#2:

controller Field:
    def Tag():
         @defaultTags = [ "green", "trees", "growth" ]

#3:

controller Field:
    def Tag():
          PropertyBag["defaultTags"] = [ "green", "trees", "growth" ]

#4:

class FieldController(Controller):
   def Tag():
          PropertyBag["defaultTags"] = [ "green", "trees", "growth" ]

#5:

public class FieldController : Controller
{
	public void Tag()
	{
		PropertyBag["defaultTags"] = new string[] { "green", "trees", "growth" };
	}
}

Any comments?


Comments

Arne Claassen

I guess I'm not sure that i'd agree that driving an internal DSL away from the original language is a bad thing. For me i'd go with 1 or 5. The inbetween ones seem like they compromise the clarity of the DSL in order to fit better into the internal language, which lends confusion as to what is DSL and what is native syntax that can be used for other things.

Markus Zywitza

I disagree. All DSL grades can be useful, provided that it is possible to do something else than specifying property bags params with it.

The example above shows only the syntactic sugar, but the question is, how much logic support them. Any of #1 to #4 is completely useless if only a handful of commands are possible.

OTOH, if they allow the full power of boo, all of them are useful, no matter where you have to write def, action, class or controller.

I don't comment on MonoRail with C#. It simply works :-)

Ayende Rahien

All of them allows you to use boo, yes.

the question is if this adds value or does it subtract it? Does the desire to work in the terms of MVC subtract from the value in understand what the code does?

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. The insidious cost of allocations - 8 hours from now
  2. Buffer allocation strategies: A possible solution - 3 days from now
  3. Buffer allocation strategies: Explaining the solution - 4 days from now
  4. Buffer allocation strategies: Bad usage patterns - 5 days from now
  5. The useless text book algorithms - 6 days from now

And 1 more posts are pending...

There are posts all the way to Sep 11, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    03 Sep 2015 - The industry at large
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats