As a programmer of both languages...

  • Thread starter Tomás Ó hÉilidhe
  • Start date
T

Tomás Ó hÉilidhe

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.
 
R

Richard Heathfield

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>
 
M

Martin Ambuhl

Tom�������������������������������� 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.

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

[vapid language-war fodder snipped]
 
J

jacob navia

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.

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.
 
J

jacob navia

Martin said:
Tom�������������������������������� 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.

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.
 
I

Ian Collins

jacob said:
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++.
 
M

Martin Ambuhl

jacob said:
Martin said:
Tom�������������������������������� 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.

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).
 
J

jacob navia

Ian said:
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 :)
 
U

user923005

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.

Is it better to eat with a fork or a spoon?
When I am eating green beans, I use a fork, but when I am eating peas,
I use a spoon. Which is to say that they have slightly different
purposes, even though both are used for eating. You can eat green
beans with a spoon or peas with a fork, but it does not work out as
well that way.
C++ is a fork but C is a spoon. Which is to say, they have slightly
different purposes, even though both are used for programming.
If I am writing simple procedural filters, I will use C.
If I am writing a complex system that needs inheritance and templates,
then I will use C++.
C++ does not remove the need for C and C cannot accomplish all the
things that C++ can accomplish as easily.
They are not competitors, except for the overlapping set where the
needed functionality is easily derived from either language.
Do we really need a C++ compiler with templates to write a state
machine for a toaster IC?
Do we really want to code a 10 million line project in C?
C++ hides complexity, which is nice if you have an extremely complex
project. But that's not always the case.
It is pointless to debate if C is better than C++ or if C++ is better
than C because both of them are good for what they are best at.
You don't throw out the jigsaw because you bought a circular saw. I
am not going to use a jigsaw to rip a 10 foot panel, and I am not
going to use a circular saw to cut out a light socket opening.
So choose your tools wisely, and don't toss them out unless you are
sure that you don't need them.

IMO-YMMV.
 
J

Julienne Walker

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 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. ;-)
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.
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
 
K

Keith Thompson

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.
[snip]

Yes. Why must you start yet another one?
 
C

cr88192

<snip>

<
Is it better to eat with a fork or a spoon?
When I am eating green beans, I use a fork, but when I am eating peas,
I use a spoon. Which is to say that they have slightly different
purposes, even though both are used for eating. You can eat green
beans with a spoon or peas with a fork, but it does not work out as
well that way.
C++ is a fork but C is a spoon. Which is to say, they have slightly
different purposes, even though both are used for programming.
If I am writing simple procedural filters, I will use C.
If I am writing a complex system that needs inheritance and templates,
then I will use C++.
C++ does not remove the need for C and C cannot accomplish all the
things that C++ can accomplish as easily.
They are not competitors, except for the overlapping set where the
needed functionality is easily derived from either language.
Do we really need a C++ compiler with templates to write a state
machine for a toaster IC?
Do we really want to code a 10 million line project in C?
C++ hides complexity, which is nice if you have an extremely complex
project. But that's not always the case.
It is pointless to debate if C is better than C++ or if C++ is better
than C because both of them are good for what they are best at.
You don't throw out the jigsaw because you bought a circular saw. I
am not going to use a jigsaw to rip a 10 foot panel, and I am not
going to use a circular saw to cut out a light socket opening.
So choose your tools wisely, and don't toss them out unless you are
sure that you don't need them.

IMO-YMMV.

yes, all this is true.


actually, in my case, I don't often use spoons, so more often it turns into
an issue of using a fork vs chopsticks.

fork, good for larger objects, inconsistent objects (rice, ...), ...
chopsticks are better for when everything is consistent-sized (and, they
also have many other often non-food-related uses, such as retrieving screws,
plugging in or unhooking small connectors, ...), and in many cases, it is
just more "correct" to use chopsticks.

at home though, I am lazy, I usually just use forks, or often not bothering
with utensils...


now, likewise, I most often use C.
C++ offers a lot of things that, IMO, I either don't need, or go against my
design practices.

C++ tends to make large, highly-centralized code bases (much of the project
being focused on some centralized design and class hierarchy), wheras I tend
to focus on a modular approach (I like my codebase to be made of many
largely independent pieces, rather than some large highly-centralized
system).

but mostly, C is a lot simpler, which matters more than a little to those of
us who are compiler writers...
 
M

Mark McIntyre

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.

Oh great, another debate about religion.

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

*threadplonk*.
 
C

CBFalconer

jacob said:
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.
 
C

Christopher Benson-Manica

[comp.lang.c] "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.

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?
 
T

Tomás Ó hÉilidhe

jacob navia said:
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.
 
I

Ian Collins

jacob said:
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.
 
S

somenath

Tomás Ó hÉilidhe said:




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 ++)
 
R

Richard Heathfield

somenath said:

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.
 
J

jacob navia

Ian said:
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.
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++?
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.
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top