The Ita Programming Language
The applications and the operating system for the computer have been written
in a custom high level language. The language looks quite similar to the
"curly brace" languages like C++/C#/Java.
Features
- safe/unsafe code
- Garbage Collection
- Classes & Go Style Interfaces
- Co-routine support
- Array Types
- Delegates
- All types have reflection information available
Although there are several relatively advanced features, the language
is quite simple in other ways. For example the only primitive type in the
language is a 32bit integer type. More complex types must be created
by composing Objects or integers.
The language also tends to avoid the use of special syntax or keywords
when the functionality can be achieved through other mechanisms. This choice
was taken because it simplified the parser/grammar for the language and some
other aspects of implementing the system. Instead, several "intrinsic" functions
and methods are used to achive the same results.
Instead of having class constructors, classes are expected (but not required)
to have static 'Init' methods that create a new instance of the class. Internally
the Init methods make use of the 'New' intrinsic method to create a new uninitialized
instance of the class which is initialized before being returned. This
implementation avoids language support for constructors, and eliminates special
keywords like new.
Although reflection API's are not currently implemented, the compiler generates
the required meta data for each type. This information is very useful because
it allows for accurate garbage collection. Even though reflection API's
are not available, they should be quite easy to implement.
Unsafe code is also very important because it allows for the runtime library
for the language to be written in the language itself. For example the GC for
the language is written in the language using unsafe code. In fact, even operations
like multiplication and division are written in the language. Of course it may
be desirable to rewrite some of those operations in assembly to improve performance.
However, I wanted the system to be flexible enough to allow for these operations to
be written in a high level language.
Unlike C or C++, there is direct language level support for arrays.
This support is important to allow for bounds checking of array accesses. Arrays
can also be used in unsafe code as a way to access arbitrary memory locations.
For example an array can be initialized to point into text video RAM and then
the memory can be modified through the array variable. This feature can
be used as a crude subsitute for many C pointer operations.
Sample Code
Here is a some sample code written in the programming language. As you can
see, it is quite similar to other 'curly brace' languages:
class CounterApp
{
Object PrintCounter(Object startValue)
{
Integer arg = startValue;
int start = arg.mValue;
int end = start + 20;
while start < end
{
Console.out.PrintInt(start).EndLine();
start += 1;
Thread.Yield();
}
}
int Run(String[] args)
{
Thread thread0 = Thread.Init(this.PrintCounter, "PrintCounter");
thread0.Start(Integer.Init(100));
Thread thread1 = Thread.Init(this.PrintCounter, "PrintCounter");
thread1.Start(Integer.Init(0));
thread0.Join();
thread1.Join();
return 0;
}
}
|