We’ve been extremely busy the last months in order to have a well
polished release of NDepend v3 completely integrated in VS 2010, 2008
Now, having NDepend as a companion in all my VS instances makes each
of my programming day bright [:)]. But it is already time to think about
what’s next. We have tons of plans and you are welcome to publish all
your secret wishes for NDepend vNext in the comment of this post.
At least, now I have some time to look what is happening outside of
the NDepend sphere. I stumbled on this great talk:
C# 4.0 and beyond by Anders Hejlsberg and I foster you to watch it,
at least from the minute 55 if you are already acquainted with C#4
features. Anders explains that C# and VB.NET compilers are currently
being migrated from C++ to managed code. A goal is to achieve Compiler
as Service paradigm.Compiler as Service will let the programmers
evaluate on the fly a piece of code from a string, to an in-memory live
IL code. Concretely, it is as easy as calling a CSharpEvaluator.Eval(String):
Delegate method. The input argument string contains a C# method
declaration and body. The output is a delegate object pointing to the
freshly compiled method. The method can then be executed at whim by
invoking the delegate object. Several pieces of code can be evaluated
consecutively in order to generate living code at runtime.
As far as I understand, the primary motivation behind more flexible
compilers, is to provide a framework that makes easy to write code that
can generate new code and refactors existing code! This, is the door
open to what is called meta-programming,
definition from wikipedia:
is the writing of computer programs that write or manipulate other
programs (or themselves) as their data, or that do part of the work at
compile time that would otherwise be done at runtime. In many cases,
this allows programmers to get more done in the same amount of time as
they would take to write all the code manually, or it gives programs
greater flexibility to efficiently handle new situations without
- C#1 was all about delivering a new language for a new platform.
- C#2 was all about providing generics to improve strong typing,
especially in collection handling situations.
- C#3 was all about letting write strongly typed queries abstracted
from the date source. As a consequence C#3 fosters a more declarative
way of programming.
- C#4 was mainly about dynamic programming to inter-operate with
dynamic programming environment.
- C#5 will be concerned with meta-programming.
(On a personal recurrent note, I still consider C# as being
flawed since it doesn’t support non-nullable
reference types. This might look like a detail, but this single
flaw hinders each of my programming day for 8 years now, that I am
programming with C#. I can attest that the absence of non-nullable
reference type is more or less responsible for a third of bugs my team
If I understand well, C#5 will open the possibility to refactor
automatically a portion of source code (at compile time or at runtime?),
in order to make it runnable concurrently on multi-core. Making
possible to write and maintain concurrent code more easily will be a
concern of C#5. But I guess concurrency is just one domain of
application of future C#5 language and compiler enhancements (the same
way integrated queries are just one domain of application of C#3
language enhancements). We are living exciting times [:)]
Finally, if you cannot wait putting your hands in C#5 eval things and
imitating Anders Hejlsberg doing magic, know you can play with the Mono
compiler that already supports the Compiler as Service paradigm (see
this Miguel’s post).
Notice that for once in the Mono sphere, a special care has been taken
to make this Mono C# compiler code packed in the form of a typical
Visual Studio solution.