Archived

This topic is now archived and is closed to further replies.

buck71

C versus C++

Recommended Posts

Hello I have been working on learning C for a while now and want to start moving towards making games. It seems though that all game development is done in C++. Obviously I would like to make the best game but it seems a shame to not use what Ihave learned of C. Is C++ certainly better for games? If C can do all that C++ can do where do I find out how? Does anyone work primarily with C? etc etc... Any thoughts would be appreciated

Share this post


Link to post
Share on other sites
Quake 3 -> C
Half-Life -> C++.

It''s all down to preference, so try which you like. They are very similar, it all depends whether you want to program procedurally or OO.

End of thread - no more needs to be said.

( Hey, that rhymes! )

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
C++ is an extension of C. If you use C++, you are using parts of the C language. C++ is C and OO (object orientation). I primarily use C in most of my programs, but once in a while will include sections of C++.

Billy

Share this post


Link to post
Share on other sites
All my game programming has been ALL in C (a side-scrolling shoot em up, and a board-game AI that learns how to win at tic-tac-toe, checkers, and connect-four) (except DirectX), so it can be done; however, sometimes I wish I had created classes for encapsulation and done some polymorphism with it, but, oh well.

Nutts

Share this post


Link to post
Share on other sites
quote:
Original post by buck71
So, where can I find good tutorials/books on games programming and C? I have so far found nothing in the shops.


take a look here it has a rather cool sections calleds "books and software" and "articles and resources", i think they will be of great use

if you cant buy books online, get info on the book online and go to your local store (waterstones, whsmith) and ask them to order it.

also, might a suggest to not jump straight into game development, learn at least the basics of the language first, that way you save time and confusion...

Share this post


Link to post
Share on other sites
quote:
Original post by buck71
So, where can I find good tutorials/books on games programming and C? I have so far found nothing in the shops.


heh off the top of my head I can''t think of any non C game programming books. OpenGL game programming is pretty good IMO and Tricks of the Windows Game Programming Gurus is supposed to be good but I''ve never been able to get a copy and i think it would be slightly pointless now.

Share this post


Link to post
Share on other sites
You should also consider the possibility of employment at some future date. I know of no companies that use C any more. ''C'' shops have moved on to C++.

But even if you are not by profession a programmer, you should consider C++. It is extremely powerful once you understand the subtleties.


D.V.

Share this post


Link to post
Share on other sites
I made my first couple of games in straight C with DirectX, and am making another one now in C++ with classes and boy, I wish I had done that from the start, it makes the coding so much simpler and easier to debug.

Share this post


Link to post
Share on other sites
quote:
Original post by DeltaVee
You should also consider the possibility of employment at some future date. I know of no companies that use C any more. ''C'' shops have moved on to C++.


That''s funny, the way I''ve heard it, more companies use C than C++ still. Can you site the reference for where you got that? I don''t remember where I found mine, but I''m not trying to say you''re wrong, just that I''m informed differently . My advise is to just learn to code both, they''re much alike, and then you won''t care which one you use. I write a lot of code in C (modular mostly), but I like C++ too (for OO stuff).

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
DeltaVee,

You couldn''t be more wrong. Case in point, the industry I work in, Embedded Systems. While there are plenty of embedded systems that do use C++, the majority still use C. Embedded systems are real-time crucial, and the pro''s C++ provides vs it''s cons with respect to Embedded Systems are not enough to warrant using it over C.

Nutts

Share this post


Link to post
Share on other sites
And every single issue of Embedded Systems tech magazines have something about C++ in it. The reality in embedded systems (also an area I work in) is that one embedded system is not like another, just like games. Some embedded systems need to go on a 1MHZ proc with 3 registers. You don''t want to use virtual inheritence in that case. Others have 2 megs of external RAM on a workhorse (like mobile phones) with hundreds of code modules. Then you''d want to use C++. It''s all about what''s right for your app.

Share this post


Link to post
Share on other sites
if you mean C++ in an object oriented context, OO is simply an attempt to implement solutions using object representation. a superset of Structured Programming, another way to organize your data and functions...instead of seperately, you can ''encapsulate'' or merge your data and your code together. OOP was created to mimic the way ppl solve problems in everyday situations.

you''ll be learning basically 3 new things if you havent already.. ''encapsulation'' ''polymorphism'' and ''inheritence'' which''ll make your code alot more maintainable imo.

so whatever you''ve learned with C you wont be throwing away when you start using C++...alot of the times youll be mixing both procedural and OO ways of solving problems...think of it as broadening your horizons.

Share this post


