Skip to content
Biz & IT

Microsoft .NET

n a remarkable feat of journalistic sleight-of-hand, thousands of column …

Peter Bright – | 0
Story text

Microsoft .NET

In a remarkable feat of journalistic sleight-of-hand, thousands of column inches in many "reputable" on-line publications have talked at length about .NET whilst remaining largely ignorant of its nature, purpose, and implementation.  Ask what .NET is, and you'll receive a wide range of answers, few of them accurate, all of them conflicting.  Confusion amongst the press is rampant.

The more common claims made of .NET are that it's a Java rip-off, or that it's subscription software.  The truth is somewhat different.  Before talking about these claims, first the important question needs to be answered:

What is .NET?

.NET is a "software platform".  It's a language-neutral environment for writing programs that can easily and securely interoperate.  Rather than targetting a particular hardware/OS combination, programs will instead target ".NET", and will run wherever .NET is implemented.

.NET is also the collective name given to various bits of software built upon the .NET platform.  These will be both products (Visual Studio.NET and Windows.NET Server, for instance) and services (like Passport, HailStorm, and so on).

The components that make up .NET-the-platform are collectively called the .NET Framework.

This article will concentrate on the .NET Framework; a follow-up will tackle .NET-the-software.  Also within this article will be discussion of the standardization process happening in parallel, and a discussion of the differences between .NET and its major rival, J2EE.

The .NET Framework

The .NET Framework has two main parts:

  1. The Common Language Runtime (CLR).
  2. A hierarchical set of class libraries

The CLR is described as the "execution engine" of .NET.  It provides the environment within which programs run.  The most important features are:

  • Conversion from a low-level assembler-style language, called Intermediate Language (IL), into code native to the platform being executed on.
  • Memory management, notably including garbage collection.
  • Checking and enforcing security restrictions on the running code.
  • Loading and executing programs, with version control and other such features.

Before talking in more detail about these, a few bits of terminology need to be clarified.

Managed Code
"Managed Code" is code that targets .NET, and which contains certain extra information — "metadata" — to describe itself.  Whilst both managed and unmanaged code can run in the runtime, only managed code contains the information that allows the runtime to guarantee, for instance, safe execution and interoperability.
Managed Data
With Managed Code comes Managed Data.  CLR provides memory allocation and deallocation facilities, and garbage collection.  Some .NET languages use Managed Data by default — C#, Visual Basic.NET, JScript.NET — whereas others — C++ — do not.  Targetting CLR can, depending on the language you're using, impose certain constraints on the features available; for instance, C++ loses
multiple inheritance.  As with managed and unmanaged code, one can have both managed and unmanaged data in .NET applications — data that doesn't get garbage collected but instead is looked after by unmanaged code.
Common Type System
The CLR uses something called the Common Type System (CTS) to strictly enforce type-safety.  This ensures that all classes are compatible with each other, by describing types in a common way.  CTS defines how types work within the runtime (their declaration and usage), which enables types in one language to interoperate with types in another language, including cross-language
exception handling.  As well as ensuring that types are only used in appropriate ways, the runtime also ensures that code doesn't attempt to access memory that hasn't been allocated to it (that is to say, the code is type-safe).
Assemblies
.NET programs are constructed from "Assemblies".  An Assembly is a compiled and versioned collection of code and metadata that forms an atomic functional unit.  All Assemblies contain a Manifest, which contains the Assembly name, version, and locale, has a list of files that form the Assembly, what dependencies the Assembly has, and what features are exported by the Assembly.

When you target .NET with your compiler, what gets generated isn't native code.  Instead, it's a small PE wrapper around three blocks of data.  PE (Portable Executable) is the binary format used to contain Win32 programs.

PE files contain a stub MS DOS program (if you've ever tried to run a Win32 executable from DOS and seen the "This program requires Microsoft Windows" message, you've seen that stub in action).  .NET binaries will then contain a Win32 stub — to either use .NET to run the actual program, or to say something like, "This program requires .NET to run" if it isn't available.

The first block of data within the PE wrapper is the IL itself.  IL looks approximately like assembler.  This is the bit that actually gets compiled and executed.

The second is called the metadata.  This describes the contents of the file — for instance, what methods it provides, what parameters they take, and what they return.

