Spec# pronounced ‘Spec Sharp’ is new attempt at a more cost effective way to develop and maintain high-quality software. This language is being developed by Microsoft Research and has left me completely dumbstruck. My favourite programming language is C# of which I’m self taught, but I was formally trained in C/C++.
Spec# is an extension to C# that introduces the notion of contract based programming. If you have tried Windows Communication Foundation, you will be familiar with the notion of contracts. Spec# takes things to a whole new level, and is very very explicit – this is a complete understatement by the way.
When you are defining your encapsulated fields and methods you have to go into a great more detail about how those fields and methods will operate, all at compile time. In C++, C# or Visual Basic, a developer usually writes a chunk of code and then compiles that code into a .dll or executable. It is only at this stage when problems are identified, and resolutions are effected. Spec# does not allow this because as you write your code it checks everything. One of the key features is that you have to specify values as non-null. This is a big deal.
What non-null stipulations allow for, is very performant code (‘performant’ is a word used by Technical Fellows so it is now a word – as far as I am concerned). This is because code is not being checked for being null which is something that is always done for Common Language Runtime languages. The way the Spec# team achieve this is through their ‘brain-box’ knowledge of Microsoft Intermediate Language.
I will certainly be keeping my eyes on this one.