|
Overview
Managed Extensions for C++ is a set of keywords and attributes to bring the C++ syntax and language to the .NET Framework. It is commonly referred to as Managed C++. NOTE: Managed C++ is being superceded by a new language set, designated C++/CLI, which as of early 2005, is currently in beta testing. The information provided in this article will eventually become obsolete. Managed C++ is not a complete standalone, or fully fledged programming language, but it is merely a set of grammatical and syntaxual extensions implemented by Microsoft to bring C++ to the .NET Framework (essentially, the CLR) and to allow for managed programming for C++ programmers. Microsoft Corporation, (NASDAQ: MSFT) headquartered in Redmond, Washington, USA, was founded in 1975 by Bill Gates and Paul Allen. ...
Scope of this article It is also advised to the reader that this article be interpreted merely as informational and not to provide a tutorial on Managed Extensions for C++. While conventions and syntax may be explained here, it will not provide a 'crash-course' or anything like that on how to program using Managed C++. Also, as stated before, this article will eventually be superceded by the already-in-beta-testing langauge, C++/CLI.
Who would use Managed C++ One of the many things about Managed C++ is the question of its useability. Who would use Managed C++ when C# and Visual Basic .NET are already very powerful languages to use for programming with the .NET Framework? The main purpose of Managed C++ was not only to provide C++ programmers to utilize their skills in C++ to access a rich and stable platform for Windows Programming, but also to allow existing C++ projects and source code to be speedily ported over to the .NET Framework, should programmers require it. Since Microsoft has already released plans to base its next generation operating system, Longhorn, partly on managed code, it would be logical to assume that existing technologies that Microsoft implements itslef would be ported and re-implemented to provide the same base design and accessibility as the technology changes. It can be assumed that Managed C++ was conceived soley based on that reason. The name Longhorn can refer to one of several things: Texas longhorn cattle. ...
Summary of additional or ammended functionality provided in Managed C++ Programs coded in Managed C++ provide additional functionaliy of the .NET Framework and the CLR such as: Exensible Metadata - Which is the information provided to describe the structure and types of a managed component. It can be extended and reused to create software components. It is used heavily in C# and Visual Basic .NET Garbage Collection - The CLR is fully managed by a garbage collector, so all applications and programs coded in Managed C++ need not worry about memory management. It is a process automated by the CLR itslefl i.e. the delete operator need never be called in managed C++ code. Code Reusability and Interoperability - Code targeted for the .NET Framework produces MSIL (MS Intermediate Language, similar to Java bytecode) and thus, modules compiled and components (assemblies rather) can be reused by other program components written in another language targeting the .NET Framework, such as JScript .NET, C#, Visual Basic .NET and other 3rd party languages for .NET. This provides the potential to use Managed C++ code in your simple JScript .NET scripts or applications. Versioning Capabilities - New methods and data members can be introduced into existing managed classes without breaking binary compatibility with existing client side software. Binary Headers - This provides for the reusing of any precompiled metadata; any .exe, .dll, .obj or .netmodule compiled into MSIL can be referenced from a C++ source file and be reused. This is comparably faster than referencing an uncompiled C++ source code file. Increased Code Protection - With the introduction of garbage collection into C++, Managed C++ is less prone to the common buffer overflow errors caused by the absence of data type checking in unmanaged C++. The garbage collector helps to reduce (not completely though) the frequency of these errors. In computer programming, a buffer overflow is an anomalous condition where a program somehow writes data beyond the allocated end of a buffer in memory. ...
Unified Programming - Managed C++ also has the potential to be less verbose than standard unmanaged code, since all managed function calls and inherited classes are derived from the .NET Framework Base Class Library (BCL, sometimes referred to as FCL or Framework Class Library), whose API provides TCP/IP networking capabilities, textual manipulation functions, data access (from ODBC to SQL), XML services (from XSD to XSL), GUI programming (Windows Forms), mail services (SMTP), cryptography (X509 Certificates and XML digital signatures), MSIL generation (essentially emitting instructions in MSIL), file I/O, manual manipulation of the CLR garbage collector and even providing management information to manipulate the WMI console.
Advantages of using Managed C++ over unmanaged code - Programmers need not worry about manual memory management, any classes under Managed C++ can be designated to be managed by the CLR garbage collector simply by adding a modifier keyword, __gc before the class keyword. i.e. __gc class new { }; is managed under the garbage collector.
- Managed and unmanaged code can be mixed together in the same assembly seamlessly. This provides for the programmer to keep unmanaged code that cannot be ported over to the .NET Framework in the same program without re-writing it completely. Some ramifications of using this hybrid convention are present though.
Disadvantages of using Managed C++ over unmanaged code - Stated preceding this section is the statement that Managed C++ code could be less verbose than unmanaged code. This statement only applies to API references between different libraries. Managed C++ introduces alot of new keywords and syntaxual conventions that can impede on the readability of managed code. A very bad example of quite verbose managed C++ code is the declaration of an array of arrays.
- Like in Java, there is the presence of an unnecessary overhead of features that most Managed C++ programmers and programs don't really need. This will reduce performance on most applications. The overhead of a garbage collector is the main performance inhibitor. In almost all performance critical applications, unmanaged native code is the preferred option.
- Managed C++ is to be superceded by C++/CLI and thus is to be made obsolete when beta testing on C++/CLI finishes.
- Managed C++ does not support ASP.NET web applications. Note: It is not implied by the preceding sentence that it would be a good thing that Managed C++ was supported by ASP.NET, simpler, less strict languages such as JScript would be much more appropriate for ASP.NET, as most people would agree.
- Managed C++ requires a slightly harder learning curve than other .NET languages that could be applied to projects that still produce the same result, since the implications of pointers in C++ are still required, even in managed C++ code.
TO BE FINISHED Wikibooks has more about this subject: Programming:Java Java is an object-oriented programming language developed initially by James Gosling and colleagues at Sun Microsystems. ...
|