Why C is really a bad programming language

S

spinoza1111

Richard Heathfield stumbled on the reason. Because he's reasonably
competent in terms of a low standard, he realized that he had to write
his own string handlers, and he did so. He may have done an acceptable
job. He used Boyer Moore for searching.

But soft: wait a second.

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

Dijkstra said that the good programmer would work at state of the art
applications and not "reinvent the wheel".

In 1986 I got a job doing software for real estate appraisal. I felt
guilty because I spent the first couple of weeks rolling string
handlers. I now believe this is unethical behavior and malpractice,
today, if it wasn't then.

Even if you wrote the handlers long ago, you're still forcing the
customer to use proprietary approaches that may fail. Richard says his
string handlers work with EBCDIC, but hasn't told me how he would test
this assertion, since the only hardware that supports EBCDIC is IBM
big iron.

I wrote a big library for old Visual Basic to replicate functionality
I'd learned in Rexx including finding blank delimited words. I now
think this was, in Shakespeare's words, a waste of spirit in an
expense of shame.

Don't use C. It doesn't make you clever and studly any more than wine
makes Mummy clever.
 
T

Thomas Matthews

spinoza1111 said:
Richard Heathfield stumbled on the reason. Because he's reasonably
competent in terms of a low standard, he realized that he had to write
his own string handlers, and he did so. He may have done an acceptable
job. He used Boyer Moore for searching.

But soft: wait a second.

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

Way back in historic times, there were few languages available that
could manipulate text, port to different platforms and provide access
to low level features.

As people like to improve things and find evil in the current ways,
other languages came along that contained support for "strings".

Other people liked the C language and decided to make libraries
to correct its flaws.

Many applications don't use strings. Take the embedded world for
example. Many embedded applications never see a UI so never need
to handle strings (save for exception debugging techniques).

Dijkstra said that the good programmer would work at state of the art
applications and not "reinvent the wheel".

In 1986 I got a job doing software for real estate appraisal. I felt
guilty because I spent the first couple of weeks rolling string
handlers. I now believe this is unethical behavior and malpractice,
today, if it wasn't then.

Perhaps you chose the wrong language or the company chose the
wrong language. SNOBOL is a nice text processing language.

Even if you wrote the handlers long ago, you're still forcing the
customer to use proprietary approaches that may fail. Richard says his
string handlers work with EBCDIC, but hasn't told me how he would test
this assertion, since the only hardware that supports EBCDIC is IBM
big iron.

One can test EBCDIC without running on an IBM old machine.
Investigate Test platforms, such as CPPUNIT and JUNIT frameworks.

I wrote a big library for old Visual Basic to replicate functionality
I'd learned in Rexx including finding blank delimited words. I now
think this was, in Shakespeare's words, a waste of spirit in an
expense of shame.

One of my hatreds of BASIC (it is an acronym) is that there is no
standard. Microsoft has bastardized basic into Visual Basic and
keeps changing the rules of the language.

At one company I worked with, they couldn't upgrade to the latest
VB without rewriting all of their existing code.
Don't use C. It doesn't make you clever and studly any more than wine
makes Mummy clever.
Since when do any languages, computer or verbal, every make anyone
studly or clever?

As you may not have learned by now, you choose a language based
on the project. Some of the considerations are development
correctness, schedule, resources that know the language, and its
productivity. Very few organizations write huge projects in
assembly; simply because of the productivity level.

If your stuck with a language that offers too many ways to
shoot yourself in the foot, become disciplined and write
better code and document what you do.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
C

Chris Dollin

spinoza1111 said:
Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

(a) strings may not be in the application domain.

(b) one may be writing the string support.

(c) support for strings may be subsumed into support for sequences
(and string literals).

(d) C /does/ support strings. Support does't imply perfection.
 
N

Nick Keighley

On 31 July, 07:49, Thomas Matthews

One of my hatreds of BASIC (it is an acronym) is that there is no
standard.  Microsoft has bastardized basic into Visual Basic and
keeps changing the rules of the language.