The third is the manifest.  This describes what other components the executable needs in order to run.  It also contains public keys of external components, so that the CLR can ensure that the external component is the one that the executable thinks it is.

When running the executable, the CLR uses Just-In-Time compilation.  As each method within the executable gets called, it gets compiled to native code; subsequent calls to the same method don't have to undergo the same compilation, so the overhead is only incurred once.

JIT compilation raises some issues.  One is that it demands resources — memory and processor particularly.  To solve this, MS have two JIT compilers: a normal one, that optimizes compiled code fairly well, but can be processor and/or memory intensive; and an "EconoJIT".  EconoJIT might not optimize the code as well, but it'll require less memory and processor time to run.  It will also allow your running program to discard the compiled form of a method, thereby freeing up memory, at the expense of having to compile it again.  A third kind of compiler has been hinted at (though hasn't made it into the version 1 release), called the "OptJIT".  It will work a little differently; it will use a subset of IL (OptIL) with additional information to suggest to the OptJIT compiler how to generate its output; there may also be greater optimization of the IL.  The idea is to reduce the overhead due to the JIT compilation without sacrificing the quality of the emitted machine code.

  

Performance Issues

The other issue is, of course, performance.  JIT compilation can provide good results once a program is up and running, but can be very slow at load time (as it has to both load and compile the program), and can't necessarily perform some of the more expensive (time-wise) optimizations that optimizing compilers perform.  To tackle this, there's a mechanism for compiling the executable and storing that compiled form — ahead-of-time (AOT) compilation.  The compiler was originally called "PreJIT", though now has been renamed NGen (for Native [code] GENeration).  A number of the core Framework files are compiled in this way, to reduce their start-up overhead.  The IL version is still kept around, and if the system is unhappy with the PreJITted copy for some reason, it can fall back on JIT compilation.  Unfortunately, version 1 of the CLR doesn't regenerate AOT files should they become invalidated in any way; they have to be manually generated instead.

The current implementation of NGen simply uses the same JIT compiler as would normally be used.  It performs no further optimizations.  Nor does the regular JIT compiler perform any profiling/recompilation — it's a one-off affair.  This is perhaps a little disappointing.  The specification does not require this behaviour — the PreJIT doesn't have to use the regular JIT, and the regular JIT doesn't have to perform compilation as a one-off action.  But these features are somewhat notable omissions from Microsoft's first release; profiling JIT compilers are becoming common in the Java world, and optimizing native code compilers are becoming the norm, with considerable benefits from their use.

Whilst JIT compiling can perform well on some processors, there are concerns raised over processors such as the Itanium (and, indeed, by all IA64 processors).  In the IA32/x86 world, processors that reschedule machine code in order to streamline execution have become standard — all current x86-compatible processors do this.  However, the design of IA64, in an attempt to increase performance, relies on the compiler to order instructions; dynamic instruction rescheduling by the processor is contrary to the entire design motivation of IA64.  Because the IA64 architecture requires instruction ordering to be explicit, it makes effective compiling much harder to do — one can't rely on the processor to re-order code as and when possible.  This job is hard enough to do ahead-of-time — whether it can be done at all effectively dynamically remains to be seen.  It might be the case that the only way to get acceptable performance on such processors is to compile everything ahead-of-time.

 

Assemblies can be both single-file and multi-file.  One file will contain the Manifest, the other parts of the Assembly contain the implementation.  Whether they be single-file or multi-file, Assemblies constitute a single unit — whilst they may be made up of multiple files, they're atomic as far as .NET is concerned.

Single file assemblies contain all the data in a single file, including the manifest and any resources it may need.  Multi-file assemblies might, for instance, have external resources (bitmaps, icons, sounds, etc.) or have one file for the core code and another for helper libraries.  In multi-file assemblies, the manifest may be located in a PE all by itself, or in a PE alongside IL and metadata.

Assemblies can be shared or private.  Private assemblies live within an application's directory, shared assemblies in a common Assembly repository (currently, %systemroot%Assembly), called the Global Assembly Cache (GAC).  Private assemblies would typically be written by the author of an application, for use by that application.  Version control is left at the discretion of the author, and the assembly name is simply the filename, minus any file extension, of the file that contains the manifest.

