The Whiteoak Programming Language

Introducing structural typing into Java





The Whiteoak programming language is an extension to Java that introduces a greater degree of flexibility into the language. Motivating the development of Whiteoak is the understanding that due to extensive use of libraries, components, and external data sources, the developer has limited control on how the objects in her program are created. The developer then spends a great deal of her time just gluing together systems of objects using all sorts of fancy patterns. Whiteoak addresses this predicament by the introduction of structural types, thereby allowing abstraction over objects. This mechanism nicely complements the well known inheritance mechanism which allows abstraction over classes. Structural types resemble standard Java interfaces but are different in several key aspects. First, structural types employ structural typing (AKA: duck typing, structural conformance, structural subtyping) in Java. This means that in order for a class to conform to a structural type it only needs to provide the required methods. Structural types may define non-abstract methods. This allows client code to "attach" methods to existing objects. These attached methods are over-rideable: if the underlying object provides such a method it will take precedence over the one defined by the structural type. Unlike interfaces, Structural types may define fields and constructors, thereby introducing virtual fields and virtual constructors into the language. Whiteoak offers type operators that enable the compsoition of new structural types using trait-like or mixin-like semantics. Moreoever, If a structural is used only once there's no need to name it: structural types may be anonymous. In order to write Whiteoak programs you only need to have a Java 6 JVM installed on your machine. The compiler can be downloaded either as a command line tool or as an Eclipse plugin. The compiler outputs standard class files so a compiled Whiteoak program can run on any JVM.