Tuesday, 24 January 2012

6 Reasons to become an ASP.NET Programmer

6 Reasons to become an ASP.NET Programmer.

#1: ASP.NET is compiled and not interpreted.

ASP.NET applications are always compiled and we cannot execute C# code without it being compiled first.

There are 2 stages of compilation:

1) C# code which we write is compiled into intermediate language called Microsoft language MSIL. This is reason that .NET is stated as language independent. All .NET languages are compiled into almost identical IL codes. First compilation happens when page is requested for the first time, or through pre-compilation. The compiled file with IL code is an Assembly

Points to remember here

a) ASP.NET applications are not compiled every time .MSIL code is created once and regenerated only when the source is modified.
b) If we are building web project inside Visual Studio, the code is compiled into IL when we compile the project
c) If we are building a projectless website, the code is compiled when we request the page. For both scenario, compile code goes to JIT.

2) Second stage of compilation happens before the page is actually executed. At this point, the MSIL code is further compiled into low level machine code. This is called JIT , Just in Time compilation.
Point to remember for JIT:

a) Before JIT, compiler needs to know about hardware platform and OS on which application will run on, i.e. 32 bit or 64 bit.
b) As ASP.NET pages are not compiled every time. Similarly, the native machine code files are cached in a system directory that has a path like: \Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.
c) ASP.NET files are found in a directory with a 2.0 version number
Rather than a 3.5 version number because ASP.NET 3.5 uses the ASP.NET 2.0 engine.

Image reference: http://www.malgreve.net/2008/03/windows-process-net-application-domain.html

#2: ASP.NET has multiple language support.

Although when we write code, we will choose any single language like C# and VB.NET, but no matter what language we choose, all code had to get compiled ultimately into MSIL, because IL is the only language which CLR understands. If we compile c# code and look at its IL code, it will be same for vb.NET code. How this is achieved?

CLS: Common Language Specification defines laws that all language (C#, VB.NET) must follow, such as method overloading etc. So any compiler for any language which generates IL code to be executed in CLR must follow rules defined in CLS. The CLS gives developers, opportunity to work within a common set of specifications for languages, compilers, and data types.
*ILDASM is Microsoft visual studio tool to view IL codes.

#3: ASP.NET comes within .NET Framework.

Within .NET Framework classes are grouped into a logical, hierarchical container which is called a namespace and different namespace provides different features. They offer features for all kind of coding which we do, and this called Class Library.
So the way we use these class library classes in ASP.NET is same the way we use in other type of .NET application, like window or standalone. In other words, .NET gives the same tools to
Web developers that it gives to rich client developers.

#4: CLR Hosts ASP.NET

When we write code in ASP.Net, we are said to write managed code, code which runs within CLR. So the whole of .NET is referred to as managed code. So ASP.NET also runs inside the runtime environment of the common language runtime. Now this brings lots of benefits

Image reference: http://geekswithblogs.net/sdorman/archive/2008/11/10/clr-4.0-in-process-side-by-side-clr-hosting.aspx

a) Garbage collection and memory management: The garbage collector keep running periodically inside the CLR, and it automatically get back any unused memory for inaccessible objects. As soon as reference to an object goes out of scope (or your application ends), the object becomes available for garbage collection.
b) Type Safety: when we compile an application, .NET adds information in out assembly that has details like classes, member’s variables, data types, this is called metadata. The benefit of this is that other application can use them with looking for additional files, and compiler can verify that every calls is valid at runtime.
c) Multithreading: CLR gives us pool of thread which various classes can use, which mean with one thread we can do communicate with web services asynchronously , read files etc.

#5: ASP.NET Is Object-Oriented:

While writing code for ASP.NET, we have full access to all objects in the .NET framework. We can also exploit full Object oriented programming conventions, i.e. we can create reusable classes, code with interfaces, extend existing classes with inheritance etc, so ASP.NET have is truly a object oriented language.
Let us understand how it does. Consider server controls, actually they are epitome of encapsulation. From the code behind we can access them and manipulate their object to customize their appearance, can bind data into it. Instead of forcing the developer to write raw HTML manually, the control objects
Render themselves to HTML when the page is finished rendering. In this way, ASP.NET offers server
Controls as a way to abstract the low-level details of HTML and HTTP programming.

#6: ASP.NET applications are easy to deploy and configure.

Deploying an ASP.NET application is relatively simple because with every installation of .NET framework provides the same core classes, all we need is to copy all the files from virtual directory on a production server,. Just make sure that the host machine has .NET installed.
ASP.NET makes configuration simpler by not replying on IIS for security information such as user information and user privileges. This is possible because ASP.NET keeps settings stored inside we.config file. The web.config file is placed in the same directory as your web pages. It contains a hierarchical grouping of application settings stored in an easily readable XML format. When you modify an application setting, ASP.NET notices that change and smoothly restarts the application in a new application domain (keeping the existing application domain alive long enough to finish processing any outstanding requests). The web.config file is never locked, so it can be updated at any time.

Posted by March 2, 2011 
Post a Comment