Shared assemblies are intended to be used by multiple authors.  They therefore have stricter constraints — there must be rigorous version control, and a mechanism to ensure that the assembly name is unique.  They contain some extra pieces of information.  The assembly has a pair of encryption keys.  One is called the "public" key, the other "private".  The private key is kept guarded by the creator of the assembly; the public key is published within the manifest.  The file containing the manifest is hashed, and that value is signed with the private key.  Hashing is the process of generating a number (called a hash) from some input — in this case, the file containing the manifest.  The algorithm can only be used one-way, which means that one cannot generate the input from the hash; in addition, the algorithm is designed so that small changes to the file (commonly indicative of tampering) result in a different hash.  This signed hash is the digital signature of the assembly.

When loading a shared assembly, the following are used to identify which assembly to load:

  • its name
  • its public key
  • its version
  • its locale

Requiring all these bits of information permit multiple versions of the same assembly to co-exist (the GAC might contain 1.0.0.0/English, 1.0.0.0/Spanish and 2.0.0.0/English of an assembly, and will make sure that programs get the version they expect).  When installing an assembly into the GAC, the system verifies the digital signature of the manifest file.  It does this by hashing the manifest file itself, then decrypting the signature stored in the manifest using the public key, and then comparing the two hashes.  Click here for more details on how digital signing works.

The rest of the verification occurs at runtime.  When an assembly tries to load an assembly from the GAC, the first thing that is done is to compare the public key of the assembly within the GAC to the public key that the referring assembly has on record.  If they don't match, an exception is thrown.  If the assembly has multiple parts, each part is hashed as it is loaded, and this hash is compared to the value stored in the manifest — again, if they do not match, an exception is thrown.

 
The GAC in Explorer
 

When an application needs to use a particular assembly, it queries the GAC for an assembly matching the name, public key, version, and locale.  The components of the assembly have their hashes checked in the same way as was used to verify the PE file.  If an assembly can be found that matches the query, and it hasn't been tampered with, then the application can load the assembly.

Why is this important?

It eliminates ".dll hell".  Multiple versions of "the same" assembly can co-exist in the GAC, which means that libraries no longer have to maintain backwards compatibility with their predecessors, and that a program will always get the version it's expecting.  This can be done even within the same program — if you have a web server, you can run multiple versions of the same application within it, side-by-side.

The quite rigorous protection against tampering with files provides some guarantees that the files won't be modified after release; this should provide some protection against, for instance, viruses (were a virus to infect a file it'd refuse to run).  

Metadata

Metadata

An important feature of managed code is the metadata.  Metadata is data describing data, and all manner of metadata is used in .NET.  As mentioned, there’s information identifying a particular assembly, and the assemblies that assembly relies upon.  The security privileges required by the assembly are also listed.

There’s detailed information about the types/classes provided by the assembly, along with descriptions of methods, interfaces, and members.  This is important for a number of reasons.  It makes the assemblies self-describing.  This ensures that the descriptions are always accurate, unlike mechanisms such as C/C++ header files, where the interface described in the header could become out of date, and no longer an accurate description of how a library works ? the "fragile interface" problem.  Similarly, it removes the need to have some kind of an interface description or type library file, such as Interface Description Language (IDL) as is used in COM development.  This information is also important for language interoperability; it describes the classes in an assembly so that other classes (perhaps in other languages) can inherit from them.

The final kind of metadata is attributes.  Attributes are important enough to get their own section heading.  So here it is:

Attributes

Attributes provide a flexible and extensible way of modifying the compile-time and run-time environment.  A real example is an attribute called DllImport.  This is used to denote that a function should be imported from a native library (a DLL), rather than being in a .NET library.  To import a function from a DLL, one writes an appropriate function prototype, and applies an attribute to that prototype that tells the runtime, "you should get the code to this function from this library".  The runtime hides the messy details ? for instance, the fact that this imported function won’t be in IL but instead native code ? and allows you to concentrate on what’s important.

They can also act at compile-time; for instance, there’s an attribute that allows you to mark functions as obsolete, so that they emit a compile-time warning to tell the programmer to use the updated version of the function, or that the function is deprecated and may be removed.

