Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

If all becomes Managed, Why C++?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fdan4817 - 17 May 2005 18:23 GMT
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
Carl Daniel [VC++ MVP] - 17 May 2005 19:11 GMT
> I read an earlier thread about a Java developer switching to .Net
> with much interest.
[quoted text clipped - 9 lines]
> 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
[quoted text clipped - 5 lines]
> 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
fdan4817 - 17 May 2005 19:44 GMT
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

...
> -cd
Ioannis Vranos - 18 May 2005 00:51 GMT
> I read an earlier thread about a Java developer switching to .Net with much
> interest.
[quoted text clipped - 11 lines]
> 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/presentations/Sutter_-_Is_C++_Relevant_on_Modern_
Environments_%28keynote%29.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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.