When should use C?

E

eas

Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?

Thanks in advance!
 
T

Tom St Denis

eas said:
Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?

C simple. Thor like ugga simple!

Realistically C doesn't have an advantage over C++ other than a simpler
compiler.

Tom
 
T

Toni Uusitalo

eas said:
Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?
C might give you better portability when writing a library that's intended
to be callable from different languages since most of languages allow
importing of C libraries or calling of C functions.

p.s. you should google for "c over c++" or similar search string, I'm sure
people have discussed this topic many times on the usenet before ;-)

with respect,

Toni Uusitalo
 
J

Jack Klein

Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

Let's pose an analogous question:

Given a tool box that contains both a hammer and a screwdriver, what
other factors should determine which tool to use, hammer or
screwdriver, besides worker's familiarity level?

A professional, and indeed anyone will common sense, will user their
judgement to select the best tool available to him/her to do the job
at hand.

No matter how many more nails than screws one has inserted in one's
career, one should be able to recognize when to use the screwdriver
rather than the hammer.
In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?

Thanks in advance!

Note by the way that your question is not really topical here. The
very existence of the C++ language is irrelevant, immaterial, and
off-topic in comp.lang.c.

If you want opinions on comparisons between languages, you want
(marginally) alt.comp.lang.learn.c-c++ or (much better idea) a
language neutral group like comp.programming.
 
J

Jarmo

Jack Klein said:
Let's pose an analogous question:

Given a tool box that contains both a hammer and a screwdriver, what
other factors should determine which tool to use, hammer or
screwdriver, besides worker's familiarity level?

Jack, your analogy seems more akin to "should I use Word or Excel" than to
"should I use C or C++".
 
M

Mark McIntyre

C simple. Thor like ugga simple!

Realistically C doesn't have an advantage over C++ other than a simpler
compiler.

What? This is worse than your usual nonsense.
 
R

Richard Heathfield

eas said:
Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

It's simple. Always use C.

Well, what answer did you expect in comp.lang.c? No other language,
including C++, is topical here.
 
A

August Derleth

eas said:
Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

In my opinion, you should use C unless you need an object-oriented
paradigm and you don't feel like building your own object system on top
of C. (It is possible to do just that, but it's fairly complex and isn't
something the maintnence programmer is going to expect. :) )

Of course, if you need to use a specific library that's only callable
from C++, using C would probably be needlessly complex. However, I think
most C libraries are trivially callable from C++.
In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?

OS design is mainly done in C and has been since the 1970s-1980s. It's
done in C instead of assembly because C is portable, so you don't need
to rewrite as much to make the OS run on a different machine. It's done
in C instead of C++ because C is simpler and most C++ constructs are
simply not needed. (Maybe there is a lingering perception of compiled
C++ programs being slower or less efficient, but that is hardly the case
anymore.)
 
P

Peter Nilsson

Richard Heathfield said:
It's simple. Always use C.

Well, what answer did you expect in comp.lang.c? No other language,
including C++, is topical here.

That doesn't mean you have to live in an ivory tower. ;)
 
R

Richard Heathfield

Peter said:
That doesn't mean you have to live in an ivory tower. ;)

Neither does it mean that I do. :) I have been known to use off-topic
languages, but I try to refrain from so doing in /this/ newsgroup.
 
S

Servé Lau

Jack Klein said:
Let's pose an analogous question:

Given a tool box that contains both a hammer and a screwdriver, what
other factors should determine which tool to use, hammer or
screwdriver, besides worker's familiarity level?

A professional, and indeed anyone will common sense, will user their
judgement to select the best tool available to him/her to do the job
at hand.

No matter how many more nails than screws one has inserted in one's
career, one should be able to recognize when to use the screwdriver
rather than the hammer.

Ok, now you've explained that languages are tools best fit for some jobs.
Maybe answering for what job C is best would be in order? I mean, it's a lot
easier to determine what you need with a hammer and a screwdriver than it is
with prog languages and this knowledge does not come by itself.
 
P

Paul Hsieh

eas said:
Given a platform that supports both C and C++ compiler, what other factors
should determine which programming language to use, C or C++, besides
programmers' fluency level?

First of all, programmers' fluency level *MUST* trump all other
considerations. C++ introduces many new concepts -- the biggest
problem being that the most experienced C++ programmer can completely
baffle an average or inexperienced C++ programmer just in the course
of regular usage. So if you have any consideration for maintenance,
and your programmers are not all of equivalent level of proficiency in
C++, then there will be a very high hidden maintenance cost (i.e.,
that of your best programmer being the only one who will ever be able
to debug/maintain your project.)

That said, C++ is the obvious logical progression of the C language.
Its extra features does give it more power, while its
incompatibilities with C don't hamper its functionality. With MSCV
and gcc becoming extremely compliant, there is no real barrier to
entry anymore.
In what areas of software developments are you using C instead of C++? What
benefits of using C in these areas?

C's main benefit is that a larger audience of people will understand C
code than C++. Bstrlib (http://bstring.sf.net) has been written
mostly in C, with a completely seperate C++ wrapper, for example.
Besides being fairly stable, its very easy for anyone to understand
how it works. If it were written completely in C++, it would have cut
off half of its audience.
 
C

Chris Torek

Ok, now [Jack has] explained that languages are tools best fit for some jobs.
Maybe answering for what job C is best would be in order? I mean, it's a lot
easier to determine what you need with a hammer and a screwdriver than it is
with prog languages and this knowledge does not come by itself.

Well, perhaps. But when do you use a belt sander vs. an orbital
sander vs. a sanding block? When do you want a rasp and when do
you want a file? How about a miter saw, a keyhole saw, a jigsaw,
a backsaw, a hacksaw, and a coping saw? (Or if you're in the
construction biz you probably just use a sawzall for everything,
including filing and sanding. :) )

Seriously, the differences between "closely related" languages like
C, Pascal, and C++ are small enough to be like the situation with
the various saws. In many cases, *any* of them will serve. But
a program best written in Prolog is probably not well-served by
being written in C.

So when are procedure-oriented (even C++ is rather procedure-oriented,
for a language that claims to be object-oriented; compare with
Smalltalk for instance), imperative, normally-compiled,
not-too-far-from-the-machine-instruction-set languages appropriate?
I would say that some indictators include having a problem that
requires large amounts of "compute time" spent in small amounts of
code -- hence "compilation" and "close to the metal" become desirable
-- and you have a fair amount of "human time" to throw into
programming the solution. Another indictator is when you and your
team are already familiar with the procedure-oriented language you
choose. If *no* portability is required, however, you might consider
coding even "closer to the metal" (in assembly) under similar
conditions. This generally greatly increases the amount of "human
time" required, of course.
 

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

Forum statistics

Threads
474,135
Messages
2,570,784
Members
47,342
Latest member
KelseyK737

Latest Threads

Top