this is hardly confined to Microsoft...
At one company I worked with, they couldn't upgrade to the latest
VB without rewriting all of their existing code.

<snip>

this isn't confined to Basic, I have a C++ application that faces the
same
problem.
 
L

luserXtrog

Richard Heathfield stumbled on the reason. Because he's reasonably
competent in terms of a low standard, he realized that he had to write
his own string handlers, and he did so. He may have done an acceptable
job. He used Boyer Moore for searching.

But soft: wait a second.

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

Dijkstra said that the good programmer would work at state of the art
applications and not "reinvent the wheel".

In 1986 I got a job doing software for real estate appraisal. I felt
guilty because I spent the first couple of weeks rolling string
handlers. I now believe this is unethical behavior and malpractice,
today, if it wasn't then.

Even if you wrote the handlers long ago, you're still forcing the
customer to use proprietary approaches that may fail. Richard says his
string handlers work with EBCDIC, but hasn't told me how he would test
this assertion, since the only hardware that supports EBCDIC is IBM
big iron.

I wrote a big library for old Visual Basic to replicate functionality
I'd learned in Rexx including finding blank delimited words. I now
think this was, in Shakespeare's words, a waste of spirit in an
expense of shame.

Don't use C. It doesn't make you clever and studly any more than wine
makes Mummy clever.

Alright, fine. We all agree to abandon both C and this newsgroup.
You first.
 
N

Nick Keighley

Richard Heathfield stumbled on the reason.

Could you and Richard bugger off to your own news group to fight your
private war?

Dijkstra said that the good programmer would work at state of the art
applications and not "reinvent the wheel".

Did Dijkstra *really* say this? I always thought his command of the
english language was pretty good.
 
G

gwowen

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

Hi Han,

The reason I use C despite its lousy string handling, is that the
applications I write don't require good string handling. 99.9% of
the strings I use occur in printf(), telling me how the numerical
calculation is progressing. NULL terminated strings work great for
this.

I can't use Fortran, as there is no Fortran expertise in the company.
I can't use C++[0], because C++ doesn't have "restrict", and
"restrict"
allows the compiler to use SIMD instructions without me having to hand
code them.

There are plenty of interesting programs that don't do complicated
string handling.

Peace Out

[0] Actually, I do use C++ for the 0.1% of non-trivial string stuff.
It is ridiculously easy to call these C++ routines from C, which
is another positive point for C.
 
M

Mark Storkamp

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

Most of my programs are in gcode. The only place you can use strings
there is in the comments. Are you suggesting that there would be a
better language for me to use just because it has no concept of strings?
I'll use awk when appropriate, and c when it fits the task.

Just as I wouldn't throw out a hammer just because it doesn't drive
screws, I'll keep c in my tool box too.
 
S

spinoza1111

(a) strings may not be in the application domain.

No error messages on some little microcontroller? And this should
control all other applications? Why do programmers, working on
automating chip shops, chop shops, Chinese restaurants and turf
accountants, always want to code as if they are controlling phallic
symbols? Is it some sort of Walter Mitty fantasy? And why do
programmers hate language? I coded overlays before most of you sprats
were born to be able to associate error numbers with English
explanations on an 8K mainframe ergo I think this is B.S.
(b) one may be writing the string support.

Yes, we seem to be always reinventing the wheel in C. But never mind,
it's a great language, right?
(c) support for strings may be subsumed into support for sequences
    (and string literals).

(d) C /does/ support strings. Support does't imply perfection.

Good enough for government work?
 
S

spinoza1111

Could you and Richard bugger off to your own news group to fight your
private war?


Did Dijkstra *really* say this? I always thought his command of the
english language was pretty good.

It was better than yours, as mine is. You know, "english" isn't a
common noun.
 
S

spinoza1111

Thomas Matthews said:



True enough. But of course one can test it on IBM big iron if that
happens to be available. (I speak as one who has written and tested a
great deal of C code on IBM mainframes.)



And that's one of the huge advantages of C - as long as your code and
the implementation both conform to the Standard, you're home and dry.

Wow! No need to debug! Kewl!
 
S

spinoza1111

