A New Programming Platform
Let us look at what we have just discussed from the point of view of .NET as a new programming platform:
Code can be
to prevent unauthorized actions.
It is much easier to program than the Win32 API or COM.
of the platform can be implemented on many different kinds of computers (as has been done with Java).
All the languages use one class library.
with each other.
There are several important features to the .NET platform:
Modern programming relies heavily on reusable code provided in libraries. Object-oriented languages facilitate the creation of class libraries, which are flexible, have a good degree of abstraction, and are extensible by adding new classes and basing new classes on existing ones, "inheriting" existing functionality.
The .NET Framework provides over 2,500 classes of reusable code, which can be called by all the .NET languages. The .NET Framework is extensible, and new classes can inherit from existing classes, even those implemented in a different language.
Examples of classes in the .NET Framework include Windows programming, Web programming, database programming, XML, and interoperability with COM and Win32. The .NET Framework is discussed in the
chapter and throughout the rest of the book.
Common Language Runtime
provides services to executing programs. Traditionally, there are different
for different programming environments. Examples of run-times include the standard C library, MFC, the Visual Basic runtime, and the Java Virtual Machine. The runtime environment provided by .NET is called the Common Language Runtime, or CLR.
Managed Code and Data
The CLR provides a set of services to .NET code (including the .NET Framework, which sits on top of the CLR). In order to make use of these services, .NET code has to behave in a predictable fashion, and the CLR has to understand the .NET code. For example, to do runtime checking of array boundaries, all .NET arrays have identical layout. NET code can also be restricted by type safety requirements.
As we will discuss in the next chapter, the restrictions on .NET code are defined in the Common Type System (CTS) and its implementation in the Microsoft Intermediate Language (MSIL or IL). The CTS defines the types and operations that are allowed in code running under the CLR. For example, it is the CTS that restricts types to using single implementation inheritance. MSIL code is compiled into the native code of the platform.
.NET applications contain metadata, or descriptions of the code and data in the application. Metadata allows the CLR, for example, to automatically serialize data into a storage.
Code that can use the services of the CLR is called managed code.
Managed data is allocated and deallocated automatically. This automatic deallocation is called
. Garbage collection
memory leaks and similar problems.
Microsoft and ECMA
Microsoft has submitted specifications for the C# programming language and
parts of the .NET Framework to the European Computer Manufacturers Association (ECMA) for standardization. The ECMA specification defines the platform-independent Common Language Infrastructure (CLI). The CLR can be thought of as the CLI plus the Base Class Libraries (BCL). The BCL has support for the fundamental types of the CTS, such as file I/O, strings, and formatting. Since the CLR is platform-dependent, it makes use of the process and memory management models of the underlying operating system.
The ECMA specification defines the Common Intermediate Language (CIL). The ECMA specification allows for CIL to be compiled into native code or interpreted.
Managed code can be checked for type safety. Type-safe code cannot be subverted. For example, a buffer overwrite cannot corrupt other data structures or programs. You can only enter and leave
at fixed points; you cannot calculate a memory address and start executing code at an arbitrary point. Security policy can be applied to type-safe code. For example, access to certain files or
interface features can be allowed or
. You can prevent the execution of code from unknown sources.
Not all code that makes use of the facilities of the CLR is
type safe. The classical example is managed C++. Managed C++ code can make use of CLR facilities such as garbage collection, but cannot be
to be type safe.
Multiple Language Development
suggests, the CLR supports many programming languages. A "managed code" compiler must be implemented for each language. Microsoft itself has implemented compilers for managed C++, Visual Basic .NET, Jscript, and the new language C#. Well over a
other languages are being implemented by third parties, among them COBOL by Fujitsu and Perl by ActiveState. To accommodate the use or creation of .NET data types, however, new syntax often has to be introduced. Nonetheless, programmers do not need to be retrained in a completely new language in order to gain the benefits of .NET. Legacy code can be accessed through the interoperability mechanism.
A practical key to success in software development is a set of effective tools. Microsoft has long provided great tools, including Visual C++ and Visual Basic. With .NET they have combined their development tools into a single integrated environment called Visual Studio .NET.
VS.NET provides a very high degree of functionality for creating applications in all the languages supported by .NET.
You can do multiple language programming, debugging, and so on.
VS.NET has many kinds of designers for forms, databases, and other software elements.
As with the languages
, third parties can provide extensions to Visual Studio .NET, creating a seamless development environment for their language that interoperates with the other .NET language. The tool set includes
support for building Web applications and Web services. There is also great support for database application development.
The Importance of Tools
The importance of tools should not be underestimated. Ada, a very powerful programming language, never achieved widespread use. While part of the initial vision was to create a standard Ada Programming Support Environment (APSE), most of the attention was paid to specifying the language, not the APSE. Consequently, Ada never did develop any development environment comparable to that of Visual Studio, Smalltalk, or some of the Java
Visual Studio .NET will be highly
for productivity, and much training will be available. Microsoft has far more resources to throw at Visual Studio .NET than do smaller
in the highly
tools market. Java is highly standardized in the language and API, but tools, which are required for productivity, are not standard.