🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Should I move to C++ from C#? (Advice)

Started by
5 comments, last by frob 3 years, 5 months ago

Hi, I've been an indie dev for about 4 years and I've mainly worked with C# (Unity, Monogame, GLFW through bindings) and I want to continue developing on a professional level. I'd like the chance to work at a small studio but as far as I know, most of them favor C++ unless they specifically state Unity as the engine they're working on. I've been diving into C++ and judging by complexity I'd say it would take some time before I really become used to it. I think most of the stuff in C++ can be achieved in C# up till now (other than platform specifics/drivers?). Would any professional offer some advice?

Thanks

Advertisement

Most of the stuff in C++ can be achieved in C#?

Definitely not. Have you ever dealt with the need to JIT C#? It can get nasty. Garbage collection? Satisfy no-alloc profile?

Nonetheless, if you have a solid target (if not an offer) you sure want to please them. The dice are cast already. Be sure C++ is not a thing…

Most of the companies requiring C++ I talked to are unaware C++ comes in various versions and some of them think drawing buttons in QT is the pinnacle of technical excellence.

Out of those who were aware some were still talking C++11 and would consider C++14 “modern”. I would expect C++17 to be a “modern” and viable version nowadays. I expect a gaming company to be far more proficient to this regard.

Modern C++ is basically another thing. Be sure to assimilate the core guidelines in addition to the massive language.

Consider trying it before committing. Due to the fragmentation above I would encourage you to invest at least a couple weeks in Rust.

TL; DR: dropping C# for C++ doesn't seem a thing to me - they do different things - but that's only my viewpoint.

Previously "Krohm"

I'm mostly a C++ programmer these days. There are defiantly some things that would be hard or impossible to emulate in C#. A lot of these things have to do with memory management. I never even use the stock C++ memory management system. Using the C# garbage collector would be a disaster for me. Probably I would get a 2X memory usage increase if I had to go to C#. That likely translates into a lot more cache misses.

That being said I guess it really depends on what you are tying to do. Obviously you can still do a lot in C#. If your goal is to get a job and you find that knowing C++ helps you in that regard, then it's probably worthwhile to switch. I personally don't think C++ is so hard, ‘if’ you learn it from the bottom up. This is VERY controversial. Many teacher will tell you the exact opposite of what I'm going to say. …… Lean C first! or rather lean old C++ first. This will give you a better understanding of the underlying computer architecture. The main problem with “modern” C++ is it's supposed to make things easier, however by the time you get into complex stuff you still end up having to understanding the lower level things, or you can get yourself into trouble really fast.

Also I've seen a lot of guys spend an inordinate amount of time tying to figure out how to used the standard library to do something, when they could have just written the code from scratch in the time they spent talking about it. I typically don't use the standard library for much. I don't really like the fact that it's a black box. Also it's not so stable as there are things actually slated for removal from the language. There are those that love it however. You will have to figure that out for yourself. Either way, I still recommend at least understanding lower level C++ programming.

Microsoft is investing a lot at the moment to make the gap between C++ and C# nearly void in case for targeting different platforms. .NET 5 has been released and from a first look, it seems to be well designed, however, I never used WPF and so Winforms has always been the base for my UI driven code. I won't drop a language you have learned either (except for Java -.-) so it is totally valid to use C# and C++ side by side.

Krohm said:
Most of the companies requiring C++ I talked to are unaware C++ comes in various versions and some of them think drawing buttons in QT is the pinnacle of technical excellence

I don't agree with that! Companies that use C++ (at least in games business) do know what they are doing and they do know the difference between different C++ standards. But from a real low.level view, most of those “modern” features seem useless to me. Lambdas are hard to optimize and shouldn't even be used in high-performance code in my opinion. I also don't trust the async/await implementation put into C++20, again because you have limited control over what happens behind the scenes and debugging such code is a nightmare!

Nearly every “fancy feature” added to the C++ standard already has a dozen well working solutions on GitHub.

pelvisparsley said:
most of them favor C++ unless they specifically state Unity

That might also be not entirely true. Most small (indie) studios I know use Unity so you have a good base when you want to work for them and even if they go for Unreal or use a custom solution, they still need C# developers as well. Unreal's toolchain is entirely written in C#, it's packagees have C# files to configure Editor and Build Pipeline and even when not using Unreal, tools are more and more written in C# today, so you can start as a tools programmer in such a company while learning C++ on side.

From my experience, C# and C++ have much in common and some differences. You can do everything in C# as well as in C++ but both languages have their benefits. While C# is faster to start with, so easier in it's memory management and framework features, C++ is more low level. In C++ you can have full control over where and how memory is used and interpreted (every tried to use and integer as a byte array?) and the preprocessor is a powerfull tool to decrease repeptitive workloads on the programmers side. C++'s template systems is also way more than C# generics, all of it makes C++ a valid language, especially for fast and/or low-level code.

So feel free to learn and use both!

Thank you for the responses

pelvisparsley said:
I want to continue developing on a professional level. I'd like the chance to work at a small studio but as far as I know, most of them favor C++ unless they specifically state Unity as the engine they're working on.

Yeah, that's a problem. You need to think about this differently.

There are game programmers who develop entirely in C#. There are game programmers who develop entirely in C++. There are game programmers who code entirely in JavaScript and HTML. There are game programmers who develop entirely in Java, others in Swift, others in Kotlin, others in Python, and on and on with other programming languages. If you look out at the wide world of professional programmers, most programmers know not just ONE language, but know multiple well or at least dabble in a few languages. In large games there are usually a multitude of languages in the project, including programming languages, scripting languages, tools languages, and more.

Employers are looking to hire people who can solve their problems. If you only know a single programming language you are valuable only if their programming concerns are in that language, or if they are willing to train you to fit the target language. Small studios might include only one language on their forms, but they want someone who can be fluent in whatever code language they're exposed to.

You already know C#, which is a good one. If your goal is to learn languages to increase your skills professionally, then the ever-changing core languages in recent years are C++, JavaScript, Java, and C# which you already know. C++ is a good choice to learn next for a widely-used language. If you're looking for backend work consider learning Java and Go and especially SQL. If you're looking for Apple environments consider learning Swift. If you're looking for Android environments consider Kotlin. Consider Python and Lua if you're think about tools work. If you're looking for graphics work learn GLSL/HLSL/MSL, the three shading languages have a lot of overlap but still have their own quirks. There are really no wrong answers at what to learn next, just learn something.

I have always recommended programmers try to pick up at least a passing understanding in one language or technology every year. It doesn't need to be advanced, but enough that if you look at the code you can grok what it says.

This topic is closed to new replies.

Advertisement