The difference between C and C++

W

wkaras

Default said:
Untrue. C as of the latest standard has features that are not found in
C++.
....

Strictly speaking, you're right. But the things that were added
by C99 (and are not in C++) I'd say would either be used
sporadically, or used heavily only in a few applications. The
C++ features not present in C are useful often and in many
applications.
 
R

Randy

Then you were watching Sesame Street about the time I was writing
code for a defense company.

--RY
 
V

Victor Bazarov

Randy said:
Then you were watching Sesame Street about the time I was writing
code for a defense company.


I don't doubt that. I watch Sesame Street any time I have a chance
these days. Did you mean to offend me with your remark? You need
to do better next time.

Oh, if you have a C++ question, don't forget to include it next time
you post here. With all defense work on DSPs in assembly, you must
be getting confused what we're talking about here.
 
L

Lindsay

Interesting point. There have been times when I have posted snippets of code
on this NG, only to be told it's not C++. But I'm using MS C++ .Net Standard
to program with, so it must be C++, yes?
 
L

Lindsay

I guess then, that my answer is: C is as obselete or out-of-date as Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE. There
are features in XP that 98SE does not have but 98SE did things that XP does
not (er, I can't actually think of one, but I'm sure there is).

But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.
 
C

Christopher Hulbert

Lindsay said:
I guess then, that my answer is: C is as obselete or out-of-date as Windows
98SE is. Plenty of people still use Windows 98SE, but it's no longer
supported and the latest version is Windows XP which supersedes 98SE. There
are features in XP that 98SE does not have but 98SE did things that XP does
not (er, I can't actually think of one, but I'm sure there is).

Bad analogy. C IS still supported. For reference see the 1999 C standard. When
people write code in C they are choosing not to use those extra "features". A
lot of scientific/numerical programs don't need classes,templates,etc. So the
question is if you don't need/want those features is there any reason to use
C++? C vs. C++ is a personal opinion. Some people like the whizbang features
C++ offers some don't. The key to programming is to use the right tool for the
job that you're comfortable with. That can be C,fortran,C++,java,whatever.
But..... This does lead me to another question:

If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.
You should be posting here if your question pertains to the C++ standard. You
should be posting to a NG like comp.os.ms-windows.programmer if your question is
of the form, "How do I do ... on windows".
 
B

Bo Persson

Lindsay said:
Interesting point. There have been times when I have posted snippets
of code on this NG, only to be told it's not C++. But I'm using MS
C++ .Net Standard to program with, so it must be C++, yes?

It's more a question of style. Some code is obviously C code, even
though it is compilable with a C++ compiler. Compare these simple
snippets:


#include <stdio.h>

int main()
{
printf("Hello world\n");
}

---------------

#include <iostream>
#include <ostream>

int main()
{
std::cout << "Hello world!" << std::endl;
}


Here the second example is defintely C++, while the first one is
arguably a C program.

If you have questions about the finer nuances of the format string
conventions, or how to use some obscure C library function, like
wcscmp(), you have better do that in a C news group. Many C++ coders
just don't care much about those "dark corners", so we can't answer
anyway.


Bo Persson
 
J

jschementi

No, C is not an obsolete language; the linux kernel and the Apple
development tools are two examples of really prominent software written
in C, so it is very much alive :)

Like any language, C has it's strengths and weaknesses, and the
developer has to choose if it's the best tool for the job.

~Jimmy
 
J

John Carson

Lindsay said:
Interesting point. There have been times when I have posted snippets
of code on this NG, only to be told it's not C++. But I'm using MS
C++ .Net Standard to program with, so it must be C++, yes?

The strict test is whether the code conforms to the C++ standard. Since MS's
compiler is not 100% conforming with the C++ standard, it is possible that
something might compile on it without being standard C++.

As a practical matter if you successfully compiled code on MS's C++ compiler
and were told it was C and not C++, then the person claiming that was almost
certainly wrong.

