why still use C?

J

Joona I Palaste

who are you to determine who can participate here and who not?
i just determined you are a very rude &$§"$"!/§$") and
do not deserve to discuss here.

I'll join the club. *PLONK*

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Make money fast! Don't feed it!"
- Anon
 
R

Richard Heathfield

Dan said:
In <[email protected]> "cody"


If you're not aware of the basic standard C features, what makes you
think that you're qualified to participate to this discusion?

No qualification is required for participation in Usenet discussions in
general[1] or comp.lang.c discussions in particular.

Having said that, cody provides a good case for introducing such a
qualification.



[1] There are occasional exceptions, such as the mildly arcane qualification
in the scary devil monastery (I won't give away the secret, but basically
anyone who /can/ post there is, de facto, qualified to post there).

(I presume a.s.r still requires this trick?)
 
G

goose

There. I feel better now. :)

<grin> do you, then ? a really really *really* small part
of me wants to type in "so, what was your C question?" :)

goose,
high on sugar, feeling silly right now
 
M

Mike Wahler

goose said:
"Mike Wahler" <[email protected]> wrote in message
<grin> do you, then ? a really really *really* small part
of me wants to type in "so, what was your C question?" :)

OK, I'll bite:

Did anybody here [C] that [C]hicago [C]ubs game
yesterday? What a [C]ontest! A [C]lash of Titans.

The opposing [C]atcher [C]rushed a three-run homer,
[C]ausing his team to [C]ome [C]loser to victory.
[C]ommentators [C]alled it a [C]rucial at-bat.
It seemed to [C]ow the formerly [C]heering home
team [C]rowd.

A [C]enter fielder [C]omitted an error, allowing a
[C]rit[C]al run to s[C]ore.

The [C]losing pit[C]her made a [C]omplaint about
the umpire's De[C]ision [C]on[C]erning a pit[C]h he
[C]onsidered a strike. "You [C]an't [C]!" he [C]laimed.

The opposing team managed to [C]ling to their lead,
[C]lapping ea[C]h other on the ba[C]k and [C]elebrating
after the [C]lose of the game.


Yes, I'm trying to be [C]lever and [C]reative, as
you [C]an [C], although I'm probably [C]ourting
[C]ondemndation by [C]ranky [C]oders, who might
demand [C]essation or [C]loset me in their killfiles
without [C]omment.

:)

-Mike
 
R

Richard Bos

Richard Heathfield said:
Dan Pop wrote:

[1] There are occasional exceptions, such as the mildly arcane qualification
in the scary devil monastery (I won't give away the secret, but basically
anyone who /can/ post there is, de facto, qualified to post there).

(I presume a.s.r still requires this trick?)

Yes.

Richard
 
M

Mike Wahler

cody said:
that's what i call an answer :)


i didn't know who he was

A good reason to "look before you leap" :)
i only knew how he reacted to my
question and his answer seemed to me a bit aggressive.

Many new visitors here get that impression.
People here have a wide variety of personalities.
Try to see past that, and I think you'll find this
place a good source of quality information.
i mean't "why C instead of C++". i assumed all C programmers would use C++
Why?

and so i said that this is no problem since in C++ they cann still use
c-functions

Nobody said that using C++ is a problem. Some said that
they're unable or unwilling to use it, for various reasons.
or static functions as they are the same as c-functions, basically.

Functions declared as 'static' share the same characteristics
in C and C++, with one exception:

C++ defines a construct 'static member function' which has
no counterpart in C.
iam sorry if i didn't made that clearer.


i didn't knew that.

Again, "Look before you leap" :)
iam not an ignorant.

"Ignorant" is not a noun. It is an adjective, used to
describe a person's level of knowledge about a given
subject. As in, "I'm ignorant of the exact arrival
time of the train, since I don't have a schedule."
Or, "I'm ignorant about auto repair, I've lever learned
it." "Ignorant" means "Don't know."

Ignorance is not a character flaw. But in my opinion,
denial of it when it exists (which is what you seemed
to be doing), is.
why do you think i asked this question?

To reduce your ignorance about C and C++,
I would hope.
i only wanted reasons why people still use C. ok now i have got enough
reasons.

- C is simpler than C++
- some people don't like OOP
- some people don't want to learn OOP
- some projects don't need OOP

