A little thought about .NET Framework, CTS, CLI, CLS, CLR and C#

/*

Author: Jiangong SUN

*/


Terms:

CTS: Common Type Specification

CLI: Common Language Infrastructure

CLS: Common Language Specification

CLR: Common Language Runtime

JIT: Just In Time 

CIL: Common Intermediate Language

MSIL: MicroSoft Intermediate Language 

VES: Virtual Execution System

NGEN: Native image GENerator

FCL: Framework Class Library

BCL: Base Class Library


Relationships: 

CLR  <==> VES <==> JVM in Java

Managed code <==> MSIL <==> CIL

Unmanaged code <==> native code <==> machine code


CLR, CTS, CLS and metadata specification are all parts of CLI.

CTS: Microsoft introduces CTS to intercommunicate among data types in different programming languages.

CLS: It defines rules that all .NET languages should respect, and it's part of CTS.

CLR is the Microsoft implementation of VES. 

CLR contains: Garbage collector for automatic memory management, JIT for compilation from CIL to native code, Type checker, Debug engine, Security engine, Class loader, Thread support, Exception manager, Com marshaler.


Computers can only understand machine code.

Machine code is a sequence of binary (1 and 0).


C# is a compiled language, because it's compiled to CIL, and then it's interpreted by JIT to machine code.


The difference between compiled language and interpreted language is: Interpreted language will be executed by interpretor, line by line on local machine.


Compiled language:

More rapid execution speed, because it’s already compiledand targeted to local machine

Less memory usage, because it’s compiled


Interpreted language:

Independent platform, because it doesn’t need to be compiled

Code size is smaller than compiled code


.NET Framework: consists of Common Language Runtime and Class Library. 


C# source code execution steps:

C# source code --C# Compiler(csc.exe) --> CIL/MSIL (managed code/ byte code) stores in assemblies like DLL or EXE --JIT in CLR or NGEN--> native code (unmanaged/machine code) --> Execution


Difference between managed code and native code/machine code/unmanaged code:

Code compiled by C# sharp compiler is called managed code, it's stored in assemblies like DLL or EXE files.

Managed code is the intermediate code between source code and native code.

Managed code is CPU independent code.


MSIL must be converted to CPU-specific code which is machine code to be run, it will be compiled by JIT compiler in CLR at runtime.

CLR supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture.

Native code runs straight on the CPU. They are machine code targeted towards a specific architecture (for instance, Intel's x86). It'sCPU-Specific code.

Native code is the code whose memory is not "managed". There is no reference counting, no garbage collection.


Assembly contains metadata type, assembly manifest who contains assembly metadata, CIL, and resources.

Metadata is data describes the states of assembly and a detailed description of each type and attribute in application.

Metadata contains: 

- Descriptions of assembly: Identity (Name, version, culture, public key), the types that are exported, other assemblies that the assembly depends on, security permissions needed to run.

- Description of types: Name, visibility, base class, and interfaces implemented, members (methods, fields, properties, events, nested types)

- Attributes: additional descriptive elements 



Difference between JIT and NGEN:

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. 

Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly.



references:

http://stackoverflow.com/questions/601974/clr-vs-jit

http://fr.slideshare.net/ArunPrasadVidhyaarthi/introduction-to-net-framework

http://core-techno.blogspot.fr/2011/06/basics-of-net-framework-il-clrctscls.html

http://www.codeproject.com/Articles/1825/The-Common-Language-Runtime-CLR-and-Java-Runtime-E#_computers

http://stackoverflow.com/questions/5525082/jit-vs-ngen-what-is-the-differene

http://msdn.microsoft.com/en-us/library/zw4w595w.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值