The place where the future is�
If you can take a peep into the future you would see .Net written all over it. .Net offers a whole new programming paradigm that will change the way you think about writing Windows based software. This article would help you to understand the nuts and bolts of this bold new technology.
hough not documented there are two nightmares known in the programming world. One is the development nightmare and another is the distribution nightmare. Let�s elaborate on this.
Suppose we wish to develop an Internet application that allows businesses to communicate vital information with each other across existing communication lines. Let�s look at typical solution that can be offered to this problem using Microsoft technologies. If the application is an n-tier application then we would need HTML, DHTML & Java Script in the front-tier; VBScript, ASP, MTS, C++, VB, COM in the middle-tier and SQL, ADO in the back-tier. Developers possessing sufficient skill in all of these areas are few and costly. In short, a perfect recipe for development nightmare.
Even if the developers are able to successfully develop the applications, they would be required to spend hours battling component version conflicts (popularly known as DLL Hell) when the time comes to install their products. Assured distribution nightmare, in short.
Sun�s solution to this problem could be to use Java applets and servlets in the front-tier, Enterprises Java Bean (EJB) or CORBA or RMI in the middle-tier, and JDBC and a suitable database in the back-tier. The common theme here is every developer should learn Java language. This is a far-fetched dream. Though an attempt to make every programmer a Java programmer has met with more than a lukewarm success, the ground reality is that there would be several languages in existence, each camp having its own faithful band of programmers.
.Net is an attempt to bring order to this chaos. .Net is a development platform that makes it easier for programmers using different languages to quickly create robust internet applications. That indeed is a tall claim and we need to examine how much promise it holds. After all we all are aware how quickly technologies appear and vanish.
Why .Net Makes Sense?
If we take a peek at how Windows technologies have evolved over the last decade or so, you would notice that it has been all along a process of slow (and at times painful) evolution. For example, COM (Component Object Model) originated as OLE (Object Linking and Embedding). In the initial days OLE was to a large extent, a means to link different office documents together. From that it evolved into COM, DCOM and finally COM+. Likewise Visual Basic made its debut as a way of placing useful controls into an application. It slowly graduated into a complete development language. Likewise Software Development Kit (SDK) evolved into Microsoft Foundation Classes (MFC). Though new technologies like Active Template Library (ATL) have made their appearance, the emphasis has also been on extending the capabilities of existing technologies. The primary reason for this has been an attempt to ensure backward compatibility. Though the backward compatibility in itself is good it also makes coding for new technologies difficult. For example, at times even experienced developers find the learning curve too steep. One may argue that Visual Basic does avoid complexities, but then Visual Basic is unable to utilize the flexibility offered by Windows API.
.Net is about revolution rather than evolution. One such revolution occurred when the world moved from sequential programming under DOS to Event-driven programming under Windows. Another has come in the form of .Net. It was becoming increasingly difficult for Microsoft to keep extending tools and languages to meet the conflicting demands of exploiting the features of new hardware and language developments and still maintains the backward compatibility. The languages, tools and the environments all were showing signs of strain. It was time to begin with a clean slate. And this fresh start is what .Net and C# is all about. .Net is a new framework for programming on Windows and C# (pronounced as C Sharp) a new language that has been designed to work on .Net. Microsoft�s experience in the developer environments gathered over the last two decades reflects in the .Net framework. Likewise, a deeper understanding of Object-Oriented Programming (OOP) reflects in C#. However, note that the backward compatibility has not been lost entirely. Existing VC++ and VB programs would continue to work. So also would the COM components. VC++ and VB have been enhanced to be able to exploit the capabilities of the .Net framework. However, in many cases where fresh development has to be undertaken coding in C# would be easier and efficient than using VC++.Net or VB.Net.
Let�s now see why would .Net become a popular development environment in future.
Language Of Choice
A developer can pick the .Net language that he likes most, write components in it, and share the compiled binary version of his component with other developers using other .Net languages. As on date there are 22 languages including VB, C++, C#, COBOL, etc. from which the programmer can choose. Microsoft has made the specifications for .Net development platform freely available to compiler vendors in the form of Common Language Specification (CLS). Vendors can develop compilers that produce standard binary code confirming to the CLS.
The language interoperability lets us develop different modules of an application in different .Net compatible languages. All this languages even share the same development environment.
Easy Deployment
Though Dynamic Link Libraries (DLLs) help save disk space and memory by letting different applications share the same code, their usage leads to two problems:
- When a new version of DLL was used to overwrite an earlier version there was a danger of breaking some existing software. It was very difficult to track down such versioning problems.
- A DLL developed in one language may not be usable by another language.
Both these difficulties where avoided in COM. However, in COM the description of methods and interfaces is stored in type-library, whereas, GUIDs are stored in registry. This spreading out of information may make some information go out of sync. This has been avoided in .Net using what are known as assemblies.
Deployment in a .Net environment involves a mere file copy. There are no versioning problems as all the version information is included in the metadata (data about data) that is distributed with the component. Even different versions of the same component can run side by side on the same machine.
Less Plumbing Code
VS.Net development environment eliminates a lot of hand coding by providing wizards and liberal use of drag & drop functionality. .Net also provides standard classes that developers can use to create powerful applications quickly.
Improved Dynamic Web Page Support
More early web sites were static in nature because they were merely collections HTML pages. A need was felt to create HTML pages dynamically (and programmatically) as per the user request. Under Windows platform creation of such dynamic web pages were done using ASP (Active Server Pages) scripts. Though we can write powerful ASP scripts it still suffers from two limitations�it is an interpreted scripting language and it is non object-oriented. .Net eliminates these difficulties. The code in the dynamic web pages is compiled and can be written in a .Net aware language like C#. This technology is known as ASP.Net and it processes browser requests in a more efficient manner.
Support For Web Services
In the next few years, lot of software components would become available in the form of Web Services. Some examples can be service to calculate tax, service to get whether report, service to track shipment, service to evaluate credit card, etc. The clients will have to simply subscribe these services to be able to use them. Before .Net Microsoft provided limited support for web services through the SOAP (Simple Object Access Protocol) toolkit. .Net offers extensive support for developing web services.
The .Net Framework
.Net is actually wrapper around the operating system. Software developed with .Net doesn�t have to worry about operating system tasks like File Handling and Memory Allocation. Even though Microsoft doesn�t say so, this appears to be a silent preparation for the future where the software developed for .Net would be portable to a wide variety of Hardware and OS. Beta version of VS.Net supports all versions of Win2000, Windows NT4, Win9X and Windows ME. .Net makes development of Internet applications as easy as Desktop applications. Secondly, it provides a very high level of integration of front, middle and back-tier. The following figure shows major components of .Net framework.

