C++ or C?

M

Magcialking

somebody told me that c++ is superior to c while others insist that c++
is just a junk.
I don't know which to follow.I want to know exactly the difference
between them, and their respective advantage and disadvantage.
 
V

Victor Bazarov

Magcialking said:
somebody told me that c++ is superior to c while others insist that
c++ is just a junk.
I don't know which to follow.I want to know exactly the difference
between them, and their respective advantage and disadvantage.

www.google.com and read about the differences until you're blue in
the face.

Oh, while you're at it, look up "trolling", and try not to do it.

V
 
P

Phlip

Magcialking said:
somebody told me that c++ is superior to c while others insist that c++
is just a junk.

C++ was invented later, and it's easier to program. That means many new
libraries, using it, are often fat and bloated.

However, C++ permits as many efficiencies as C. You should write clean C++
style code, and keep it not ugly and bloated. Then if it's slow, you can use
C-style code that's more efficient. So ideally you can get the best of both
worlds.

Now try comparing a C language to any other language. Tip: Don't go straight
to Java. Get a high-level language like Ruby or Smalltalk, and learn to
compare it to C++.
 
U

uralmutlu

Magcialking said:
somebody told me that c++ is superior to c while others insist that c++
is just a junk.
I don't know which to follow.I want to know exactly the difference
between them, and their respective advantage and disadvantage.

Try to compare an apple and a pear.

The inventor of C++ Bjarne Stroustrup has a few things to say on the
subject: http://www.research.att.com/~bs/bs_faq.html
 
M

Magcialking

I heard that nearly 95% programs in the GNU world are written with C,
and except in the game industry, C is much more widely used, is that
true?
 
P

Phlip

Magcialking said:
I heard that nearly 95% programs in the GNU world are written with C,
and except in the game industry, C is much more widely used, is that
true?

C is much older, and is responsible for the majority of the programming
infrastructure we use. Items like Unix, grep, Apache, Perl, and Berkeley
Sockets were all written in C.

That's not because C is better; just because it's older. And C++ cannot yet
compete for some platforms that only have C compilers. The most useful
system things must port to such platforms, hence they must use C.

Modern development, for most platforms, that requires relatively high
performance and portability will use C++. So your cell phone might run C++,
and your videogame most likely will.

Curiously, many videogames use libraries like Renderware that are themselves
written in C. This disadvantages some students, who learn its style, and
then use that style inappropriately in their C++ code.

The question arises to what purpose you will put these answers. If you seek
which language to learn, learn a soft easy one like Ruby first, and then
learn C++. Only learn C as you need it.

If you want to pick a language to start a project, you should pick a soft
one like Python, Ruby, or Smalltalk. Use soft languages to program faster,
and only convert modules to C++ as you need.

Most videogames also use a soft layer, typically Lua, to program their
high-level logic without worrying about the nuts-and-bolts that raw C++
requires.
 
N

noone

I heard that nearly 95% programs in the GNU world are written with C,
and except in the game industry, C is much more widely used, is that
true?

It is true that most widely used GNU tools are written in C and not in
C++. This is probably more for historical reasons than anything else.
Many of those projects were started before C++ became as popular and
finding C programmers to contribute is easier. To their credit many GNU
project managers won't rewrite in C++ until there is an overwhelming
reason to do so since the end result is more often a new C program that
simply uses some C++ constructs and achieves the worst of both worlds.

You gotta teach GNU developers to adequately document and professionally
engineer their code first. open-source project docs are generally
TERRIBLE!
 
J

Jerry Coffin

[ ... ]
However, C++ permits as many efficiencies as C.

More, AAMOF. Essentially all of the basic techniques of C are available
in C++, and C++ adds a few tricks of its own (especially via templates)
that are difficult to match in C.
You should write clean C++
style code, and keep it not ugly and bloated. Then if it's slow, you can use
C-style code that's more efficient.

....or or many cases, well written C++ that's considerably better than
you could reasonably plan on producing with C.

Don't get me wrong: I'm not trying to bash C at all. Nonetheless, for
quite a few tasks, a C++ programmer can aspire to considerably more than
simply matching the efficiency of C, especially in terms of speed. If
your main concern is executable size, then C or extremly C-like coding
usually work extremely well. Given the current prices of memory and hard
drives, many people find larger executables quite reasonable if they run
enough faster -- which they often do.
 
N

noone

[ ... ]
However, C++ permits as many efficiencies as C.

More, AAMOF. Essentially all of the basic techniques of C are available
in C++, and C++ adds a few tricks of its own (especially via templates)
that are difficult to match in C.

And of course something that folks don't know or try to forget is that C++
was originally called "C with classes" and C++ compilers were simply C
code preprocessors.
 
U

uralmutlu

Magcialking said:
I heard that nearly 95% programs in the GNU world are written with C,
and except in the game industry, C is much more widely used, is that
true?

GNU mainly deals with OSs, drivers, compilers, etc and they are mainly
written in C.

You can't compare C to C++, a statement like "C is more widely used
than C++" doesn't make sense. Although, there is a relationship between
C and C++, they serve different purposes.

There are millions of application developers around the world and
application developers use c++, java, #c, etc. So even if there is more
C than C++ at the low level in our computers, I don't think anyone can
tell how widely C++ is used to build propriatery applications.
 
I

Ian Collins

Phlip said:
Modern development, for most platforms, that requires relatively high
performance and portability will use C++. So your cell phone might run C++,
and your videogame most likely will.
Cell phones are more likely a mix of C and (unfortunately) Java these days.
 
U

uralmutlu

Ian said:
Cell phones are more likely a mix of C and (unfortunately) Java these days.

Symbian is C++ and some philips models have a linux based OS with Qt.
However, majority of cell phones probably use C, or shall we say the
code and applications running on them is developed in C.
 
R

Robert J. Hansen

somebody told me that c++ is superior to c while others insist that c++
is just a junk.
I don't know which to follow.I want to know exactly the difference
between them, and their respective advantage and disadvantage.

Anyone who thinks C++ is superior to C, or vice-versa, is clearly so
ignorant that they should be dismissed out of hand. There is no such
thing as 'superiority' with respect to programming languages, only ways
in which they excel or fail to excel.

If you'd care to ask a more narrowly-focused question, people can
probably give you more useful answers.
 
J

Jerry Coffin

[ ... ]
And of course something that folks don't know or try to forget is that C++
was originally called "C with classes" and C++ compilers were simply C
code preprocessors.

At least as I understand things, C with Classes started out as a set of
macros, that were fed to a perfectly normal C compiler (along with your
source code, of course).

IMO, most people would be better off forgetting most of this
relationship when they're writing C++ code though -- IMO, one of the
most common sources of poorly written C++ is authors who think and write
too much like they're writing C with a few extra bells and whistles.
 
I

Ian Collins

Symbian is C++ and some philips models have a linux based OS with Qt.
However, majority of cell phones probably use C, or shall we say the
code and applications running on them is developed in C.
A large number of the new operator branded phones use Java.
 

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

Latest Threads

Top