Microsoft on Visual C++’s Future / 微软谈Visual C++的未来 invited the Visual C++ Team for a week long slow chat answering questions about VC++’s Yesterday, Today, and Tomorrow.

C++/CLI and C#

Both languages are about equally powerful in this context. The biggest strength of C++ is evident when you need to also use OS functionality that is only exposed as native or COM APIs since you can just call them. The biggest strength of C# is that it is a simpler language with a build model that allows for easier tools support.
C++/CLI code tends to be faster for 2 different reasons:
1) Writing identical code and running it on x86 is up to a few percent faster in some cases because we run the optimizer when emitting MSIL code to compensate for some analysis the x86 JIT compiler is not able to do. On x64 the difference is less.
2) Some patterns that are much more natural in C++/CLI like using our deterministic finalization avoid putting undue pressure on the garbage collector and in some cases that can have dramatically positive performance effects. In C#you can obtain the same effect through using blocks or by explicitly calling Dispose in a finally clause, but that code is not the natural way to write it in C#.

Ronald Laeremans
Acting Product Unit Manager
Visual C++ Team

 Why ref / value?

Why were the ref / value keywords introduced? I don’t see any value they add to the language, they only seem to unnecessary complicate things.
Why can’t I inherit a value struct from an other value struct?

The CLR has the concept of a reference type and a value-type and we need to expose these concepts in C++/CLI. A reference type lives on the garbage collected heap while a value-type lives on the stack. We did consider (for about 10ms) going the C# route abd having ‘struct’ mean a value-type but we very quickly decided that this would break too much C++ code.
As value-types are meant to represent small values and as the only live on the stack (if we ignore the thorny issue of boxing) then for performance reasons it makes sense not require that all value-types are sealed. The is a CLR requirement so if C++/CLI wants to run correctly on the CLR we need to follow their rules – and I for one think that this a rule that makes sense. If you find that you need to inherit from a value-type then the changes are that you should really be using a reference-type.

Jonathan Caves
Visual C++ Compiler Team

 Is future in managed code?If so when?

I want you to learn when we are able to write system applications with managed code(like c#).For example if I want to develop a firewall application ,I must write kernel mode device driver.Nowadays I can not do this with managed code(like c#) ;I must use win32 api so much.But when can we write such application if microsofts future is in managed application?
I give a lot of time to learn c# and develop some server-client and applications.But when i want to do much more than these i see that managed code is a disappointment(not only for system application also for performance).Then now i turn back c++.How long will this continue?Does winfx end this?
What is the roadmap of Microsoft for managed code?
I am looking for your answers.

The future is definitely "mixed". For the foreseeable future I see developers using a mixture of "managed code", be it C#, VB, Java or whatever else appears on the horizon, and "native" code – C, C++, etc. There is not going to be a sudden switch from one to the other – purely native code will be around for a long time and what we today consider "managed code" is probably just a step on the road to some future technology.



Writing kernel mode code has always meant operating in a significantly restricted environment. In fact Microsoft does not support using C++ to write kernel mode drivers because currently the compiler cannot guarantee that compiler generated code like destructors and some funclets will always be put in a segment that will be allocated in non pageable memory.
We are far away from allowing one to use CLR code to write kernel mode device drivers. In fact I personally believe we will most likely get there only when we have an OS that itself is mostly written in managed type safe code.


Ronald Laeremans
Acting Product Unit Manager
Visual C++ Team

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: