Peter Olcott wrote:
I want to be able to make my .NET applications run
just as fast as unmanaged C++. From my currently
somewhat limited understanding of the .NET framework
and the C# language, it seems that Boxing/Unboxing
might present of problem. Since C++ has pointer syntax,
I was thinking that this might eliminate the need for
Boxing and Unboxing. Am I right?
One of the things that my application needs is something
exactly like std::vector<unsigned int>. In C++ this has
the same performance as an array of "int". Is there
something like this in C#, or can I use managed C++
and a std::vector of managed memory?
You are right that boxing may be one of the points where the performance
of your .NET app suffers, but AFAIK you can't change that by using
(managed) C++ as a language. C# can use pointers in unsafe code and
managed C++ doesn't have anything else than that to offer either. The
issue of boxing doesn't have anything to do with which language you are
using.
The STL collection sample you give makes use of C++ templates to provide
for typed collections. You are correct in assuming that typed collections
will get rid of boxing overhead - you can do the exact same thing with
..NET Generics in .NET 2 (constructs like List<uint>). I'm lacking the
experience with managed C++ to say whether or not it's possible to make
use of C++ templates in managed code - I guess it might be possible
because C++ templates are a compiler feature, as opposed to .NET Generics,
which are a runtime feature. Given the choice, I'd opt for Generics of
course, if only for compatibility with other .NET languages.
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619
http://www.sturmnet.org/blog