Common Intermediate Language: Difference between revisions

Content deleted Content added
Fix an external link
m Disambiguating links to Object-orientation (link changed to Object-oriented programming) using DisamAssist.
 
(14 intermediate revisions by 13 users not shown)
Line 3:
{{refimprove|date=November 2017}}
 
'''Common Intermediate Language''' ('''CIL'''), formerly called '''Microsoft Intermediate Language''' ('''MSIL''') or '''Intermediate Language''' ('''IL'''),<ref>{{cite web |url = https://docslearn.microsoft.com/en-us/dotnet/standard/managed-code |title = IntermediateWhat Languageis "managed code"?|publisher=Microsoft| date=19 April &2023 execution}}</ref> is the [[intermediate language]] binary instruction set defined within the [[Common Language Infrastructure]] (CLI) specification.<ref>{{cite web |url = https://www.ecma-international.org/publications-and-standards/filesstandards/ECMAecma-ST335/ECMA <!--335.pdf |page = 32 --> |title = ECMA-335 Common Language Infrastructure (CLI)}}</ref> CIL instructions are executed by a CLICIL-compatible runtime environment such as the [[Common Language Runtime]]. Languages which target the CLI compile to CIL. CIL is [[Object-oriented programming|object-oriented]], [[Stack machine|stack-based]] [[bytecode]]. Runtimes typically [[Just-in-time compilation|just-in-time]] compile CIL instructions into [[native code]].
 
CIL was originally known as Microsoft Intermediate Language (MSIL) during the beta releases of the .NET languages. Due to standardization of [[C Sharp (programming language)|C#]] and the CLI, the bytecode is now officially known as CIL.<ref>{{cite web
Line 12:
 
==General information==
During compilation of [[List of CLI languages|CLI programming languages]], the [[source code]] is translated into CIL code rather than into platform- or processor-specific [[object file|object code]]. CIL is a [[CPU]]- and platform-independent instruction set that can be executed in any environment supporting the Common Language Infrastructure, such as the [[Common Language Runtime|.NET runtime]] on [[Microsoft Windows|Windows]], or the [[cross-platform]] [[Mono (software)|Mono]] runtime. In theory, this eliminates the need to distribute different executable files for different platforms and CPU types. CIL code is verified for safety during runtime, providing better security and reliability than natively compiled executable files.<ref>{{cite book| url = https://books.google.com/books?id=VGT1_UJzjM0C&q=CIL+is+platform-independent&pg=PA15| title = Benefits of CIL| access-date = 2011-02-17| last1 = Troelsen| first1 = Andrew| date = 2009-05-02| publisher = Apress| isbn = 9781590598849}}</ref><ref>{{cite web|url=https://www.visualcplusdotnet.com/visualcplusdotnet1.html|title=Unmanaged, Managed Extensions for C++, Managed and .Net Framework|website=www.visualcplusdotnet.com|access-date=2020-07-07}}</ref>
 
The execution process looks like this:
Line 54:
 
===Object-oriented concepts===
CIL is designed to be object-oriented. YouOne may create objects, call methods, and use other types of members, such as fields.
 
Every [[Method (programming)|method]] needs (with some exceptions) to reside in a class. So does this static method:
Line 137:
 
==Example==
Below is a basic [["Hello, World]]!" program]] written in CIL assembler. It will display the string "Hello, world!".
<syntaxhighlight lang="csharp">
.assembly Hello {}
Line 294:
==See also==
*[[LLVM]]
*[[MLIR (software)]]
*[[List of CIL instructions]]
*[[List of CLI languages]]