Friday 15 February 2008

BOO Who?

Anybody that reads Ayede Rahien's blog will notice that he is writing a book called Building Domain Specific Languages with BOO. What? BOO? What the hell is BOO? I am a big fan of Anede and quickly wanted to get up to speed with BOO and what it is all about. Most of the my initial reading was taken right off the BOO website.

Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility.
GREAT! I Love python's syntax! Who needs all those brackets anyway. But why do we need a whole new language to do Domain Specific Programming? And wait, what's up with Iron Python are these two not destine to clash? What am I not understanding here?

IronPython is not a take on Python it is just a reimplementation of python, where as BOO is completely different Language that is based off python syntax. Boo is statically typed, while IronPython is dynamical typed. OK, they are not even close to the same thing. Its another one of the those classic programming examples where upon first glance something that looks like a snake and moves like a snake but is actually some type of Duck.

OK! Then the difference has to be with the fact it is a Domain Specific Language. Hmmm "Domain Specific" I think I know what that means... but do I?? I mean I have heard the term thrown around and thought I had a grasp on it. I must still be missing something.....

Martin Fowler says
Domain specific language (DSL) is a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of
software problem.
OK well that is kind of what I thought. SO if company XYZ has a corporate policy that all phone numbers have to be 3 digits, why wouldn't I just create a method or an even better an extension method. Seems pretty straight forward...

But Wait is that really a DSL? If you dig into it there are 4 types of DSL(From Chapter one of building DSL's) External, Graphical, Fluent and Internal/Embedded. OK now we are getting into it.

  • External is specifying everything from how an If statement works to operator semantics.
  • Graphical is a DSL that is not textual, but rather uses shapes and lines in order to express intent
  • Fluent - are interfaces are a way to structure your API in such a fashion that operations flow in a natural manner.
  • Embedded - Internal DSL are built on top of an existing language, but they don’t try to remain true to the original programming language syntax. They try to express things in a way that would make sense to both the author and the reader, not to the compiler.
Ayede Says:
Extension methods and lambda expression will certainly help, but they will not change the fundamental syntax too much. There are better alternatives for writing Domain Specific Languages than C#.
A DSL should be readable for someone who is familiar with the domain, not the programming language. A DSL built on top of an existing language can also be problematic, since you want to limit the options of the language, in order to make it clearer in what is going on, rather than turn the DSL into a fully fledged programming language; we already have that in the base language, after all. The main purpose of an internal DSL is to reduce the amount of stuff that you need to make the compiler happy, and increase the clarity of the code in question.

So what does this all mean? Well it means he sold another book....

No comments:

Post a Comment