OOP is not the only reason people use C++. C++
can be used with many other programming styles.

So make those last three:
- some people don't like C++
- some people don't want to learn C++
- some projects don't need C++
- some platforms dosn't provide a proper C++ compiler.

i didn' know that i would create such a large discussion.

Now you know. :)
so what do you advise? should i write in the subject of my next posting:

"warning! german poster with probably wrong capitalization, punctuation and
grammar"

Actually, yes, something like that. But keep the subject
line only about the actual question. But then in the body
of your message, write a short note at the top:

"My native language is not English, please excuse errors,
and ask if my message is not clear."

Many other non-English speakers post here, and this is
what most of them do.

If you post here very long, people will get to know you,
and this 'warning' will not be necessary every time.
i didn't know that my english is so bad. i would be very grateful if
somebody give me a hint what is wrong with my grammar.

Actually, after reading this, I believe your grammar seems
to have already improved. However, your capitalization needs
much work, though. :)

Compare:

I didn't know that my English is so bad. I would be very
grateful if somebody gave me a hint about what is wrong with
my grammar.

You don't need to be perfect, nobody is. Just do the best
you can.
that is correct all nouns, proper names and beginnings of a sentence are
capitalised.

In English, capitalize the first word of every sentence,
and all pronouns (for example "I") and proper nouns.
If your defense of your English is that
you're German, I would have expected too many capital
letters, not none at all. :)

you underestimated my lazyness :-[=]

Yes, sometimes I get lazy, too.
some commas in german are optional.

English has firm rules about commas, but hardly anyone
understand them all or agrees about them. I try to
use them where, if I were speaking, I would pause.
It seems to work for me.
Is it true that sentences are begun in lower case?

neither in english nor in german but my shiftkey is broken.
i brough is to the workshop last week but it is still not ready :)

But how did you write "C", "C++", "OO", and "OOP" in
your messages?
no, but you can use C++ without programming OOP sinc C++ is a hybrid
language
which supports various programming paradigms, including structured,oop,
functional and more.

Yes. But then why did you write above:
i only wanted reasons why people still use C. ok now i have got enough
reasons.

- C is simpler than C++
- some people don't like OOP
- some people don't want to learn OOP
- some projects don't need OOP

Three out of four imply that C++ == OOP and nothing else,
which is simply not true.

So it seems to me that either you still believe this,
or have changed your mind.

By the way, C++ does not have direct support for functional
programming. What you probably mean is 'procedural programming'.


oop need language support at least to a certain level.

No. Whatever built-in support is not there can be
written using existing language features in virtually
any language. It could even be done in assembly language,
especially one which has macros, if you have enough time. :)
when people programm
oop in C then it is certainly faked.

No. They use the language features which are available
to program in whatever paradigm they want. This does
not make it 'fake'. C++ is often preferred when doing
OOP, because of its built-in features which support it,
and help prevent making mistakes.
it was just an example how some people fake oop in c.

It's not 'fake'. Also, a function pointer inside a struct
can be (and is) used for other things besides OOP.
yes. i have good knowlegde about c++,c# and java. a OO-language needs
classes,ctors,dtors,virtual,abstract,static methods and access modifiers.

Some of those things people will say must exist as built-in
features in order to call a language a "true" or "pure" OO
language. There is always much debate about this, which I
doubt will ever result in any consensus.

But all of those concepts can be implemented in any language
at all. It often requires more work, but it can be (and is)
done.
i consider operator overloading as optional.

It's a very useful tool, but is not an OO concept.
I also often see it overused and abused.
does C++ have a concept of sealed classes? that are classes which cannot be
subclassed.

No. It doesn't need them. If you want to talk about
that further, post a question about it to comp.lang.c++

Many others have already asked about and discussed this
issue in that newsgroup, try reading the older messages
about it.
surely not. it was just an example cos c++ is the successor of c.

Not really. C++ was derived from C, but is not at all
intended to replace it.
thats what i meant. why use a tool or another when you have a tool which
combines both?

How large or heavy is the combined tool? How much
does is cost? I'd use the easiest to use tool that
does the job. C++ is a very large language compared
to C, and much more difficult to learn.
why use C when you can use C++ which contains C? thats what i meant.