A lot of people have a religious zeal about promoting a programming style
that uses certain code that is only legal in C++ in preference to code that
is legal in both C and C++ (e.g., cout rather than printf). In pursuit of
this goal, they overstate their case by falsely claiming that some
constructs available in both C and C++ are not C++ at all.

I do, however, agree with Bo that if you are using code that is legal in
both languages but involves features of the language that most C++
programmers don't use because they prefer C++-specific alternatives, then
you will often get better advice on comp.lang.c than on comp.lang.c++.
 
W

wkaras

Lindsay wrote:
....
If I am programming using MS Visual C++ .Net Standard 2003, should I be
posting here? If I have a Windows XP issue, I wouldn't post to a Windows
98SE NG just because it may apply.

You should be aware that Visual C++ has alot of extensions to ISO
C++. These extensions are used heavily in the GUI library and
other Visual C++ libraries, so the typical VC++ uses is pretty
much forced to use them. There are also some minor features
(like no anonymous enums) that seem to be missing from VC++.
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a VC++-specific
group.

Since this is not a moderated group, everyone has to use their
own best judgement about what to post. Someone will always
find a reason to grouse about almost anything you post. I
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.
 
J

JustBoo

find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.

Oh, you didn't get the memo? They are all writing Java and
Python for Dell... ... in New Delhi of course!

The land that had nourished him and had borne him fruit
now turned against him and called him a fruit. Man, I hate
land like that. -- Jack Handey
 
R

Roman Werpachowski

(e-mail address removed) napisal(a):
In my opinion, C is an obsolete language. The only reason to post
anything
to comp.lang.c is to communicate with the many people who don't agree
that
C is an obsolete language.

Not at all. When speed is what matters, C is IMHO preferable over C++.
 
P

persenaama

When speed is what matters, C is IMHO preferable over C++.

There's hardly a difference if the C++ programmer knows his job,
compiler toolchain withstanding - it's always possibility that the
available C++ compiler is poor compared to the available C compiler,
but that's a different issue from one being debated.

If there is that *toight* loop that is hogging clock cycles in your
program written in C++, you have all the options open for optimization
as in C and some more tricks to keep the code still *readable*,
example: preprocessor macros versus templates. (ofcourse, you can write
really obfuscated code with templates which will make macro spaghetti
look like work of art in comparison :)

If the bottleneck isn't one tight loop or other but architechtural,
then the language doesn't make so big of a difference.

So, what I am interested in.. is.. what is your interesting hypothesis
based on?
 
L

Lindsay

I didn't say it was obselete. There was an analogy there, but perhaps you
didn't see it. Point is, this NG is named comp.lang.c++. If I am writing
using a C++ IDE, then shouldn't I use this NG for help?
 
L

Lindsay

Ah! Good idea. VC++ NG here I come!

Lindsay wrote:
...

You should be aware that Visual C++ has alot of extensions to ISO
C++. These extensions are used heavily in the GUI library and
other Visual C++ libraries, so the typical VC++ uses is pretty
much forced to use them. There are also some minor features
(like no anonymous enums) that seem to be missing from VC++.
So if you have a question about code that's using VC++-specific
features/libraries, it's probably better to ask it in a VC++-specific
group.

Since this is not a moderated group, everyone has to use their
own best judgement about what to post. Someone will always
find a reason to grouse about almost anything you post. I
find it especially funny when people complain about postings
with Indian English grammer or spelling, when there may now
be more C++ programmers in India than any other country.
 
W

wkaras

persenaama wrote:
....
If there is that *toight* loop that is hogging clock cycles in your
program written in C++, you have all the options open for optimization
as in C and some more tricks to keep the code still *readable*,
example: preprocessor macros versus templates. (ofcourse, you can write
really obfuscated code with templates which will make macro spaghetti
look like work of art in comparison :)
....

Why do you believe that there is a speed advantage to using the
preprocessor rather than templates for generic code?

With VC++, l've observed problems where it won't really inline
functions which are declared inline. Did you switch from a
templated inline function or a templated class with inline
functions to macros, and see a speedup?
 

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,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top