473,414 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

As a programmer of both languages...


There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

I'm a programmer who started out in C++, and who's currently doing
an embedded systems project in C. The relationship and comparison
between the two languages is very simple in my opinion.

The objective of C++ was to build upon C; to take everything that C
can do, and then add a few more features, such as classes, operator
overloading, and exceptions.

Overlooking the small differences between the common subset of the
two languages (e.g. converting from void*, the type of character
literals), it's quite accurate to say that C++ is C with some more added
features.

So at the most basic, you can say that C++ is better than C in that
it can do everything C can does, and that it has a few more extra
features. That's great and all, but the price to pay for these extra
features is the increased complexity of the compiler. I'm currently
writing a program for the PIC 16F684 microcontroller (which is less than
the size of a postage stamp), and there wouldn't be a snowball's chance
in hell of me finding a C++ compiler for it. Why? Because nobody's
bothered writing one. I mean *have* *you* *seen* the size of the C++
Standard? :-O Not only that, but when programming for embedded systems,
the nature of the programs doesn't tend to give rise to a desire for
object-orientated programming. The current program I'm writing is a
Connect4 game, and there hasn't be one instance yet in which I've
yearned for object orientation (even though I use classes extensively
when writing PC applications).

So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't seem
like changing any time soon. And for the less-than-proficient among us,
there's Java for PC's, and Basic for micrcontrollers.

--
Tomás Ó hÉilidhe
Dec 11 '07 #1
36 1833
Tomás Ó hÉilidhe said:
>
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
It is indeed a vacuous debate. Some problems fit better in C than in C++
and vice versa, and some programmers are better at C than at C++ and vice
versa. One's language choice depends partly on the program and partly on
the programmer.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 11 '07 #2
"Tomï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï ¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ " wrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
Not really, except for a few idiots like you who try to restart such
stupid "debate". Go away.

[vapid language-war fodder snipped]
Dec 11 '07 #3
Tomás Ó hÉilidhe wrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
No, it has never been a discussion about C or C++, since most people
here will agree that C is the better choice

What we are discussing is whether we should incorporate into C some
modifications like operator overloading and try/catch into the core C
language.

I have developed a C compiler that implements those enhancements in a
way that is compatible with the C standard. This offends many people
here that say that C "doesn't need" those things and even if it
disappears, it is better to leave it like it is now.
I'm a programmer who started out in C++, and who's currently doing
an embedded systems project in C. The relationship and comparison
between the two languages is very simple in my opinion.

The objective of C++ was to build upon C; to take everything that C
can do, and then add a few more features, such as classes, operator
overloading, and exceptions.
The difference between C and C++ is the object orientation of C++. C is
not object oriented.
Overlooking the small differences between the common subset of the
two languages (e.g. converting from void*, the type of character
literals), it's quite accurate to say that C++ is C with some more added
features.
Too many added features pecisely. What I am proposing is not taking all
of that but just two, to make C an easier language to use.
So at the most basic, you can say that C++ is better than C in that
it can do everything C can does, and that it has a few more extra
features. That's great and all, but the price to pay for these extra
features is the increased complexity of the compiler. I'm currently
writing a program for the PIC 16F684 microcontroller (which is less than
the size of a postage stamp), and there wouldn't be a snowball's chance
in hell of me finding a C++ compiler for it. Why? Because nobody's
bothered writing one. I mean *have* *you* *seen* the size of the C++
Standard? :-O Not only that, but when programming for embedded systems,
the nature of the programs doesn't tend to give rise to a desire for
object-orientated programming. The current program I'm writing is a
Connect4 game, and there hasn't be one instance yet in which I've
yearned for object orientation (even though I use classes extensively
when writing PC applications).
A simple language is needed, not ONLY for the PIC 16F684. A simple
language is needed because it is easier to use!

Now, it can't be TOO simple, because that makes it HARDER to use than
necessary.
So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't seem
like changing any time soon. And for the less-than-proficient among us,
there's Java for PC's, and Basic for micrcontrollers.
No. C is a general purpose programming language. With a few enhancements and
a better library it can become a great programming language for
many tasks.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 11 '07 #4
Martin Ambuhl wrote:
"Tomï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï ¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ " wrote:
> There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

Not really, except for a few idiots like you who try to restart such
stupid "debate". Go away.

[vapid language-war fodder snipped]
Please do not take this ... well... person, as representing anyone but
himself.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 11 '07 #5
jacob navia wrote:
>
The difference between C and C++ is the object orientation of C++. C is
not object oriented.
Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.

--
Ian Collins.
Dec 11 '07 #6
jacob navia wrote:
Martin Ambuhl wrote:
>"Tom��������������� ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿ ½" wrote:
>> There seems to be constant vacuous debate about which is better
or preferable, C or C++, and it looks like one of these discussions
is on-
going right now in this newsgroup.