Most of my programs are in gcode. The only place you can use strings
there is in the comments. Are you suggesting that there would be a
better language for me to use just because it has no concept of strings?
I'll use awk when appropriate, and c when it fits the task.

Most programmers, apart from the truly competent (who are few and far
between), hate language. They don't read much apart from technical
stuff and the sports pages. They fantasize a world of silence without
texts, and having no string handling suits them fine.

As a result, FBI agents working on terrorist leads prior to 7-11 were
not able to query data bases prior to 9-11 using Boolean queries. As a
result, a language with deficient string handling is destroying the
lives of Iraq veterans who have to wait months for care while "MUMPS"
drops their records on the floor. As a result, name and address
information was dropped by bank programmers from bundles and tranches
of securitized mortgages: when borrowers stopped making payments, the
value of securitized mortgages went to zero and the Panic of 2008, as
well as the Depression of 2009...? resulted.

Oh, am I being off-topic? Or am I stating An Inconvenient Truth?

We'll find out soon enough. We'll find out in 2038 when C's date
representation runs out of gas, if not before.
 
S

spinoza1111

Could you and Richard bugger off to your own news group to fight your
private war?


Did Dijkstra *really* say this? I always thought his command of the
english language was pretty good.

--
Nick Keighley

The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offense. -E. W. Dijkstra

Modern Cobol is BETTER than C, standard or otherwise.
 
N

Nobody

But soft: wait a second.

Why on EARTH would anyone EVER use a language for applications or even
hard core programming that does not support strings?

What is a string? A sequence of bytes? Or a sequence of "characters"
(however you want to define that term; a Unicode codepoint isn't
necessarily a character either).

Are strings mutable? If a is a string, does a=b "clone" the underlying
data or just copy the reference? What is the time complexity for inserting
and deleting characters? Is it the same at the beginning, end, and middle
of the string? What is the time complexity for retrieving the nth
character (it won't be O(1) if the strings are e.g. bytes in UTF-8 but you
want the nth Unicode character).

If you concatenate strings to create a new string without destroying the
existing strings, where does the memory come from? stack? malloc()? Who is
responsible for freeing the memory?

Sure, a high-level language which treats strings as primitive objects and
handles memory (de)allocation automatically will be lot simpler to code
in. Chances are it will also be significantly less efficient.
 
M

Mark Storkamp

spinoza1111 said:
Most programmers, apart from the truly competent (who are few and far
between), hate language. They don't read much apart from technical
stuff and the sports pages. They fantasize a world of silence without
texts, and having no string handling suits them fine.

As a result, FBI agents working on terrorist leads prior to 7-11 were
not able to query data bases prior to 9-11 using Boolean queries. As a
result, a language with deficient string handling is destroying the
lives of Iraq veterans who have to wait months for care while "MUMPS"
drops their records on the floor. As a result, name and address
information was dropped by bank programmers from bundles and tranches
of securitized mortgages: when borrowers stopped making payments, the
value of securitized mortgages went to zero and the Panic of 2008, as
well as the Depression of 2009...? resulted.

Oh, am I being off-topic? Or am I stating An Inconvenient Truth?

Off-topic I have no problem with. Rambling is another issue altogether.
You quoted me as if to respond to my comments. Just what is your point?
Broaden your viewpoint a bit to realize that not every application, or
field, requires string handling. Nearly 100% of what I do (programming
in gcode) has absolutely no use for strings. You asked "Why on EARTH
would anyone EVER use a language for [...] hard core programming that
does not support strings?" I tried to answer that. I make my living
writing programs that don't use strings.

I sometimes wish C had matrices and complex numbers, too. But it
doesn't. Oh well. There are other languages that do.

Coming from an assembly language background, I found C to be quite an
improvement over masm. If it doesn't suit you, go write something that
does. (But what language would you choose to write it in so it can be
ported to the most environments?)
 
J

jameskuyper

Mark Storkamp wrote:
....
I sometimes wish C had matrices and complex numbers, too. But it
doesn't. Oh well. There are other languages that do.

C99, for example.
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top