An Authors View on C

F

Fao, Sean

A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author.  I also find it
hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

See what you think:

http://www.embedded.com
showArticle.jhtml;jsessionid=4DOBHEJ2YZUKUQSNDBCSKHQ?articleID=15306089

Sean
 
R

Richard Heathfield

A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author. I also find
it hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

See what you think:

http://www.embedded.com
showArticle.jhtml;jsessionid=4DOBHEJ2YZUKUQSNDBCSKHQ?articleID=15306089

It is true that C allows you to do stupid things. It is also true that C
allows you to do clever things. C doesn't get in your way. It's up to you.
If you'd rather it were up to the language to protect you from yourself,
you're using the wrong language. C is powerful, like a chainsaw. And just
like a chainsaw, it can do a lot of damage in the wrong hands. That doesn't
mean that C is a bad language, any more than chainsaws are bad tools.

The 99% figure is wrong. Only 90% of PC programs have memory leaks. (So
prove me wrong.) Cf Sturgeon's Law.
 
J

jacob navia

Fao said:
A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author. I also find it
hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

See what you think:

http://www.embedded.com
showArticle.jhtml;jsessionid=4DOBHEJ2YZUKUQSNDBCSKHQ?articleID=15306089

That article has many points. The basic principle is stated at the start:
C, the most popular of all embedded languages, is an utter disaster, a bizarre hodgepodge meant to
give the programmer far too much control over the computer. C++ isn't much better. The languages are
designed to provide infinite flexibility, to let the developer do anything that can be done on the
computer.

<<
You have to limit what the programmer can do to avoid mistakes. This is a bad conclusion from real
facts like the difficulty of using correctly malloc and free.

I proposed garbage collection as the means of solving this. GC allows you to avoid
malloc and free. See http://www.cs.virginia.edu/~lcc-win32.

Another real fact is the primitive string type in C and the absence of bounds
checking of arrays, specially strings. The use of a bounded array type is long
overdue and C will continue to have critics that will point out this defficiency in the
language as long as no solution is proposed by the standard.

It is a pity that we go on with a badly conceived data type. Bounded strings would
be really a bonus for the language. We are in the final phase of releasing a string
package for the above implementation.

Bounded strings are much faster than traditional strings. The strlen() function
is just a memory read: you just access the "size" field.

Other functions like strcat and others can be implemented *much* faster and
without any buffer overflows.

The whole package is easier to do with the garbage collector.

The other points in the article are ridiculous. He says, for instance
C has no formatting rules. It's easy and usual to write source in astonishingly cryptic ways. Any
language that allows utterly random use of the ENTER key (it's perfectly legit to hit ENTER after
almost every character in C) is more an encryption tool than an aid to creating reliable and
maintainable code.

<<

Now, if you can't even format your own program as you seem fit...

jacob
 
J

Joe Wright

Richard said:
It is true that C allows you to do stupid things. It is also true that C
allows you to do clever things. C doesn't get in your way. It's up to you.
If you'd rather it were up to the language to protect you from yourself,
you're using the wrong language. C is powerful, like a chainsaw. And just
like a chainsaw, it can do a lot of damage in the wrong hands. That doesn't
mean that C is a bad language, any more than chainsaws are bad tools.

The 99% figure is wrong. Only 90% of PC programs have memory leaks. (So
prove me wrong.) Cf Sturgeon's Law.
The chainsaw analogy notwithstanding, C allows me to "scrape paint" all
the way down to "bare metal". It is precise as a fine surgeon's scalpel.
Memory leaks, whatever they are, have nothing to do with C. Statistics
show that 98.7 percent of all statistics are made up. I don't know what
caviar has to do with this. Dammit, where's my drink?
 
R

Ricardo Gibert

C is fine language for good programmers. It's a bad language for bad programmers.

IMO the language should have never become popular, since most programmers are not good enough for the language. However, human
nature being what it is, most programmers do not see themselves as being the bad programmers that they are.
 
M

Malcolm

