C and C++

W

wilberX

I have a question on how closely C and C++ are related. If i am
correct C++ is OOP while C is not. Now how closely can an OOP language
and a procedural language be related? How much knowledge of C is
required to understand C++? Thanks.
 
P

Phlip

wilberX said:
I have a question on how closely C and C++ are related. If i am
correct C++ is OOP while C is not. Now how closely can an OOP language
and a procedural language be related? How much knowledge of C is
required to understand C++? Thanks.

To what purpose will you put the answer?

C++ is C with a few keywords added and just a couple bugs removed.

Those new keywords permit better OOP style. Folks have written OOP in C
since forever; it's just harder.

Now you define OOP before asking what the difference between the languages
is.
 
M

Mike Wahler

wilberX said:
I have a question on how closely C and C++ are related.

Fairly closely.
If i am
correct C++ is OOP while C is not.

C++ has native facitilies which support OOP,
but that's only one of several programming styles
it supports.
Now how closely can an OOP language
and a procedural language be related?

C++ isn't *only* an OOP language. One can
write procedural code with it as well. Both
C and C++ can be considered 'general purpose'
languages.

How 'close' C and C++ are depends upon your notion
of 'close'. E.g. the syntax of one is quite similar
to that of the other. But the semantics are often
different.
How much knowledge of C is
required to understand C++?

None at all.

You're welcome.

-Mike
 
M

Michael Redlich

Phlip said:
C++ is C with a few keywords added and just a couple bugs removed.

I wouldn't characterize C++ so lightly. Have you forgotten about
operator overloading, exception handling, templates, namespaces, and
the STL?? A person graduating from C to C++ has somewhat of a steep
learning curve if he/she wants to develop good, quality code.
Those new keywords permit better OOP style. Folks have written OOP in C
since forever; it's just harder.

True, one can essentially create an "object" using the struct
mechanism.

Mike.
 
B

BigBrian

Michael said:
A person graduating from C to C++ has somewhat of a steep
learning curve if he/she wants to develop good, quality code.

Your statement sounds like you're infering that C++ is better than C
since you suggest that people graduate from C to C++. This really
isn't true in every case, both languages have tasks for which each is
better than the other. The linux kernel is writen in C, not C++. I
would bet most of the developers for the linux kernel would take issue
with the statement that they needed to graduate to C++.
True, one can essentially create an "object" using the struct
mechanism.

True, but that's not enough to support OOP. You also need to implement
your own way of handling dynamic binding to support polymorphism.

-Brian
 
O

osmium

wilberX said:
How much knowledge of C is
required to understand C++? Thanks.

None at all is required. C++ is a complete (albeit irritating) free
standing language
 
V

Victor Bazarov

BigBrian said:
Your statement sounds like you're infering that C++ is better than C
since you suggest that people graduate from C to C++. This really
isn't true in every case, both languages have tasks for which each is
better than the other. The linux kernel is writen in C, not C++. I
would bet most of the developers for the linux kernel would take issue
with the statement that they needed to graduate to C++.

The debate of "this language is better than that language" is pointless,
especially when the arguments given have no merit. Linux kernel is not
written in C because C is "better". It's written in C because most of
who are contributing, have no time, nor desire to graduate to C++. Or
because they are simply afraid or contemptuous (or both).

V
 
D

Dietmar Kuehl

Michael said:
True, one can essentially create an "object" using the struct
mechanism.

You can program in entirely object oriented ways in C! The first
extensive use of object oriented programming in C I came across is
Xt, the X toolkit implementing widgets on top of X11. Each widget
was derived using a certain convention on how to use structs. This
supported run-time polymorphism very much like 'virtual' functions
do in C++. Of course, this required some form of manual set up of
something similar to a virtual function table (effectively a struct
describing the class and which function to call effectively).
 
D

Dietmar Kuehl

Victor said:
The debate of "this language is better than that language" is pointless,
especially when the arguments given have no merit. Linux kernel is not
written in C because C is "better". It's written in C because most of
who are contributing, have no time, nor desire to graduate to C++. Or
because they are simply afraid or contemptuous (or both).

.... or those involved in implementing the Linux kernel consider C to
be the more appropriate tool. The fact that C and its ABI is pretty
stable since ages and that GCC's C compiler is less buggy than GCC's
C++ compiler also adds to the reasons in favor of C. Although I would
prefer to use C++ as a language, I can agree with many of the reasons
people have for using C. Of course, I also disagree with at least
some reasons given in favor of C.
 
J

Jim Langston

BigBrian said:
Your statement sounds like you're infering that C++ is better than C
since you suggest that people graduate from C to C++. This really
isn't true in every case, both languages have tasks for which each is
better than the other. The linux kernel is writen in C, not C++. I
would bet most of the developers for the linux kernel would take issue
with the statement that they needed to graduate to C++.

