About C++/CLI

Problems with the old Managed C++ syntax

The main complaint everyone had about the Managed Extensions to C++ was that the syntax was too ugly and twisted with all those double underscores thrown about. People also felt that compared to C#, MC++ was a second class .NET language and didn’t directly support the CLI, but used contorted workarounds – for example MC++ did not have a for-each keyword construct.

C++ programmers also found the poor integration between C++ and .NET a major disadvantage when they considered moving to .NET using MC++; for example you couldn’t use C++ features like templates on CLI types and you couldn’t use CLI features like garbage collection on C++ types. To make things more confusing, both unmanaged C++ pointers and managed reference pointers used the same * based syntax which was quite confusing because __gc pointers were totally different in nature and behavior from unmanaged pointers.

And there was another issue with code verification – MC++ produced executables were not verifiable and this was an area where C# had a big advantage over MC++ applications.

ECMA ruling

On October 6th 2003, the ECMA announced the creation of a new task group to oversee development of a standard set of language extensions to create a binding between the ISO standard C++ programming language and Common Language Infrastructure (CLI). It was also made known that this new set of language extensions will be known as the C++/CLI standard, which will be supported by the VC++ compiler starting with the Whidbey release (VS.NET 2005).

Advantages with C++/CLI

The C++/CLI standard proposed an elegant syntax and grammar for writing managed applications with C++. This gave a natural feel for C++ developers and allowed a smooth transition from unmanaged coding to managed coding.

C++/CLI offered first-class support to CLI features like properties, garbage collection, generics for both managed and unmanaged classes. C++/CLI also supported native C++ features like templates and deterministic destructors on both managed and unmanaged types. So essentially, C++/CLI successfully bridges the gap between C++ and .NET, and brings the best of both worlds to both unmanaged and managed programming.

And the icing on the cake is that the C++/CLI compiler outputs fully verifiable .NET code and now those annoying C# programmers can stop bragging about something their compiler does that the C++ compiler couldn’t do.

Oh well, I guess that’s it from me for the moment.

Advertisements

3 thoughts on “About C++/CLI

  1. Hi Nish,

    How to declare a pointer to pointer in managed environment?

    public class ref Buffer //managed class
    {
    private:
    Image** m_images;
    };

    Here Image is also a managed C++ class.

    I am trying to do like this. But it is not working.
    Could you please help this in issue?

    Thanks
    Sudhakar Chavali

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s