jacob navia said:
You have to limit what the programmer can do to avoid mistakes. This > is
a bad conclusion from real facts like the difficulty of using correctly
malloc and free.
The malloc free problem is the consequence of paring the language down so
that these are just ordinary functions.
I proposed garbage collection as the means of solving this. GC allows >
you to avoid malloc and free. See
There's a case for garbage collection, but why not just use C++ and the
standard template library if you want a higher-level langauge?
Another real fact is the primitive string type in C and the absence of
bounds checking of arrays, specially strings. The use of a bounded
array type is long overdue and C will continue to have critics that will
point out this defficiency in the language as long as no solution is
proposed by the standard.
Just about everyone has a go at a better string library for C. Asciiz
strings are easy to implement and work with, and in most programs string
handling isn't a bottleneck. Again, why not go for C++ if you want a
built-in string class?
Bounded strings are much faster than traditional strings. The strlen()
function is just a memory read: you just access the "size" field.
Sure. But you're changing the spirit of the langauge by putting in support
for them eg

string foo = "FRED"; actually fills a structure with information about the
string literal.
Other functions like strcat and others can be implemented *much*
faster and without any buffer overflows.
Though implementation time includes programmer time as well as CPU time, and
for many applications is much more important.
The whole package is easier to do with the garbage collector.
Exactly. Once you start messing about with structures and dynamically memory
for strings you have to free them, adding complexity to your program, or you
have to have some automatic garbage scheme, adding complexity to the
compiler.
 
E

Eddahbi Karim

He should define ``perfect''. This of course is something based on
ones ideological reasoning.
I personally think one can achieve ``perfect''(robust, flawless) code
in C by undertsanding its pitfalls.

I don't know how he can say "perfect" a code.
Most of the problems he says was about careless programmers.

A careless programmer doesn't perfect his code... because he doesn't
care about.
 
B

brendon

But only a beginner would so. And as such, such a
novice shouldn't be using the language for _any_ serious development until
they have actually understood the language. I really don't see the
logic.

