ASP.NET基礎再出發系列 之一

來源:互聯網
上載者:User

什麼是.net framework?

==========================

你可以把.net framework看作是編寫和運行軟體的一個可安裝的基礎設施. 你在Windows作業系統上安裝了這個基礎設施之後, 它就會建立一個龐大的代碼類的庫用以協助你書寫代碼, 它還會建立一個與這些代碼相匹配的運行平台, 也叫做進程虛擬機器或應用程式虛擬機器.

 

.net framework可以工作在很多不同的代碼語言上, 確切的說是任何一種支援.NET的語言, 比如說C#, ASP.NET, VB.NET. 這個基礎設施包含各種各樣的類, 涵蓋諸如User Interface rendering, 檔案讀寫, 資料庫連接, 網路通訊, 加密等等方面. 所有的這些都在base class library中, 程式員在寫代碼的時候會將這些基礎類應用到自己的代碼中去.

 

.net framework的精準定義如下:

A process virtual machine runs inside the OS as a normal application. It serves a single application process and is spun up when the application begins, and destroyed when the application stops. This little, isolated environment helps the code inside to be indifferent to hardware and OS details.

它是一個在作業系統上啟動並執行普通應用程式進程. 它提供了一個單獨的應用程式進程, 並且在應用程式開始的時候被建立, 並在應用程式結束的時候被銷毀. 這個小的, 隔離的環境會協助其中的代碼忽略作業系統和硬體的細節.

 

什麼是CLR?

==========================

CLR全稱是Common Language Runtime, 它是.net initiative的核心部分, 更重要的, 它或許是CLI(common language infrastructure)標準的核心部分. 它是由.net提供的用於運行軟體的虛擬機器.

The purpose of the Common Language Infrastructure, or CLI, is to provide a language-neutral platform for application development and execution, including functions for exception handling, garbage collection, security, and interoperability.

Common Language Infrastructure(CLI)的目的是為應用程式開發和執行提供一個非語言相關的平台, 其中包括用於實現異常處理, 垃圾收集, 安全控制和互通性的函數.

 

CLR是.net framework的虛擬機器組件. 所有的.net程式在CLR的監督之下執行, 從而保證在記憶體管理, 安全, 異常處理方面的某些屬性和行為得到設定和執行.

CLI標準定義了一個環境, 這個環境允許在不同的電腦平台上, 多種進階語言可以在其中使用而不需要針對某種架構重新編寫. 它有點像為DLL服務的硬體抽象層(HAL), 這樣開發人員就不需要擔心運行程式或DLL的作業系統或者CPU的種類.

 

During compilation of .NET programming languages, the source code is translated into Common Intermediate Language code rather than platform or processor-specific object code. CIL is a CPU- and platform-independent instruction set that can be executed in any environment supporting the Common Language Infrastructure (either the .NET runtime on Microsoft Windows operating system, or the independently derived Mono, which also works on Linux or Unix-based operating systems). CIL code is verified for safety during runtime, providing better security and reliability than natively compiled binaries.

在.net程式設計語言的編譯過程中, 原始碼彙編翻譯為Common Intermediate Language(通用中繼語言)代碼, 而不是被翻譯為面向具體平台或處理器的目標代碼. CIL是一種獨立於CPU和平台的指令集, 該指令集可以在任何支援Common Language Infrastructure的平台上執行(可以是windows作業系統上的.net runtime, 或者是獨立派生的叫做Mono的平台, Mono可以在Linux或基於Unix的作業系統上工作). CIL代碼會在運行時候驗證安全性, 從而比natively編譯的二進位檔案有更好的安全性和健壯性.

 

你作為一個開發人員, 在.NET 進階語言上進行編寫代碼的工作, 比如說C#.

編譯器讀取你的代碼後建立中繼語言(CIL)代碼, 這種代碼是比較低等級的, 但是仍然是可以讀懂的代碼.

在運行時, just-in-time編譯器會把CIL代碼翻譯為’native code’, 所謂native是指對某個指定的OS是native的.

 

 

CLR負責一下的方面:

  • 記憶體管理
  • 線程管理
  • 異常處理
  • 垃圾收集
  • 代碼安全

 

那麼什麼是Just-in-time編譯呢?

==================================

Just-in-time compilation (dynamic translation) is a way of improving code/program performance. Instead of compiling ahead-of-time (which is the other, static type of code compilation), JIT is always compiling just as code is needed, and if a piece is already compiled, this piece will be cached for later use.

Just-in-time編譯, 也叫dynamic translation(動態翻譯), 是一種提供代碼或程式效能的途徑. JIT從來只是在代碼需要被執行的時候進行編譯, 而不是在執行前全部編譯(也就是另一種靜態代碼編譯方式), 並且如果一段代碼已經編譯過了, 那麼這個編譯過的段會被緩衝起來供稍後使用.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.