![]() |
|||||||||||||
|
Aikido (programming language) |
| Paradigm | object oriented, multithreading, scripting language, imperative |
|---|---|
| Appeared in | 2003 |
| Designed by | David Allison, Sun Microsystems |
| Typing discipline | Partially dynamic (duck), weak |
| Major implementations | Aikido |
| Influenced by | C, C++, Java, JavaScript, Perl, BASIC, Verilog, Ada 83, Pascal |
Aikido is a relatively new programming language that can be used for rapid scripting, prototyping and general programming tasks. It was developed in Sun Microsystems Laboratories by David Allison and released as open source in September 2003. It is a dynamically typed, object oriented language with built-in multithreading. In some respects it is similar in functionality to Python, Perl, JavaScript and Java. Syntactically it is very similar to C++ and Java.
Full documentation for the Aikido language is available in the Programmers reference manual
Contents |
The name Aikido refers to the Japanese martial art of the same name and was chosen because the language, like the martial art is derived from many other parts, taking the most desirable aspects of each. The original name for the Aikido language was Darwin but this was such a common name that it was unavailable for use by Sun.
The original use for Aikido was as the control language for an assembler for an internal experimental simulation project within Sun Microsystems Laboratories. The language run-time system still maintains the hooks necessary to make it into a control language.
Modern scripting languages are used for many tasks ranging from control of the computer operating system to general application programming. The ever increasing speed of computers has made it much more feasible to write programs using an interpreted language rather than the traditional compiled languages.
Interpreted languages typically run slower than their compiled cousins, but provide much more flexibility for the programmer, resulting in a much compressed development time.
Aikido is an interpreted language that retains most of the syntactic characteristics of C++. Most of the elements of the language will be familiar to anyone who understands C++ (or Java, since it is also derived somewhat from C++).
The Aikido language was designed with a number of goals in mind.
The Hello world program in Aikido is very simple:
println ("Hello world")
This is executed by the following command in a Unix like shell (assuming that it is saved in a file called hello.aikido
$ aikido hello.aikido
The result is
$ aikido hello.aikido Hello world $
Aikido is supplied primarily as source code. It is written entirely in C++ and is available for Linux, Mac OS X and Solaris. There is currently no Windows port available.
Aikido contains a number of novel language features:
var x = 1 var pi = 3.14159265
x = pi // error, cannot change type once defined
This feature reduces programming errors by not permitting arbitrary type changes at runtime. A variable may also be declared as generic thus allowing its type to change.
->) may be used to stream data to and from devices and program elements.;) character is optional in Aikido. It may be used if desired to separate statements but the language compiler has a special algorithm that is used to detect the end of statements unambiguously. This means that you rarely need to insert a semicolon at the end of a line, unlike most other languages.In common with many other languages, Aikido provides the following program constructs:
A variable may also be declared as fully dynamic using the generic keyword. In this case no value need be assigned to it at declaration time
A function can be declared as returning a particular type. The actual value returned is cast to the return type at runtime.
class Planet (name) extends Object (name) {
public function draw (screen) {
// draw the planet
}
}
var earth = new Planet ("earth")
earth.draw (screen3)
The following example shows the various parameter mechanisms
function foo (a, public b, var c, d:int, e = "hello", ...) {
// a is private and passed by value
// b is public and passed by value
// c is passed by reference
// d is cast to int on call
// e is passed by value and has a default value
// more parameters available in args variable
}
The use of access control for functions is only useful in the case of function derivation.
In addition, raw memory may be allocated for use in the program using the familiar malloc function. This memory is garbage collected when there are no references remaining. Access to the contents of the memory is performed using the peek and poke facilities, borrowed from the venerable BASIC language.
An interpreted programming language cannot execute a program independently from the operating system upon which it is running. It must make use of the operating system facilities to perform certain tasks such as input/output, memory allocation, etc. Aikido provides a relatively easy way to invoke code that resides outside the interpreter in an external library. This facility is normally referred to as native function access.
Along with general scripting and programming, Aikido can be used as a control language for a larger application. One such application is Command Line Interpreter where it can be used to provide a built-in scripting ability.
Whenever the Aikido interpreter comes across a section of code that it does not understand, it has the ability to pass this off to another program known as a worker. This worker program can then use this unrecognized text as a command.
Aikido is in part derived from the syntax and semantics of other programming languages.
Aikido's syntactic constructs are mostly derived from the C++ programming language. The expression syntax is almost exactly like C++ with some extensions for higher level constructs. The object orientation is similar to C++ except that multiple inheritance is not available.
Java is also a language that is similar in construct to C++. Aikido takes a number of Java's constructs in favor of similar constructs in C++. For example, the object oriented class structure is Java-like in that is provides single inheritance, uses extends for derivation and provides interfaces.
Niklaus Wirth's Pascal language provides a number of features that Aikido has borrowed. In particular, the lexical structure of an Aikido program is similar to that in Pascal. This is known as lexical scoping and allows a nested block to access the variables in an enclosing block. Some syntactic elements are also derived from Pascal. For example, the use of the keyword "var" to denote call by reference in function formal argument lists.
Python and Aikido are quite similar in some respects, but vastly different in others. Syntactically, Aikido is a lot different from Python, the former being derived from the C family of languages, and the latter having a unique syntactic style. Despite their differences, Aikido and Python share a similar goal and runtime ability. The runtime libraries for both languages are very similar, with Python having a much richer set of functions.
Aikido is very similar to the JavaScript language. Syntactically it is almost identical, but one major difference is the object orientation features. JavaScript uses a prototype style of inheritance where Aikido uses a traditional class hierarchy.
Aikido's runtime library is relatively small in comparison to other languages. A lot of the features normally found in runtime libraries in other language systems are built in to the Aikido interpreter. For example, Aikido provides extensive string manipulation operations in the interpreter itself rather than relying on calls to an external library.
Most of the library functions and classes are used to provide operating system access facilities. For example, runtime library functions are available to access the operating system shell.
The runtime library is accessed in an Aikido program by importing one of the few files contained in the Aikido package. Once imported, the functions and classes of that section of the runtime library can be used in the program.
Many of the features and facilities in Aikido are subject to a number of US patents: