Boo is an object oriented, statically typed programming language developed starting in 2003, which seeks to make use of the Common Language Infrastructure support for Unicode, globalization and web style applications, while using a Python-inspired syntax and a special focus on language and compiler extensibility. Some features of note include type inference, generators, multimethods, optional duck typing, macros, true closures, currying, and first class functions.
Boo is open source–licensed under an MIT/BSD style license.
Boo can be used together with Microsoft .NET and Mono.
Code samples
print "Hello, world!"
Fibonacci series generator function
def fib(): a, b = 0L, 1L while true: yield b a, b = b, a + b
import System.Windows.Forms import System.Drawing class MyForm(Form): def constructor(message as string): b = Button(Text: "Click Me") b.Location = Point(100, 50) b.Click += do(): MessageBox.Show(message) self.Controls.Add(b) f = MyForm("you clicked the button!") Application.Run(f)
Asynchronous design pattern with a closure
import System def run(): print("executing") print "started" result = run.BeginInvoke({ print("called back") }) System.Threading.Thread.Sleep(50ms) run.EndInvoke(result) print "done"
plusX = { a as int | return { b as int | return a + b }} print plusX(3)(4)
In English: "plusX is a function taking integer a, which returns another function taking integer b that returns a+b."
Edit: This isn't currying. This is just a function that returns a function. Currying would be something like:
def add(a as int, b as int):
return a + b
add_two = add(2)
Then, add_two would be a partially applied add, with a=2.
add_two(5)
Would set b=5, call the function, and return 7.
Which Boo cannot do.
See also
- IronPython - an implementation of Python for the .NET framework, similar to Jython.
External links
- Boo Homepage
- Boo Language Guide
- Boo Google discussion group
- Duck Typing - dynamic typing in boo
- "Gotchas" for Python users
- Boo Recipes, including: