Common language Runtime (CLR)

Source: Internet
Author: User

At the core of the. NET Framework is its runtime execution environment, known as the Common Language runtime (CLR) or. NET Runtime. Usually
The code that will run under CLR control is called managed code (mamaged).
However, you need to compile them before the CLR executes the well-written source code (in C # or in other languages).
In. NET, a compilation is divided into two phases:
(1) Compile the source code into Microsoft intermediate Language (IL).
(2) The CLR compiles IL into platform-specific code.
This two-stage compilation process is important because the Microsoft intermediate language is the key to providing many of the benefits of. Net.
Microsoft intermediate Language and Java bytecode share one idea: they are all low-level languages and the syntax is simple (using the digital generation
Code, rather than text codes), can be converted very quickly to local machine code. For code, this well-designed general syntax has
Important Advantages: Platform independence, improved performance, and interoperability of languages.

Platform agnostic
First, this means that the same file that contains the bytecode directive can be placed in either platform, the last stage of the run-time compilation process
It can be done very easily, so that the code can be run on a specific platform. In other words, compiling as an intermediate language gives you the ability to get MT
Platform-agnostic, which is the same as Java-platform-agnostic when compiled into Java bytecode.
Attention. NET platform independence is currently only in the theoretical category, because when writing this book, The complete implementation of MT can only
For the Wmdows platform, but people are actively preparing to make it available to other platforms.

Lift Performance
In front of the IL and Java comparison, in fact, IL than Java bytecode function is larger. Il is always compiled on the fly (called JIT
Compile), and Java bytecode is often interpreted. One disadvantage of Java is that when you run your application, Java bytecode
The process of converting to internal executable code results in a loss of performance (but recently, Java can be JIT-compiled on some platforms).
The JIT compiler does not compile the entire application one at a time (this will have a very long start-up), but instead compiles only the
That part of the code (which is its name by the Dipper.) Once the code has been compiled once, the resulting local executable program is stored until the exit
The application so that it does not need to be recompiled the next time this part of the code is run. Mhmoa that the process should be
It is much more efficient to compile the entire application code than at first, because most of the code for any application is not actually
executed during each run. With the JIT compiler, this code is never compiled.
This explains why the managed IL code is almost as fast as the local machine code, but does not explain why
Microsoft believes this will improve performance. The reason is that the last part of the compilation process is done at run time, and the JIT compiler exactly
To know what type of processor The program is running on, and can take advantage of any features or specific machine code instructions provided by the processor
To optimize the final executable code.
Traditional compilers optimize code, but their optimizations are independent of the specific processor that runs the code. This is because the transmission
Compiler is the code that is compiled into the local machine executable before the software is released. That is, the compiler does not know the processor that is running the code
Type, such as whether the processor is compatible with the XB6 processor or the Alpha processor, which is beyond the scope of the basic operation.

Interoperability of languages

Using IL supports not only platform independence, but also the interoperability of languages. In short, it is possible to compile any language
For intermediate languages, code compiled into intermediate languages can interoperate with code compiled from other languages.

COM and COM +
Technically, COM and COM + are not technology-oriented MT, because their components cannot be compiled into it but
If the original COM component was written in C #, then using managed C # could do so in some way. However, COM +
is still an important tool because its attributes are not in the. Fully implemented in net. In addition, COM components can still use the--. NET
COM interoperability is integrated so that managed code can call COM components, and COM components can call managed code.
In general, the new components are written as net components, mostly for convenience, as this can be exploited. NET base
Other benefits of class and managed code.

Common language Runtime (CLR)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.