Link to post
Share on other sites
I seem to remember that when some of the first PC C++ products came out, e.g. Glockenspiel C++, they actually translated C++ back into C for compilation by a standard C-compiler. I guess some of the OO features of C++ classes were translated back into C pointers to funtions and virtual tables of pointers to functions, e.g. a C structure with a member that is a pointer to a function is similar to a C++ class that has properties and methods.

My point is that C++ is an extension to C, it is backwards compatible with C but sufficiently different enough to be given a different name. It''s possible to write OO code in C, and its easy to write non-OO code in C++. It is however easier to write OO code in C++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just learn both. While there are differences, they are interchangable in a lot of cases.
You can pick whichever one you want for the specific game you are programming, and later if you want a job you will have that many more options. Obviously (from the other posters) both are used currently in the industry.

Share this post


Link to post
Share on other sites
quote:
Original post by BeerNutts
DeltaVee,

You couldn''t be more wrong. Case in point, the industry I work in, Embedded Systems. While there are plenty of embedded systems that do use C++, the majority still use C. Embedded systems are real-time crucial, and the pro''s C++ provides vs it''s cons with respect to Embedded Systems are not enough to warrant using it over C.

Nutts



Like I said ''I don''t know of...'', there are probably some out there.

In all reality, what would you rather do, support a legacy system or work on a new project.

I used to support legacy (COBOL) systems, and I got out ASAP. The future is always (generally) in the new (then it was C) now it is C++ and more recently Java.

I have not come across pure C code for about 7/8 years now. And that''s on both sides of the atlantic.


D.V.

Share this post


Link to post
Share on other sites
quote:
In all reality, what would you rather do, support a legacy system or work on a new project.


Delta Vee,

I am developing a leading edge Digital Cable Settop box for Television which uses all new technolgies, and, outside of a few modules, all of our code is written in C. This includes our application level code, which does tons of stuff, including a web-browesr through the TV and executing Java Script, etc. This product has been in development for about 3 years, and it sure as hell isn't "legacy."

Your idea is that C is never a thought when developing a new system. The only place that MIGHT be true is in the world of Windows programming. Like Python_regious said, Quake3 was developed with C; is that legacy code?

I get a bit upset with people who think C++ is this all great and powerful thing; There are some good things about C++, but for the most part it's just bloated, over-featured, and slow! C++ is only an extension of C; Compilers have been known to 1st compile C++ code into C code, then into assembler. C is older than C++, but don't EVER group it with COBOL of all languages! They are night and day! C is still actively being used on new systems.

quote:
The future is always (generally) in the new (then it was C) now it is C++ and more recently Java.


I guess since Assembly is old that no-one will ever use it any more either? And, Java has a long way to go before it can be used in any real time environment (especially since it needs Native code, which defeats 1/2 the prupose of Java).

quote:
Like I said 'I don't know of...'


That leads me to believe there's plenty of systems "you don't know of."

Nutts

Edited by - BeerNutts on November 9, 2001 4:59:56 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
WHY? This post comes up every few days, its common, stop responding. People can do their own research.

Share this post


Link to post
Share on other sites
Glad to see that the fact that the post comes up so much has stopped us from flaming each other saying "C is better! C++ is better! you are wrong, they are the same in the end!"

I heard C is still used a lot because sometimes is hard to teach old programmers new tricks I learned both right in the transition (C was still the most powerfull, C++ was earning more terrain, and java was just out) so even when I consider myself to be a C++ programmer, I dont estrictly follow the rules, I dont make an Application class, I stick to the old main (or WinMain) function that does most of the work instead of just instancing a CApp class, of course I make objects for everything I "feel" more tangible like images, sprites, maps, etc.

Share this post


Link to post
Share on other sites
BeerNutts, yeah your right. Just because I don't see any C development doesn't mean that there isn't any.

If I sit down and think about it for a little bit BEFORE I open my big fat yap, there are a lot of applications that are preferable in C.

Embedded system and device drivers are two that come to mind. Controllers is another.

Sorry if I came off like a know it all.

So in conclusion. Learn C AND C++.



D.V.

Edited by - DeltaVee on November 11, 2001 11:54:33 AM

Share this post


Link to post
Share on other sites
Learn both. Then experiment by doing some small task in both. Get a feel for which you like better. Its actually matter of preference of the entire group working on the project, leaving you to only make sure your code works as fast and efficiently as possible within the set of specs you were given. Case in point, a lot of the stuff you learned in C is still applicable in C++, you can think of classes as just a extension of structs, and do most of your work with the same mentality. The stuff involving virtual functions and polymorphism seem to just be sort of side effects that you had in C when it came down to type casting that void pointer. I''m probably simplifying it a bit much, but its not really a big situation, learn both.

Share this post


Link to post
Share on other sites