Introducing the .NET Framework and JScript .NET
The .NET Framework is a unified, object-oriented set of services, libraries, and programming languages, which developers can take advantage of to build robust, networked applications and services. The .NET Framework architecture, shown in Figure 1, is made up of four main components:
- Common Language Runtime -- includes the Common Type System
- .NET Class Library
- Unifying components (ASP.NET and Windows Forms)
- Visual Studio .NET
Basics of the Common Language Runtime
The one sentence definition of the Common Language Runtime is: the Common Language Runtime provides managed execution services to applications that target the .NET Framework. The definition introduces two new concepts: "managed execution services" and "applications that target the .NET Framework".
Figure 1. Architecture of the .NET Platform.
If you write script code within an HTML page you're already familiar with working in an environment that provides "execution services" - for example, consider the code in Listing 1.
Listing 1. A simple HTML Page with Script.
Figure 2. Using IE to open the demo page.
As you review the sample code, you'll notice that the code isn't at all concerned about tasks like managing memory or handling data type conversions. The scripting engine, the entity that's part of Internet Explorer and executes the code in the sample, handles the details of managing memory and ensuring that the data the code uses is of the correct type. The result of the scripting engine's work is that it simplifies the code developers need to write to get their applications working. Another aspect of the code in Listing 1 is that it clearly assumes that a particular type of application or system will consume or execute it -- Internet Explorer is the consumer of the code in this example.
The .NET Common Language Runtime is similar to the scripting engine in Internet Explorer, except that it works for all programming languages that target the .NET Platform (there are about 25 programming languages that are either currently available or under development that target the .NET Platform). Like the scripting engine in Internet Explorer, the Common Language Runtime provides memory and thread management services to applications, but goes beyond that to provide additional benefits like configuration management, error handling, component lifetime management, and security services. As a result of the Common Language Runtime, applications are easier to write, manage, and deploy.
Introduction to the Common Type System
A component of the Common Language Runtime is the Common Type System (CTS). The CTS is a common set of data types that are available to all .NET-programming languages, enabling applications to easily interoperate and exchange data regardless of what programming language they're implemented in. For example, a JScript .NET program can easily use and pass data to another application written in Visual Basic .NET, Visual C# .NET, or any other .NET-programming language. In fact, .NET programming languages transparently map their internal data types, such as JScript's Number type, to their equivalent CTS types without any involvement from the developer -- making cross-language interoperability a breeze! Examples of CTS data types include String, Int32, and UInt64.
Basics of the .NET Class Library
The .NET Class Library is a collection of hundreds of classes and objects that can be used from any .NET programming language. The .NET Class Library models the services that the .NET Framework and underlying operating system provide, establishing an easy to understand and consistent approach to taking advantage of system services regardless of what programming language you use. Some examples of the tasks you can perform using the .NET Class Library include: creating applications with a graphical interface, processing files, working with XML, debugging, working with security sub-systems, and more.
The .NET Class Library is divided into namespaces, as shown in Figure 3, making it easier to work with (a namespace is a logical grouping of related classes). For example, ADO.NET classes and objects -- the updated version of ADO (ActiveX Data Objects) - resides in the System.Data namespace.
Figure 3. Organization of the .NET Class Library.
The unifying components of the .NET Framework bring the other key elements of the .NET Framework together based on two distinct applications models:
- Windows Forms.
ASP.NET provides a Web-based application model in the form of components and controls that make it easy to build Web applications and Web Services. ASP.NET exposes a common set of controls to developers including buttons, text boxes, and other controls. Unlike their equivalent simple HTML controls, which developers must manage on their own using ASP or client-side code, ASP.NET controls manage their state and have advanced rendering capabilities. ASP.NET controls reside on the server and enable developers to work with them without regard to where the controls get rendered (delivered) - making developing Web-based applications much easier. ASP.NET controls render themselves based on the capabilities of the browser that's accessing an ASP.NET page. For example, text field along with a button and some code to ensure that the text field is filled in can be rendered as plain HTML or Dynamic HTML (DHTML - HTML combined with client scripts) depending on the capabilities of the client's browser thereby eliminating a whole class of problems associated with browser incompatibilities.
Page 1 of 2