Another misconception. C++ does *not* contain C. It has
many similar things, but many of them which *look* exactly
the same, will *behave* differently in each language, often
very subtly. This misconception is a source of many bugs
and incorrect programs (and arguments. :) )
you can
use c++,
nobody will force you to use its additinal features.

But you must use the language itself, which is *different*
from C. The C standard library functions are all available,
but that's not the same thing as the *language*, which is
*not* the same.
iam indeed grateful as you pointed out that my question was misunderstood
here.

Perhaps. But we all know that you have misunderstood what
C and C++ are and are not. We tried to tell you this.
i was wondering why some people didn't understand it, now i know why.

It doesn't really matter why, but you didn't understand
about C *or* C++. We tried to tell you this.
no, i'm not saying that.

Your previous comments seem to indicate otherwise.
nobody will throw away C. it still exists in C++

No, absolutely not.
as C++ is fully backward
compatible

No, absolutely not.
(at least C94 if iam correctly informed)

You have not been correctly informed.
surely not.

Your previous comments seem to indicate otherwise.
surely not.

Your previous comments seem to indicate otherwise.
i wanted to learn about C why people still use it and now i know why :)

Much more than you wanted to hear, I suspect. :)
me to..

now i know why iam always misunderstood here: it certainly is my bad grammar
:)

That is only a small part of it. Most of us understood
you well enough to know what you were saying. You *definitely*
did *not* understand what C and C++ are and are not.
That's not a crime, or anything to be ashamed about,
all you need to do is learn. The best in the business
read and post here, and you can learn much about C from
them. I certainly have, and continue to learn more every
day. The same is true about C++ in the newsgroup comp.lang.c++

Good luck, and have a nice day.

-Mike
 
J

Jeff Mitchell

Sidney Cadot said:
I can't answer for people in general of course, but as a moderately
able C programmer with a thorough dislike of C++ I can try to
explain what my motives are.
<snip>

That was an excellent response, thank you.

For my current work (programming for an embedded device), use of C++
over C is really a matter of notational convenience. I turn off
exceptions and I do not use templates save for one trivial vector
class (hand-written, not STL).

By notational convenience I mean,

(1) I don't need to say self->data, I can just say m_data. It doesn't
sound like a big deal, but all that s-> clutter really adds up.
Applications for this device cannot use static data, so every
piece of data must come from a struct or class.

(2) The ARM CPU doesn't have floating point. It is an enormous
advantage to define my own fixed-point class with +, -, *, /, etc
operators.

(3) Virtual functions are used but not common. In this regard I trust
my C++ compiler. There is very little difference in code size. I
always know which virtual functions are overridden by which
subclasses so it's just a "distributed switch statement".

(4) I get a warm, fuzzy feeling using socket.open() verses
My_Library_Socket_open(socket). You could call this a straw man,
but I am especially careful about name clashes. The alternatives
are (a) to be not so careful or (b) to rig function pointers
inside structs. I don't like either.

(5) 'extern "C"' can be used if you want an application such as
Mathematica to call into your C++ library. In fact, that's
exactly what I'm doing.

What is your opinion on using a limited subset of C++, if only for
convenience?

Jeff
 
C

cody

"Ignorant" is not a noun. It is an adjective, used to
describe a person's level of knowledge about a given
subject.

In german there "Ignorant" can be used as noun or adjective.
In English, capitalize the first word of every sentence,
and all pronouns (for example "I") and proper nouns.

i know, its just my lazyness which hinders me to do that :)
But how did you write "C", "C++", "OO", and "OOP" in
your messages?

magic :)
No. Whatever built-in support is not there can be
written using existing language features in virtually
any language. It could even be done in assembly language,
especially one which has macros, if you have enough time. :)

i disagree on that. how can you make sure that all data is properly
encapsulated if
the language provides no support?
It's not 'fake'. Also, a function pointer inside a struct
can be (and is) used for other things besides OOP.

i know
How large or heavy is the combined tool? How much
does is cost? I'd use the easiest to use tool that
does the job. C++ is a very large language compared
to C, and much more difficult to learn.

the new tool is very heavy and hard to use, it has many buttons and if you
press the wrong one the whole thing blows up. that's C++.
By the way, C++ does not have direct support for functional
programming. What you probably mean is 'procedural programming'.

