TOM is probably one of the
coolest languages around. It is based heavily on
Objective-C with some cleaned up
syntax and added features. It's main goal is to be
extensible, very extensible. Some of the basic
features are:
- Extensibility of objects, even at runtime. That's right, you can extend a class at runtime. This adds some cool possibilities, for example you could extend a binary only library in your program.
- An extension can add methods, variables, and even superclasses to a class
- support for default argument values and multiple return values
- multiple inheritance. This could be good or bad depending on which side of the issue you are on
- lots of reflection on objects including classes, member variables, and methods
- garbage collection and distributed objects
- GTK and Gnome support
- methods can contain C code
- An Apache TOM module exists to allow apache modules written in TOM
- TDBC (The TOM DataBase Connectivity) allows database access, currently only PostgreSQL.
- The Tools are GPL, the libraries LGPL'd.
The syntax of TOM most closely resembles Objective-C with some differences. As an example, here is a simple Hello Word program.
implementation class HelloWorld
int main Array argv
{
print "Hello, world!" nl];
}
end;
The first line defines a class called HelloWorld, and is preceded by implementation meaning that the following code (up to end;) is the implementation of the class. The implementation may contain methods and variables. In this case, we simply define a method called main which returns int and takes an argument of type Array.
Our method consists of one line, which contains three nested messages. Like Objective-C, methods as passed in TOM with the syntax reciever message. For the inner message (stdio out), we send the message "out" to the object "stdio" which manages all input and output. This in turn calls the out method of the stdio object, which returns an OutputStream object. We could assign this to a variable, but instead we use nested messages and send the returned object the message "print "Hello, world!". This calls the "print" method of the OutputStream object, and passes along a string argument of "Hello, world!". As you can probably guess, this prints out the string. Then we send nl which flushes any output and starts a new line.
TOM's homepage exists at http://gerbil.org/tom. There is a wealth of excellent documentation and example code there, well worth checking out.