C++ claimed to have "more power" than C# what does this mean?

Started by
7 comments, last by Alaric 17 years, 6 months ago
I decided to start learning C# rather than C++ based on reading some similar topics, but I keep hearing people talk about all the more "power" C++ has. What does that mean? [Edit: Changed subject. - Oluseyi] [Edited by - Oluseyi on October 1, 2006 8:44:25 PM]
Advertisement
C++ allows for direct memory access. It is more powerful, but more dangerous. C++ is a much "lower level" language, giving you direct access to memory and making it your responsibility that you delete all memory you allocate after you're done with it.

C++ is also marginally faster because it is directly executed by the machine, whereas C# compiles to an interpreted byte-code.

If you're learning programming for the first time, learn something high-level. Java, C#, or Python are good options. C++ has too many points where you can confuse the hell out of yourself if you don't have a lot of programming experience. If you're just starting out, you don't want to mess around with memory leaks, seg faults, or cryptic template syntax errors.
Quote:Original post by omgh4x0rz
I decided to start learning C# rather than C++ based on reading some similar topics, but I keep hearing people talk about all the more "power" C++ has. What does that mean?

It means the speaker doesn't know what he's talking about.

Your thread title is of a format we disapprove of. I've edited it to be more agreeable.
C++ is a systems programming language. It's designed to write device drivers, operating systems, and other hardware-close code in. It is 100% predictable in what it will and won't do on the system (even the standard libraries have pretty strong guarantees). The draw-back is that you get no hand-holding -- an error is likely to cause significant trouble.

C# is an application programming langauge. It is designed to develop spreadsheets, accounting software, and even most games. It contains several features that make the life of the programmer easier. Garbage collection is first and foremost among them, but also full reflection and introspection, runtime type and code generation and other such support. Also, C# executes in a "safe" and "trusted" environment, which can protect the system from bugs or malicious code through degrees of isolation and insulation. However, the price for these features is that you're not exactly sure what the program will do when, on a small scale -- only at a higher level. This makes C# unsuitable to use for device drivers, operating systems, and other code where 100% determinism is paramount.

C# has raw access to memory just like C++ -- if you use "unsafe" blocks. C# can also call most existing DLL code using P/Invoke -- again, in an "untrusted" and "unsafe" context. Thus, if you give up some (but not all) of the cushioning of C#, you will get some (but not all) of the features of C++.
enum Bool { True, False, FileNotFound };
@hplus0603:

Can you give any examples of commercial games where the majority is written in C#?
Quote:Original post by Dave
@hplus0603:

Can you give any examples of commercial games where the majority is written in C#?
I am aware I am not hplus0603 [wink] but ...

Arena Wars
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
Quote:Original post by Tac-Tics
C++ is also marginally faster because it is directly executed by the machine, whereas C# compiles to an interpreted byte-code.


C# does not compile to an interpreted byte-code. It is compiled to an IL (intermediate language) that gets JIT compiled on execution. It is directly executed by the machine just like any other native application. .NET applications are NOT interpreted.
Quote:Original post by Dave
Can you give any examples of commercial games where the majority is written in C#?

The three games done by Koios Works were written in C#. Any games in production using the Reality Engine have the game written in C# and only the core engine is in unmanaged C++.
...yeah, I think RDragon beat me to it. C# (as long as it is maintained under the .NET framework) is not an interpreted language. .NET assemblies are maintained as MSIL (Microsoft Intermediate Language) that are JIT compiled at run-time. I think your claim that it is "interpreted" is probably a semantics issue. Using Java as an example (Interpreted language) java code is maintained in a standard format (java byte-code) which is then interpreted by a specific virtual machine specifically flavored for its operating system. .NET code can only be run on a Microsoft Windows platform (...if you completely discount the Mono project) that runs the .NET framework.


....And just to state what's already been said: Anyone who told you that C++ is "more powerful" than C# either is referring to software interfacing with hardware fairly low on the OSI model or they don't know what they are talking about. A particular language is just a means to an end, so if someone is fluent in C++ there shouldn't be any reason why they shouldn't be able to accomplish the same kinds of tasks as a C# programmer, but C# was specifically designed for application development. If you are a new programmer, I would definitely suggest learning C#. It is a true object-oriented language, whereas C++ is a hybrid language. EVERYTHING (and I mean everything, even your primitive data types) in C# inherits from the Object class. C++ maintains way too much support for deprecated practices for a new programmer to really need to take it up. I've debugged tons and tons and tons and tons....of "object-oriented" code where programmers egregiously broke the rules of object oriented programming to complete a task because "the compiler let them" I know that's getting kind of off topic, but in my opinion C++ is a language you learn if you HAVE to be able to do something that required direct memory manipulation and you would learn C# to do everything else.


And remember, Please Dont Throw Sausage Pizza Away.......Never

[Edited by - Alaric on October 1, 2006 11:38:21 PM]

This topic is closed to new replies.

Advertisement