not C++ as language, but the STL has many functions/functors which are used
for the functional programming paradigm.
the "repeat" function is an example.
 
M

Mike Wahler

cody said:
In german there "Ignorant" can be used as noun or adjective.

I wrote my message in English.
i know, its just my lazyness which hinders me to do that :)

I think you'll find that you will be taken much
more seriously if you make the effort to write
correctly. Around here, laziness is not well
received.

No, you've been caught in a lie. Just admit it,
apologize, and perhaps people will take you seriously.
i disagree on that.
how can you make sure that all data is properly
encapsulated if
the language provides no support?

Most programmers use their brains, and don't
let the language do all their thinking for them.

You know it's not 'fake'? Then why did you call it
'fake' *two* times?
the new tool is very heavy and hard to use, it has many buttons and if you
press the wrong one the whole thing blows up. that's C++.

So don't use it. But your first message was claiming
that people should not use C and use C++ instead.

I use both C and C++ and have successfully written
many programs with them. Some I have written using
a combination of both. Nothing "blows up".
not C++ as language, but the STL has many functions/functors which are used
for the functional programming paradigm.

If you really think so, post a message (not here), but
at comp.lang.c++ and tell me what they are.
the "repeat" function is an example.

There is no 'repeat' function in C++ (or in C either).

But if you want to talk about C++, here is not the place.
Go to comp.lang.c++ to discuss C++. But I'll warn you
that the most expert C++ people in the world are there,
and know if what you say is right or wrong. Much of
what I learned about C++ I learned from them.

I suggest you start there by *asking questions* not
*telling* people about C++, since you obviously have many
misconceptions about it.

But be sure to read their FAQ first.


-Mike
 
C

cody

In german there "Ignorant" can be used as noun or adjective.
I wrote my message in English.

I just wanted to say that in german it can be used as noun, too.
No, you've been caught in a lie. Just admit it,
apologize, and perhaps people will take you seriously.

you don't understand humour, do you?
Most programmers use their brains, and don't
let the language do all their thinking for them.

then try to programm a fully functioning OOP application in pure C.
it is impossible to make sure no one can unintentional access private
variables.
You know it's not 'fake'? Then why did you call it
'fake' *two* times?

storing a function pointer in a struct is commonly used by C programmers.
But i noticed that some programmers abused this to fake OOP features.
There is no 'repeat' function in C++ (or in C either).

my mistake, i thought there was. however there is a foreach function which
has
a bit of functional programming and there is a header file which name is
<functional>.
 
D

Dave Von Pless

There is both a speed and size penalty for using C++ where
pain C would do. The penalty isn't as bad as it used to be.
^^^^

I usually think of C++ as being 'painful C' myself. ;-)

Dave
 
S

Sean Fraley

Dave said:
^^^^

I usually think of C++ as being 'painful C' myself. ;-)

Dave

To be honest, I started programming with C++, and quite often think of C as
the more painful to use for many things. I guess it just depends on which
direction your coming from. Kind of like when country boys see the city as
a rude, dirty, and corrupt while the city boys see the country as
backwards, dirty, and twisted.

Sean
 
S

Sidney Cadot

cody said:
then try to programm a fully functioning OOP application in pure C.
it is impossible to make sure no one can unintentional access private
variables.

Well, the same is the case in C++. I hope not to be chastized too hard
by the crowd here for showing some C++ code but here you go:

#include <iostream>

class YadaYada {
private:
int a;
public:
YadaYada() { a=0; }
void showme() { std::cout << a << std::endl; }
};

int main()
{
YadaYada y;
y.showme();
*(int *)&y=1;
y.showme();
return 0;
}

....Now compare this with some C code that tries to do member hiding:

#ifdef INTERNAL
#define PRIVATE(x) x
#else
#define PRIVATE(x) this_is_private_do_not_touch_me_ ## x
#endif

struct YadaYada {
int PRIVATE(a);
};

Sure, the C way is clunky at best. My point, however, is that both in C
and C++ it is quite possible to circumvent the measures taken for hiding
private data; in both of the examples shown above you would simply have
to be malicious to do it. If you're looking for OOP languages with truly
shielded private variables, you should be reading up on programming
languages instead of ascribing properties to C++ that it doesn't have.
my mistake, i thought there was. however there is a foreach function which
has a bit of functional programming and there is a header file which name is
<functional>.

