Advertisement

C vs. C++

Started by September 11, 2002 09:01 PM
20 comments, last by DM0407 22 years, 1 month ago
For engine programming, I would suggest you use C++ for the difficult things, and C for the easy things.

As I have been told (don''t let me fool you into thinking I am not capable of carrying incorrect information), C++ handles ''hard'' tasks better than C, but C handles simple things (simple things like physics ;p) better than C++.

You should learn C to the extent in which you so desire to learn. [not a flame]John Carmack... *sigh*. If you think John Carmack is the greatest programmer of all time you have poor priorities.[/not a flame]
/*-=-=-=-=-=-=-=-=-=-=-=-= trae@illicitstudios.com=-=-=-=-=-=-=-=-=-=-=-=-*/
A programming language is a tool to get something done. Whether you use C or C++ or Java or even a dialect of BASIC depends on what you want to do.
Want to make a prototype to see how something works? Use BASIC, which allows you to code something really quickly.

As for C/C++/Java, I know that among them C++ is the most versatile in terms of what you can do. Java IS Object-Oriented. C++ can be, but can also be C-like in its nature. C++ was designed to allow multiple paradigms, and that is probably why so many people swear by it. They can claim that they like it because it lets them do X, whereas some other language can only do Y. But then still other people will instist that C++ also does Y.

Forget the language. The language is only important as it is the specific tool you use, but if you can''t use general categories of tools, you can''t do anything with it. When you learn to drive, you learn how to turn, how to brake, how to accelerate, how to park.
You don''t learn how to do this ONLY in a certain type of car. You learned how to do it so that even if you were driving an automatic or a stick, you could still control the car and make it go where you wanted to go.
Now you might have to learn how to control a stick, but the point is that it is a detail. Driving a car is still driving a car. The stick is a tool you use to make the car go, but an automatic does the same thing. Think of it like C++ and Java. Java is the automatic that controls what goes on under the hood pretty seamlessly (garbage collection comes to mind) whereas C++ allows you to have more control over what happens by using a manual transmission method.

If you can program in an Object-Oriented way, then you will be able to pick up C++ AND Java AND ML, etc.
Procedural/modular coding: C and C++
Again, C++ is pretty versatile in what it can do. It also makes it more complex to learn/debug, I guess, but then familiarity with your compiler is a good way to help alleviate any pain there.
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Advertisement
DRAT! All of my post was lost due to a connection problem... well anyway here goes again:

In reply to GBGames:

Do you really consider C++ a manual transmission?


In reply to DM0407:
'Does anyone know any good C touts' here:
http://rocs.acomp.usf.edu/tut/c.php


/*-=-=-=-=-=-=-=-=-=-=-=-=
trae@illicitstudios.com
=-=-=-=-=-=-=-=-=-=-=-=-*/

[edited by - taciturn on September 13, 2002 1:27:34 AM]
/*-=-=-=-=-=-=-=-=-=-=-=-= trae@illicitstudios.com=-=-=-=-=-=-=-=-=-=-=-=-*/
quote: Original post by GBGames
Procedural/modular coding: C and C++


C can do some OO stuff too with structs, and you can use function pointers to fake methods as well.

Any more advanced OO concepts such as inheritance can''t be done in C though.


Henrym
My Site
I am a noob (obviously) and I''m a little short on money . I downloaded the Bloodshed-Dev-C++ compiler and was wondering if this compiler is any good. Another question If I learn c++ with Microsoft Visual c++ will I be ablem to use that on Dev-C++. Last is there a difference between Visual C++ and C++

Ishamael02
Betrayer of Hope
Eldar_mage
Peter B
Ishamael02Betrayer of HopeEldar_magePeter B
On the topic of having a vector of strings and ints... just use std::string instead of char* - don''t make things more difficult for yourself than you have to. You''ll end up with memory leaks if you forget to free up strings that have references held in the vector.
Advertisement
If you read any game programming book you can see that 99% of the code is a mix of c++ and c, so learning a little bit of c is a must.
I use dev-c++, also cause I lack money, but it does what I want so I''m happy with it. I would recommend it.
quote: Original post by henrym
Any more advanced OO concepts such as inheritance can''t be done in C though.


Inheritance and polymorphism can be done in C too - but it''s messy.

"Object Oriented Programming in C" Laurent Deniau - June 01, 2001

Portable Inheritance and Polymorphism in C by Miro Samek December 1997, EmbeddedSystems Programming

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
quote: Original post by Ishamael02
I am a noob (obviously) and I''m a little short on money . I downloaded the Bloodshed-Dev-C++ compiler and was wondering if this compiler is any good. Another question If I learn c++ with Microsoft Visual c++ will I be ablem to use that on Dev-C++. Last is there a difference between Visual C++ and C++

Dev-C++ is really just an "integrated development environment" (IDE) - an interface for the compiler - in this case the MingW version of gcc. As far as C++ the language goes - the gcc compiler will be more conformant to the standards.

Visual C++ is also an IDE. The Visual part pertains to the presence of many tools for graphically designing an application. MSVC6 had a few problems conforming to the standards - mostly regarding templates. If you''re just starting to program, it will be a few months to a year before you get far enough along for this to raise it''s head. But if you''re using Dev-C++ you won''t likely have to face that issue at all - but you''ll have other ones no doubt - that''s just the nature of the beast.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement