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".

The listing is a simple HTML page that contains some JavaScript code. The person function isn't a true function in the sense that it doesn't do anything useful - it takes two parameters and copies them to itself using the this object. When the code in the createPerson function executes, Internet Explorer creates an instance of a person object and dynamically adds two new attributes to it (name and email). The code in the demo function uses the name and email attributes of the new person object to populate the input box that's on the page - the result of opening the page is shown in Figure 2.

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.

Unifying Components

The unifying components of the .NET Framework bring the other key elements of the .NET Framework together based on two distinct applications models:

ASP.NET

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.

Windows Forms provide a rich user experience by exposing a common set of controls to all .NET programming languages making it easy to build "traditional" windows applications (applications that, in large part, execute on a user's system and have a graphical interface). For example, JavaScript and JScript developers traditionally rely on browsers like Internet Explorer to provide user interface capabilities for their applications. The Windows Scripting Host provides a simple command-line based interface and some message boxes, and is far from providing complete graphical application support. Through Windows Forms, JavaScript and JScript developers can easily create a Windows application - complete with menus and other common controls.