4 ms·
I've seen this type of comment before but usually in the context of someone that already knows either C# or C++. As someone that doesn't know either what factor
by fredophile 12y ago
I've seen this type of comment before but usually in the context of someone that already knows either C# or C++. As someone that doesn't know either what factors make you want to learn C# over C++?
- MichaelGG 12y agoC#'s tooling and ease-of-use really blows C++ away. Plus there's the safety, where it's rather difficult to introduce a memory-safety issue into C# code, vs C++ where we see vulnerabilities every week due to this problem. I doubt people use C++ if they have another choice. The big problem is that C#'s implementations do not handle memory well enough. The default for them is to heap-allocate most objects, then leave it up to the GC. This means a lot of hacky code to achieve good performance, but it still can't match C++ in many cases. (I'd guess that many apps could see a good double-digit% increase in perf in C# if you could just use the stack more often.) Plus, if you can use C#, you can probably use F#, which is a far better language than either C++ or C#. Whereas if you need to be runtime-free and C-ABI compatible, your choices of expressive languages are rather limited (Rust being the most exciting one, probably.) Edit: Also, C++ compilers tend to do a far better job at codegen. Though MS is starting to hint that they're gonna up their JIT story, but they've got a long way to go. Edit: As to why you'd want to learn one or the other, if you're in games, it seems like you should probably learn C++ because it's so prevalent in games. C# is easy enough to pickup on the side though.
- fredophile 12y agoWhile I appreciate your well thought out reply I don't think you have the perspective I'm interested in learning about. From your reply I'd say you already know at least one of the two. I'm interested in knowing why someone without experience in either would choose C# over C++ or vice versa.
- prewett 12y agoMaybe I misunderstand, but I don't think you want the advice of someone who doesn't know either, you want the advice of someone who knows both well. FWIW, I'm a longtime C++ user, and used C# with Unity for a bit. I would recommend C++ if you need high-performance, low-level control, or access to native APIs. I would recommend C# if you want good performance in a Java-like language with the best parts of Java and C++. Also if you want to get a job with the Microsofty sorts of companies that have historically used C#. However, you are more realistically constrained by your 3D engine. Unity does not have the option of C++ (to my knowledge). I'm assuming Unreal does not support C#. In the case of 3D engines your choice of engine is much more important than language.
- fredophile 12y agoI know both. I want to know what the thought process is that people are using to choose one over the other when they don't know either of them. I'm trying to learn their perspective, not get advice.
- pjmlp 12y ago> Unity does not have the option of C++ It does on the professional version via the plugins system. http://docs.unity3d.com/Manual/NativePlugins.html http://docs.unity3d.com/Manual/NativePlugins.html
- pjmlp 12y ago> Though MS is starting to hint that they're gonna up their JIT story, but they've got a long way to go. They aren't hitting at it, they are releasing RyuJIT and .NET Native on .NET 4.6.
- pjmlp 12y ago> As someone that doesn't know either what factors make you want to learn C# over C++? If you want to try a job at the game industry start with C++. Besides Unity, C# tends to be mostly used for tools. In what used to be a domain of MFC/C++ and Qt/C++. This might change with .NET Native now coming into the picture. If you rather want to learn a language for a job at the IT industry at large, start with C# which alongside Java has been taking C++'s place, specially in Windows shops.