myself being a beginner in c i have a bit of understanding of
pascal/delphi. I agree with you on that statement. it doesn't matter
what language you use, you shouldn't be doing any serious stuff until you
know excatly what you are doing, and not be afraid to ask for help if you
suspect a problem, experienced people are only to willing to help as i
have found out in the past.
(Using a chainsaw as an example after reading Richard Heathfield's post) I
can walk around with a chainsaw and cut people up with it, but does this
mean that I should? And because I can do this, does it make a chainsaw a
crappy tool?
execatly


Understanding the semantics of C is not something that will be achieved in
21 days, 24 hours, or what have you.

he might have read those books but you have to experiment with the
language and not be afraid to ask. not doing that sort of thing the
person concerned ain't going to get very far. reading the books are fine
but it is going beyond what is written is the idea.

``But no language should allow stupid mistakes like buffer overruns or
undetected array overflows. ''


debugging, and using testing.


They are only mistakes when the careless C programmer is using them in
incorrect situations.
I myself, have never had a problem with buffer overflows. You might find
yourself fall afoul to this issue if you haven't given the algorithm for
solving a problem, some actual thought.

so true


``Geodesic claims 99% of all PC programs (most written in C and C++ of
course) have memory leaks, all caused by poor use of malloc() and free().''
And of what percentage is this done by the careless programmer? I wouldn't
be surprised if careless programmers counted for the majority. But he just
fails to hint at that because it wouldn't make his poor point.

if a delphi news group, i had seen a similar type of critisism<spelling>
and like you say it was the programmer fault, his code was shotty, and
hard to follow, and this particular person had mem leaks, and process
leaks(cpu maxing out).
 
J

j

Fao said:
A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author. I also find it
hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

See what you think:

http://www.embedded.com
showArticle.jhtml;jsessionid=4DOBHEJ2YZUKUQSNDBCSKHQ?articleID=15306089

Sean

``C, the most popular of all embedded languages, is an utter disaster, a
bizarre hodgepodge meant to give the programmer far too much control over
the computer.''

Too much of what he says is aimed around miniscule problems that clueless C
programmers can fall into.
Oh, I can dereference a null pointer, I don't have to get a diagnostic for
doing so, that is right. But only a beginner would so. And as such, such a
novice shouldn't be using the language for _any_ serious development until
they have actually understood the language. I really don't see the logic.
(Using a chainsaw as an example after reading Richard Heathfield's post) I
can walk around with a chainsaw and cut people up with it, but does this
mean that I should? And because I can do this, does it make a chainsaw a
crappy tool?

Understanding the semantics of C is not something that will be achieved in
21 days, 24 hours, or what have you. What does this guy want? Does he
actually want to learn the pitfalls of C so he knows what to avoid and to
better himself as a programmer in C or does he want to be able to use a
language which is completely faultless? Oh, perhaps he would like to design
such a language that is entirely faultless. I think his criticisms are
extremely poor and could be concluded by anyone that say, finished reading
``Teach Yourself C In 21 Days".


``But no language should allow stupid mistakes like buffer overruns or
undetected array overflows. ''

They are only mistakes when the careless C programmer is using them in
incorrect situations.
I myself, have never had a problem with buffer overflows. You might find
yourself fall afoul to this issue if you haven't given the algorithm for
solving a problem, some actual thought.

buffer overflows, heap overflows, double frees', one byte overflows/frame
pointer overwrite, integer overflows; If you fall afoul to any of these,
that is the problem of the bloody careless programmer, not the language.

``Geodesic claims 99% of all PC programs (most written in C and C++ of
course) have memory leaks, all caused by poor use of malloc() and free().''

And of what percentage is this done by the careless programmer? I wouldn't
be surprised if careless programmers counted for the majority. But he just
fails to hint at that because it wouldn't make his poor point.

``Here's a C hint that will improve your job security: embrace double
indirection. Even better, try triple. Real programmers use quadruple. The
only limit to the number of asterisks placed in front of a pointer is the
size of one's cojones or how adventurous you feel. ''

Another poor criticism. Again, who would use excessive indirection
constantly? If not for an ioccc entry then I would say a beginner. But then,
the only people fooled by this article would be beginners of C.

``Even something as simple as integer math produces unexpected results:
20,000 + 20,000 is (ta-da) a negative number. Is this cool or what! ''

He could achieve proper results with the 'U' suffix to denote an integer
constant of unsigned int, is that cool or what! But whose fault is that?
Certainly not the language's.

``C has no formatting rules. It's easy and usual to write source in
astonishingly cryptic ways. Any language that allows utterly random use of
the ENTER key (it's perfectly legit to hit ENTER after almost every
character in C) is more an encryption tool than an aid to creating reliable
and maintainable code. ''

You would have to be a complete retard to not be able to format your code
correctly. This is _another_ poor criticism.

``No other language has an obfuscated code contest. Win by writing code that
works but that's so convoluted no C expert can understand why. Most of the
entries look like a two year old hit a few thousand random keys. And no, I'm
not putting the URL of the contest here; these people are code terrorists
who should be hunted down and shot. ''

Complete drivel. These contests are done only for fun. No serious
applications are being developed.

``A great programming language should encourage users to create perfect
code.''

He should define ``perfect''. This of course is something based on ones
ideological reasoning.
I personally think one can achieve ``perfect''(robust, flawless) code in C
by undertsanding its pitfalls.
 
J

jacob navia

Malcolm said:
There's a case for garbage collection, but why not just use C++ and the
standard template library if you want a higher-level langauge?

Because C++ suffers from obesity. Too complex for a human mind.
There is no 100% compliant compiler for C++ besides Comeau C++ and the
EDG front end.
 
J

James Antill

You have to limit what the programmer can do to avoid mistakes. This is a bad conclusion from real
facts like the difficulty of using correctly malloc and free.

I proposed garbage collection as the means of solving this. GC allows you to avoid
malloc and free. See http://www.cs.virginia.edu/~lcc-win32.

Boehm GC has been around a _long_ time for C programs that want it.
Another real fact is the primitive string type in C and the absence of bounds
checking of arrays, specially strings. The use of a bounded array type is long
overdue and C will continue to have critics that will point out this defficiency in the
language as long as no solution is proposed by the standard.

It is a pity that we go on with a badly conceived data type. Bounded strings would
be really a bonus for the language. We are in the final phase of releasing a string
package for the above implementation.

Oh, another one. See http://www.and.org/vstr/comparison.html ... I'm
pretty sure your implementation has been tried and tested before.
Bounded strings are much faster than traditional strings. The strlen() function
is just a memory read: you just access the "size" field.

Other functions like strcat and others can be implemented *much* faster and
without any buffer overflows.

The whole package is easier to do with the garbage collector.

I doubt that, I have implemented (and many others have too) a nice string
API without having to resort to not implement resource deallocation.
 
J

Jarno A Wuolijoki

Is this one of them? ;-)

Sounds quite credible to me. Besides, a quick googling shows that
the survey has even been performed several times:

"42.7 percent of all statistics are made up on the spot"
"78 percent of all statistics are made up on the spot"
"73 percent of all statistics are made up."
"78.6 percent of all statistics are made up on the spot."
"83 percent of all statistics are made up on the spot."
"47.62 percent of all statistics are made up on the spot?"
"88.2% of statistics are made up on the spot"
"33% of statistics are made up"
 
M

Morris Dovey

A guy at http://www.embedded.com gave his opinion on the C
language and I was shocked to see the number of supporters for
the author. I also find it hard to believe that 99% of all
code has memory leaks; but, I suppose I could be wrong.

Jack Ganssle wrote:

"A great programming language should encourage users to create
perfect code. It must bound our options, limit our freedom,
remove the degrees of freedom that lead to stupid bugs."

Mr Ganssle presents an interesting viewpoint. I was attracted to
C precisely because I saw the language as a tool that would
expand my options and set me free to explore new solution
methodologies /without/ having to spend 90% of my time and effort
defeating the 'safeguards' that prevented getting the job done.
I've continued using the language because it has been the best
(for project- and task-specific definitions of /best/) for nearly
all of my projects for more than twenty years.

If Mr. Ganssle has a need for a language with Ada-like
characteristics, then he should probably /use/ Ada to satisfy his
needs. To me his complaints are comparable to a whining about how
his cat doesn't bark when there's a stranger at the door.

[Sorry, Jack - stupidity hath no remedy.]
 
P

pete

``Even something as simple as integer math produces unexpected
results: 20,000 + 20,000 is (ta-da) a negative number.
Is this cool or what! ''

(20000 + 20000) is not a portable expression.
If it looks negative, then it's undefined.
He could achieve proper results with the 'U' suffix to
denote an integer constant of unsigned int, is that cool or what!

.... or even the 'L' suffix, if he wants a signed type.

Choosing types with enough precission
to hold the results of operations,
is not an advanced topic in C.
 
S

Sam Hobbs

A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author.  I also find it
hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

The guy is Jack Ganssle. Pretty well respected in the area of embedded
programming.

Interesting to note that he says among other things:
". . . I do like programming in C."
and does not mean it facetiously.

Even the article title: "My Love-Hate Relationship with C" indicates
that he is not opposed to the language.

Also interesting to note that it is not Jack who claims that 99% of
programs have memory leaks, but a company which sells software to help
with such things as memory leaks.

As for the number of people who "agreed" with him, SO WHAT. Surely we
all know that there are lots of people out there who don't like the
features of C -- some of them even offered their own ideas in this
thread.

Sam
 
D

Dan Pop

In said:
A guy at http://www.embedded.com gave his opinion on the C language and I
was shocked to see the number of supporters for the author.  I also find it
hard to believe that 99% of all code has memory leaks; but, I suppose I
could be wrong.

See what you think:

http://www.embedded.com
showArticle.jhtml;jsessionid=4DOBHEJ2YZUKUQSNDBCSKHQ?articleID=15306089

The guy didn't understand a very simple thing: both the strength and the
weakness of the language come from the fact that it was designed to
provide a *thin* abstraction layer over the bare metal. If you want/need
a thicker layer, choosing C is a mistake. That's why nobody's going to
change the fundamental design of C. If you need Ada, use Ada.

Dan
 
A

Arthur J. O'Dwyer

(20000 + 20000) is not a portable expression.
If it looks negative, then it's undefined.

Not at all.

if( (20,000 + 20,000) == (-7,000) )
puts("C sucks!");

;-)

-Arthur
 
J

Joe Wright

Arthur said:
Not at all.

if( (20,000 + 20,000) == (-7,000) )
puts("C sucks!");

;-)
What do you suppose those commas will do? Did you know that ajo is
Spanish for garlic?
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top