managed vs unmanaged c++

Started by
19 comments, last by Nemesis2k2 18 years, 8 months ago
What's the difference between managed and unmanaged c++. I've heard it mentioned alot but having been programming for a couple of years I'm not sure which one I am currently using. Currently I used MS VS.NET (2002). Is that managed or unmanaged? Which one is better? What are the basic benefits of each? Thanks in advance, ~guyaton
~guyaton
Advertisement
Unmanaged code , compiles to the classic "pure" exe , like in
previous Visual c++ compilers.It is Native .exe that works just as
if u would made it with intel's compiler or what have you.

Managed code, uses the .net bytecode.
It therefore needs the .net runtime to work.

Benefits are (visual studio '02/03 , '05) :
In unmanaged code u work with a much more standard compliant
implemantation of the C++ standard, compared to VC++ 6.
Since it is Native , you reap the benefits of runtime speed.


In Managed code, u get all the benefits of the .net platform,
wich is in microsoft's vision, the future of the windows platform,
as Longhorn will have crucial technology like avalon/indigo extend
the .net codebase.

The Managed C++ version also gives u the option to use the Garbage
Collector, wich provides you with a facility to automate the freeing
of allocated memory.

Hope this helps :)
Also MSVC++ .NET can produce either standard C++ exectuables or managed C++.

So saying that you're using VC.NET doesn't mean that you're using managed c++ or unmanaged C++.
how do i switch between them? I'm assuming with unmanaged there's a higher potential for memory leaks? does managed attempt to fix this? how do i enable the optional garbage collector?

thanks again,

~guyaton
~guyaton
Managed C++ has a somewhat different (well, additional) syntax than unmanaged C++. If you've been learning through books, school, or tutorials, I can almost guarantee that you've been learning unmanaged C++. To use the features of managed C++, you'll have to find some reference material or tutorials or something to help you learn to use the additional syntax that managed C++ provides. It isn't one of those things where you just turn it on or off. Programming in managed C++ takes a slightly different programming mindset than programming in unmanaged C++, and code doesn't typically translate from one to the other without at least a few changes here and there.

Note that you can mix managed and unmanaged code together in a single project, however, so that it becomes easier to slowly migrate a completely unmanaged project into a largely or completely managed project.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
I meant turning it off/on in the Visual Studio enviroment. If i'm writting unmanaged code, there's no need to have extra "stuff" in my exe...right?
~guyaton
#pragma managed
#pragma unmanaged
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
I am using managed C++ for my level editor, and my main engine is regular C++, using vs.net 2003.

I am using windows forms as well, and AFAICT, the managed C++ part of windows forms at least is a buggy mess. Sort of the red-headed stepchild of .net forms.

Now that I know the things to watch out for, I'm productive in it, but it was not easy.

I have not tried managed C++ in a non-windows forms environment, so I can't comment about it.
Right, the current incarnation of Managed C++ is an ugly beast, and really should only be used if you have to use it. If you want to do .Net, use another language like C# or wait for the next incarnation of Managed C++ called C++/CLI which is supposed to actually integrate nicely with .Net.
Turring Machines are better than C++ any day ^_~
Quote:Original post by intrest86
Right, the current incarnation of Managed C++ is an ugly beast, and really should only be used if you have to use it. If you want to do .Net, use another language like C#


Agreed.

Managed C++ should not even exist IMO. I've heard that benchmarks show managed C++ is slower than managed C#, and the biggest reason to use C++ over C# anyway is speed. C# is far easier to code and very easy to learn - I learned the entire language in literally a day. I don't know why Microsoft thought managed C++ would be a good thing, I see it as an oxymoron because it destroys the main purpose of using C++.

This topic is closed to new replies.

Advertisement