Jump to content
  • Advertisement
Sign in to follow this  

C/C++ Question...

This topic is 4811 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

If C and C++ are basically the same things just about... why do some people use C instead of C++, if C++ is a better C?

Share this post


Link to post
Share on other sites
Advertisement
Because C++ is a bigger, more complex C. They don't want to relearn how to do things they can already do easily enough in their current language. To take advantage of the features of C++ requires a new way of thinking about problems and doing things than in C, and learning to do that takes time, time they probably feel is better spent working on their code.

Share this post


Link to post
Share on other sites
C++ has more advanced features that _can_ make programs more bloated. Classes with virtual inheritance, as well as exception handling are two main sources of potential bloat. These days most apps on a PC can be written in C++ (or even in other languages that have more overhead like Java or Python). Some people use C out of habit, some people use it because they are maintaining C code, and some people are using it because the platform they write for (such as an embedded platform) can't handle the overhead or doesn't have a C++ compiler available for it.

Share this post


Link to post
Share on other sites
C++ is simply (C)++ (remember increament operator?)
it's basically C with Object Oriented features added. OOP (Object Oriented Programming) is a different approach toward solving probloms with ease of program development in mind though it has some performance drawbacks which can be easily ignored (well, almost) considering it's benefits. It's just next generation programming, like moving from linear programming to functional programming back in 70's. By the way have you ever heard of next generation Aspect Oriented Programming (AOP)? Technology is moving fast!

peace

[Edited by - kN1gH7 on March 17, 2005 4:46:47 AM]

Share this post


Link to post
Share on other sites
Progress for the sake of progress is not always a good thing. There are trends and fads that come and go.

Ansi C, Vs C++ (Object Oriented Code)

Ansi C,

Structured Code Top down design.
Ansi C has the ability to encapsulate your code, and varibles somewhat with functions that you write and call from your main (which is incidentally a function as well)Functions should be written in Header Files and #included in your main, then called.

#include "myfunctions.h"

main()
{

// Assuming mysqrtfunct was defined in myfunctions.h
int mySqrtFunct();
}


C++
Object Oriented Design.
Object Oriented simply means that the concept of encapsualtion from Ansi C was expanded upon to create Objects. To create an object you create a class. A class can contain functions, and variables within that class. everything in that class can then be referenced back to the calss.

I'm far more familure with Ansi C. So, I'll be writing my games in Ansi C. I think that is the overall consensus. Whatever you are more familure with is what you should design in. Don't get bogged down by semantics. If you're having to look up syntax then you lose momentum.

James D. Cullen

Share this post


Link to post
Share on other sites
Quote:
Original post by kN1gH7
C++ is simply (C)++ (remember increament operator?)
it's basically C with Object Oriented features added. OOP (Object Oriented Programming) is a different approach toward solving probloms with ease of program development in mind though it has some performance drawbacks which can be easily ignored (well, almost) considering it's benefits. It's just next generation programming, like moving from linear programming to functional programming back in 70's. By the way have you ever heard of next generation Aspect Oriented Programming (AOP)? Technology is moving fast!

peace


i read an article about it once.... could hardly even understand the concept.
got an ideas or links?

Share this post


Link to post
Share on other sites
Quote:
Original post by DynaEmu
If C and C++ are basically the same things just about... why do some people use C instead of C++, if C++ is a better C?

C++ is a big language. There's a lot of different parts of it and a lot of different ways of using it. C++ is not limited to being "a better C", this is just one of its uses. In addition, C++ was designed with the idea of "you only pay for what you use", meaning that you don't have to use a feature if you don't want to, and you don't pay a performance cost for unused features. For example, classes and templates are two things C++ has that C doesn't, and both are completely optional as well as combinable.

One of the reasons people use C is that, while there is almost certainly a better way of doing it in C++, it's entirely possible that they don't know what that better way is! This is complicated by C++ not being taught properly - most of the time it seems to be taught as "a better C" rather than teaching the really powerful stuff - also by the idea floating around that it's better to learn C before C++.

The other thing is that most of C++'s more advanced features lead to bloat if you don't use them properly. You only pay for what you use - the catch is understanding exactly what it is you're asking of the language and how to specify what it is you want. For example, using the <FONT=courier>virtual keyword for all functions indiscriminately adds overhead, and is enabling a feature you're not actually using. All of the added "bloat" is actually adding additional functionality of some sort, and can be remedied either by taking advantage of this functionality or finding out how to switch it off.

Finally, there are lots and lots of C coders around, who are happy with C. C++ is a lot to learn, and to use it properly you have to re-learn nearly everything you learned in C. Not many people want to do that.

Share this post


Link to post
Share on other sites
check this:
http://www.cs.ubc.ca/~gregor/papers/kiczales-ECOOP1997-AOP.pdf

oh, btw, did you know java is (c++)-- ? guess why ;)

Share this post


Link to post
Share on other sites
One Item that just came back to mind. Using C++ and pointers in C++ also leads to Mem leaks. More specifically if your not carefull allocating anc calling pointers your memmory usage will incrmentally increase. I remember having to manually deallocate, or destroy pointers. Has this been cleared up in new releases of the C++ language?

I remember there being quite alot of strange problems with C++. Now this was 10 years ago, well back in 1991. I can see this as contributing to the bias towards ANSI C, and against C++

As instructors, or mentors, remember the "Good Old days" They just perpetuate the cycle by teaching a bias, unconciously, or not.

And yes I guess I just dated myself as ancient. :P

Jim Cullen

Share this post


Link to post
Share on other sites
Quote:
Original post by kN1gH7
check this:
http://www.cs.ubc.ca/~gregor/papers/kiczales-ECOOP1997-AOP.pdf

oh, btw, did you know java is (c++)-- ? guess why ;)


Java was created to address the shortcomings of C++ that I mentioned earlier.
Java is not C++, The designers kept the syntax and some of the features of C++, but Java is an interpreted language run on a VM. Java is not compiled. The similarities between Java and C++ are purely asthetic.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!