Not really, except for a few idiots like you who try to restart such
stupid "debate". Go away.

[vapid language-war fodder snipped]

Please do not take this ... well... person, as representing anyone but
himself.
Yes, I had forgotten about Jacob Navia, a troll who comes here to flog
his commercial software (available with a free license if you never use
it for anything useful).

Dec 11 '07 #7
Ian Collins wrote:
jacob navia wrote:
>The difference between C and C++ is the object orientation of C++. C is
not object oriented.
Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.
Yes, and you can choose to write in C using a C++ compiler and
framework. Does that mean that C++ is C???

C++ was defined during the 90ties as THE object oriented language.
Now, that the hype as gone and people start realizing that this wasn't
the silver bullet after all, C++ will be sold as a "multi paradigm"
language.

But the basic machinery: constructors/destructors/classes/methods
is still there. I do not understand why this fads must be followed:
it was conceived as an OO language and it was marketed as an OO language
for around 10 years.

Now they start marketing it as "Multi paradigm". this is handy yes,
but the facts are stubborn.

You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.

Of course you can write a hello world program without them but explain
me how do you ignore classes in C++?

I think it would be quite hard.

Multi paradigm?

Maybe, who knows what buzzword will be invented in the future, but
the fact is that without classes you just can't do anything at all in
C++.

Or... I am just "dense" and fail to grasp the obvious :-)
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 11 '07 #8
On Dec 11, 2:24 pm, jacob navia <ja...@nospam.comwrote:
Tomás Ó hÉilidhe wrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

No, it has never been a discussion about C or C++, since most people
here will agree that C is the better choice
The better choice for what? I'd like to believe that most people here
are enlightened enough to realize that personal preference alone
doesn't make a language suitable for a project.
What we are discussing is whether we should incorporate into C some
modifications like operator overloading and try/catch into the core C
language.
To be honest, I haven't seen many people advocating those additions.
However, I *have* seen countless people argue endlessly about whether
C is better than C++ or vice versa. I'd much rather see discussions
about how to improve the languages (preferably located in the correct
newsgroup) than truly petty holy wars about which one is better.
I have developed a C compiler that implements those enhancements in a
way that is compatible with the C standard. This offends many people
here that say that C "doesn't need" those things and even if it
disappears, it is better to leave it like it is now.
I don't think anybody has a problem with extensions. It seems to me
that the problem is discussion of extensions or improvements in a
newsgroup that's devoted to the standard language. Discussion of
extensions should be relocated to the newsgroup for the compiler in
which they're implemented, and improvements should be relocated to a
newsgroup that's devoted to the language standard (comp.std.c). In the
correct newsgroup those discussions can do more good.
The objective of C++ was to build upon C; to take everything that C
can do, and then add a few more features, such as classes, operator
overloading, and exceptions.

The difference between C and C++ is the object orientation of C++. C is
not object oriented.
Templates are something of a big difference as well. ;-)
Overlooking the small differences between the common subset of the
two languages (e.g. converting from void*, the type of character
literals), it's quite accurate to say that C++ is C with some more added
features.

Too many added features pecisely. What I am proposing is not taking all
of that but just two, to make C an easier language to use.
I'm not convinced that operator overloading is such a desirable
feature that it would be one of the two that you would borrow from C+
+. Exception handling is tricky to the point where I don't see much of
it even in C++; I doubt how well it would be received in C.
So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't seem
like changing any time soon. And for the less-than-proficient among us,
there's Java for PC's, and Basic for micrcontrollers.

No. C is a general purpose programming language. With a few enhancements and
a better library it can become a great programming language for
many tasks.
I'm not sure about enhancements to the language, but some work on the
library would be nice.
-Jul
Dec 11 '07 #9
"Tomás Ó hÉilidhe" <to*@lavabit.comwrites:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
[snip]

Yes. Why must you start yet another one?

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 11 '07 #10
Tomás Ó hÉilidhe wrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
Oh great, another debate about religion.

Answer: if you have a nail, don't use a screwdriver. And vice-versa.

*threadplonk*.
Dec 11 '07 #11
jacob navia <ja***@nospam.comwrote in news:fj**********@aioe.org:
Please do not take this ... well... person, as representing anyone but
himself.

I appreciate the sentiment jacob, but please don't entertain the idea of me
entertaining people who give non-input.

I've read a few of your posts here jacob, and if you ask me, the only thing
you're doing wrong on this newsgroup is entertaining the people who talk
crap to you. Next time someone posts talking crap to you, don't reply.
Either that or get a killfile. I tend to go for the ignoring option.

--
Tomás Ó hÉilidhe
Dec 12 '07 #12
jacob navia wrote:
Tomás Ó hÉilidhe wrote:
>There seems to be constant vacuous debate about which is better
or preferable, C or C++, and it looks like one of these
discussions is on-going right now in this newsgroup.

No, it has never been a discussion about C or C++, since most
people here will agree that C is the better choice

