C... Why not c++?

D

djake

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code i really don't
understand why the same things cannot be written in c++. Using c++
it's possble to reduce developing time achieving the same result.
Can you give me a valid reason for C?
 
H

hanzac

Simple enough, the OO & template features are not needed on some
projects targeted to OS kernel development and device driver
development and other low-level libraries. Moreover, most of the
features require the C++ runtime library and it's too complex to
implement if you write a OS kernel. Note that in WHAT language do you
write the C++ runtime library?

Then you may say that C++ support C89 and some extensions and can write
code without OO. So why does C exist? I think maybe C++'s function
naming can't be compatible with C? To further improve C? I can't give
an exact reason. As to the compiler, C is often the first language to
implement and in GCC it's the background of Obj-C or C++ or Java or Ada.
 
J

john

Just a thought here but not relate to answering your question.

IMHO, I think C++ will give longer developing time due to there is more
things to be taken care of, like class, and private, public, protected,
virtual functions, also inheritance etc, and there is loads. There is more
restrictions in C++. Not a bad thing though. Instead, I think it will reduce
the maintenace time for sure.

To OP, can you exaplain to us why use C++ instead of C? :)
 
N

Neil Kurzman

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code i really don't
understand why the same things cannot be written in c++. Using c++
it's possble to reduce developing time achieving the same result.
Can you give me a valid reason for C?

For What? a PC? a MainFrame, a Printer? a TV?
For many small systems the extra overhead for C++ is too much. The
memory is in Kbytes not Megabytes.
The question there is C or assembler ( and C is not always the winner).

Your question indicates to me you are a PC programmer. So what kind of
program. a driver? a simple user app? a fortune 500 company database
system? What about the development team? what are they good at? Hey
why not Java or C# or C.Net?
C++ is not a C replacement. It has its own pluses and minuses. For
small project it is programers choice. What he is good at is quickest.
For massive projects The project leader need to figure out the best
language. C++ does not guarantee the project is coded better, or is
done quicker.

BTW if to are trolling back under the bridge.
 
E

Erik de Castro Lopo

Someone can exaplain me why use C instead C++?

Because C is a better lanugage for some tasks.

C++ is overly complicated, has way too many features and it
is way easier to write unreadable C++ than it is to write
unreadable C.
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code i really don't
understand why the same things cannot be written in c++. Using c++
it's possble to reduce developing time achieving the same result.

Bullshit. C++ is a far harder language to master than C.
Can you give me a valid reason for C?