If there isn’t an attribute to modify the way the runtime works in the way you want, you can define your own.  For instance, you might want an attribute to describe who’s authoring each bit of code, and when they last modified it.  To define an attribute, you write a class that derives from System.Attribute.  So you might define an attribute with a "name" property and a "modified date" property.  The people writing the code would use this attribute to annotate the code they were writing.  It would then be possible at runtime to interrogate these attributes, and find out who wrote each class and when.  Or do anything else that you defined; some attributes do some quite complex things (for instance, there are attributes that turn your .NET class into a COM class, without requiring you to write any COM code at all).

Language neutrality

The ability to use any language that can target IL is a fundamental feature of .NET.  This is achieved through the Common Type System (CTS).  The CTS defines how classes (or "types", in .NETese) are defined.  It describes a number of different features a class can have; member functions (methods), member variables ("fields"), events, and properties (fields that silently use accessors to get/set their values, which can, for instance, allow the creation of a read-only field).  It defines the different kinds of "visibility" that these items can have (for instance, whether a method is public, and can be called by any class, or private, and only callable by the same kind of class).  And it describes how such things as inheritance work for the class, with some constraints; all classes must ultimately derive from System.Object, and only single inheritance is supported.

The ideas that it formalizes should be familiar to anyone who has programmed with an OO language.  This standardization is important, because it allows different compilers to create compatible objects.  Whether you define your class in C#, VB, JScript, or any other language, it’ll generate the same output.

And because the output is known to work in a certain way, it no longer matters what was used to create it.  You can start off with a class written in C# and inherit from it in VB.  Then you can seamlessly use it from C++.  It makes no difference ? it just works transparently.

Whilst the CTS was designed to be as transparent as possible (to be compatible with existing language constructs) it does enforce some constraints.  C++ programmers will lose multiple inheritance (like other such systems, you can have only a single base class, but multiple interfaces).  A number of languages will lose case sensitivity (names exposed to classes in other assemblies have to be differentiated by more than case alone; names internal to a class’s implementation can still be distinguished only by case).

The language neutral aspects of .NET run deep.  There are many languages that are in a beta (or better) state, and a number of groups working on these languages have had input into the design of .NET.  One repercussion of this is that IL has certain specialized instructions.  An example of this is that it has a "tail call" instruction.  A tail call is a function call that is the final call of a routine (in imperative languages, returning the unmodified result of another function call would be a tail call).  They are of particular importance to functional languages, which typically use recursion instead of iteration.  When a recursive function is written to use a tail call, a significant optimization of the generated code can be performed.  IL can readily express such calls with its tail call instruction.  This makes writing compilers that perform such optimizations easier, and ensures that the JIT can produce optimal code.

Safety

Another thing the CLR ensures is that programs don’t attempt to do anything dangerous.  The language most changed by this is C++.  Regular C++ permits all sorts of tricks and mistakes.  One can allocate a block of memory and then write too much data to that block, overwriting whatever happened to be lying beyond the allocated block of memory.  Or one can pretend that one type is another type (deliberately or accidentally).  And one can (attempt to) access any location in memory and modify its contents.

Whilst some of these can be innocuous (deliberate treating of one type as another type, for instance) a number can be dangerous.  The most famous of these being the buffer overflow.

To counter these problems, the runtime simply states that you can’t do that kind of thing (unless you have permission to do so; one can run so-called unsafe programs that can’t be verified as safe ? indeed, they may not be safe at all).  If you try to write past the end of a buffer, it’ll catch it and throw an exception.  If you try to use types in a way that isn’t safe, it will catch it and throw an exception.  One issue with this is that there are ways of generating code that is safe but which the runtime can’t verify to be safe.  To permit such code to be run, there’s a privilege that can be assigned to users to permit them to run, for instance, unverified code from trusted sources.

The CLR also enforces restrictions similar to those restrictions already used in Windows for ActiveX controls.  These allow, for instance, an object embedded into a web page to perhaps write to your screen, but not access your hard disk.  It provides sand-boxing of programs running within the CLR.  Administrators can override the default settings ? to, for instance, allow downloaded components with a certain digital signature to have more access than they normally would.

