The Boo Language
So, what is this Boo language anyway? I am talking about it fairly often, but I never explained, and I am going to assume that people aren't following links :-)
Boo is an object oriented, statically typed language for the common language runtime with a Python inspired syntax and focused on language and compiler extensibility.
Boo is an Open Source project, released under the BSD license. This means that you are free to take, modify and use the language and its products in any way you want, without any limitation[1]
. Rodrigo B. de Oliveira started the project, and since then grown in popularity. The project is active and continually evolving. At the time of the writing, the released version of Boo is 0.8.
However, Boo seems to be following the trend of many open source projects, in that that it is not really rushing toward 1.0 release. Boo has been around for a number of years, and I have been using it for production for the last two years.
Production, in this case, means systems that move money around with my neck on the line. I have a high degree of trust in it, obviously.
Beyond being a really malleable language, suitable for DSL. Boo is also a nice language to work with for day-to-day tasks. The SharpDevelop IDE project has support for Boo, so you get the usual benefits. There is an ongoing project to support Boo in Visual Studio, and I have an active interest in seeing support for that being established. I don't much care for which IDE, but I want a standard, checklist driven way of getting a language running.
Here is a secret, I tend to think and write in Boo, translating down to C# because I have to. Boo is a far more flexible language, and the ability to reprogram the compiler makes tedious tasks in other languages an amusing challenge. Those same tedious problems are usually overcome, to some degree, by throwing code generation at the problem until it goes away.
In Boo, we would usually tell the compiler how we want to handle this, and let the compiler take over from there. This is similar to code generation, except that this is done at the compiler level, which means that we have far more knowledge about what is going on.
For example, let us say that we want to implement the singleton pattern. We need to do quite a bit of work to make it happen. Ensure that creating the singleton is thread safe, lazy initialization, make all the constructors private, ensure that serializable singleton remain singleton through serialization/deserialization, create static Instance property, have no static members on the singleton class.
To do this in most language we would have to follow an implementation pattern and write fairly repetitive code. In Boo, we can capture this usage pattern in an AstAttribute (more on that later) that will do all of that for us, at the cost of a single attribute declaration.
Similar capabilities allow correct usage of disposable, observable, and more advance techniques such as aspect oriented programming.
Some of the capabilities that Boo has can be had using IL Weaving tools such as PostSharp. The problem with those is that using them is something that happens after compilation. As a simple example, you would not be able to create a singleton in this manner, because you would not be able to generate the Instance property at the appropriate time.
Assuming that you want to use the singleton in the same assembly as it was defined, you will not be able to reference the Instance property, it will not exist until the post compile step has run. Boo, however, does this at compile time, so by the time the compiler get to the point where it is resolving the property, it has already been added.
In short, I really like the language and what it allows me to do.
[1] Well, if you are interested in creating a new language called Ba, you probably would want to make it clear where the project ancestry came from…
Comments
"There is an ongoing project to support Boo in Visual Studio..."
Which one? I'm very interested in it too since (especially with Binsor) my usage of Boo is always increasing and the scenarios get more and more complex...
How can one support this project?
http://developer.novell.com/wiki/index.php/Boo_language_package_for_Visual_Studio_2005
It was stopped for a long while, but recent interest has arisen in it.
If you are interested in helping, please post to the boo mailing list. I am very interested in getting this working
I found this document really clarifying why you'd want yet another language and what problems Boo solves:
http://boo.codehaus.org/BooManifesto.pdf
Nice post! Bumped to the boo homepage.
There's so many things to love about Boo, for one, I like having an .NET interactive interpreter to prototype ideas in a flash.
In all seriousness, is there any reason why you actually don't do your entire apps in boo? (you mention you sort of think in boo and translate to C#, wondering why just not stick to boo). Is this more of a political/business/team issue, or is there any technical reasons you chose not to?
Two major reasons,
1/ There seems to be a strong push against not using C#
2/ R#
The first reason is much bigger, though.
Boo is cool. but the compiler stuff is not too well documented.
Everybody hates Microsoft for its undocumentation called MSDN, but i haven't seen yet an oss project with decent documentation covering intermediate features.
Boo doesn't stand up in this regard.
If you are passionate you can loose valuable time digging in the source code, but i think it is a waste of time.
Liviu,
Feel free to submit documentation for the compiler.
Boo looks really interesting and powerful. And I like your boo ghost, and I'm thinking it would advantageously replace the current Boo logo which needs a refresh :-)
The Boo concept really is nice.
I'd like to comment on your example, implementing a reusable singleton. This can easily be achieved in C# with generics and inheritance, as this article shows:
http://flois.blogspot.com/2006/02/fun-with-singletons-in-c-20-part-1.html
http://flois.blogspot.com/2006/02/fun-with-singletons-in-c-20-part-2.html
(You can also find the code for download on Code Project).
You even get your choice of singleton types. Just inherit from WhateverSingleton<T>. Done.
But of course, compile-time hacking is powerful and I'm sure it's easy to find a more complicated example where it is helpful.
Roy,
take a look at things like [Disposable] attribute, which automatically implement the best practices for IDisposable implementation.
This was a very simple example.
Comment preview