C++ vs. C++ .NET

Sometwo

Limp Gawd
Joined
Nov 7, 2004
Messages
202
What exactly are the differences between C++ and C++ .NET? It seems like I hear C++ is faster and more cross platform. If I want to learn to write Windows software, does that basically mean I should learn some kind of managed C++? Is that going to be easier writing software?
 
C++ is supported on many different platforms. C# only runs on Windows, and with Mono you can get it onto some Linux-based platfomrs.

C++ and C# are about the same speed in a straight line; what slows down C# is interop with native code. That is, if you write computationall intensive code that's just working an algorithm over a data structure, you're not going to notice much difference between the two languages. When it comes time for C# to interact with code that's not writte in C# as well, the interface is notably slower.

C++ is "native", meaning the language is compiled to machine code and runs by itself, directly iwth the operating system. C# (and all the other .NET languages) are like Java; they run inside a virtual machine and are compiled first to an intermediate language which is then compiled to machine code. That code interacts with the virtual machine instead of interacting with the operating system directly.

The virtual machine helps in a few ways. Like Java, you don't have to concern yourself directly with memory management -- data types are a bit softer and you don't worry much about allocating and freeing memory. This is another performance conern; while it's easier to develop and debug software, you don't directly control your memory. Depending on the complexity of your application, you might end up fighting with the built-in memory management system and end up paying back some of the gains you got from that system.

If you're just learning, the language you choose isn't very consequential. People who start learning to write software fail to be successful because they give up or lose interest. Their choice of language is the least direct predictor of their success.
 
You can generally ignore managed C++ under Windows, unless for some reason you want to use the .NET CLR or components compiled to that.

WinForms and all the .NET goodies are nice, but C# is probably easier for making a .NET application.

Otherwise, you can write Win32 C++ Windows applications.
 
Of course, C++ has some frameworks; MFC is one. To be clear, WinForms works fine with C# -- you don't need managed C++ for it.
 
Thanks guys. I've heard some things can be done with a few lines of Python and a module that would take an equivalent C program well over 100 lines. Is there a C++ language that is as easy to write as Python?
 
And there are things that are trivial in C which are difficult or impossible in Python.

C++ is only one language, take it or leave it. There's not a list of them to choose from.
 
And there are things that are trivial in C which are difficult or impossible in Python.

C++ is only one language, take it or leave it. There's not a list of them to choose from.

You're right, I meant languages similar to C++.
 
I'm not sure how to compare "easy to write". Python is intepreted, which helps for some tasks. But it has some syntax quirks, which is annoying. It's also not strongly typed, and that creates ambiguity.
 
The only language I would describe as being highly similar to C++, with respect to what it is and what it offers (native multi-paradigm) is D. D is an interesting language, and if not for its faults a strong 'successor' to C++, but its lack of developer tools can scare off newcomers, and there are some design issues that prevent it from being the best choice in certain domains (in my opinion).

To write well-performing Windows apps with the least amount of friction, C# is probably the right choice. If you need greater control — as you might in a highly time-sensitive application — C++ is probably the right choice. Note the word 'probably' in both cases, as there are always exceptions.
 
I feel there is some confusion in this thread between C# and C++/CLI compared to just straight C++.

Generally, I'd only be interested in writing C++/CLI code if I had to do a lot of interop with unmanaged C++ classes in a managed .NET application as it is impossible to use p/invokes to deal with C++ classes, but with C++/CLI you can use them directly alongside your managed .NET code.
 
What you say about C++/CLI is true, but I think you're the first person to bring up managed C++.
 
What you say about C++/CLI is true, but I think you're the first person to bring up managed C++.

Am I? This is the confusion I was talking about... I read the title as "C++" vs "C++ .NET" so... I thought he was asking what's the difference between unmanaged and managed C++?

What exactly are the differences between C++ and C++ .NET?
 
Learn C++.
You'll be smarter and understand more about systems programming.
After doing C++, coding in C# is easy ...
 
Learning C++ won't make you smarter, but you'll come out of it with a much better sense of where the strengths and weaknesses in other languages are. It's a good way to 'grow' as a programmer, but the choice of C++ as a language for any given project is – and I say this as a tremendous fan of C++ – often, regrettably, the wrong one.
 
Off topic..

Not really off topic. Replace 'C#' in his statement with 'C++/CLI', and you suddenly have something directly relevant to the thread starter's question. You could get away with calling it subjective, but certainly not off topic.
 
Right. But what we're talking about is his post, not how you'd edit it.
 
C#, Java, whatever. Come on.

C++/CLI isn't even an option, nobody uses that. I wouldn't have written that into my reply.
 
C#, Java, whatever. Come on.

C++/CLI isn't even an option, nobody uses that. I wouldn't have written that into my reply.

C# and Java aren't the same thing. It seems like you just jumped in this thread to start a C++ is better than C# / managed languages argument. I agree that learning C++ will help you learn how a computer works more than C#, but I disagree that it will make learning C# easy... Once you know any language it is somewhat easy to pickup other languages... but with all the extensions to C# it can be a lot to pickup.
 
Back
Top