C++ < C#

C# over C++? This is the recent ever growing trend it seems to me… So opinions on this is what I seek… I feel like I spent the last few months wasted on C++ of course not literally. Knowledge is never wasted as long as you’ve learned anything but Whats the deal with the increase of game developers making engines and having the scripting/coding be in C#? Is this a marketing thing because C# is easier to learn? Is this a sign that C++ is a dying language will big game companies start developing games with C#?

What’s going on?

I think this was asked recently on these forums.

C++ won’t be going anywhere anytime soon. It’s low level capabilities are far too powerful for it to be dismissed.

However, much of that isn’t really needed for game development. In that regard, people would much prefer C#, which offers the same power of C++ without all the fuss of things they probably weren’t going to use anyway.

C++ will always be the core of a game engine. I dont expect this to ever change.

In saying that, you don’t need to know it, unless you plan on writing your own engine, or moving to UDK when it goes version 4.

I understand that Unity supports it, but to the typical indie developer its not something that needs to be learnt.

The only reason you’re seeing it a lot more, is because its much easier to code in, so supporting it puts it into the hands of less experienced game developers. Even working with strings in C++ can be a nightmare due to the multitude of varations

I’ve spent time working with it because while I wont be developing an engine myself at a game company I want to be one of the many ants that are busily working on that new game title/engine. So I’ve invested time in it to get a good paying job at a decent game company… I love Ubisoft… Wouldn’t mind working there in the future. C++ has more advantages than just engine development. It can even be used for web development. I asked because I was working with OGRE when I visited their webpage n stumbled upon http://www.neoaxis.com/ which is a fairly new game engine that is developed using OGRE for rendering and what not but the scripting language is in C#. I like C# it’s a very good language to work with. Yes C++ is like going to a strip club for the food but also enjoying the dancers. It is very complicated and for no good reason IMO but I plan to still work with it…

You are going to have to spend WAY more than a few months with c++ to get proficient enough to even be considered working for a game studio as a c++ dev.

C# is childsplay compared to C++

Just because something is bigger and more complicated does NOT mean that it is more efficient. C# is more easy to learn than C++, C++ has more features but I really doubt that someone would go through the time to use them all.

As for C# changing/dying, I don’t believe it for a second that C# would all of a sudden vanish from the gaming industry. If anything, people are just going to build off of it if for some reason gaming gets more complicated drastically.

oh i know. I am just saying that is my goal. Yeah C# is easy… very easy when placed next to C++…

Honestly I look back at starting this topic and im not sure why I did… I dunno what I was thinking lol. I guess I just wanted something I could discuss that I thought I was interesting…

Often C++ is not the challenge, proper OO is.

The first programming language I ever learnt was C++. Like everything else in my software knowledge, it was completely self taught using a combination of Sam’s Teach yourself and cplusplus.com

However, I wouldn’t recommend learning C++ as your first programming language to anyone and wouldn’t recommend the Sam’s teach yourself book on the subject beyond the first few chapters. The first few chapters are highly recommended because he explains the concept of the stack, functions etc very nicely.

It took me quite sometime to grasp the concept of pointers. C++ forces you to understand some very complex concepts such as stack, heap, dynamic memory etc. Can be daunting to the novice programmer. Csharp allows the novice programmer to conveniently avoid this complex stuff

That said, I don’t regret any of the time I spent learning C++. I just wish I had learnt the language after a more simpler one such as Csharp first

EDIT: Also I better qualify what I meant by “Learnt C++”.
“Learnt C++” = Ability to write some basic command line stuff and the ability to understand C++ code as long as it is not packed with too many preprocessor directives

http://www.cplusplus.com/doc/tutorial/preprocessor/

+1, Every new language is valuable even if you only use one.

Proper OO is often terrible in terms of performance. OO leads to efficiency at design and implementation time, but it’s pretty costly in terms of performance when adhered to strictly.

OO has a very small overhead in performance. C++ using OO will be faster than c# using non-OO

OO can have a huge impact on performance. Or, rather, a lack of DOD can have a huge impact on performance, and a lot of OO design practices are contradictory to DOD practices.

+1,

You sound like a C programmer.

Wasn’t C# built with OO in mind?

Nah, I love OO and use it the vast majority of the time. But, as I said, adhering to it blindly and strictly has its costs. OO is about thinking how a person thinks, and since the computing costs are usually negligible and it helps us develop better code more quickly it’s a great thing, more often than not. But sometimes, when raw performance is what you’re after, you’ve got pay heed to the way a CPU works and set your data up in such a way that it can tear through it as straight and fast as possible.

C++ has two advantqges over C#. Proper reference handling and (by itself) no garbage collection.

Concerning references C# is way above Java, Python and alike but it cannot and maybe will never reach the capabilities of C++. Don’t get me wrong, in modern C++ code you don’t want to use pointers, but you do want to use references, unique pointers and alike. All those things are essential for performant code. C++ just gives you a lot more power about whether something will be allocated on the stack or on the heap and whether or not you want to copy a reference or a value / object.

The second - not completely unrelated - thing is the garbage collection. Especially the older Mono version uses a really bad algorithm and until Unity upgrades to Mono 2.8 this will forever be the performance bottleneck. But even with the new garbage collector, C# will always be slower than a language without garbage collectiom. I would really hope to see garbage collection become optional, but this is just a dream at this point.

C# does however have huge advantages over other languages and I would describe it as “the best language if you’re not doing hardcore scientific, kernel or in general any sort of backend coding”. Despite everything looking “nicer”, C# offers quite a rich feature set compared to other languages. I can rcommend reading Jon Skeet’s “C# in Depth” if you really want to get to know C#. The main advantages of C# compared to for example Java are lambda expressions, non-type-erasure generics, everything LINQ, properties (get set), the possibility to define structs, the possibility to have unsigned value types and unsafe code with way less overhead and the “ref” and “out” keywords (that offer at least some control about pass by reference / value). Compared to C++ C# still has LINQ, properly implemented lambda expressions (the “properly implemented” part might or might not change with C++11) and properties going for it. This and the fact that you are just way more productive writing C# than writing C++ justify the use of C# in quite a few scenarios.

My general rule of thumb is “You wanna use some language with a C in it depending on your problem, but there’s really no reason in this universe to ever write a single line of Java.”

Normally we just use C or Assembly in CPU cycle hungry loops, it works surprisingly well. Or just tell the artists they are slack :stuck_out_tongue:

It depends on the problem space, low level vectorizable code works much better using DOD and c style programming. Larger more abstract scale problems can be more suited to OO. Research your problems and use the right tools for the task. This may be OO, DOD and a range of programming languages.

. +1.

+1.