Saturday, July 26, 2014

From the Ashes of Google's Noop, Comes the Language Wake

The programming language Noop was not an official Google product, though it was often given credit for being so. Dedication to testability was what made Noop so unique and exciting, and what generated hype about its eagerly-awaited first release.

Unfortunately Noop fell the way of most languages, and was cancelled before its enthusiastic followers got a chance to try it out.

Now our small team is excited to announce that Noop's unrealized feature set has inspired Wake, a practical object-oriented language in Alpha release status. Anyone who was interested in Noop can now instead read Wake's sleek documentation, try it out online, or join the drive to V1.

Why Noop Didn't Die

The Java community is probably the most dedicated to unit testing, which is not reflected in the language's design or standard library. A couple of really bad ideas like URL equivalence reading from static DNS calls exemplify the lack of now-common practices such as Dependency Injection. It becomes a full career to explain how to write testable code (see: Misko Hevery, the author of that article I just cited on Dependency Injection). There isn't a language in existence yet which makes testability inevitable.

Wake, like Noop, resolves the issue entirely. In Wake your program startup is dependency injected. This means you can simply declare:
every Main is:
    needs Printer;
and your startup class will get a Printer, the Printer gets what it needs, etc. Then in your test cases you can pass in any Printer you wish to verify its output.
every MainTest is:
    provides Main, Printer <- MockPrinter;
    testSomething() {
        var Main from this;
        // Test code
As you can see in this example, Wake has removed the new keyword, requiring all new objects to be created by injectable providers. This means statements you used to write as new Printer() are now Printer from PrinterProvider, a simple change that allows PrinterProvider to return any (more testable) implementation of Printer which it desires.

New Language, New Tricks

We didn't stop at testability.

A huge goal of Wake is to make the smoothest syntax of any statically-typed language. Type inference is one option, but it doesn't play as well with OOP languages as it does with functional ones. The easiest solution we saw was to stop requiring developers to name their typed variables.
greet(Person) {
    // code
Here we have a method that works on a Person, which in java we would've defined as Person person, or worse, Person p. This syntax is only possible in a language which scrapped static methods because they are death to testability.

This has an amazing side-effect on iteration. Since lists are also valid variable names, we have a completely new form of iteration in Wake.
var Entity[] = getEntities();
foreach(Entity[]) {
This foreach statement takes a list of Entity objects named Entity[], and lowers it to the variable Entity so that you can execute code on each. For those who are curious, foreach operates on expressions, not variable names. This means the above could have been written as foreach(getEntities()) save(Entity). This is a concept only possible in a language which understands your program's types, and lets your variables be named directly after them.

Current Status of Wake

Wake supports a huge array of features, including null-safe types, inheritance, method overloading, and generics. It even has a unit-testing framework, a mocking framework, and compile-time reflection. Tooling is in progress and some major features such as closures are still in progress. We won't call anything V1 until we have these features.

It is also worth noting that Wake currently compiles to Javascript. Not to spill too many beans, but we're hoping to create several more compile targets in the future. Maybe Wake will become a swiss army knife for our constantly diverging platforms.

If you are looking to try something new, advise the direction of the project, or even hack at the compiler (written in C++), then Wake might be the next (or at least the newest) language to be worthy of your excitement or contributions.