What we are discussing is whether we should incorporate into C
some modifications like operator overloading and try/catch into
the core C language.
What Tomas should realize is that such discussion is off-topic in
c.l.c, because the newsgroup discusses the C language as defined by
the ISO standard and its predecessors. Jacob seems to be rather
dull, and has never realized this, although it has been pointed out
to him many times. Discussion on changing the C language belongs
in comp.std.c. Discussion of the Navia non-C compilers belongs in
comp.compilers.lcc, on which his compiler is based.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 12 '07 #13
jacob navia wrote:
Ian Collins wrote:
>jacob navia wrote:
>>The difference between C and C++ is the object orientation of C++. C is
not object oriented.
Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.
You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.
Your ignorance continues to astound. Maybe you should take some time
out and learn C++ before slagging it off.

C++ does nothing magical with structs, if a struct is valid C, it is
equally valid in C++, nothing is added. Otherwise how could we use C
libraries with C++?
Of course you can write a hello world program without them but explain
me how do you ignore classes in C++?
By not using them?
>
Maybe, who knows what buzzword will be invented in the future, but
the fact is that without classes you just can't do anything at all in
C++.
If everything C does plus quite a bit more (like your beloved operator
overloading) amounts to nothing.....
Or... I am just "dense" and fail to grasp the obvious :-)
Probably.

--
Ian Collins.
Dec 12 '07 #14
On Dec 11, 11:52 pm, Richard Heathfield <r...@see.sig.invalidwrote:
Tomás Ó hÉilidhe said:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

It is indeed a vacuous debate. Some problems fit better in C than in C++
and vice versa, and some programmers are better at C than at C++ and vice
versa. One's language choice depends partly on the program and partly on
the programmer.

I would like to have some more inputs on the above point mentioned by
you. You are indicating that "One's language choice depends partly on
the program and partly on
the programmer"
Actually my doubt is how it can depend on program? Because we write
program to solve one particular problem .Now before writing code we
think about the algorithm which is independent of programming
language.

Could you give one small example where program decides the programming
language?

In my very small experience in programming I feel that choice of
language depends upon the availability of compiler for the target
system ,the availability of helper library and availability of the
programmer of that particular language . (This observation is solely
for choosing language between C and C ++)

Dec 12 '07 #15
[comp.lang.c] "Tom?s ? h?ilidhe" <to*@lavabit.comwrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.
And those of us who want to continue said vacuous debate are no doubt
participating in said discussion. Why don't you go join it, and leave
the rest of the group out of it?

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
Dec 12 '07 #16
somenath said:

<snip>
Could you give one small example where program decides the programming
language?
We had an example right here in comp.lang.c a day or two ago, where someone
asked for help fixing a lllooonnnggg C program, and one of the respondents
contributed an Awk script consisting of one (short and readable) line,
that replaced the C program completely.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 12 '07 #17
Ian Collins wrote:
jacob navia wrote:
>Ian Collins wrote:
>>jacob navia wrote:

The difference between C and C++ is the object orientation of C++. C is
not object oriented.

Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.
You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.
Your ignorance continues to astound. Maybe you should take some time
out and learn C++ before slagging it off.
Yes Sir!

struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C. In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default. I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?
C++ does nothing magical with structs, if a struct is valid C, it is
equally valid in C++, nothing is added. Otherwise how could we use C
libraries with C++?
Both languages are still compatible at many levels. But I am not getting
crazy, the concept of CLASS is CENTRAL to the C++ language.
>Of course you can write a hello world program without them but explain
me how do you ignore classes in C++?
By not using them?
Of course. But then you are not using C++.

If you write

int main(void) { printf("hello\n");}

you do not need classes but is it C++?
>Maybe, who knows what buzzword will be invented in the future, but
the fact is that without classes you just can't do anything at all in
C++.
If everything C does plus quite a bit more (like your beloved operator
overloading) amounts to nothing.....
You are just playing word games, a favorite sport in this group.
Of course you can write programs in C and compile them with C++,
modulo some differences it is possible. I would be surprised that you
can use the STL without using implicitly a class!!!

What I am saying is obvious. But you refuse to admit the obvious.
C++ is centered around the class/inheritance concept and that is OO.

Dec 12 '07 #18
jacob navia wrote:
Ian Collins wrote:
>jacob navia wrote:
>>Ian Collins wrote:
jacob navia wrote:

The difference between C and C++ is the object orientation of C++.
C is
not object oriented.
>
Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.

You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.
Your ignorance continues to astound. Maybe you should take some time
out and learn C++ before slagging it off.

Yes Sir!

struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C. In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default. I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?
What's your point? The fact that struct is close to a synonym for class
is irrelevant. Your example struct is equally valid in both languages,
C++ treats it exactly the same as C. Saying you can't write anything
useful in C++ without classes is like saying you can't write anything
useful in C without using structs. In both languages we represent
collections of data in structures.
>
>>Maybe, who knows what buzzword will be invented in the future, but
the fact is that without classes you just can't do anything at all in
C++.
If everything C does plus quite a bit more (like your beloved operator
overloading) amounts to nothing.....

