On Learning Boo

Learning Boo

As part of my commitment to The Pragmatic Programmer’s exhortation to learn a new language every year, I decided to tackle Boo. My interest has been piqued by the work Oren is doing in DSLs with Boo. Learning Boo seemed to be an important first step to getting to grips with that.

The first step was to get an environment in which I could write and compile Boo programs. Now this is possible using a decent text editor like Vim, and command line tools like booc and booish, but it is also possible to use an IDE for this. I downloaded SharpDevelop which has support for authoring, building and debugging Boo projects.

To give myself a starting point I have decided to work through the Boo Primer as a way of getting to know the language

One aspect that jumps out is why Boo is called ‘wrist-friendly’. There is a lot of effort expended on giving you less to type. Although it is a statically typed language, Boo does away with the need to declare types before use. Instead Boo infers the type. C# programmers will find this similar to te use of var, without the need for the var keyword.

greeting = "Hello World" //This declares a string
houseNumber = 42 //This declares an integer

I’m always typing code of the form:

var myString = string.Format("Hello {0}", name);

in C#. Boo makes this a lot easier with string interning. I get to skip the string format statement, along with the seperation of placeholder and variable for

myString = "Hello ${name}"

The use of whitespace (Boo has a Python inspired syntax) to indicate a block is one of the early aspects of the language that strikes me. It makes for great natural language syntax, because it requires no block markers, but coming from a curly brace language “{}” like C# it takes a little for the fingers to get used to. I also seem to keep missing the colon off the end of the conditional

i = 5
if i > 0:
print "i is greater than 0"
if (i < 10):
print "i is less than 10"
if (i==5):
print "i equals 5"

One issue that hit me when working through the Boo Primer was that SharpDevelop disliked me trying to declare a list as follows:

L = List(range(5))

which gave me the error

ERROR: Generic types without all generic parameters defined cannot be instantiated.

Some digging on the Boo Programming Language mailing list established that Boo now has generics and it looks like the Boo interpreter in SharpDevelop uses that type over the non-generic type. Switching to use the generic collection instead, removed the error messages

L = List[of int](range(5))

The built in list initializer syntax seems to work in SharpDevelop though:

barfoo = ['abcdefghijkl']

I like the provision of initializer syntax for arrys, lists, and hashes within the language which provides for concise syntax

Overall I have spent an enjoyable half-a-day familiarizing myself with Boo’s syntax so far. One immediate advantage to learning Boo over say learning Ruby is that you are dealing with .NET libraries. So when you see Console.ReadKey(true) in a line of Boo code your existing knowledge tells you what it is doing. You are able to leverage existing framework skills and apply them to a new language. This speeds up the learning process, because having learnt the new syntax you can to put it to use fare more quickly.

Next time I’ll play with Boo’s methods and classes. Looking forward to it.


About Ian Cooper

Ian Cooper has over 18 years of experience delivering Microsoft platform solutions in government, healthcare, and finance. During that time he has worked for the DTi, Reuters, Sungard, Misys and Beazley delivering everything from bespoke enterpise solutions to 'shrink-wrapped' products to thousands of customers. Ian is a passionate exponent of the benefits of OO and Agile. He is test-infected and contagious. When he is not writing C# code he is also the and founder of the London .NET user group. http://www.dnug.org.uk
This entry was posted in .Net, Boo, Object-Orientation. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://cixtckzw.com/ Qcfnvjrt


  • http://www.ohiocolumbus.net Columbus Business Directory

    I found your site on google, great site, keep it up. Will return in the future. Submitted this post to Google News Reader. Please come visit my site Local Business Directory Of Columbus U.S.A. when you got time.

  • http://www.columbusunitedstates.com Columbus Business Directory

    As a Newbie, I am always searching online for information that can help me. Thank you. Please come visit my site Local Business Directory Of Columbus U.S.A. when you got time.

  • http://www.mailingshippingservices.com Find A Post Office

    I really liked your post on home financing! if you have more information elsewhere let me know. please visit my site Mailbox Locator when you got time.

  • http://www.directorynutritionists.com nutrition

    Hello, What enticed you to post this article. It was extremely interesting, especially since I was searching for info on this subject last Thursday. Feel free to check out my site healthy diet when you got time.

  • http://www.4444444444444444409hcvw0wvhm9p8hemc.com Preved

    Hmmm…, http://111111111tv0m0vttqay-7vt-vt0-mqva.com selfish 222222 [url=http://33333333333333333sfgwet.com]333333[/url]Thanks for the laugh!

  • RhysC

    Am keen to see your progress Ian. I picked up Boo a year or 2 ago and never got traction, life gets in the way… perhaps you will inspire me again. Always a good read :)

  • http://reverseblade.blogspot.com Onur Gumus

    There is also nemerle, which is very much like boo, supporting macros. Boo approaches to Python and Nemerle approaches to O’Caml.

    Check out :

  • http://thesoftwaresimpleton.blogspot.com/ Paul Cowan

    These last few comments made me laugh.

    Great to see how open minded some .NET developers are.

    Everything but everything should be written in C#.

    To hell with this damn new functional programming stuff and dynamic whatsit.

    We have everything we need in C# and it is not in any way insular to think this way. Ruby and rails is nothing more than a fad to take us away from webforms.

    @TD, what if functional programming is the way things will go. Does learning WF make you more marketable then?

  • TD

    I’m not sure the advice of learning a new language every year applies any more. I do agree it’s nice to think and solve problems using different languages. However, given to choice to either study a new language or to learn a new tool or technology like WCF, WF, ASP.NET MVC, etc, I’d pick the latter because it will make me more marketable.

  • Anonymous

    I think developers are treating programming languages like a damn fad now. I’ts “in” to try a new language or create one rather than improve one that’s already there! wtf Software development shouldn’t become a fad where people think it’s “cool” to post just about new shit or new languages. Damn, slow down.

  • Anonymous

    Good God, how many fucking languages do we need. F#, Boo, Foo, shoo

  • http://thesoftwaresimpleton.blogspot.com/ Paul Cowan

    I recently blogged on boo’s compiler extensibility.


    Things like quasi-quotation are what seperate boo from other .NET languages.

    I wrote a Dsl with boo and the same one in ironruby.

    I much prefered boo.

  • http://devlicio.us/blogs/sergio_pereira/default.aspx sergiopereira

    I think the purpose of the Pragmatic Programmers suggestion of learning a new language is not just because of the syntax. In that respect I think the fact that Boo is built for the .NET runtime and uses the .NET libraries becomes a disadvantage.
    Learning Python, for example, would allow you to explore different styles of writing APIs (not to mention it’s dynamically typed).
    That’s one of the reasons I’ve been avoiding IronRuby. I want to get proficient with Ruby (MRI) and then maybe add IronRuby.

  • Jeremy Gray

    Minor note in an otherwise nice read:

    re: “interning” in “Boo makes this a lot easier with string interning.” I believe you meant to say “Boo makes this a lot easier with string interpolation.”

  • Jack

    You need to look at your code – you have badly formatted BR tags there.

  • Paco

    @carlos: Yes, boo is like static typed iron python

  • http://twitter.com/carlosjmartinez carlos martinez

    good post. do you think that boo is a better option than ironpython? i guess the syntax is very similar, so is it simply a matter of preferring CLR/DLR?

  • http://codebetter.com/members/Ian-Cooper/default.aspx Ian Cooper

    I’m conscious that I need to sort out the code formatting. I’m not sure we have a Boo style sheet, I’ll investigate.