Handmade Network»Forums
Astromop
4 posts
C vs. C++ vs. C# (Beginner)
Edited by Astromop on
Hi everyone, I am a new game developer working with Unity3D and C# to learn the basics. I am currently working on a basic 2D game. Although it has been a short while since I started, I have already run into many organization issues that have led me to begin learning more about software architecture and design patterns.

In order to do this right (dive deep enough into these topics to become an expert at them), I know I need to spend a substantial amount of time and dedication practicing. Due to this time cost, I want to focus on a single language now, which I can master over time, so as to set myself up for success in the future.

I know that Casey programs in C, I know that C# is widely used in gaming, and I know that C++ is as well. Being that my goal is become an expert in a specific language and game programming in general, what language should I choose? Is it relevant to code in C today as a game programmer? If you were in my position, what language would you choose? Is there another language besides the ones I mentioned that are worth considering?

**It might be worth noting that after learning the basics, I plan to build game-specific engines for whatever games I decide to make (Although I'm not ruling out the use of some libraries etc.).

Thank you in advance for any responses.
Mikael Johansson
99 posts / 1 project
C vs. C++ vs. C# (Beginner)
It depends on what you like to focus on. If you prefer to learn api:s and get things built quick, and let other people focus on the low level stuff, then C# may be your cup of tea.
If you want to learn how things work on a lower level, and be able to make ypur own api:s, then go for C or C++.
Choose the one that keeps you motivated.
Astromop
4 posts
C vs. C++ vs. C# (Beginner)
Thanks for the response!
Oliver Marsh
193 posts / 1 project
Olster1.github.io
C vs. C++ vs. C# (Beginner)
Edited by Oliver Marsh on
I agree with Telash, whatever keeps you motivated. I think learning C takes longer to get to a level where you are confident making big projects like games, but I think also sets you up to solve a wider range of challenges you might come across. EDIT: sorry, takes longer in that you write most of your own stuff (not longer to learn the language)
Mārtiņš Možeiko
2562 posts / 2 projects
C vs. C++ vs. C# (Beginner)
Edited by Mārtiņš Možeiko on
I would say that C# is much more complex language than C if you care about writing good code and care about getting good performance. C# language has much more features (like linq, reflection, more complex interop with native code) and you need to be careful with what you use to get good performance (memory layout, value vs reference types, garbage collector, etc...). C is much smaller and simpler language.

As for what you should learn - it does not really matter. Learning new language is always relative simple task when you know already one. Its more complex to learn API/tools/environment/framework you need to use it. In Unity case that is much work in beginning. For C again there's nothing to learn, because it "bare-metal" - there's no API/framework, its up to you to decide what to use. Write everything from scratch (like HH does), take SDL, or something different...
Allen Webster
476 posts / 6 projects
Heyo
C vs. C++ vs. C# (Beginner)
If you're already willing to put in a lot of time to get good at one of these options, then I say you should go with C or the minimalist C++ popular around the handmade network. I recommend this because, as Martins said, these options are actually simpler in the sense that they have less features and deal more directly with the bare metal. This means once you've gotten used to the language most of that time investment will go into transferable skills like computational and algorithmic thinking, hardware constraints, data formats and transformations etc.

On the other hand if you take your large time investment and put it into high level C++ or C# you'll spend a lot more of your time learning quirks of those languages, which are not transferable skills.

Also just to put into context the point you made about the relative abundance of C#, C++, and C. I actually don't have any idea what the real numbers are like for these languages so I'll take your rough estimate that C# and C++ are both super common and C not that common for the sake of argument. One interpretation of that could be that C# and C++ are more relevant and useful to the industry and that C is more irrelevant. However, one could also conclude that there is a large supply of C# and C++ and a shortage in the supply of C programmers. So fewer C programmers does not imply that C is less valuable, it could imply the opposite. Speaking from my personal experience knowing C has been very valuable.
Astromop
4 posts
C vs. C++ vs. C# (Beginner)
Thanks for all the responses!

I've chosen to go down the path of C w/ minimal C++ and SDL!
Mikael Johansson
99 posts / 1 project
C vs. C++ vs. C# (Beginner)
Why minimalistic C++? You will be paying for extra compile time, for what features?
I am not saying its a bad choice, I am just curious.
511 posts
C vs. C++ vs. C# (Beginner)
The extra compile time when going from C to minimalist C++ is negligible.

C++ compile times start to explode once you have very large and template heavy headers being included. Which in turn affects link time when a lot of duplicate symbols from inline functions and template instantiations need to be pruned.
Ryan Fleury
204 posts / 4 projects
Working at Epic Games Tools (RAD). Former Handmade Network lead. Maker of Hidden Grove.
C vs. C++ vs. C# (Beginner)
Telash
Why minimalistic C++? You will be paying for extra compile time, for what features?
I am not saying its a bad choice, I am just curious.


I think there are a few good reasons for compiling as C++. I compile my projects as C++ just because it has a few semantic features that I like to take advantage of (function overloading, operator overloading, etc.). Operator overloading is really handy when writing math that requires many nested operations. That being said, the C++ requirement of explicit pointer casting pains me at times...

If these features are used, however, I do think it's important for one to understand their implications (operator overloading implies function calling, C++ compiler involves name-mangling, etc.)
Jack Mott
110 posts
Web Developer by day, game hobbyist by night.
C vs. C++ vs. C# (Beginner)
Edited by Jack Mott on
>what language should I choose?

It doesn't matter, every rockstar game developer you ever heard of started learning with something cheesy and currently irrelevant like QBasic. Programming is programming.

> Is it relevant to code in C today as a game programmer?

Of course, especially since C is so similar to C++ that the crossover is knowledge is like 90%

You will hear lots of people hear bash on C# and GC languages, but keep in mind the most money making game of all time was made in Java, Jonathon Blow makes fun of GC languages a lot but two of his favorite games, Sausage Roll and Opus Magnum were done in C#.

Learn to program, practice making games. Do not worry for one minute which languages you learn right now. Do plan to learn some C or C++ in the future though, even if you don't make whole games with it.


BTW: random aside about Opus Magnum - that studio does the hotloading game logic trick that Casey shows in the early episodes of Handmade Hero using C# with binary serialization.

Ryan Fleury
204 posts / 4 projects
Working at Epic Games Tools (RAD). Former Handmade Network lead. Maker of Hidden Grove.
C vs. C++ vs. C# (Beginner)
MandleBro
something cheesy and currently irrelevant like QBasic


That's me! Also did Visual Basic for awhile...

Even languages like QBASIC can provide a learner a good understanding of important programming concepts like conditionals, loops, variables, etc.
101 posts
C vs. C++ vs. C# (Beginner)
Edited by pragmatic_hero on
ratchetfreak
The extra compile time when going from C to minimalist C++ is negligible.


This statement really needs some data and measurements to back it up.
Because I'd really know if it's true.

As well as - where to draw the line in regards to what constitutes a "minimalist C++" and "negligible extra time".
Is frequent use of BS free version of std::array/std::vector minimalist C++?

Is Omar Cornuts imgui minimalist C++? Is idTech4 minimalist (esp. the idLib part)?

What is known, is that even mainstream C compilers - the whole toolchain, linkers, etc - are very slow (for no good reason, on any build settings).

Doesn't HMH builds already take 3 seconds? On a really high end CPU with an SSD.
Mind you, there's almost no gameplay code in there, and HMH functionally doesn't really do all that much.

I'd extrapolate that it could go easily 6-10 seconds, for me that would rapidly suck out any enjoyment working on a game where builds take that long.
101 posts
C vs. C++ vs. C# (Beginner)
Edited by pragmatic_hero on
MandleBro
BTW: random aside about Opus Magnum - that studio does the hotloading game logic trick that Casey shows in the early episodes of Handmade Hero using C# with binary serialization.

Is there an article covering Zachtronics use of hotswapping?
Jack Mott
110 posts
Web Developer by day, game hobbyist by night.
C vs. C++ vs. C# (Beginner)
Not that I know of, they mentioned it on twitter, that they have been using it for a while and love it, would never make a game without setting that up first.

But basically they just have some class with the game state, serialize it to a file, load the new DLL, deserialize it back into the class.