This security is enforced by means of a "stack walk".  This relies on examination of the "call stack".  The call stack represents currently active functions that have been called by the function "above" them in the stack, but not yet finished.  The call stack lives somewhere in memory (there will be one for each thread), and as each function gets called, the current location on the stack moves down in memory.  Moving up the stack means going towards the function that called the current one (eventually, one will reach the beginning of the stack, which is where the first function to be called has its data).  Functions can demand certain permissions.  When they do, the runtime will examine the call stack to ensure that the permission has been granted.

For instance, one might download an assembly from the Internet that wants to read from the hard disk.  That downloaded assembly (A1 in the diagram) will therefore make a call to a system assembly, which may then call other system assemblies.  Ultimately, a point will be reached where the actual read from the hard disk will be attempted (inside assembly A4).  This requires a permission (P).  The runtime will check the permissions granted at each point on the stack, and move up the stack until either it finds the permission ? at which point the code will be allowed to continue ? or until it reaches the top of the stack, at which point an exception will be thrown.  This is an important difference to the ActiveX security model; that worked by trusting entire components to be safe.  There were a couple of problems that resulted from this; malicious code could sometimes trick the system into running the component from a more trusted location (for instance, the local hard disk instead of the Internet), resulting in a component that shouldn’t have been permitted to run being permitted to run, or by tricking a trusted piece of code into performing the nefarious task.  Stack walks solve these problems, by guaranteeing that the code making the call has the privileges it needs.

The Class Library

.NET provides a single-rooted hierarchy of classes.  The root of the namespace is called System; this contains basic types like Byte, Double, Boolean, and String, as well as Object.  All objects derive from System.Object.  As well as objects, there are value types.  Value types can be allocated on the stack (which is generally quicker to some degree than allocation on the heap), which can provide useful flexibility.  There are also efficient means of converting value types to object types if and when necessary.

The set of classes is pretty comprehensive, providing collections, file, screen, and network I/O, threading, and so on, as well as XML and database connectivity.

The class library is subdivided into a number of sets, each providing distinct areas of functionality, with dependencies between the sets kept to a minimum.  The aim is to make stripped-down implementations (for small devices) easier to create, as an implementation need only provide those sets of classes that it needs.

What it’s all for

These two things ? the CLR and its libraries ? provide a versatile platform for software development.  Whilst a lot has been made of the server/web applications, .NET is aimed at client-side development also.  This includes traditional applications (both bespoke business applications and mass market off-the-shelf applications), but also more powerful web-based applications; because finer control over security is possible, as well as more powerful UI capabilities, more capable web applications can be written, more easily; the insecure ActiveX functionality that Microsoft said would change web applications has now come of age, with a truly securable implementation.  .NET (using Windows Forms) aims to provide an alternative to (and perhaps eventual replacement for) traditional Win32 development using VB or MFC or [your favourite GUI toolkit].

One key feature of server application development is Web Services.  A Web Services is a component running on a web server that is "consumed" (i.e., used) by a traditional client application, a web-based client application, or another Web Service.  Web Services are consumed using Simple Object Access Protocol (SOAP), a remote procedure call mechanism using XML over HTTP, as their access protocol, in conjunction with WSDL (Web Service Description Language).  WSDL is used to describe the interface(s) published on the web, so that consumers of the service know how to use it.  SOAP is used during the actual execution of the consumer.  The .NET library provides a number of classes to make this easy.

.NET is also happy to use code that exists outside the CLR, and unmanaged code within .NET.  Unmanaged code can still take advantage of .NET’s class library, for instance, and still compile to IL, but it doesn’t, say, use the garbage-collected heap.  One can write native code and expose it to .NET, for better performance ? an example of this is the Windows Forms classes, which are implemented as native code.

The Framework has two components, the CLR and the class library.  MS, however, views .NET as having three main components (well, some of the time ? they’re not entirely consistent on what the platform is).  The first two are the CLR and the class library.  The third is ASP.NET.  This is misleading.  ASP.NET is, as its name would suggest, a version of Active Server Pages that use .NET technologies.  ASP.NET provides a nice environment for writing web applications.  However, it’s not true to say that it’s a fundamental technology.  Instead, it is an example of a .NET hosting application.  It runs applications within the .NET environment, and provides classes to those applications, but it isn’t, in and of itself, a key part of .NET.  This ability to host the CLR is open to other programs (in a similar, but far more capable, way in which programs can host ActiveX scripting languages to provide extensibility).

