C Or C++


rhijaen

Still Fresh
Joined
Sep 23, 2006
Messages
14
I have been teaching myself C for the past few weeks to try to code for ipodlinux..

but next semester I'm taking a C++ course at my high school

which one is better/easier for the gp2x, or does it matter

I'll be getting a gp2x for christmas so watch out for a budding programmer! B)
 
doesnt matter. sdl is in C and its not the best idea to mix c and c++ (new/malloc/free/delete etc).. but really, no big deal.
 
not much difference, its like being able to walk before you can run.

you can do a lot in c, and expand with c++ with classes and templating. but you should have to use too much ++ if you design your game right.
 
They're both general purpose languages; you can do anything in either one, just differently.. so you get to pick :)

jeff

Start with C, then do C++ likely..
 
Cool, thanks guys

I'm currently taking a VB .NET class and trying to teach myself C at the same time.

In C, arrays and pointers get me confused a lot, still not exactly sure what pointers are good for.

But i'm still trying to get through this thick book. (C for dummies all-in-one desk reference)
 
C++ essentially is C with classes and dynamic memory management. Using the OOP approach available in C++ can make coding and debugging much, much easier. On standard computers I much prefer the OOP because of ease of use. It's easier to create a project in modules and debug individual modules than trace through a ton of linked code trying to find out where the bug is.

Dynamic memory management and OOP have some necessary memory overhead, however. If you really want to optimize your code, I would personally choose ANSI C (and adhere to strict ANSI). In a small program it probably won't matter much, but I don't have any experience programming for the GP2X (still need to buy one - waiting for a few more paychecks), so I don't know how much of an impact the OOP has on the hardware. It may be negligble, or it may totally depend on the scope of the project.

For learning programming, I think it's good to start with ANSI C. It's too easy not to understand what's actually behind the code, and a good understanding of C will help you avoid that. Then shift up to C++ and take advantage of OOP.
 
rhijaen posted on Oct 18 2006 at 02:46 AM said:
Cool, thanks guys

I'm currently taking a VB .NET class and trying to teach myself C at the same time.

In C, arrays and pointers get me confused a lot, still not exactly sure what pointers are good for.

But i'm still trying to get through this thick book. (C for dummies all-in-one desk reference)

Hi

I would recommend" Programming in C++",Betnard Babani Books, M.Walmsley BP435, £6.99. It is quite small and fits in the back pocket so one can have a quick read on the bus or whatever.

I find what stumps me nowadays is the GUI! :(

Peter
 
Last edited by a moderator:
If you look for better performance, C is always faster than C++... :)
But compiler for C++ is faster than the C one. :blink:
Then my suggestion is to use C but with the C++ compiler. :lol:
 
Franxis posted on Oct 18 2006 at 12:58 PM said:
If you look for better performance, C is always faster than C++... :)
1, 2, 3, 4, I declare a Holy War :)

C is not always faster (but not slower), but if you are using fancy stuff like polymorphism, there will be a slight perfomance hit.

Then my suggestion is to use C but with the C++ compiler. :lol:

Good idea, the C++ compiler will compile ANSI C and provide better type checking. Even if you are writing C, you can also take advantage of some of C++'s features, like using a reference to pass writable values to functions rather than having to use pointers.
 
Last edited by a moderator:
jukujin posted on Oct 17 2006 at 11:23 PM said:
C++ essentially is C with classes and dynamic memory management. Using the OOP approach available in C++ can make coding and debugging much, much easier. On standard computers I much prefer the OOP because of ease of use. It's easier to create a project in modules and debug individual modules than trace through a ton of linked code trying to find out where the bug is.

Heheh don't worry you can write confusing difficult to debug code in either C or C++. There are some really nasty places for C++ bugs to hide just like in C.

I'd also recommend starting with C, then move on to C++ when you find C too restrictive or want OOP.
 
Last edited by a moderator:
Yes.

Reasons:
1. Being cross platform you can do a lot of the development on your PC
2. Lot of tutorials
3. Paeryn's accelerated SDL libraries
 
Franxis posted on Oct 18 2006 at 01:58 PM said:
If you look for better performance, C is always faster than C++... :)
But compiler for C++ is faster than the C one. :blink:
Then my suggestion is to use C but with the C++ compiler. :lol:
depends, if you are not very good at writing c, some stuff implemented using classes and templates can be faster, c++ compilers are pretty good these days.
 
Last edited by a moderator:
C++ memory foot print can be large compared to C.
Class member functions use an additional register to pass the 'this' pointer so the calling sequence "can" be more overhead if the number of explicit paramaters is more than three.

For GUI's C++ is "much" better than C, for raw compute power with a small memory foot print C is the logical choice.

As with any choice the comfort you feel using the language is "almost" as important as the language itself. You can write crap in any language. I don't care much for the things that C++ can do for me because I can't control how they get done. I started programming by writting assembly language and then learded C so I am corrupt already. Depending on the problem space C++ may be the best choice but I usually look at doing it in C first.
 
I'm still earning money for my gp2x, but in the meantime is there an emulator of some sorts i can try some code on?
 
Back
Top