473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1332
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
741
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 managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form...
1
3552
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 this method and have it set the instance to hold the right data. >From what I've read it seems I should be able to pass C# objects to managed C++ methods and it should just work; however, when I try it, my C# instance comes out null. If I step...
16
14139
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 byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
2
7301
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 source line number for each frame. This works fine for unmanaged code, but when we have a call stack that goes into or through some managed code, we cannot resolve any info for the managed frames - we can however, get all the information for the...
4
5723
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 collected. I also noticed that when replaced some of the existing MFC dialogs with managed winforms that everything is still running in the same app domain.( No context change) So my question is this, what are the performance differences in using...
9
3123
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 this, I want to use it. Is it possible to call Managed class functions from Unmanaged class? How to do it? I did something like this. I declared a managed class (in C++ CLI) called as MyManagedClass whose
12
12557
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 retreiving the data. Presently all of the c++ code is still in .NET 1.1, so we're using a _nogc bridge class wrapped in a _gc c++ class in order to facilitate this interop. But we've converted everything not c++ to .NET 2.0 and would love to
3
4712
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 application. Furthermore, I use a pointer to an unmanaged function to jump back into the managed dll. The managed part is basically a remoting enhancement which asynchronly
8
8999
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 http://www.codeproject.com/managedcpp/garbage_collection.asp - sources
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.