THE WAVE PROGRAMMING LANGUAGE
version α0.86
By Gene Thomas

Wave is a new language and powerful development environment that I am currently developing. It is so named because the programmer can surf the code, jumping between related pieces of the program; and because of the way changes propagate across the system like ripples on a pond. The language has the features of C++ but with a simpler syntax; not being constrained by backwards compatibility with C, many syntax simplifications and feature rationalisations could be made. e.g. int is a class. The Wave environment completely integrates the compiler and editor so all errors are instantly highlighted to the programmer, e.g.

 
Here there is no insert method in the set class. If the insert method is written the error will disappear.

Wave supports:

Syntax

Expressions

Code must be indented to be readable, so Wave enforces this; making the compiler aware of the indentation removes the need for error-prone {brackets} and ; semi-colons.

Wave's syntax is based on mathematics and object orientation.

'sin x' takes the sine of x, from the object orientated viewpoint we are invoking the sin method on the x object. Similarly '1 + 2' is the + method being invoked on 1 with an argument of 2. In wave methods can be symbols or named, e.g. 'myList append 9', appends 9 to myList by invoking the append method on the myList object with an argument of 9. In many cases the traditional (parentheses) may be omitted.

As in mathematics operators are assigned a precedence, so * is computed before +, e.g. 1 + 2 * 3, is 7, not 9. In Wave any method name may be assigned a precedence, symbols or names. Note that the names of methods are ascribed precedence, not actual methods, as precedence is evaluated before computing which actual method is being invoked, i.e. the order of evaluation determines which method to invoke rather than vice-versa. Method overloading is supported.

 

Highlighting a method shows its precedence.

Automatic type conversions are supported by implicit constrcutors1.

Declarations

Declarations always read simply from left to right, e.g. a reference to a list of ints is & list int, rather than C++'s half backwards list<int> &. This make complex type declarations easier to code and follow.

Generic Progamming

Wave supports generic programming, where one may code abstract data types, such as containers, which will be instantiated for each required type, e.g. one writes code for an abstract linked list, not being concerned with the type of data the list will store, lists may be created to hold ints or strings or anything else. As required concrete implementation will be generated automatically, e.g. one for storing ints, one for strings. Due to Wave's integrated compiler one can browse and step through the automatically generated code.

Source code for the generic set insert method and int instance2.

Template types such as containers have a straight forward syntax, e.g. a declaration of a set of ints is written

    var set int aSet

References

Pointer objects are seldom used in Wave as everything can be achieved with references. The old address-of operator, &, when a applied to a reference object gives a reference to a pointer which means the value may be changed. e.g.
  &head = new int

As references can be changed declaring pointers is redundant. References are fundamental as the array indexing [] method and assignment methods both return references. 'lvalues' in C are references.


1. In the present version all constructors are implicit with a cost of 0.
2. Presently the source window actually shows many errors due to the compilers limited knowledge of the template parameter type T.