ASP.NET is Multi-language
Though you may opt to use one language over
another during your application development cycle, it's important to note that
the end result will always be the same. A form of intermediate language known
as Microsoft Intermediate Language is the lowest common denominator format for
any managed application. Whether you opt to use Visual Basic.NET, C#, or any
other language during development, your code will eventually be compiled into MSIL
for execution within the .NET runtime. In a sense, MSIL is the language of .NET.
Intermediate Language
When any managed application is
compiled, it is actually compiled into MSIL, the Microsoft Intermediate
Language. MSIL is actually the code that's "under the hood," that
gets compiled down into machine code at run time by the CLR. Taking a
long-winded look into MSIL is a little premature at this juncture, but to
introduce you to it, take a look at this function, written in C#:
using System;
namespace CHelloWorld
{
class Class1
{
[STAThread]
static void Main(string[]
args)
{
Console.WriteLine("Hello World");
}
}
}
We've
written the most basic form of console application, with a single, predictable
message that gets dumped onto the screen.
Now look
at it from a different perspective. Here's the MSIL code for same class, opened
up with ILDASM.exe:
.method public static void
Main() cil managed
{
.entrypoint
.custom instance void
[mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// Code size 14 (0xe)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "Hello World"
IL_0006: call void
[mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: nop
IL_000d: ret
} // end of method Module1::Main
If you're
patient and a little logical, you can most likely deconstruct this code
yourself and figure out what's happening. Chances are you wouldn't opt to
develop an entire application in MSIL, however, so there are a few layers of
abstraction on top of it to keep you busy!
It's
important to note that MSIL was recently adopted as an ANSI standard. This recent
adoption could quite possibly spur the adoption of other common language
frameworks. In fact, a recent initiative that has come to be known as ROTOR has
spawned an open-source implementation of the Common Language Infrastructure.
This implementation, available for the Windows XP and FreeBSD operating
systems, contains a complete implementation of the C# language and various
tools similar to those found in the .NET Framework.
For more information about the
ROTOR project or Microsoft's work into this open initiative, take a look at the
MSDN article entitled "The Microsoft Shared Source CLI
Implementation," located at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Dndotnet/html/mssharsourcecli.asp?frame=true.
The Common Language Specification
The Common Language Specification
(CLS) defines the standard properties that all objects must contain in order to
communicate with one another in a homogenous environment. This environment,
being the CLR, expects certain truths to be evident about all of the elements
contained within it. These objects must adhere to a set of rules (very similar
to how XML documents are validated against schema) in order to live and
function together in harmony.
The CLS is
this governing set of rules. It defines many things that all languages must
adhere to, such as keywords, types, primitive types, method overloading, and so
on. Any compiler that generates IL code to be executed in the CLR must adhere
to all rules governed within the CLS. The CLS gives developers, vendors, and
software manufacturers the opportunity to work within a common set of
specifications for languages, compilers, and data types. Chances are that we'll
begin to see more CLS-compliant languages and compilers emerge in the near
future.
Given these
criteria, the creation of a language compiler that generates true CLR-compliant
code can be complex. Nevertheless, compilers can exist for virtually any
language, and chances are that there may eventually be one for just about every
language you'd ever need. Imagine – mainframe programmers who loved COBOL in
its heyday can now utilize their knowledge base to create web applications!
Obviously, .NET will most likely encompass any technology set with which you're
already familiar. If it doesn't already, Microsoft has provided developers the
ability to actually extend the framework by providing compilers for whatever
languages you need.
Buy Fast Track ASP.NET here
© Copyright 2002 Wrox Press
These chapter is written by Brady Gaster, Marco Bellinaso & Kevin Hoffman
and taken from "Fast Track ASP.NET" published by Wrox Press Limited in June 2002; ISBN 1861007191; copyright © Wrox Press Limited 2002; all rights reserved.
No part of these chapters may be reproduced, stored in a retrieval system or transmitted in any form or by any means -- electronic, electrostatic, mechanical, photocopying, recording or otherwise -- without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.
|
|