Pardon me if I'm wrong, but you truly come across as if you haven't got
a clue as to what you are talking about. Perhaps you care to explain
what exactly it is you mean by 'functional programming' - we may both
learn a thing or two.

Then again, this kind of discussion should perhaps be rerouted to
comp.lang.functional - might I also suggest a fitting debut: "Why do
people still use Lisp? ML is so much better..."
 
S

Sidney Cadot

Jeff said:
That was an excellent response, thank you.

Why thank you. That was written at a stage, of course, where I thought
that cody asked his question in order to learn instead of {t|pr}each.

You provide some good reasons why C++ has notational (but no less real)
advantages over C, I think. The important thing in my opinion is to make
an informed decision on ones language of choice for tackling a certain
problem, instead of just going with the tide - which nowadays probably
favors C++ over C. I can surely imagine that using C++ is a viable
option in many circumstances, especially if you limit yourself to the
subset of the language you understand, and understand the possible
ramifications with regard to portability etc.

I especially was interested in your fifth point:
(5) 'extern "C"' can be used if you want an application such as
Mathematica to call into your C++ library. In fact, that's
exactly what I'm doing.

I know that this is quite possible, but for my current project we
refrained from doing this for lack of information about portability.
Yes, we could get it to work using gcc/g++ on Intel/Apple, but our
library also has to work on HP-UX, Solaris, AIX, SGI, ..., with their
proprietary compiler suites.

One testimony to C portability is that this has worked out pretty well
(with something in the order of 100,000 lines of code). There's quite a
thrill in getting a report of a successful HP-UX compile out of the
blue, when you haven't actually tested on such a machine!

(Then again, reading the previous sentence, I think the most important
conclusion is that I need to get out more and get a life outside
computers ;-))

Best regards,

Sidney Cadot
The Netherlands
 
R

Richard Heathfield

Sidney Cadot wrote:

...Now compare this with some C code that tries to do member hiding:

#ifdef INTERNAL
#define PRIVATE(x) x
#else
#define PRIVATE(x) this_is_private_do_not_touch_me_ ## x
#endif

struct YadaYada {
int PRIVATE(a);
};

Sure, the C way is clunky at best.

Well, that way is. What about this way? Here's an extract from one of my
headers:

typedef struct TCPi_ TCP;

Beat that for data hiding!

(Yes, you can still defeat it maliciously, e.g. with an unsigned char *
pointer or with memset, but (unless you were simply destroying existing
values) you'd have to know what the data items are for, how big they are,
and which order they are in, and the visible code gives you no hints
whatsoever).
 
S

Sidney Cadot

Richard said:
Well, that way is. What about this way? Here's an extract from one of my
headers:

typedef struct TCPi_ TCP;

Beat that for data hiding!

Yes, good point.

But suppose you want to have some private and some public members, I
think you're stuck with a variation of what I showed (a feeble excuse
for my clumsy example, but still a slightly valid point I think).

This touches on an interesting notational point with regard to C++
syntax: you are forced to expose both private and public members in the
source code of the declaration of the class. Something similar with
Java, where declaration and definition coincide. Your are basically
forced to use a postprocessor on the source to be able to present a
version that is not cluttered with internals (e.g. doxygen for C++ or
javadoc for Java). I've always considered that to be bit untidy.

Regards,

Sidney
 
C

cody

Well, that way is. What about this way? Here's an extract from one of my
headers:

typedef struct TCPi_ TCP;

Beat that for data hiding!


i don't understand what you mean with that.
 
R

Richard Heathfield

Sidney said:
Yes, good point.

But suppose you want to have some private and some public members, I
think you're stuck with a variation of what I showed (a feeble excuse
for my clumsy example, but still a slightly valid point I think).

I think that I'm unlikely to want a mixture. If it is vital to /have/ a
mixture, though, I'd give serious consideration to using C++ instead. (And
this is me saying it.)
 
R

Richard Heathfield

cody said:
i don't understand what you mean with that.

That figures. Look up the word "struct" in your C book. Then look up
"typedef" in the same book. Then Google for "opaque types".
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top