Figure 1.1: .Net Framework
Let�s now understand these three components.
The Common Language Runtime
A runtime is an environment in which programs are executed. For example, to execute a program written in VB6, the machine must have a VB runtime (msvbvm.dll) installed. Similarly VC++ programs and Java programs too require unique runtime components. Since different languages require different runtime the developer�s life becomes more difficult. Imagine a situation where an ActiveX control has been developed in VB. While downloading this component a user may also have to download the VB runtime if it is not already installed on the machine. And imagine what would be the solution if Windows weren�t installed on the machine.
To avoid such problems .Net introduces a single Common Language Runtime (CLR) that all .Net languages share. The following figure shows how CLR works.

Figure 1.2: Execution Process Under .Net Framework
Once our code is written, we compile it, and the compiler translates it to Microsoft Intermediate Language (MSIL). MSIL is a CPU-independent set of instructions that can be efficiently converted to native (CPU dependent) code. MSIL code is a language independent code. The Linker then links the IL code converted by one language compiler with the IL code compiled by another language compiler. The result is an EXE or DLL, containing the IL code, which is saved to disk. VS.Net comes with different language compilers to generate IL code. Then on execution, the IL code and any requested functionality from the .Net base classes is brought together. The JIT compiler processes the combined code creating managed native code (Code that targets the runtime is called managed code. The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used.), which is passed to the CLR.
Older applications that are not .Net aware (unmanaged applications) will continue to work with Windows as they always have done. The following figure captures the difference between managed and unmanaged applications.

Figure 1.3
.Net Base Classes
.Net supplies a library of base classes that developers can use to implement applications quickly. Developers can either use them by building objects from these classes and invoking the class methods. Alternately they can derive new classes from these standard classes. These classes include:
- Classes and types related to basic database management.
- Classes to debug an application and to trace the execution.
- Types that allow reading/writing to files and other data streams.
- Members to calculate common mathematical quantities.
- Capability to inspect metadata.
- Types, which enable security capabilities.
User And Program Interfaces
This forms the top layer in the .Net architecture. This includes Windows Forms, Windows Application Services, Web Forms and Web Services. Windows forms (often called as WinForms) offer a new way to create standard Win32 desktop applications. Web Forms provide a powerful, form-based user-interface for the web. Web Services provide a mechanism for programs to communicate over the Internet using SOAP (Simple Object Access Protocol). These services are similar to COM/DCOM services that were used for object brokering & interfacing. However, Web Services allow integration with non-Microsoft platform as well.
The potential of Web Services is unlimited. For example, a software company may provide a Web Service to calculate income tax. Any company that wants to calculate income tax can subscribe to this Web Service. The customer company need not deploy the income tax calculator. It simply needs to access the Web Service. The company offering the service can dynamically update it to accommodate new taxation rates. The subscribers won�t have to do anything to get the new updates. In future a collection of such Web Services may replace packaged software. Other Web Services that can be developed include weather information, stock quotes, shipping status, news items, etc. I think you get the picture now.