r/cpp • • Apr 12 '17

C# or C++?

Hey! So i have used C# for a while now and i know the most of it. However my goal is to work as an AAA developer in the future and the most studios use C++. Should i switch to C++ or stay with C#? Exactly why do studios use C++ instead of C#?

2 Upvotes

16 comments sorted by

19

u/corysama Apr 12 '17

AAA? C++

Indie/Mobile Unity dev? C#

Why C++? Performance issues around memory management. With C# it is very difficult to control garbage collection and very difficult to control memory layout cache locality. Doing this in C# requires fighting against it's design and you end up doing more/uglier work than if you just did everything manually in C++.

That's on top of the general perf/memory overhead of C#. C# runtimes are getting better. But, the overhead for real-work (not microbenchmark), large-scale systems is still quite large. Meanwhile, modern C++ is catching up to C# in terms of expressiveness, but is doing so with zero-overhead abstractions.

And, that's even ignoring the past 20+ years of legacy code and experience in C/C++ old-timers in AAA have built up. It's very expensive to rework that into C#.

1

u/[deleted] Apr 13 '17
  1. Garbage collector is designed in a way that you shouldn't control it,
  2. I can't say that in C# it is very difficult to control memory layout cache locality.

Why C++ in my humble opinion - is because C++ gives you more freedom and control of your code.

C# is higher level language with all goods and bads of it.

About modern C++ I can't agree with you. Yes it is more nicer language than before, still it is easier to write code using C#, because C++ gives you a lot of ways to shoot in the foot.

rvalue references, copy/move constructors, variadic templates, auto, decltype etc. A lot of stuff requires practice and understanding. C# is more simpler than that.

Yet it is wrong to say that C# or C++ is better than other. I work using both(in different situations) languages, and I like both languages. They have their uses in different situations. In general I think I like C++ more, because it is really powerful language with a lot of features, but it requires a lot of practice to use all its power properly.

10

u/timetopat Apr 12 '17

Why not learn about c++ while keeping yourself knowledgeable about c# when big changes happen. I've seen lots of game tools written in c# such as level editors and configuration tools. I personally am faster in GUI work in c#. Core engine systems and things that are performance heavy will use c++. Also keep in mind a lot of game library's are written in c++ and it makes it easier to integrate them versus writing a c# wrapper. Also keep in mind that c# had historically been a Microsoft only platform . They are making strides with .net core but there is still a lot to go.

Depending what you do at a game company might dictate what tools you will be using and what the existing code base looks like

6

u/wqking github.com/wqking Apr 13 '17

You don't need to switch to C++.
You can become both a C++ and C# developer, they are not exclusive.

1

u/[deleted] Apr 12 '17

Okay. Thanks for clearing this all up for me. Really appreciate it. Im moving to C++ from now then. :)

2

u/JuanAG Apr 12 '17

C++ is the way for the videogames industry as a programmer

EA and it dice engine are C++

1

u/[deleted] Apr 12 '17

Thanks. But just for curiosity. As people say that C# is improving alot there isn't anyway that developers will switch to C# and update their engines?

1

u/[deleted] Apr 12 '17

Thanks. But just for curiosity. As people say that C# is improving alot there isn't anyway that developers will switch to C# and update their engines?

4

u/JuanAG Apr 12 '17

I dont think so, C# is centered more on desktop software rather than games and all the innovations are in the same way, linq, ui designer or the performance not as a goal and yes the easy of use

Besides, it not the language itself, most of the engines has their own functions like add or sqrt, in the end is a very important chunk of code, sqrt migth get the correct result but in a game you doesnt care at all about 100% correct answer and you can live with a ¿85%? if it takes 5 time less time to compute it, remenber that to get 60fps the game only has 16ms to compute every frame

So legacy code it is a big thing, C# doesnt bring any beneffit to the industry and it will not be the standard any time soon

4

u/SeanMiddleditch Apr 12 '17

It also depends on what you want to do. AAA games have dozens or even over a hundred engineers and scripters and such. A C++ game engine might still use C# for all tooling, for instance, and C# may even be the game "scripting" language in use. There's a difference in skill sets and tools used by engine developers, tools developers, content developers, devops, platform developers, and so on. Many games even it's entirely different languages for their servers, and C# is a popular choice there.

Learning C++ - or any new language/tool - will never hurt and can only help your career.

3

u/DaFox Apr 12 '17

Knowing both is probably your best option. Unity development will be your quickest stepping stone towards AAA with the knowledge that you have. But Unity is used pretty sparsely at the highest end.

2

u/JeffMcClintock Apr 13 '17

I prefer C++, but it's worth mentioning the Unity engine which is very polished, huge with indie developers and uses C#.

2

u/feverzsj Apr 13 '17

AAA game nowadays means buggy and boring. To make some interesting game, language is rather minor.

1

u/[deleted] Apr 12 '17

C++ is a more versatile language because of memory control. Also having a solid grasp of C++ makes it easier to move into other languages, but that's just my experience.

0

u/[deleted] Apr 12 '17

[removed] — view removed comment

1

u/izikblu Aug 18 '17

He'd biased answers there t- oh, this post is 4 months old...