Common Language Runtime (CLR)

   

A language runtime is what allows an application to run on a target computer; it consists of code that is shared among all applications developed using a supported language. A runtime contains the "guts" of language code, such as code that draws forms to the screen, handles user input, and manages data. The runtime of .NET is called the Common Language Runtime (CLR).

Unlike runtimes for other languages, the CLR is designed as a multilanguage runtime. For example, C# and Visual Basic both use the CLR. In fact, currently more than 15 language compilers are being developed to use the CLR.

Because all .NET languages share the CLR, they share the same IDE, the same forms engine, the same exception-handling mechanism, the same garbage collector (discussed shortly), and much more. One benefit of the multilanguage capability of the CLR is that programmers can leverage their knowledge of a given .NET language. For example, some developers on a team may be comfortable with C#, whereas others are more comfortable with Visual Basic. Because both languages share the same runtime, both can be integrated to deliver a solution. In addition, a common exception-handling mechanism is built into the CLR so that exceptions can be thrown from code written in one language and caught in code written in another .NET language.

graphics/newterm.gif

Code that runs within the CLR is called managed code because the code and resources used by the code ( variables , objects, and so on) are fully managed by the CLR. C# is restricted to working only in managed code, but some languages (such as C++) are capable of dropping to unmanaged code ”code that isn't managed by the CLR. One big advantage with working in managed code is that the CLR provides garbage collection ”the automatic freeing up of unused resources. You'll learn a bit more about garbage collection later in this hour .

Another advantage of the CLR is that all .NET tools share the same debugging and code-profiling tools. In the past, languages such as Visual Basic were limited to their own debugging tools, whereas languages such as C++ had many third-party debugging tools available. Now, all languages share the same tools. This means that as advancements are made to the debugging tools of one product, they're made to tools of all products because the tools are shared. This aspect goes beyond debugging tools. For example, add-ins to the IDE (such as code managers) are just as readily available to C# as they are to Visual Basic ”or any other .NET language, for that matter.

graphics/bookpencil.gif

Although Microsoft hasn't announced any official plans to do so, it's possible that Microsoft could produce a version of the CLR that runs on other operating systems, such as Macintosh or Linux. If this occurs, the applications that you've written for Windows should run on a newly supported operating system with little or no modification.


   
Top


Sams Teach Yourself C# in 24 Hours
Sams Teach Yourself Visual Basic 2010 in 24 Hours Complete Starter Kit (Sams Teach Yourself -- Hours)
ISBN: 0672331136
EAN: 2147483647
Year: 2002
Pages: 253
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net