Is this MS’s [latest] attempt to kill Java?

When one hears of what .NET is and does, a comparison to Java seems inevitable.  The two platforms are similar in a number of respects.  First, a quick run-down of the terminology.

Java is used to refer to three distinct things.

  • The Java language.  An object-oriented C-style language.
  • The Java class library.  A comprehensive (if occasionally inconsistent) class library hierarchy.
  • The Java Virtual Machine (JVM).  Source code is compiled to Java bytecode, which executes inside the JVM; traditionally, it wouldn’t be compiled into native code; high-performance JVMs, however, typically compile on-the-fly to instructions native to the underlying hardware.

.NET has approximate counterparts to the second and third of those things, but not the first (it has IL, broadly equivalent to Java bytecode, but no high-level language).  .NET was designed to be language agnostic.  One can readily take a C# class, derive a VB.NET class from it, and then use it in a Managed C++ program ? the use of different languages is invisible to the programmer.  Whilst a number of languages can compile to Java bytecode, this is not sufficient to make Java language-neutral.  Many of those languages are merely script interpreters written in Java (they do not create Java bytecode, the scripts are not aware of running on the Java platform, and hence, cannot use any Java features); many of the projects are simply abandoned.  Whilst some (for instance, Jython) can interoperate with Java classes, this represents the minority.  The ability to mix and match the languages being used ? to write a class in one language, inherit from it in another, and use it in a third ? doesn’t exist.

The class libraries have a fair degree of commonality.  Java’s is currently somewhat more extensive; .NET’s is arguably better-developed in some areas (creating forms, for instance).

Existing Java Virtual Machines either stick with the JVM idea (they run the bytecode in a virtualized machine), or (for significantly better performance) compile the bytecode to native code, and run that.  .NET will only use the second of these methods.  Whilst there’s no reason that someone couldn’t write an IL virtual machine (or even a MAJC-style physical one) this isn’t what its creators have in mind.  JIT compilation will be the norm, with certain classes compiled AOT.

There are differences in the nature of the intermediate languages.  IL would be unsuitable for interpreting because, for instance, it uses generic instructions (for instance, the instruction to add two numbers is the same whether the numbers are integers or floating point), which would require the interpreter to carry around all sorts of type information ? type information that with Java bytecode is specified in the instruction itself; Java bytecode has one instruction for adding integers and a different one for adding floating-point numbers.  On the other hand, Java bytecode is tied in some respects to the constructs that the Java language have; IL is more generic.  The design of IL has had input from a number of groups, and had features added as a response to their demands; as a result, IL has features like the previously mentioned tail call instruction; this makes it more suitable for implementing such languages than Java’s bytecode would be.

These differences add up.

The first is the most obvious to developers ? they can use the language they prefer, or is most appropriate (assuming it has a compiler targetting .NET) rather than the language the environment forces upon them.  It should provide an easy route for existing C++ or Visual Basic programmers.  Further, MS have released betas of a product called Visual J#.  It provides an upgrade for Visual J++ programmers.  There is a .NET compiler and a set of class libraries.  These implement the Java language and the Java class library in their entirety as they stood at version 1.1.4.

.NET and .COM

MS have been pushing a language and platform independent interoperability mechanism for some years now.  It’s called Component Object Model (COM).  There is a degree of overlap between the two.  .NET hides many of the messy details that COM makes programmers (or at least C/C++ programmers; VB programmers will see far fewer differences in this regard) deal with.  COM is all native code, and requires programmers to be conscious of many low-level details which make development using the full power of the technology more burdensome.  .NET makes these issues disappear.  It takes care of the details for you.

On the other hand, COM still has some things in its favour.  COM/DCOM has a huge installed base (it can be used on pretty much any Win32 machine), and is used quite extensively (particularly in newer versions of Windows).  Lots of bits of Windows rely on COM components (for instance, Explorer/Internet Explorer), and lots of applications similarly rely on them.  For the time being, at any rate, pure .NET can’t replace COM.  It does become, however, a legacy technology.

