Jump to content
  • Advertisement
Sign in to follow this  
Ultimate_Fusion

should i learn C?

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am a programmer. done java for a year and am starting to learn c++ becasue it is the way to go with game programming. do I need to learn C before i learn C++? is there any good game tutorials for beginners on the web?

Share this post


Link to post
Share on other sites
Advertisement
The only reason I can see to "start" with C would be because it's "simpler" (none of the fancy C++ bits and bobs are directly available - classes and whatnot) or to familiarise yourself with the standard C-syntax.
You know Java so should be happy with the concept of classes - and Java follows a C-type syntax. In short: I can see no point saying "first learn C, then learn C++". Just dive in to C++ - the stuff you'd start with in your "conversion" from Java will be pretty close to normal C anyway.

Share this post


Link to post
Share on other sites
I would absolutely say no. If you start with C programming you will undoubtedly pick up some C idioms that are just considered bad practice in "modern C++". This means when you start learning C++, you will have to "unlearn" some of the C ways of doing things.

I think you should pick up the book "Accelerated C++" and learn some good and modern C++. The book is fairly fast paced, but since you already know Java that shouldn't be too much of a problem.

Share this post


Link to post
Share on other sites
Normally I say learn C first because it is simpler, but coming from Java, you should have no problem with Cpp. And rohde is right; I learned C first, and I have to change a lot of my programming habits because, while they make good C, they make "messy" and "insecure" Cpp [lol]

Share this post


Link to post
Share on other sites
I would learn x86 assembler before C! At least that way you learn how a computer really works first, which is definitely a big help with serious game programming. So, IMO no don't learn C.

Share this post


Link to post
Share on other sites
I think it would be better to start with C++. A few things are done differently in C and C++, and you might get hung up on a few bad habits.

One thing I cannot stress enough is to learn binary, hex, and at least a bit about how computers work. Knowing this is essential to programming in C++. Anyone can program, but if you want to do it effectively, you need to know the inner workings of your tools, both the computer, and the compiler.

But start simple, and supplement your C++ with some lower level reading on computer circuitry, compilers, and assembly language.

Share this post


Link to post
Share on other sites
Since you know some java already, you don't need to start with c. Just jump right into c++ if you think you're ready. If you are going to college though you might have to program in c one day.

Share this post


Link to post
Share on other sites
Absolutely not.

It may be helpful to think first in terms of a *real* subset of C++ which is *similar* to C (real C is definitely not a true subset; C++ doe offer bend-over-backwards compatibility to C, but there are things you can write in C that lose something in translation to C++), and build from there. But the convenience of certain basic C++ features (std::string, containers such as std::vector, and the modern I/O library) is too much to ignore - for experienced programmers as well as beginners.

Be aware that idiomatic C++ behaves fairly differently from Java, beyond the minor syntactical differences. Because there is no native GC, there is first of all a shift towards the RAII paradigm - you try to allocate objects as locals where possible, and the language will deallocate them (as they are "on the stack") as soon as they reach the end of their scope; you are expected to make objects which can clean themselves up at this point, via "destructors" - they are similar to Java finalize() methods, except that you know when they are called, and are more frequently needed. Also because of the lack of GC, and the lack of the Java object model, there is more emphasis usually on copying objects rather than aliasing them. There is also less memory overhead per object, but you don't get to do thread synchronization so easily, and you also have to request polymorphic behaviour instead of getting it automatically. There are lots of other little gotchas too, associated with having to manage things yourself. (Which is why smart programmers rely on the standard library as much as possible; it handles common cases of "thing management" for you.)

Also be aware that statements like "becasue [C++] is the way to go with game programming" are potentially dangerous ;)

Share this post


Link to post
Share on other sites
thanks for the info guys, i am at uni now and know who how computer works so i am going to get on with learning C++.

i will be posting again when i get stuck.

thanks again later

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!