It doesn't suck?

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo (e-mail address removed) (Yes it's valid)
+-----------------------------------------------------------+
"Compiling C code with warnings switched off is like practicing
high wire trapeze without a safety net. Even experienced
practitioners try to avoid it." -- me
 
M

Martin Ambuhl

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.

Your question is backwards. It should be: when should you bother with
the pig-of-a-language C++ instead of using C? There are times when C++
is justified, although I would really rather use a real object-oriented
language for those.
 
M

Malcolm

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Apart from a few minor details, C++ is designed for object-oriented designs.
So the question really becomes, why use procedural rather than OO
techniques?
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code I really don't
understand why the same things cannot be written in c++.
Languages are equivalent. I'm currently implementing an OO adventure in
stright C, which is more trouble than its worth (wish i could use Java but I
can't)
Using c++ it's possble to reduce developing time achieving the same result.
That's just Bjarne Strousup's propaganda. In certain carefully-chosen cases
he is of course correct. However generally an object-oriented design takes a
lot longer to implement than a procedural one, because you have two
dependency hierarchies (the object inheritance hierarchy and the object call
hierarchy) rather than one (the function call tree), so it is much more
difficult to produce an elegant design. However OO really comes into its own
when you want a third party programmer to extend your functions without
recompiling or modifying your code.
Can you give me a valid reason for C?
The British army recently bought an assault rifle from a Swedish company,
and asked for the automatic fire option to be taken out. You might ask, what
is the point of that, since a gun which can fire bursts or single shots can
do everything that a single-shot gun can do, and more? The reason was that,
in the heat of battle, it was thought that soldiers would fire wildly and
waste ammunition. This consideration outweighed the cases when firing a
sustained burst would be beneficial.
It is the same with C++. From experience, programmers will forever play with
the language if allowed to program in C++. They try out templates, and
multiple inheritance, and experiment a bit with virtual functions or
operator overloading to see how they work. In C they just get the job done.
 
T

Tim Prince

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code i really don't
understand why the same things cannot be written in c++. Using c++
it's possble to reduce developing time achieving the same result.
Can you give me a valid reason for C?
It's easier to make a 25 year old C program work on current systems than
it is likely to be with a 4 year old C++ program. I just heard that
CERN, which I suppose is one of the more competent organizations turning
out open source C++, doesn't want to maintain an important C++ package,
now that the original author went on to other pursuits. C programs are
sometimes written, accidentally or not, to have a reasonable lifetime.
 
C

Chris Barts

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) wrote:
| Simple enough, the OO & template features are not needed on some
| projects targeted to OS kernel development and device driver
| development and other low-level libraries. Moreover, most of the
| features require the C++ runtime library and it's too complex to
| implement if you write a OS kernel. Note that in WHAT language do you
| write the C++ runtime library?

All of this is true enough, and those reasons can also be used to favor
assembly over C.

|
| Then you may say that C++ support C89 and some extensions and can write
| code without OO.

Then he would be wrong. C++ is not a strict superset of C89 or C99, and
a C++ compiler in conforming mode should not accept every conforming C89
program.

| So why does C exist? I think maybe C++'s function naming can't be
| compatible with C?

This is a rather bizarre statement. I really can't tell what you mean by it.

| To further improve C?

Only rarely do modifications to C++ become modifications to C. It
usually wouldn't make any sense to apply a C++ feature to C.

| I can't give an exact reason. As to the compiler, C is often the first
| language to implement and in GCC it's the background of Obj-C or C++ or
| Java or Ada.
|

Wrong. gcc does /not/ convert everything to C. gcc has language-specific
frontends for /every/ language to convert the source to an internal
representation. (RTL, to be precise.) Read the documentation.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBhMd9KxatjOtX+j0RAoFbAJsEx+liERw6TkMvabEXrGCsSItNUwCeIGBY
mgT+5tHVNjwTKfvJv0HOWC4=
=FZ1E
-----END PGP SIGNATURE-----
 
S

Str0nG

Erik said:
Because C is a better lanugage for some tasks.

C++ is overly complicated, has way too many features and it
is way easier to write unreadable C++ than it is to write
unreadable C.


Bullshit. C++ is a far harder language to master than C.

Please don't use strong language in a completely inappropriate context.
If you can't contribute something useful, be quiet.

By the way, both c++ and c have advantages and disadvantages, which have
been outlined in several documents. Simply referring to a flat learning
curve isn't enough.
It doesn't suck?

You shouldn't probably answer if you're biased.
 
S

Str0nG

Erik said:
Because C is a better lanugage for some tasks.

C++ is overly complicated, has way too many features and it
is way easier to write unreadable C++ than it is to write
unreadable C.


Bullshit. C++ is a far harder language to master than C.

Please don't use strong language in a completely inappropriate context.
If you can't contribute something useful, be quiet.

By the way, both c++ and c have advantages and disadvantages, which have
been outlined in several documents. Simply referring to a flat learning
curve isn't enough.
It doesn't suck?

You shouldn't probably answer if you're biased.
 
O

Old Wolf

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Every project written in C on which i've worked could be written in
c++

Because every platform under the sun has a C compiler, but most
of them don't have a C++ compiler, or do have one but it is
very quirky and poor at standards compliance.
 
E

E. Robert Tisdale

djake said:
Someone can exaplain me why use C instead C++?
Until now I've never found explanation for this.
Every project written in C on which I've worked could be written in
C++, and when in nowadays happen still to see C code I really don't
understand why the same things cannot be written in C++. Using C++,
it's possble to reduce developing time achieving the same result.
Can you give me a valid reason for C?

The only reason that C still exists is that
there are a large number of C programmers
that still aren't comfortable with C++.
There is no reason now to expect them to ever learn C++.
We are just waiting for them to retire or die.
 
N

Neil Kurzman

E. Robert Tisdale said:
The only reason that C still exists is that
there are a large number of C programmers
that still aren't comfortable with C++.
There is no reason now to expect them to ever learn C++.
We are just waiting for them to retire or die.

That maybe true for some projects, but not all. Talk to the Java / .Net
crowd an they will tell you C++ is the is dead too.
Few (if any) 8 bit CPUs run C++ , or ever will. For small projects is it
worth the bother?
Programmer should have more than 1 tool in the tool box.
 
C

Chris Barts

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil Kurzman wrote:

| Few (if any) 8 bit CPUs run C++ , or ever will.

This is nonsense. The CPU will run any object code it's handed. It
doesn't matter if the code comes from a C++ compiler, a Forth compiler,
a Prolog compiler, or a human being with toggle switches and LEDs.

You might not write code in C++ for an embedded system, but there might
not be a good reason not to, either. If gcc supports the target
platform, or if you write a backend that allows it to, you automatically
get a C++ compiler that targets that system. Then it's merely a matter
of analyzing the benefits C++ brings as opposed to the downsides.

(If you say that the 8-bit chip won't be running a C++ compiler, you
should realize that 8-bit chips are rarely used as development platforms
these days. It's much, much more common to write and compile the code on
a more capable machine, test it on an emulator, and only transfer it to
the physical target system once it's been tested and debugged.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBhf/JKxatjOtX+j0RAqGwAJ0bqpf1lBU5fb0Fc/MHvNV7HHQcQgCeOYY6
oFAYHUTae9cbbWB7kwwhC5c=
=UCwa
-----END PGP SIGNATURE-----
 
C

Capstar

Chris said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil Kurzman wrote:

| Few (if any) 8 bit CPUs run C++ , or ever will.

This is nonsense. The CPU will run any object code it's handed. It
doesn't matter if the code comes from a C++ compiler, a Forth compiler,
a Prolog compiler, or a human being with toggle switches and LEDs.

I think Neil didn't try to say that those 8 bit CPU's are incapable of
running C++, but that there aren't any C++ compilers to target those CPU's.

Mark
 
C

Capstar

Chris said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) wrote:
| Simple enough, the OO & template features are not needed on some
| projects targeted to OS kernel development and device driver
| development and other low-level libraries. Moreover, most of the
| features require the C++ runtime library and it's too complex to
| implement if you write a OS kernel. Note that in WHAT language do you
| write the C++ runtime library?

All of this is true enough, and those reasons can also be used to favor
assembly over C.

In some situations assembly is favored over C. But if you write assembly
for a specific CPU, and you want to have the same program on another CPU
you can start from scratch again. So C's portability is also a big issue.
| I can't give an exact reason. As to the compiler, C is often the first
| language to implement and in GCC it's the background of Obj-C or C++ or
| Java or Ada.
|

Wrong. gcc does /not/ convert everything to C. gcc has language-specific
frontends for /every/ language to convert the source to an internal
representation. (RTL, to be precise.) Read the documentation.

I think (e-mail address removed) ment that the Obj-C/C++/Java/Ada compiler
itself is written in C since C is often the first language a compiler is
written for.

Mark
 
D

dandelion

(If you say that the 8-bit chip won't be running a C++ compiler, you
should realize that 8-bit chips are rarely used as development platforms
these days.

Depends what you call 'development platform'. Most compilers that *target*
8-bits systems run on 32-bit systems (and for a good reason). If that was
intended, you are certainly right.

However, when writing for an 8-bit platform I wish to note the following:
C++ *tends* to produce 'fat' code due to all the stuff it does automatically
for you and the routinelets (c'tor, d'tor, etc) it requires. If you choose
(Babbage, Turing, Neumann and Dijkstra forbid) to use STL components on an
8-bit (Say) Atmel ATMega (64kx16) or Motorola 68HC11 you will get into
footprint problems *very* fast. Besides, I am curious how OO compilers
handle Harvard-architectures, since many u-controllers are not
Turing-machines.

C, OTOH, tends (if some care is taken and a good optimizing compiler is
used) to produce quite 'lean' object-code, which will get you into footprint
problems a lot less fast.

The above, of course, merely rests on my expirience and 'proof' is not the
plural of anecdote.
 
J

jacob navia

Someone can exaplain me why use C instead C++? Until now i've never
found exaplanation for this.
Every project written in C on which i've worked could be written in
c++, and when in nowadays happen still to see C code i really don't
understand why the same things cannot be written in c++. Using c++
it's possble to reduce developing time achieving the same result.
Can you give me a valid reason for C?

Why C?

Contrary to the opinions of most people in this group I think that C has
many advantages over C++: simplicity, being the most important.

I do not think that C is a language for people that do not want to
learn anything else (as Mr Tisdale remarks) but I am of the opinion that
C can be used as a general purpose programming language where you can
develop GUI application and many other kinds of software.

C is not "object oriented" and as such, it doesn't impose a framework
on the programmer that is implicit n the whole language. You are free,
in C, to use the paradigm that fits the application best.

I do not see C as dead and static, on the contrary, I have tried within
the lcc-win32 compiler system to introduce extensions that make C
programming easier without introducing undue complexity: default
arguments, operator overloading, and some others.

C++ is seldom portable, and even code that compiled 4 years ago will not
compile in more recent versions of the same compiler. When you need
software that will have to be rewritten in a few years, you can use it.
For software that needs to run longer, C is the language of choice.

jacob

http://www.cs.virginia.edu/~lcc-win32
 
G

Guillaume

The only reason that C still exists is that
there are a large number of C programmers
that still aren't comfortable with C++.
There is no reason now to expect them to ever learn C++.
We are just waiting for them to retire or die.

Happy trolling!
I think you just deserve a plonk for that fine analysis.
 

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,156
Messages
2,570,878
Members
47,404
Latest member
PerryRutt

Latest Threads

Top