The future of programming languages

Recently a lot of new programming languages arrived, but only a few are really innovative.

Just a few weeks ago Apple announced its new programming language called Swift. Even though Swift has some nice features I consider it already outdated. Another example is the latest release of the Java language, Java 8. Here we saw features like lambda expressions appearing, which have been around in .NET / C# for almost a decade (7 years).

Now why do I think that those examples are already obsolete? In my opinion it is all about stronger meta programming capabilities. C had the preprocessor. That was a good idea and certainly very elegant at the time (and it helps solving many problems in C, however, it also creates new ones). But with C++ templates became the standard. In Java or C# we call it generic programming and it basically represents a simplified version of templates. Nevertheless the idea is to express reproduce-able code in terms of code. The compiler will use the template and create concrete code versions once requested with template arguments.

Of course this is not real meta programming, but I consider it an important step towards meta programming. The first step is to give the compiler some code. The second step and ultimate goal of meta programming is to modify that code within the compiler. This is most of the time a set of AST (abstract syntax tree) transformations. With templates this happens automatically. The nodes that contain references to, e.g., a template type T, will be transformed to the concrete type U.

The programming language D is already quite strong in meta programming. Also C++11 defined constexpr to do some lightweight compiler code execution. Of course every medal has two sides and in D we can write compiler executed code that will eventually run forever. Nevertheless D makes it possible to write one template function that behaves differently for different types (using e.g. the static if condition).

Now Roslyn (project name of the .NET Compiler Platform) will not include such directives - they remain language dependent and the C# team is not moving one step further in this direction. This does not sound like the future, however, Roslyn is actually a superset of this and therefore much stronger. Roslyn allows the code to be hooked on to the compiler. The team officially emphasizes the possibility to cross-check for proper usage (of a library) or to follow company coding standards.

But there is one other possibility: Compile-time code transformations. Roslyn makes it actually possible to write in a kind of DSL (domain specific language) and transform it to C# code during compilation. This makes template generators like T4 nearly obsolete. Also this creates a new era.

So what is future of programming languages? It goes certainly beyond the language. The compiler is a vital part that has to offer services and meta programming capabilities. The times where compilers have been used as black-boxes should definitely be over. I just hope that one day we will see a new programming language that is only based upon a compiler service. This would certainly make the language as flexible and extensible as possible.

Additionally we would not be required to wait a couple of years until lambda expressions or similar features arrive in a language.