C vs. C++

R

Richard

William Hughes said:
Indeed, that is precisely the point. The entire language exists,
and if you program in it its features
have effects, even if you do not use them. You can write a simple
program in C++, you cannot program in C++ and program in a simple
language.

- William Hughes

You make no sense.

A simple C program or C++ program is still C or C++.

Programming C++ does not mean you have to use classes etc.

So the question still stands. C is pretty much a subset of C++.

What simple program can you program in C that you can not as simply
program in C++?
 
W

William Hughes

You make no sense.

A simple C program or C++ program is still C or C++.

Programming C++ does not mean you have to use classes etc.

Yes, however, programming in C++ does mean that you have to program in
a
language with classes etc, even if you do not use them.
And even if you do not use the features the fact that they exist
has effects. So not using features is not the same as not
having features.
So the question still stands. C is pretty much a subset of C++.

What simple program can you program in C that you can not as simply
program in C++?

I have already pointed out that no such program exists. So what?
You can write a simple program in C++, however, if you program
in C++ you are not programming in a simple language because C++
is not a simple language. Not using some of the features of C++
does not change C++ into a simple language.


- William Hughes
 
B

Bartc

Richard said:
You make no sense.

A simple C program or C++ program is still C or C++.

Programming C++ does not mean you have to use classes etc.

So the question still stands. C is pretty much a subset of C++.

What simple program can you program in C that you can not as simply
program in C++?

A C++ program containing only C-compatible code sounds like a C program to
me, even if it's technically a C++ one too.

Being compilable with C++ tools is irrelevant.
 
R

REH

Yes, however, programming in C++ does mean that you have to program in
a
language with classes etc, even if you do not use them.
And even if you do not use the features the fact that they exist
has effects.  So not using features is not the same as not
having features.

I usually stay out of languages wars (as they are silly), but that
statement is just wrong. C++ follows the "if you don't use it, you
don't pay for it" philosophy. Having classes in the language has no
effect on a program that does not use classes. It is the same with
exceptions, templates, et. al..

REH
 
R

Richard

William Hughes said:
Yes, however, programming in C++ does mean that you have to program in
a
language with classes etc, even if you do not use them.

Err, that's what I said.
And even if you do not use the features the fact that they exist
has effects. So not using features is not the same as not
having features.

We are not talking about hypothetical effects from things we do not even
use. By your logic we should be as concerned about something not being
as simple because its a different ISO C compliant compiler.
I have already pointed out that no such program exists. So what?

You did not actually. Or if you did I apologise and must have missed it.
You can write a simple program in C++, however, if you program
in C++ you are not programming in a simple language because C++
is not a simple language. Not using some of the features of C++
does not change C++ into a simple language.

Sure, but what that has to do with the question is a bit of a
mystery to me.

Once again;

,----
| >> What simple program can you program in C that you can not as simply
| >> program in C++?
`----

We could talk about the complex parts of C++ as you seem intent on doing
but that has nothing to do with the question.
 
J

jameskuyper

Bartc wrote:
....
A C++ program containing only C-compatible code sounds like a C program to
me, even if it's technically a C++ one too.

Even if that code has different behavior in C? Or do you exclude code
that is legal in both C and C++, but with different meanings, from "C-
compatible code"?
 
B

Ben Bacarisse

REH said:
I usually stay out of languages wars (as they are silly), but that
statement is just wrong. C++ follows the "if you don't use it, you
don't pay for it" philosophy. Having classes in the language has no
effect on a program that does not use classes. It is the same with
exceptions, templates, et. al..

This is true but does not settle the matter unless you can show that
once can avoid using these features. I don't think it always possible
to avoid them. A C program that does complex arithmetic is hard to
write in C++ without using classes and templates (specifically the
template class "complex"). As a result you might as well also use
iostreams since there may be some trouble reading and writing these
any other way.
 
R

Richard

Ben Bacarisse said:
This is true but does not settle the matter unless you can show that
once can avoid using these features. I don't think it always possible
to avoid them. A C program that does complex arithmetic is hard to
write in C++ without using classes and templates (specifically the
template class "complex"). As a result you might as well also use
iostreams since there may be some trouble reading and writing these
any other way.

You have a point about complex numbers - but "complex" numbers fall out
of the remit of programming something "simple".... :-;
 
R

REH

This is true but does not settle the matter unless you can show that
once can avoid using these features.  I don't think it always possible
to avoid them.  A C program that does complex arithmetic is hard to
write in C++ without using classes and templates (specifically the
template class "complex").  As a result you might as well also use
iostreams since there may be some trouble reading and writing these
any other way.

Maybe I misunderstood the statement. I thought he was saying that a
program that didn't use classes was still affected by the fact that
the language supported classes. Avoiding said features in a given
program is a different issue. If I was was using C++ and needed
complex numbers, I would use the classes. Why wouldn't I?

REH
 
J

jameskuyper

REH said:
I usually stay out of languages wars (as they are silly), but that
statement is just wrong. C++ follows the "if you don't use it, you
don't pay for it" philosophy. Having classes in the language has no
effect on a program that does not use classes. It is the same with
exceptions, templates, et. al..

If I make a typo that results in well-formed C++ code that is a syntax
error or constraint violation according to the C standard, will a C++
compiler give me diagnostic messages about it? Of course not.
Therefore, the unused features of C++ will interfere with the
development of such code.
 
R

REH

If I make a typo that results in well-formed C++ code that is a syntax
error or constraint violation according to the C standard, will a C++
compiler give me diagnostic messages about it? Of course not.
Therefore, the unused features of C++ will interfere with the
development of such code.

I wasn't replying to the "writing C code in C++" stuff. I have no
comment on that argument. I was replying to the assertion (as I
understood it), that a C++ program that didn't use any classes was
somehow inherently affected by the language's support of classes.

REH
 
R

Richard

jameskuyper said:
If I make a typo that results in well-formed C++ code that is a syntax
error or constraint violation according to the C standard, will a C++
compiler give me diagnostic messages about it? Of course not.
Therefore, the unused features of C++ will interfere with the
development of such code.
Yes, but now we are diverting into the fantasy land of pedantry and
c.l.c

The simple and clear question is:

,----
| >> What simple program can you program in C that you can not as simply
| >> program in C++?
`----