You are just playing word games, a favorite sport in this group.
Of course you can write programs in C and compile them with C++,
modulo some differences it is possible.
That's not what I said. Are function templates OO? Is function
overloading OO? Are exceptions OO?

Does your beloved operator overloading make sense without structs?
I would be surprised that you
can use the STL without using implicitly a class!!!
Many of the C++ standard library algorithms work equally well with
pointers. Very little of the STL is OO, which ironically is a common
criticism of it from OO purists.

All of the extensions to C you keep pushing are available in standard
C++, today.

--
Ian Collins.
Dec 12 '07 #19
jacob navia said:
Ian Collins wrote:
>jacob navia wrote:
>>Ian Collins wrote:
jacob navia wrote:

The difference between C and C++ is the object orientation of C++. C
is not object oriented.
>
Are you really dense, or just being obtuse? As you have been told
many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.

You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.
Your ignorance continues to astound. Maybe you should take some time
out and learn C++ before slagging it off.

Yes Sir!

struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C.
Yes, for reasons which have nothing to do with classes.

In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default.
Stroustrup says much the same thing, albeit more quietly. But it can be
said just as correctly (or incorrectly) that, in C++, each "class"
definition is just a struct where all members are private by default. So
if the claim is that C++ is "all about classes" (which I don't accept),
then it can just as logically be said that C++ is "all about structs".
And, just as it is possible in C to write programs - *useful* programs -
that don't use structs, so it is possible in C++ to write useful programs
that don't use classes.
I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?
Yes - if you really want to know what a C++ struct is, the place to look is
ISO/IEC 14882.

<snip>
If you write

int main(void) { printf("hello\n");}

you do not need classes but is it C++?
The behaviour of that program, either in C or in C++, is undefined. (I
believe that C++ even requires a diagnostic message to be produced during
translation of that program.) If you want people to treat your views about
C seriously, you might want to start off by learning enough about C that
you can write a simple "hello" program properly.
<snip>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 12 '07 #20
jacob navia wrote:
>
struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C. In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default. I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?
I think I see your conceptual problem, do you claim that

class A {
public:
int age;
char *Name;
};

Is OO while

struct A {
int age;
char *Name;
};

isn't?

You appear to be confusing the use of structures with object orientation.

One can choose to write OO code in C or in C++. The choice depends of
the nature of the problem. One of the cleanest OO designs I have seen
is the old OpenView GUI toolkit, a textbook example of OO C.

--
Ian Collins.
Dec 12 '07 #21
Richard Heathfield, the pedant in chief wrote:
>If you write

int main(void) { printf("hello\n");}

you do not need classes but is it C++?

The behaviour of that program, either in C or in C++, is undefined. (I
believe that C++ even requires a diagnostic message to be produced during
translation of that program.) If you want people to treat your views about
C seriously, you might want to start off by learning enough about C that
you can write a simple "hello" program properly.
All this crap because there wasn't an

#include <stdio.h>

I am not compiling heathfield. I am writing to people, and
people can understand (contrary to compilers that can't)

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 12 '07 #22
jacob navia said:

<snip>
All this crap because there wasn't an

#include <stdio.h>
The "crap", as you put it, is in the code you posted. You asked whether it
was a C++ program, and I answered your question. If you don't want
answers, don't ask questions.
I am not compiling heathfield. I am writing to people, and
people can understand (contrary to compilers that can't)
People understand better than you realise.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 12 '07 #23
jacob navia said:
Ian Collins wrote:
>What's your point? The fact that struct is close to a synonym for class
is irrelevant. Your example struct is equally valid in both languages,
C++ treats it exactly the same as C. Saying you can't write anything
useful in C++ without classes is like saying you can't write anything
useful in C without using structs.

I have never written anything serious in C without using data types and
structures.
A C program that did not use any data types would be astoundingly empty.
But if you have *never* written anything serious in C that didn't use a
structure, this says less about C than it does about the limits of your
programming experience. Are you really sure that you meant to say that?
Structures are central to C, as classes are to C++.
Structures are important, but I wouldn't say they were central.
>In both languages we represent
collections of data in structures.

C++ uses inheritance. Didn't know that you can inherit from a C
structure.
He didn't claim otherwise.

<snip>
>All of the extensions to C you keep pushing are available in standard
C++, today.

Yes, and so what?
So if people want them, they'll use C++. If people want their *absence*,
for reasons of simplicity or portability or whatever, they'll use C. You
do C no favours by trying to move it closer to C++.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 12 '07 #24
Richard Heathfield wrote:
jacob navia said:
>I have never written anything serious in C without using data types and
structures.

A C program that did not use any data types would be astoundingly empty.
But if you have *never* written anything serious in C that didn't use a
structure, this says less about C than it does about the limits of your
programming experience. Are you really sure that you meant to say that?
If I #include <stdio.hI include the definition of FILE, that is
a structure... If I include time.h I include several structures in
there, as in stdlib.h that defines div_t and others...

Really, I can't imagine a program not using a structure definition!

Of course, you can find a contrived example but... let's be realistic.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 12 '07 #25
jacob navia said:
Richard Heathfield wrote:
>jacob navia said:
>>I have never written anything serious in C without using data types and
structures.

A C program that did not use any data types would be astoundingly empty.
But if you have *never* written anything serious in C that didn't use a
structure, this says less about C than it does about the limits of your
programming experience. Are you really sure that you meant to say that?

If I #include <stdio.hI include the definition of FILE, that is
a structure...
FILE isn't actually required to be a structure. It is "an object type
capable of recording all the information needed to control a stream,
including its file position indicator, a pointer to its associated buffer,
an error indicator that records whether a read/write error has occurred,
and an end-of-file indicator that records whether the end of the file has
been reached", which does seem to suggest that a structure is a sensible
implementation, but it's *not* actually required by the Standard. So a
program that uses streams may or may not be using structures - you can't
actually tell. Certainly the visible code (for who in their right mind
pokes about in standard headers?) bears no evidence of the use of structs
where FILEs are concerned.

But anyway, it is now clear that you regard including a header that
contains a structure type definition as somehow "using" that structure,
regardless of whether the structure type is referred to within the C
source itself, in which case your statement is pretty meaningless really.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 12 '07 #26
On 11 Dec, 18:31, "Tomás Ó hÉilidhe" <t...@lavabit.comwrote:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

I'm a programmer who started out in C++, and who's currently doing
an embedded systems project in C. The relationship and comparison
between the two languages is very simple in my opinion.

The objective of C++ was to build upon C; to take everything that C
can do, and then add a few more features, such as classes, operator
overloading, and exceptions.
"a few"! You missed templates (and consequently the STL).

- inline
- references

Overlooking the small differences between the common subset of the
two languages (e.g. converting from void*, the type of character
literals), it's quite accurate to say that C++ is C with some more added
features.
C with a large pile of new features...

So at the most basic, you can say that C++ is better than C in that
it can do everything C can does, and that it has a few more extra
features.
that's not the way I use "better". I'm not knocking C++. I like C++.
But X isn't "better" than Y because it does more. Would you carve
your dinner with a Swiss Army Knife?

I can claim to pretty well know C.

Admittedly I've never used signal.h, locale.h, float.h, wctype.h,
longjmp.h or volatile. I've used goto once and seen register and
continue in other people's programs. I know auto is a keyword.

Ok so I don't *really* know C.

C++ is a a tougher nut. I've just about grasped what to put in
my thrown objects but I would not dare claim to have reached the
dizzy heights of "Exception Safe". algorithm slightly scares me.
STL error messages almost don't frighten me anymore. I've barely
touched templates and the only namespace I've used is std.
Then there's Template Metaprogramming...

Should all my virtual functions be protected?

That's great and all, but the price to pay for these extra
features is the increased complexity of the compiler.
riight. So C++ *isn't* an unqualified "better"?

I'm currently
writing a program for the PIC 16F684 microcontroller (which is less than
the size of a postage stamp),
I'm amazed it's so large. Isn't that the size of a pentium? Or do
you have very small stamps where you come from?

and there wouldn't be a snowball's chance
in hell of me finding a C++ compiler for it. Why? Because nobody's
bothered writing one. I mean *have* *you* *seen* the size of the C++
Standard? :-O
yup. I even have access to a hardcopy. And you then need a book on
STL and Myers books and...

Not only that, but when programming for embedded systems,
the nature of the programs doesn't tend to give rise to a desire for
object-orientated programming. The current program I'm writing is a
Connect4 game, and there hasn't be one instance yet in which I've
yearned for object orientation (even though I use classes extensively
when writing PC applications).
I suppose it depends how embedded, embedded is. Designing OO still
makes sense. Protocols often look like inheritance trees.

So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't seem
like changing any time soon. And for the less-than-proficient among us,
there's Java for PC's, and Basic for micrcontrollers.
Basic? Basic for microcontrollers? ug.

--
Nick Keighley

"If you think C++ is not overly complicated, just what is a protected
abstract virtual base pure virtual private destructor, and when
was the last time you needed one?"
-- Tom Cargil, C++ Journal.
Dec 12 '07 #27
Nick Keighley <ni******************@hotmail.comwrote in
news:58**********************************@b40g2000 prf.googlegroups.com:
> So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't
seem like changing any time soon. And for the less-than-proficient
among us, there's Java for PC's, and Basic for micrcontrollers.

Basic? Basic for microcontrollers? ug.

I'm doing an embedded systems project in college at the moment for
my degree. There was a finite number of projects to choose from, and
each had a description. In the description for the embedded systems
project, it mentioned using the Basic Stamp microcontroller and
programming it in Basic.

Before I chose which project I wanted to do, I approached the
embedded systems lecturer and asked him if I could code it in C and
use a proper microcontroller; thankfully he was more than happy to
accomodate me!

Another project choice was to write a webserver. The description
mentioned doing it in Java. I put my hand up and asked if I could do
it in C++... and I got a paragraph of non-information back. So then
I asked again "Just to clarify, can I do it in C++?". I got an
answer something to the effect of "we'll see" and so I went with the
embedded systems project. I'm actually quite glad I did because it's
quite interesting and exciting, plus I got to design my own printed
circuit board and have it sent off to be made. I get the circuit
board back after Christmas and then I can populate it with
components and finally try out my program on it :-D

Plus I get to do the embedded systems project on my own, whereas the
webserver project was a group effort. I also asked the
aforementioned lecturer if I could write a webserver on my own but
the answer to that was No... which was a definite deal-breaker
considering I was the only person in the room who had more than
trivial understanding of any programming language. Electronic
Engineering for you.

--
Tomás Ó hÉilidhe
Dec 12 '07 #28
"Tomás Ó hÉilidhe" <to*@lavabit.comwrote in
news:Xn***************************@194.125.133.14:
I also asked the
aforementioned lecturer if I could write a webserver on my own but
the answer to that was No... which was a definite deal-breaker
considering I was the only person in the room who had more than
trivial understanding of any programming language.

Of course, "only person" doesn't encompass the lecturers :-P

--
Tomás Ó hÉilidhe
Dec 12 '07 #29
jacob navia wrote:
Ian Collins wrote:
>jacob navia wrote:
>>Ian Collins wrote:
jacob navia wrote:

The difference between C and C++ is the object orientation of C++.
C is
not object oriented.
>
Are you really dense, or just being obtuse? As you have been told many
times before, C++ is a multi paradigm language. You can *choose* to
write OO or procedural code in C++.

You can't program in C++ without using classes. Even if you define
a simple structure it is actually a class.
Your ignorance continues to astound. Maybe you should take some time
out and learn C++ before slagging it off.

Yes Sir!

struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C. In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default. I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?

The ability to name a type using 'A' instead of 'struct A' is just
syntactic sugar, not object orientation. Note that this is also a valid
C++ program:

struct A {
int age;
char *Name;
};

int main(void)
{
struct A jacob;
}

Calling structs classes isn't what makes C++ more object oriented than
C. It's what you do with those structs that matters. C++'s object
orientation comes primarily from the fact that it supports member
functions; many other features of C++ help make object orientated code
easier to write, but it's the member functions that make it an object
oriented language.

When you define a struct with no member functions, whether it's called a
struct or a class, you're defining something that is no more object
oriented in C++ than the same code would be in C if you replace 'class'
with 'struct'.

C++ does implicitly define certain special member functions even for
classes with no explicitly declared or defined member functions. These
include things like the default constructor, destructor, copy
constructor, and copy assignment operator. However, C++'s special rules
for POD (Plain Old Data) types mean that the semantics of using the
special member functions for POD structs (such as A above) are identical
to the semantics of the corresponding code in C. They therefore do
nothing to make POD structs in C++ any more object-oriented than they
are in C.
>C++ does nothing magical with structs, if a struct is valid C, it is
equally valid in C++, nothing is added. Otherwise how could we use C
libraries with C++?

Both languages are still compatible at many levels. But I am not getting
crazy, the concept of CLASS is CENTRAL to the C++ language.
No, it's not. C++ classes and structs can support object orientation
more completely than C structs, and that's an important part of the
language, but it's built on top of C. You still have a language fully as
powerful as C even if you never use the object-oriented features of C++
classes that are not supported in C. And object orientation is just one
among several ways that C++ extends C. Generic programming is arguably
becoming far more important in modern C++ than object orientation.
>>Of course you can write a hello world program without them but explain
me how do you ignore classes in C++?
By not using them?

Of course. But then you are not using C++.

If you write

int main(void) { printf("hello\n");}

you do not need classes but is it C++?
Of course it is. You can also any of the many C++ features that have
nothing to do with object orientation, such as templates and exceptions.
If that isn't C++, what is it?
What I am saying is obvious. But you refuse to admit the obvious.
C++ is centered around the class/inheritance concept and that is OO.
Dec 12 '07 #30
jacob navia wrote:
Ian Collins wrote:
>What's your point? The fact that struct is close to a synonym for class
is irrelevant. Your example struct is equally valid in both languages,
C++ treats it exactly the same as C. Saying you can't write anything
useful in C++ without classes is like saying you can't write anything
useful in C without using structs.

I have never written anything serious in C without using data types and
structures. Even a "hello world" program needs stdio.h that has (at
least) the definition of FILE.

Structures are central to C, as classes are to C++.
>In both languages we represent
collections of data in structures.

C++ uses inheritance. Didn't know that you can inherit from a C
structure.
The fact that you can do more things with a C++ struct than you can do
with a C struct doesn't mean that you're forced to do them. Contrary to
your original objection, you can use C++ structs without writing a
single line of C++ code that is any more object oriented than
corresponding C code, and you can do that without giving up any valuable
feature of C.

....
Exceptions are objects in C++. The exceptions I am proposing for C
aren't objects but just integer error codes, what is quite different.
Integers are also stored in objects, both in C and in C++. C++
exceptions can be integers. The existence of objects isn't what makes
code object oriented, otherwise C would be an object-oriented language too.
Dec 12 '07 #31
somenath <so*********@gmail.comwrote:
On Dec 11, 11:52 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>Tomás Ó hÉilidhe said:
There seems to be constant vacuous debate about which is better or
preferable, C or C++, and it looks like one of these discussions is on-
going right now in this newsgroup.

It is indeed a vacuous debate. Some problems fit better in C than in C++
and vice versa, and some programmers are better at C than at C++ and vice
versa. One's language choice depends partly on the program and partly on
the programmer.


I would like to have some more inputs on the above point mentioned by
you. You are indicating that "One's language choice depends partly on
the program and partly on
the programmer"
Actually my doubt is how it can depend on program? Because we write
program to solve one particular problem .Now before writing code we
think about the algorithm which is independent of programming
language.

Algorithms may be independent of programming languages in that any
algorithm *can* be implemented in any (Turing-complete) programming
language. Some algorithms can, however, be *much* easier to implement
in one programming language than in another.

>
Could you give one small example where program decides the programming
language?


Pick for example some algorithm that involves using a single-linked list.
You could implement this algorithm in FORTRAN 77, or older versions of BASIC,
but it would be quite painful since these languages lack several features
that are usually used when implementing linked lists (e.g. user-defined datatypes,
pointers and dynamic memory allocation.)

If you were to implement the same algorithm in, say, Standard ML it would
most likely be much easier since that language has single-linked lists as
one of the basic datatypes.
If on the other hand you were writing a program to do lots of calculations
involving matrices and vectors, the FORTRAN would seem a much better choice
than SML.
C++ (and to a somewhat lesser extent C) is somewhat unusual (but not unique)
among programming languages in that even if they seldom are the best tool
for any given job, they are also almost never a really bad choice.

>
In my very small experience in programming I feel that choice of
language depends upon the availability of compiler for the target
system ,the availability of helper library and availability of the
programmer of that particular language . (This observation is solely
for choosing language between C and C ++)


--
<Insert your favourite quote here.>
Erik Trulsson
er******@student.uu.se
Dec 12 '07 #32
On 12 Dec, 11:56, "Tomás Ó hÉilidhe" <t...@lavabit.comwrote:
Nick Keighley <nick_keighley_nos...@hotmail.comwrote innews:58**********************************@b40g20 00prf.googlegroups.com:
So my own point of view is that while C++ is the programming
language to be used today for PC's, game consoles and the like, C is
still the king when it comes to embedded systems, and that doesn't
seem like changing any time soon. And for the less-than-proficient
among us, there's Java for PC's, and Basic for micrcontrollers.
Basic? Basic for microcontrollers? ug.

I'm doing an embedded systems project in college at the moment for
my degree. There was a finite number of projects to choose from, and
each had a description. In the description for the embedded systems
project, it mentioned using the Basic Stamp microcontroller and
programming it in Basic.

Before I chose which project I wanted to do, I approached the
embedded systems lecturer and asked him if I could code it in C and
use a proper microcontroller; thankfully he was more than happy to
accomodate me!

Another project choice was to write a webserver. The description
mentioned doing it in Java. I put my hand up and asked if I could do
it in C++... and I got a paragraph of non-information back. So then
I asked again "Just to clarify, can I do it in C++?". I got an
answer something to the effect of "we'll see" and so I went with the
embedded systems project. I'm actually quite glad I did because it's
quite interesting and exciting, plus I got to design my own printed
circuit board and have it sent off to be made. I get the circuit
board back after Christmas and then I can populate it with
components and finally try out my program on it :-D

Plus I get to do the embedded systems project on my own, whereas the
webserver project was a group effort. I also asked the
aforementioned lecturer if I could write a webserver on my own but
the answer to that was No... which was a definite deal-breaker
considering I was the only person in the room who had more than
trivial understanding of any programming language. Electronic
Engineering for you.
sounds fun!

--
Nick Keighley
Dec 12 '07 #33
James Kuyper <ja*********@verizon.netwrites:
jacob navia wrote:
[...]
>Exceptions are objects in C++. The exceptions I am proposing for C
aren't objects but just integer error codes, what is quite different.

Integers are also stored in objects, both in C and in C++. C++
exceptions can be integers. The existence of objects isn't what makes
code object oriented, otherwise C would be an object-oriented language
too.
We're getting into yet more confusion caused by multiple meanings of a
word, similar to the problems we've had with "byte" and "stack".

Both the C and C++ standards define the word "object". In C, an
object is a "region of data storage in the execution environment, the
contents of which can represent values". The C++ definition is quite
similar.

This meaning has little or nothing to do with the concept of
"object-oriented" programming.

Another meaning of "object" is, more or less, an instance of a class
type; this is the sense that's consistent with the idea of
"object-oriented" programming. (But the C++ standard does *not* use
the word *object* in this sense.)

C++ exceptions, as I understand it, are *typically* objects in the
latter sense (or perhaps they're values rather than objects?), but
they needn't be. For example, ``throw 42;'' is a legal C++ statement.

Note that the C++ standard also defines the concept of "POD" (which
stands for "Plain Old Data", I think). A POD class, for example, is a
class (a struct or union) that doesn't have any of the C++-specific
stuff (static members, destructor, etc.). C++ code that uses only POD
types is not object-oriented in the usual sense of the term.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 12 '07 #34
In article <47******@news.midgard.homeip.net>,
Erik Trulsson <er******@student.uu.sewrote:
>C++ (and to a somewhat lesser extent C) is somewhat unusual (but not unique)
among programming languages in that even if they seldom are the best tool
for any given job, they are also almost never a really bad choice.
And where they ARE a bad choice, you can probably at least use them to
implement a better one.
dave
(the world runs on languages whose implementations are written in C)

Dec 12 '07 #35
Richard Heathfield wrote:
jacob navia said:
>>
.... snip ...
>>
I have never written anything serious in C without using data
types and structures.
I have.
A C program that did not use any data types would be astoundingly
empty. But if you have *never* written anything serious in C that
didn't use a structure, this says less about C than it does about
the limits of your programming experience. Are you really sure
that you meant to say that?
>Structures are central to C, as classes are to C++.

Structures are important, but I wouldn't say they were central.
You can write fairly elegant programs using only stdin and stdout,
with getc and putc. The fact that those are normally implemented
using such complicated items as FILEs and structures has nothing
essential to do with it. A suitable library can be written (for
that program) without those complications.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 13 '07 #36
jacob navia wrote:
Ian Collins wrote:
>In both languages we represent
collections of data in structures.

C++ uses inheritance. Didn't know that you can inherit from a C
structure.
C++ offers the option of using inheritance to extend C structs, it
doesn't force one to use it.
>
Exceptions are objects in C++. The exceptions I am proposing for C
aren't objects but just integer error codes, what is quite different.
C++ exceptions can be integers as well as objects.
>>
All of the extensions to C you keep pushing are available in standard
C++, today.

Yes, and so what?
If I want them, I use C++, if I don't I use C. Same as if I want
reflection I use PHP. I don't push for reflection in C or C++ even
though it is a very useful addition, I use a language that supports it.

A programmer should build up a toolkit of languages and libraries and
know which one best fits the problems he or she encounters.
Why wouldn't those extensions be acceptable then?

Why must C be frozen for the benefit of C++?
I never said it should, the languages have lives of their own. They may
occasionally cross-pollinate (bits of C++ in C99, bits of C99 in C++
next) but one does not drive the other.

--
Ian Collins.
Dec 13 '07 #37

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Angie | last post by:
Hello, My name is Angela Mastrodonato. I'm a web designer who would like the assistance of a php programmer. Some of my clients have requested more dynamic web sites, and I am in the beginning...
7
by: stormslayer | last post by:
Folks: I've been considering a shift to python. I currently use c++builder (borland) or perl. I do computational models / statistics programming, and was interested in python b/c it a. has...
10
by: PMD96 | last post by:
I'm new to programming and have been recommended to start with Python. I've reviewed the tutorial and am looking for additional learning tools to learn programming and Python. Any recommendations?
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
3
by: OJLP | last post by:
Hi. I am about to embark on C# learning. I have had limited VB experience. Can anyone offer any advice as to some good books / courses to attend, for a newbie to get the basics as quick as...
31
by: amruta | last post by:
hi, i m new in programming.at present i m learning computer languages. i just want to know how u can develop a skills of any language, how u can be master in any languages. can any one help me.
13
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
13
by: BK | last post by:
Our .Net team has just inherited a junior programmer that we need to get up to speed as quickly as possible. Unfortunately, his skill set is largely Access with some VB6 and ASP classic...
65
by: Chris Carlen | last post by:
Hi: From what I've read of OOP, I don't get it. I have also found some articles profoundly critical of OOP. I tend to relate to these articles. However, those articles were no more objective...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.