I read an article (web page discussion) about why the linux kernal is still
in C and not C++. They had looked at implementing it in C++ but new would
give them many of problems. In a kernal memory is allocated in many
differnt places, since the kernal is the one that is ultimately responsible
for allocating the memory that new uses.

They could of used C++ if they were to limit uses of new, but it was decided
that since a lot of people work on the kernal that some programmer wouldn't
be aware of all the limitations and use new where they weren't supposed to
(or even std templates that use alloc such as std::string) and break things.

From what I read they would of used C++ for the kernal if they could without
these problems. So it wasn't a fact of C++ being inferior to C, but the
fact that wasn't the best language for the use.

If I program on an AS/400 I'll most likely use RPG (Report Program
Generator) even though you can get a C or C++ compiler. RPG is not better
than C or C++, but it is the most appropriate langauge for the use.

Also, it could be argued that C is a subset of C++, or C++ is a superset of
C. You can still program a C program in C++ without using any of the C++
objects or such with minimal changes.

In my opionion, no langauge is better than any other langauge. Languages
are designed with specific purposes in mind when they are designed. If they
are used for that purpose, then they are probably the best langauge for that
purpose.
 
M

Michael Redlich

BigBrian said:
Your statement sounds like you're infering that C++ is better than C
since you suggest that people graduate from C to C++. This really
isn't true in every case, both languages have tasks for which each is
better than the other. The linux kernel is writen in C, not C++. I
would bet most of the developers for the linux kernel would take issue
with the statement that they needed to graduate to C++.

I don't see how my statement implied that C++ is *better* than C. I
was merely trying to point out that there is more to learning C++ than
Philip seemed to make it out to be. Maybe I shouldn't have used the
term "graduated." It was simply a metaphor for someone who is a C
developer that is interested in learning C++. I also should have said,
"good, quality C++ code."
True, but that's not enough to support OOP. You also need to implement
your own way of handling dynamic binding to support polymorphism.

I also didn't say that you could *fully* support OOP with C. That's
why I use C++ and Java...

That's the problem with these Usenet groups. There's no face-to-face
interaction, and there's potential for misunderstandings because these
groups are global. I'm from New Jersey, and you all know how we talk
over here: "Yea, I'm from Joisey..." :)

Mike.
 
M

Michael Redlich

Jim said:
In my opionion, no langauge is better than any other langauge. Languages
are designed with specific purposes in mind when they are designed. If they
are used for that purpose, then they are probably the best langauge for that
purpose.

Amen, brother! I couldn't agree more...

Mike.
 
J

Jerry Coffin

[ ... ]
In my opionion, no langauge is better than any other langauge. Languages
are designed with specific purposes in mind when they are designed. If they
are used for that purpose, then they are probably the best langauge for that
purpose.

Obviously you've never tried to use Intercal, UnLambda or
brainf*(k. Some languages are definitely worse than
anything that could possibly be considered rational, sane
or intelligent.
 
T

TB

Jim Langston skrev:
In my opionion, no langauge is better than any other langauge. Languages
are designed with specific purposes in mind when they are designed. If they
are used for that purpose, then they are probably the best langauge for that
purpose.

Well, most commercial languages are classified as "general-purpose",
hence lack the fourth generation specialization. But they do have
different designs that easier promotes the langauges over others in
certain problem domains (today most obvious on the oop stage).
 
T

TB

Jerry Coffin skrev:
[ ... ]
In my opionion, no langauge is better than any other langauge. Languages
are designed with specific purposes in mind when they are designed. If they
are used for that purpose, then they are probably the best langauge for that
purpose.

Obviously you've never tried to use Intercal, UnLambda or
brainf*(k. Some languages are definitely worse than
anything that could possibly be considered rational, sane
or intelligent.

You mean "brainfuck".

Esoteric languages are their own language group with their own purpose,
just like all pure research languages produced. And UnLambda has some
very interesting properties that should not be shrugged off as something
"worse than anything that could possibly be considered rational".
 
P

Phlip

JustBoo wrote:

That's the party line. Let's just say the paradigm that sucks under C++
least is OOP. ;-)

The opposite of "procedural" is "event driven". OOP enables that, but it's
not the opposite of "procedural".
"In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move."
- Douglas Adams

How dare you cite holy scripture in a public forum??!
 
N

Neil Cerutti

None at all is required. C++ is a complete (albeit irritating) free
standing language

Nearly. You are stuck with the C standard library for certain things,
and you won't find that library documented in the C++ Standard.
 
R

Ron Natalie

Phlip said:
To what purpose will you put the answer?

C++ is C with a few keywords added and just a couple bugs removed.

And unfortunately a more than a few bugs propagated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top