473,382 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

If all becomes Managed, Why C++?

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
Nov 17 '05 #1
3 1319
fdan4817 wrote:
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
Nov 17 '05 #2
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

"Carl Daniel [VC++ MVP]" wrote:
....
-cd

Nov 17 '05 #3
fdan4817 wrote:
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/is...s/default.aspx

http://pluralsight.com/blogs/hsutter...0/05/2672.aspx

http://blogs.msdn.com/branbray/archi.../07/51007.aspx

http://www.accu.org/conference/prese...keynote%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.
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
2
by: asanford | last post by:
We use StackWalk(StackWalk64) from dbghelp.dll to walk our callstacksas needed, using the various Sym* methods (SymGetSymFromAddr, SymGetLineFromAddr) to resolve source file, function name, and...
4
by: William F. Kinsley | last post by:
My understanding is that when I re-compile a existing MFC application with the /clr switch, that the code generated is managed(with some exceptions) but that the data isn't, i.e. not garbage...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
12
by: DaTurk | last post by:
Hi, I have a rather interesting problem. I have a unmanged c++ class which needs to communicate information to managed c++ via callbacks, with a layer of c# on top of the managed c++ ultimatley...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.