Learning C

Started by
27 comments, last by Serapth 12 years, 9 months ago
I already started to learn C++ and have found it very complicated. I have heard that C is a lot simpler and a tiny bit faster.
Im more concerned with the difficulty of the language than the actual features.
The goal is to be able to make 3d games one day. Im pretty sure I can use OpenGL in C and If I ever need a high level language for the game logic I could use Lua or something.

Does this make sense to do?
Is learning C for the sake of simplicity a good idea?
Will I hit any roadblocks, or will I need to learn c++ at some point?
Advertisement
C is definitely a much simpler and cleaner language. It'll be a lot faster to learn and slightly easier to master than C++. However, it does cut you out of a lot of really powerful stuff, and will require more code and more care to handle certain things that C++ can largely automate for you (memory/resource management is a big one; C lacks anything like C++'s RAII idiom).

I would say tough it out and learn C++. You'll sacrifice too much, and C really is not designed for beginners or for people who want to get stuff done fast.

Alternatively, you could switch entirely to a language which isn't horrible, like, say, C#, Python, Ruby...

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


C is definitely a much simpler and cleaner language. It'll be a lot faster to learn and slightly easier to master than C++. However, it does cut you out of a lot of really powerful stuff, and will require more code and more care to handle certain things that C++ can largely automate for you (memory/resource management is a big one; C lacks anything like C++'s RAII idiom).

I would say tough it out and learn C++. You'll sacrifice too much, and C really is not designed for beginners or for people who want to get stuff done fast.

Alternatively, you could switch entirely to a language which isn't horrible, like, say, C#, Python, Ruby...


Well what If I dont really care about the extra code?
If I am a master at C then I just have to write it.
In C++, it will always be frustrating and difficult.


But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.
Python and ruby arent really for 3d games...?
Learning C can be useful from an educational standpoint, because many higher level languages are based on the C syntax. Unfortunately you will have to do a lot boilerplate work on your own in C, which usually leads to programming errors. C++ can be little better in that respect, as it introduces some language features that helps you write "safer" code. What's really important about C++ is that it introduces you to concepts, such as object oriented programming, as do other languages, such as C#, etc. OO changes the way you structure code and how you think about programming problems. I think C is a good starting point, but you should not ignore other languages, as you will have to work with them at some point.
Latest project: Sideways Racing on the iPad
Oh boy.


  • You should always care about extra code. Extra code is more stuff to type, more stuff that can go wrong, more stuff you have to maintain and remember. More code is BAD.
  • You won't be a master at C any time in the next 10 years, sorry. It takes a long time to get that good at things. By then you'll really, really hate the language and want something more powerful.
  • C++ will not "always be frustrating and difficult." It only seems that way because you don't know it yet. Give it time. It'll come.
  • C# has DirectX support via XNA, and OpenGL bindings via libraries like Tao.
  • C# is cross-platform. There is nothing tying you to Windows. See the Mono project, for instance.
  • Get rid of this absolutely disgusting notion that there's a "right way" to make games. If the game is playable and fun, you did it right. If the game isn't playable, or isn't fun, you did it wrong. Nobody on this planet should give a flying shit how you made it. That isn't the point.
  • Many 3D games use Python, Lua, Ruby, and other scripting languages for high-level logic. Yeah, you'll have to do some guts-work in a lower-level language, but don't ever make the mistake of thinking that just because you don't want to write a 3D engine in a given language that the language is useless for game development.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

How have you been studying C++ ? If you dont have one you should get a book.. if you really want to make games you should learn C++..

Playing around with C# and XNA could be a good idea as you'll learn to code.. Its not hard to make a transition into C++ later and its alot easier to learn.. you wont be making hardcore games right away anyways.. and with C# and XNA you might not loose your motivation beeing frustrated :)
Alright thanks.

Im just gonna learn C++ then.

Can anyone recommend me a book?
I already started to learn C++ and have found it very complicated. I have heard that C is a lot simpler and a tiny bit faster.

The first thing you should be aware of is that C++ (with few exceptions) possesses all the syntax that C does. For that reason, virtually everything you can write in C will be translated by a C++ compiler the same way a C compiler would do it. The main difference is that C++ also provides the ability to write object-oriented code (along with something called template (meta-)programming), which makes C++ a significantly more complex language.

As for speed C++ actually has the potential to outperform C (big time, even), provided that 1) you are using a compiler with good optimization capabilities (like Visual C++), and 2) you know what you are doing. The real problem is that if you do not have a thorough understanding of both the language and how your code is translated to binary instructions by the compiler, your intuitive solution to a given problem may likely be more efficient if you write it in C.

But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.
Python and ruby arent really for 3d games...?

There are basically two types of developers; those focused on development time, and those focused on efficiency. Personally I belong to the latter, but if have no problem raising the system requirements for your product instead of using a couple of years to research and develop a performance-oriented framework from scratch, and you don't mind using a combination of a gazillion different scripting technologies to get the job done as fast as possible (which -in the end- yields a much more error-prone solution, btw), then by all means write your game in C#, Java, Python, Flash, HTML or whatever requires the smallest amount of work (this is how many modern games are developed anyway). If, on the other hand, you want your code to be as efficient as possible then start with C combined with a basic understanding of assembly programming, and move on to C++ when you feel ready for it.
But I would use C# but theres no cross platform or DirectX/OpenGL. I do not want to use XNA. I want to make games the right way.


Check your preconceived biases at the door, at least until you actually know more than you do. Seriously, where do newbie developers come up with these preconceived stupid ideas. There is no one right way. Hell, it's becoming more and more common for games to be made using a number of languages, especially triple A titles. Also yes, C# *DOES* have DirectX AND OpenGL AND is cross platform.


There are basically two types of developers; those focused on development time, and those focused on efficiency. Personally I belong to the latter, but if have no problem raising the system requirements for your product instead of using a couple of years to research and develop a performance-oriented framework from scratch, and you don't mind using a combination of a gazillion different scripting technologies to get the job done as fast as possible (which -in the end- yields a much more error-prone solution, btw), then by all means write your game in C#, Java, Python, Flash, HTML or whatever requires the smallest amount of work (this is how many modern games are developed anyway). If, on the other hand, you want your code to be as efficient as possible then start with C combined with a basic understanding of assembly programming, and move on to C++ when you feel ready for it.



... and now I see where people come in with these preconceived ideas. This advice is epically bad, if you are a new developer, ignore this completely. This isn't 1986, starting with C & assembly is about as stupid a way to start as you could come up with. Additionally, your summary of "two kinds of developers" is incredibly short sighted. You especially missed the pragmatic developer, who uses the right tool for the job. Where your bizarro world comment in the mid paragraph about scripting comes from, boggles my mind. First off, the majority of C++ houses these days don't even roll their own engines anymore, it's just a piss poor use of time. Second, in these C++ based games, they still contain a ton of scripting. And no, done right, it is much LESS error prone, as the scripts are effectively sandboxed and more fault tolerant than static code. To say nothing of the various advantagous.
In regards to the first question, no, starting with C is not a good idea. The libraries are laughably bad, you need to do things that are just horrifically primitive by modern language standards ( manaully null terminating strings? ). Frankly too, C is more or less obsolete, outside of embedded systems and a few other niche markets.

This topic is closed to new replies.

Advertisement