Datasheet
You should note that the platform independence of .NET is only theoretical at present because, at the
time of writing, a complete implementation of .NET is only available for Windows. However, a partial
implementation is available (see, for example, the Mono project, an effort to create an open source imple-
mentation of .NET, at
www.go-mono.com/).
Performance improvement
Although we previously made comparisons with Java, IL is actually a bit more ambitious than Java byte
code. IL is always Just-In-Time compiled (known as JIT compilation), whereas Java byte code was often
interpreted. One of the disadvantages of Java was that, on execution, the process of translating from Java
byte code to native executable resulted in a loss of performance (with the exception of more recent cases,
where Java is JIT compiled on certain platforms).
Instead of compiling the entire application in one go (which could lead to a slow start-up time), the JIT
compiler simply compiles each portion of code as it is called (just-in-time). When code has been com-
piled once, the resultant native executable is stored until the application exits, so that it does not need to
be recompiled the next time that portion of code is run. Microsoft argues that this process is more effi-
cient than compiling the entire application code at the start, because of the likelihood that large portions
of any application code will not actually be executed in any given run. Using the JIT compiler, such code
will never be compiled.
This explains why we can expect that execution of managed IL code will be almost as fast as executing
native machine code. What it doesn’t explain is why Microsoft expects that we will get a performance
improvement. The reason given for this is that, because the final stage of compilation takes place at run-
time, the JIT compiler will know exactly what processor type the program will run on. This means that
it can optimize the final executable code to take advantage of any features or particular machine code
instructions offered by that particular processor.
Traditional compilers will optimize the code, but they can only perform optimizations that are indepen-
dent of the particular processor that the code will run on. This is because traditional compilers compile
to native executable before the software is shipped. This means that the compiler doesn’t know what
type of processor the code will run on beyond basic generalities, such as that it will be an x86-compatible
processor or an Alpha processor. Visual Studio 6, for example, optimizes for a generic Pentium machine,
so the code that it generates cannot take advantage of hardware features of Pentium III processors. On
the other hand, the JIT compiler can do all the optimizations that Visual Studio 6 can, and in addition it
will optimize for the particular processor the code is running on.
Language interoperability
The use of IL not only enables platform independence; it also facilitates language interoperability. Simply
put, you can compile to IL from one language, and this compiled code should then be interoperable with
code that has been compiled to IL from another language.
You’re probably now wondering which languages aside from C# are interoperable with .NET, so the fol-
lowing sections briefly discuss how some of the other common languages fit into .NET.
Visual Basic 2005
Visual Basic .NET 2002 had undergone a complete revamp from Visual Basic 6 to bring it up-to-date with
the first version of the .NET Framework. The Visual Basic language itself had dramatically evolved from
5
.NET Architecture
05_575341 ch01.qxd 10/4/05 7:03 PM Page 5