Mathematics and Computation

May 7, 2008

An object-oriented language Boa

Filed under: plzoo, software — Andrej Bauer @ 00:32

I have added another language, called Boa, to the Programming Languages Zoo. It is an object-oriented language with the following features:

  • integers and booleans as base types,
  • first-class functions,
  • dynamically typed,
  • objects are extensible records with mutable fields,
  • there are no classes, instead we can define “prototype” objects and extend them
    to create instances.

In many respects the language is a bit like a combination of Python and Javascript, which explains its name. It was interesting to see the students’ reaction to the language. The only object-oriented language they knew previously was java, so the lack of classes bothered them. They were amused by the fact that since “everything is an object” we can extend an integer with a function to get an object which behaves both as an integer and as a function (we did not learn about intersection types), like this:

Boa> let x = 42 with (fun x -> x + 1000)
x = 42 with <fun>
Boa> x + 10
52
Boa> x 17
1017
Boa> x x
1042

Isn’t that cute?

2 Comments »

  1. Did you mean a combination of Python and Lua, because that’s what it sounds like, and it would be a closer match, with the snaky reference like Python and the short spelling and sound of Lua. Plus boas are populous in Brazil, the home of Lua.

    Comment by BMeph — November 11, 2008 @ 23:58

  2. I mentioned javascript because I thought more people knew that javascript had “objects without classes”. I did not actually know where boas came from. Thanks for letting me know.

    Comment by Andrej Bauer — November 17, 2008 @ 01:20

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress

Listed on BlogShares