Skip to end of metadata
Go to start of metadata

"Hello, Boo!"

This tutorial assumes you have basic computing knowledge and are comfortable with the command line interface of your operating system. If you're familiar with programming in general, you might just want to browse the code snippets and ignore the rest of the article in general.

*Things required:
*A .NET runtime - either Microsoft's .NET Runtime on Windows, or Mono on Linux.
*Your favorite text editor.
*Being comfortable with the command-line, for now.
*Free time.

Before we even get started, its time to show you the obligatory "Hello, world!" application. Every language tutorial has them, and Boo is no exception! Everybody's gotta start somewhere.

Crack open Your Favorite Text Editor.
On the very first line, type,

Save the file as, and make a note of the directory its been saved in.
Go to the command prompt and find the directory you installed Boo into, and go to the bin subdirectory. /boo/bin, if you will!

Now, type,

You'll see "Hello, world!" printed on screen. Welcome to Boo.

"What is this 'print' thing?"

Print is an expression in Boo that is used to feed output to a device called "Standard Output."
Ignoring the concept of "Standard Output" completely, what it means (for now) is that the "print" expression will just show text in the console, like you just saw with the hello world program.

"Hello, $name"

What if we want to get really specific - what if we want to print out someone else's name instead of just saying hello to the entire freaking planet, eh? We could, of course,

but everytime we wanted to say hello to someone new, we would be in quite a quandary!

But, never fear, for your hero is here, and he will now show you how to read input from the user - don't worry, its really easy and you don't have to worry about it. Crack open and replace its contents with,

and save the file.

We'll break it down line-by-line in a second, but for now, run "booi" just like you did before, and stare in awe: nothing's happening! All there is is a blinking cursor! Type your name and press enter. I typed "Bongo," because I'm a freak.

Neat, eh, but what happened?

System is a namespace - its like a box with lots of delicious snacktreats in it, or, if you're on a diet, like a box full of slightly stale protein bars. The "Console" class is one of these delicious treats, just waiting to be plucked from the box. We could have accessed the "Console" class by using "System.Console," but we didn't - why?
Using the "import" keyword is a way of saying, "dump all the contents of the System namespace into my file so I don't have to keep typing the namespace, 'System,' before everything." Why would you do this? Because you're lazy, that's why.

Here you are doing two things - you are calling a member of the "Console" class, called "ReadLine()", and storing a value it returns into "name." ReadLine() is a method that waits for the user to type something and press enter, and returns a string of characters. This string goes into the "name" object. Thus, were the user - an upstanding citizen such as yourself - to type "Bongo," then "name" would now have the contents "Bongo" after the user pressed the enter key.

This is the easiest part of the program - its called "String Interpolation" The curly brace symbols essentially mean, 'embed this object inside of this string,' so when you write "$name" you are really saying, "replace $name with the contents of name." Since we typed in "Bongo" earlier and stored that in the name variable, instead of seeing "Hello, $name" printed on the screen we will instead see, "Hello, Bongo." Take special note: using $<object> actually calls a special member that every object has, called, 'ToString()' - this member returns a string that represents a formatted description of the object. Not all classes implement their own custom ToString() member, so you might see something strange like 'System.DateTime' instead of the actual date and time.

*Create a program that reads in the user's name and prints outs something like, "Your name is $name. Hello, $name!" except that $name is replaced with the user's name.
*Create a program that reads in the user's first name, and then the user's last name, and print them together, like, "Your name is $firstname $lastname." You'll need at least two variables, and if you just read the last sentence, you'll probably have an inkling of how to do it. Re-examine the

program if you are feeling lost.

*Tip: There are many more classes available in the System namespace - go to Microsoft .NET Class guide and check out the namespaces available - there are tons of classes inside! Remember to use "import" or else you'll be typing System.Console" all year long.

  • No labels


  1. As a next step, I'm trying to get the Hello World recipe working using WinForms. But when I try "import Windows.Systems.Forms" I get a Namespace error message suggesting "maybe you forgot to add an assembly reference." What step am I missing?

    (I'm quite experienced with Python and understand COM but I'm new to dotNET. I've got the dotNET 1.1 redistributable and SDK installed here on WinXP SP2. For boo itself I'm using


  2. Ok, I've dug in deeper and I'm learning. One discovery is the difference between the contents of and I had intially installed only the latter. Then I experimented and learned that contains a full distribution.

    So with a full install I've found the various hello scripts in the examples folder. One thing I learned is to use "import System.Windows.Forms from System.Windows.Forms" not just "import System.Windows.Forms".

    Another ah-ah is the importance of using booi not booish. So now the hello world examples work. And booc makes .exe's – very nifty.


  3. Oh brother – as the fog starts to clear I realize I got totally confused about and I'll get this straight yet.


  4. Hi, when you are compiling a boo script with booc, you need to add a reference to the System.Windows.Forms.dll. You can do this either on the command line (booc -r:System.Windows.Forms.dll -out:myscript.exe, or in your script change your import line to this: import System.Windows.Forms from System.Windows.Forms

    Also things have been changing so fast that you might want to get tortoisesvn and download the source from the SVN repository, see:

    And one last thing. If you want you can skip all the above and get the boo add-in (download the installer from that page) for the free SharpDevelop IDE. Then you don't have to use booc directly, and also that installer is very recent so it will have the newer features in boo.

  5. I forgot to mention, I didn't see your comments until today. If you send any questions you have to the Mailing Lists we can answer them quicker.