Managed code: Difference between revisions

Content deleted Content added
MrGumballs (talk | contribs)
Link suggestions feature: 1 link added.
 
(33 intermediate revisions by 30 users not shown)
Line 1:
{{Short description|Computer program code}}
'''Managed code''' is computer program code that requires and will execute only under the ''management'' of a [[Common Language Runtime]] [[virtual machine]], typically the [[.NET Framework]], or [[Mono (software)|Mono]]. The term was coined by [[Microsoft]].
{{RefImprove|date=April 2019}}
 
'''Managed code''' is [[computer program]] code that requires and will execute only under the ''management'' of a [[Common Language RuntimeInfrastructure]] (CLI); [[Virtual Execution System]] (VES); [[virtual machine]], typicallye.g. the[[.NET]], [[CoreFX]], or [[.NET Framework]],; [[Common Language Runtime]] (CLR); or [[Mono (software)|Mono]]. The term was coined by [[Microsoft]].
Managed code is the compiler output of [[source code]] written in one of over twenty high-level programming languages that are available for use with the Microsoft .NET Framework, including C#, J#, Microsoft Visual Basic .NET, Microsoft JScript and .NET, while unmanaged code refers to programs written in [[C (programming language)|C]], [[C++]], and other languages that do not need a runtime to execute. Managed code in the Microsoft .Net Framework is defined according to the [[Common Intermediate Language]] specification.
 
Managed code is the compiler output of [[source code]] written in one of over twenty high-level [[List of CLI languages|programming languages]], including [[C Sharp (programming language)|C#]], [[J Sharp|J#]] and [[Visual Basic .NET]].
== Terminology ==
The distinction between managed and unmanaged code is prevalent and only relevant when developing applications that interact with the [[.NET Framework]] or other Common Language Runtime (CLR) implementations, like [[Mono (software)|Mono]]. Since many older programming languages have been ported to the CLR, the differentiation is needed to identify ''managed'' code, especially in a mixed setup. In this context, code that does not rely on the CLR is termed ''unmanaged''.
 
== Terminology ==
A source of confusion was created when Microsoft started connecting the .NET Framework with C++, and the choice of how to name the [[Managed Extensions for C++]]. It was first named ''Managed C++'' and then renamed to ''[[C++/CLI]]''. The creator of the C++ programming language and member of the C++ standards committee, [[Bjarne Stroustrup]], even commented on this issue, "On the difficult and controversial question of what the CLI binding/extensions to C++ is to be called, I prefer C++/CLI as a shorthand for "The CLI extensions to ISO C++". Keeping C++ as part of the name reminds people what is the base language and will help keep C++ a proper subset of C++ with the C++/CLI extensions."<ref name="Stroustrup">{{cite web |author=Stroustrup, Bjarne |title=Bjarne Stroustrup's FAQ: What do you think of C++/CLI? |date=2009-06-29 |url=http://www.stroustrup.com/bs_faq.html#CppCLI |accessdate=2009-06-29 }}</ref>
The true and fine distinction between managed and unmanaged code is prevalent and only relevant when developing applications that interact with theCLR [[implementations.NET Framework]]Since ormany otherolder Commonprogramming Language Runtime (CLR) implementations, likelanguages [[Mono List_of_CLI_languages|(softwarelist)|Mono]]. Since many older programming languages have been ported to the CLR, the differentiation is needed to identify ''managed'' code, especially in a mixed setup. In this context, code that does not rely on the CLR is termed ''"unmanaged''".
 
A source of confusion was created when Microsoft started connecting the .NET Framework with [[C++]], and the choice of how to name the [[Managed Extensions for C++]]. It was first named ''Managed C++'' and then renamed to ''[[C++/CLI]]''. The creator of the C++ programming language and member of the C++ standards committee, [[Bjarne Stroustrup]], even commented on this issue, "On the difficult and controversial question of what the CLI binding/extensions to C++ is to be called, I prefer C++/CLI as a shorthand for "'The CLI extensions to ISO C++"'. Keeping C++ as part of the name reminds people what is the base language and will help keep C++ a proper subset of C++ with the C++/CLI extensions."<ref name="Stroustrup">{{cite web |author=Stroustrup, Bjarne |title=Bjarne Stroustrup's FAQ: What do you think of C++/CLI? |date=2009-06-29 |url=http://www.stroustrup.com/bs_faq.html#CppCLI |accessdateaccess-date=2009-06-29 }}</ref>
== Uses ==
 
== Uses ==
The [[Microsoft's Visual C++]] development environmentcompiler can produce both managed code, running under the .NET CLR, or compiledunmanaged binaries, running directly on the Windows platform with the help of its C++ Runtime Library.<ref name="Gregory">{{cite web |author=Gregory, Kate |date=2003-04-28 |title=Managed, Unmanaged, Native: What Kind of Code Is This? |date=2003-04-28 |url=httphttps://www.developer.com/netmicrosoft/cplusc-sharp/article.phpmanaged-unmanaged-native-what-kind-of-code-is-this/2197621 |accessdateaccess-date=2009-04-22 }}</ref>
 
Benefits of using managed code include programmer convenience (by increasing the level of abstraction, creating smaller models) and enhanced security guarantees, depending on the platform (including the VM implementation). DrawbacksThere includeare slowermany startuphistorical speedexamples of code running on virtual machines, such as (the managedlanguage code[[UCSD mustPascal]] beusing [[Justp-incode machine|p-timecode]], compilationand the operating system [[Inferno_(operating_system)|JITInferno]] from [[Bell compiledLabs]] byusing the VM)[[Dis andvirtual generallymachine]]. increased[[Java use(programming oflanguage)|Java]] systempopularized resourcesthis onapproach anywith machineits that[[Java isbytecode|bytecode]] executingexecuted by the code[[Java virtual machine]].
 
[[Google]] also mentions that [[Java (programming language)|Java]] and [[Kotlin (programming language)|Kotlin]] are managed code in their [[Android software development#NDK|Android NDK]] [[Java Native Interface|JNI]] documents. <ref>{{Cite web|title=JNI tips {{!}} Android NDK|url=https://developer.android.com/training/articles/perf-jni|access-date=2020-06-21|website=Android Developers|language=en}}</ref><ref>{{Cite web|title=Getting started with C++ and Android Native Activities|url=https://medium.com/androiddevelopers/getting-started-with-c-and-android-native-activities-2213b402ffff}}</ref>
There are many historical examples of code running on virtual machines, such as the language [[UCSD Pascal]] using [[p-code machine|p-code]], and the operating system [[Inferno (operating system)|Inferno]] from [[Bell Labs]] using the [[Dis virtual machine]]. Java popularized this approach with its [[Java bytecode|bytecode]] executed by the [[Java virtual machine]]. The WLanguage of WINDEV is also a pCode running on a virtual machine.
 
==References==
Line 22 ⟶ 24:
*[http://channel9.msdn.com/Showpost.aspx?postid=68302 Microsoft Research OS written in managed C# code], Channel 9
 
[[Category:.NET Framework terminology]]