If all becomes Managed, Why C++?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I read an earlier thread about a Java developer switching to .Net with much
interest.

It still has not resolved some questions that I am wrestling with. I am new
to Windows programming (other than MS Access VBA). I have been working in
C#.Net (VS 2002) for several months now, just plugging along learning a
little at a time.

I have two concerns after reading more about C++ versus C#.

1) It seems (for now, at least) that C++ programs can be written and
compiled to run without the .Net framework. However, if I write C++ programs
in VS.Net is this still true? Perhaps more to the point, will this continue
to be true? It seems from everything I read that writing to native code
independent of the .Net framework will soon be impossible.

2) How much difference is there really between the speed and efficiency of a
C# program versus an equivalent C++ (assuming both are well-coded)? So far,
the C# programs I have written seem responsive enough. I am not sure how much
difference I could notice if I wrote in C++.

Finally, I would like to ask if someone could suggest some good tutorial
sites for writing simple C++ Windows interface programs (with a form/window,
not just console output).

Thanks,
Dan
 
fdan4817 said:
I read an earlier thread about a Java developer switching to .Net
with much interest.

It still has not resolved some questions that I am wrestling with. I
am new to Windows programming (other than MS Access VBA). I have been
working in C#.Net (VS 2002) for several months now, just plugging
along learning a little at a time.

I have two concerns after reading more about C++ versus C#.

1) It seems (for now, at least) that C++ programs can be written and
compiled to run without the .Net framework. However, if I write C++
programs in VS.Net is this still true?
Yes.

Perhaps more to the point,
will this continue to be true?

Yes. For many years to come.
It seems from everything I read that
writing to native code independent of the .Net framework will soon be
impossible.

2) How much difference is there really between the speed and
efficiency of a C# program versus an equivalent C++ (assuming both
are well-coded)? So far, the C# programs I have written seem
responsive enough. I am not sure how much difference I could notice
if I wrote in C++.

If both are well-written, they're generally competetive - not more than a
few percent difference if both are managed code. Comparing manged C# to
unmanaged C++ you might see a 30% difference (or more in some cases). In
some cases the native C++ will be 30% slower (!), but usually those cases
represent pathological usage of memory allocation that's not typical of
modern C++ practice (i.e. allocating everything, even local variables, on
the heap).

IME, the advantages of C++ are in programmer productivity when building
functionality more complex than a form with buttons on it. The .NET
framework makes all that basic UI stuff easy, so if that's all you're doing,
sitck to C#. However, if you have a nead to have complex functionality not
related to UI, C++ still wins hands-down, primarily due to two things
(again, IME): C++ templates and the C++ standard library. .NET generics
close this gap somewhat (and offer some things that C++ templates don't
have), but they're not on par yet. Best yet, from C++/CLI you have both C++
templates and .NET generics, so you can mix and match, using the best tool
for the job in all cases.
Finally, I would like to ask if someone could suggest some good
tutorial sites for writing simple C++ Windows interface programs
(with a form/window, not just console output).

Personally, I'd recommend staying away from managed C++ until VC2005 is
released. There are two reasons for this.

1. Using the new C++/CLI syntax, it's quite easy to transliterate a C#
example to C++.
2. The coverage of C++/CLI in the MSDN library docs is much better in the
2005 library (i.e. far more topics actually have C++/CLI examples).

My expectation is that a lot of managed development will shift to C++/CLI
once VC2005 is released. Of course, I'm biased...

-cd
 
Thanks for your response. It was extremely helpful. For now I will continue
down my C# path, but intend to learn C++ as well. I will begin doing some
small projects just to get familiar with it.

It sounds to me like your idea of moving toward C++/CLI is a good one since
it provides the best of both worlds, so to speak.

Thanks again,
~Dan

:
....
 
fdan4817 said:
I read an earlier thread about a Java developer switching to .Net with much
interest.

It still has not resolved some questions that I am wrestling with. I am new
to Windows programming (other than MS Access VBA). I have been working in
C#.Net (VS 2002) for several months now, just plugging along learning a
little at a time.

I have two concerns after reading more about C++ versus C#.

1) It seems (for now, at least) that C++ programs can be written and
compiled to run without the .Net framework. However, if I write C++ programs
in VS.Net is this still true? Perhaps more to the point, will this continue
to be true? It seems from everything I read that writing to native code
independent of the .Net framework will soon be impossible.


In C++ it is possible to write both managed and unmanaged code, even combined inside the
same application. In simple words, the C++ code that makes use of .NET, is managed. If you
stick only with .NET facilities inside an application, then the entire application is a
pure managed one.

2) How much difference is there really between the speed and efficiency of a
C# program versus an equivalent C++ (assuming both are well-coded)? So far,
the C# programs I have written seem responsive enough. I am not sure how much
difference I could notice if I wrote in C++.


With VS 2005, C++ becomes the systems programming language of .NET.



Some references:

http://msdn.microsoft.com/msdnmag/issues/05/01/COptimizations/default.aspx

http://pluralsight.com/blogs/hsutter/archive/2004/10/05/2672.aspx

http://blogs.msdn.com/branbray/archive/2003/11/07/51007.aspx

http://www.accu.org/conference/pres...Relevant_on_Modern_Environments_(keynote).pdf


And a page of mine:

http://www23.brinkster.com/noicys/cppcli.htm


Finally, I would like to ask if someone could suggest some good tutorial
sites for writing simple C++ Windows interface programs (with a form/window,
not just console output).


The default for a VC++ .NET application is a Form, not console. Since VS 2003, VC++, VC#
and VB share the same designer (RAD) with drag and drop components.
 
Back
Top