I am astonished that this can cause so much apparently blinkered
response.
 
J

jameskuyper

REH said:
I wasn't replying to the "writing C code in C++" stuff. I have no
comment on that argument. I was replying to the assertion (as I
understood it), that a C++ program that didn't use any classes was
somehow inherently affected by the language's support of classes.

I'll grant you that it is harder for a typo to cause accidental use of
a class than it is to accidentally make use of many other C++
features; but the principle is still the same. Because classes involve
various special keywords such as "class", "protected", "virtual",
"public", "private", etc., you have to, at a minimum, know what those
keywords are so that you can avoid them.
 
W

William Hughes

I usually stay out of languages wars (as they are silly), but that
statement is just wrong. C++ follows the "if you don't use it, you
don't pay for it" philosophy. Having classes in the language has no
effect on a program that does not use classes.


It may not have an effect on the program
(this depends on definitions) but it
certainly has an effect on the programmer.
E.g. it has effects on the compiler (e.g.
error detection). It is simply wrong to state
that the by not using features, a programmer is
not affected by the existence of these features.

- William Hughes
 
R

REH

It may not have an effect on the program
(this depends on definitions) but it
certainly has an effect on the programmer.
E.g. it has effects on the compiler  (e.g.
error detection). It is simply wrong to state
that the by not using features, a programmer is
not affected by the existence of these features.

Sure, that I agree with. I thought you talking about just the
resulting, compiled program.

REH
 
W

William Hughes

Sure, but what that has to do with the question is a bit of a
mystery to me.


It depends. If you interpret your original question

What can you do in C that can not be done in C++?

narrowly as


What program can you program in C that you can not as simply
program in C++?


nothing. However, it you interpret

What can you do in C that can not be done in C++?

more widely, then the answer

Program in a simple language.

is relevant and correct.

- William Hughes
 
J

jacob navia

jameskuyper said:
I'll grant you that it is harder for a typo to cause accidental use of
a class than it is to accidentally make use of many other C++
features; but the principle is still the same. Because classes involve
various special keywords such as "class", "protected", "virtual",
"public", "private", etc., you have to, at a minimum, know what those
keywords are so that you can avoid them.

Yes, did you know?

int (*export)(int a,char *name);

is illegal C++.

It is a pity that C++ did not develop positional keywords. In my
extensions to C, I always use positional keywords, i.e. keywords that
would be otherwise a syntax error. Otherwise, they are not recognized
as keywords.

Using lcc-win you can still write

int operator = 5;

the "operator" keyword is recognized only in the prefix of a function
definition.

It would be much easier for all if C++ would follow that convention
but I suppose it is too late now.
 
J

jacob navia

Richard said:
You make no sense.

A simple C program or C++ program is still C or C++.

Programming C++ does not mean you have to use classes etc.

So the question still stands. C is pretty much a subset of C++.

What simple program can you program in C that you can not as simply
program in C++?

Look Richard, C++ is just syntactic sugar around C.

Proof:

Comeau C++ compiler works by generating C, not assembly.

And the fact that it is one of the best C++ compilers around
proves that you can write in C ANYTHING you can write in C++.

:)
 
R

Richard Tobin

jacob navia said:
Look Richard, C++ is just syntactic sugar around C.

Proof:

Comeau C++ compiler works by generating C, not assembly.

Several Lisp compilers work by generating C, so I suppose Lisp
is just syntactic sugar around C.

:)

-- Richard
 
J

jacob navia

Richard said:
Several Lisp compilers work by generating C, so I suppose Lisp
is just syntactic sugar around C.

:)

-- Richard

Yes. It is.

Actually Eiffel does the same, Camel does the same, and many
other languages.

All those are just different sugar flavors of C.

You a bittersweet lisp, that instead of grains has parentheses,
the slightly acid Eiffel, that tortures C into a languages as complex as
Ada...

:)

Well, take this "sugar" with a grain of salt.
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top