But the good news is, you can use COM components from .NET, and you can expose .NET objects as COM components.  The necessary details are worked out for you; all the programmer needs to do is to add some attributes to their code and their .NET classes can be used just like COM components.  Thus the gap between .NET and COM is bridged.  All the messy parts are taken care of by the attributes (this is a demonstration of why attributes are so powerful; two distinct technologies are painlessly integrated using a few lines of code, despite the complexity of what must go on to permit this).

Why haven’t I mentioned C#?

C# is MS’s new language.  It’s a C-style language that is essentially "C++ for Rapid Application Development".  C# is an unusual beast.  Unlike other languages ? for instance, C and C++ ? its specification is just the grammar of the language.  It has no standard library of its own ? no "stdio.h" or "iostream" or any equivalent.  Instead, it was designed with the intention of using the .NET libraries as its own.  Whilst it is heavily dependent on .NET because of this, it isn’t a part of .NET.  It has no special role in the world of .NET ? it compiles to IL, just as any other .NET language does ? and has similar capabilities to other .NET languages (include Managed Extensions for C++ and Visual Basic .NET).  Whilst it’s true that C# would have a hard time surviving without .NET (due to its specification lacking any native library), .NET doesn’t need C#, and would be complete without it.  C# does provide a good match for .NET, however ? almost all of .NET’s features are available cleanly from C#.

.NET and standards

.NET uses a number of open standards extensively; Web Services use SOAP (which uses XML data over an HTTP transport) to interact, UDDI for learning about Web Services, and others.

.NET itself is also subject to some standardization efforts.  The CLR is a superset implementation of something called the CLI ? Common Language Infrastructure ? a standard whose creation is being governed by ECMA.  Technical Committee 39, a group of ECMA members, has undertaken to create a standard for C# and CLI, and to subsequently submit those standards to ISO.  They will then continue their work on those two standards, and ECMAScript (the scripting language originally based on JavaScript/JScript).

The CLI specifies things such as the Common Language Specification (CLS), which is the mechanism used to describe the types, classes, and methods of CLI code, as well as the core class library.  And, as mentioned, the C# specification is also being developed in tandem.

One thing that needs to be made clear is that .NET itself is not "open".  .NET is an implementation, and the notion of "open" does not apply.  However, it is an implementation of open standards.  Its core is an implementation of the standards that ECMA et al. are working on.

.NET goes beyond the specification in a number of areas.  In particular, the specification doesn’t contain ADO.NET (the .NET version of ADO, MS’s high-level database API), or WinForms (for providing windowing capabilities).  These are closely related to ADO/OLEDB (MS’s database access architecture) and GDI+ (the new OO graphics APIs available as add-ons for Win32 OSes), or ASP.NET (a much improved .NETified version of ASP).  Currently, ECMA’s mandate is only to provide a "small set of base classes", so these omissions make sense given that context.  However, one would expect that the standard class library will grow to incorporate such elements given time ? to achieve the stated intent (application portability) such higher-level features seem inevitable.

MS’s implementation of the CLI isn’t alone.  Aside from some MS-led effort to provide a version for FreeBSD, the most promising project is probably Mono.  Mono is being developed by Ximian.  Importantly, Mono will (ideally) have versions of both WinForms and ADO.NET; the WinForms component will use GTK+, the ADO.NET equivalent will use GNOME-DB.  Further discussion of .NET, Mono, and the standards involved can be read here.


That sums up the foundation of .NET.  One thing that hasn’t been mentioned is subscription software.  The simple reason for this is that, despite the claims that have been made in the computing press, .NET is not subscription software.  This begs the question ? why has it been so widely claimed that it is?  The reason for this is presumably due to the Web Service mechanism, which could be used as a mechanism for writing subscription software.  That, however, is a subject for the next article, which will look at software and services built on .NET, or used for building .NET applications.

 

A big thank you to Handor, for your invaluable feedback input.

Assembly and stack walk images ? Microsoft Corporation.  Public-key encryption and digital signing images ? Netscape Communications Corporation. Article text ? Peter Bright.

0 Comments

Comments are closed.