 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ray Konopka Guest
|
Posted: Mon May 22, 2006 10:14 pm Post subject: eWeek: "Save Me from Cleverness" - One more reason I love D |
|
|
Hi All,
Peter Coffee's "Save Me from Cleverness" (May 15, 2006) is another
great example of why I love Delphi.
http://www.eweek.com/article2/0,1895,1959854,00.asp
Although the article does not specifically mention Delphi, it does
speak volumes regarding the tersness of the C family of languages
and the impact of cleverness in programming. Some highlights
of the article are:
"In the case of the recently discovered X Window flaw, the
missing marks were a pair of parentheses, creating a classic
case of the machine doing exactly what it was told instead
of what was wanted. In two places where the code should
have said "geteuid()" (call function "geteuid" with no
arguments and return the result), there instead appeared
"geteuid" (return the memory location of the "geteuid" code)."
"The error would have been caught if the C programming
language distinguished between the concepts of zero (a number)
and null (absence of a value), but it does not. The convenience
of using "0" for both, and the cleverness of letting a function's
name serve as both verb of invocation and noun of code
location, are defining features of the C language-of which
cleverness critic Kernighan, ironically, was one of the
main designers."
"Another good rule to remember is that most code will be written
only once but read many times, and that it's more important for
a language to be easy to read without ambiguity than to be
easy to write with few keystrokes."
Of course, developers can also be "clever" in Delphi as well. What is
surprising is that over the past few years the term clever has lost its
positive connotation (with respect to programming) and whenever I
hear the term used when reviewing code, red flags shoot up immediately :)
Ray |
|
| Back to top |
|
 |
Jerry Hayes Guest
|
Posted: Mon May 22, 2006 11:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
my favorite snippet from the article:
Programming guru Brian Kernighan has famously said that debugging code is
twice as difficult as writing it-and, he said, it follows that, "If you
write the code as cleverly as possible, you are, by definition, not smart
enough to debug it." |
|
| Back to top |
|
 |
Matt Jacobs Guest
|
Posted: Mon May 22, 2006 11:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Ray Konopka" <rkonopka (AT) raize (DOT) com> wrote:
| Quote: | "The error would have been caught if the C programming
language distinguished between the concepts of zero (a number)
and null (absence of a value), but it does not. The convenience
of using "0" for both, and the cleverness of letting a function's
name serve as both verb of invocation and noun of code
location, are defining features of the C language-of which
cleverness critic Kernighan, ironically, was one of the
main designers."
|
C is often referred to as a high-level assembly language, so following
in that vein, NULL as zero, and the ability to interchange them, makes
sense. All it means is programmers have to be diligent -- an attribute
that appears to be missing in many programmers today. |
|
| Back to top |
|
 |
Roger Lascelles Guest
|
Posted: Tue May 23, 2006 12:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Matt Jacobs" <noyb (AT) noyb (DOT) com> wrote in message
news:nne472lah17rsic5865k7rdrc5t7adnus4 (AT) 4ax (DOT) com...
| Quote: | C is often referred to as a high-level assembly language, so following
in that vein, NULL as zero, and the ability to interchange them, makes
sense. All it means is programmers have to be diligent -- an attribute
that appears to be missing in many programmers today.
|
There is no good reason for NULL to be written as the number zero - the
representation of NULL in the machine varies between CPUs and is not always
a row of cleared bits.
The argument for clearer languages is that even diligent programmers make
mistakes.
I don't accept that a language which works at a low level has to be as badly
designed as C is.
I do accept than some people are more productive in C than others.
Roger Lascelles |
|
| Back to top |
|
 |
Mr. John A. Jackson Guest
|
Posted: Tue May 23, 2006 3:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
Another way of putting it: "Save Me from Coding Cute".
"Ray Konopka" <rkonopka (AT) raize (DOT) com> wrote in message
news:447231e8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi All,
Peter Coffee's "Save Me from Cleverness" (May 15, 2006) is another
great example of why I love Delphi.
http://www.eweek.com/article2/0,1895,1959854,00.asp
Although the article does not specifically mention Delphi, it does
speak volumes regarding the tersness of the C family of languages
and the impact of cleverness in programming. Some highlights
of the article are:
"In the case of the recently discovered X Window flaw, the
missing marks were a pair of parentheses, creating a classic
case of the machine doing exactly what it was told instead
of what was wanted. In two places where the code should
have said "geteuid()" (call function "geteuid" with no
arguments and return the result), there instead appeared
"geteuid" (return the memory location of the "geteuid" code)."
"The error would have been caught if the C programming
language distinguished between the concepts of zero (a number)
and null (absence of a value), but it does not. The convenience
of using "0" for both, and the cleverness of letting a function's
name serve as both verb of invocation and noun of code
location, are defining features of the C language-of which
cleverness critic Kernighan, ironically, was one of the
main designers."
"Another good rule to remember is that most code will be written
only once but read many times, and that it's more important for
a language to be easy to read without ambiguity than to be
easy to write with few keystrokes."
Of course, developers can also be "clever" in Delphi as well. What is
surprising is that over the past few years the term clever has lost its
positive connotation (with respect to programming) and whenever I
hear the term used when reviewing code, red flags shoot up immediately :)
Ray
|
|
|
| Back to top |
|
 |
Matt Jacobs Guest
|
Posted: Tue May 23, 2006 8:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Roger Lascelles" <rogerlasAToptusnet.com.au> wrote:
| Quote: |
"Matt Jacobs" <noyb (AT) noyb (DOT) com> wrote in message
news:nne472lah17rsic5865k7rdrc5t7adnus4 (AT) 4ax (DOT) com...
C is often referred to as a high-level assembly language, so following
in that vein, NULL as zero, and the ability to interchange them, makes
sense. All it means is programmers have to be diligent -- an attribute
that appears to be missing in many programmers today.
There is no good reason for NULL to be written as the number zero - the
representation of NULL in the machine varies between CPUs and is not always
a row of cleared bits.
|
You mean it varies by C compiler.
| Quote: | The argument for clearer languages is that even diligent programmers make
mistakes.
I don't accept that a language which works at a low level has to be as badly
designed as C is.
|
What's so bad about C?
| Quote: | I do accept than some people are more productive in C than others.
|
Brevity has value too. <g> |
|
| Back to top |
|
 |
Relaxin Guest
|
Posted: Tue May 23, 2006 10:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Mr. John A. Jackson" <j> wrote in message
news:447273fa (AT) newsgroups (DOT) borland.com...
| Quote: | Another way of putting it: "Save Me from Coding Cute".
|
or "Save me from having to think". |
|
| Back to top |
|
 |
Relaxin Guest
|
Posted: Tue May 23, 2006 10:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Matt Jacobs" <noyb (AT) noyb (DOT) com> wrote in message
news:nne472lah17rsic5865k7rdrc5t7adnus4 (AT) 4ax (DOT) com...
| Quote: | "Ray Konopka" <rkonopka (AT) raize (DOT) com> wrote:
C is often referred to as a high-level assembly language, so following
in that vein, NULL as zero, and the ability to interchange them, makes
sense. All it means is programmers have to be diligent -- an attribute
that appears to be missing in many programmers today.
|
I agree, also he (the author) fails to mention that 0 (zero) is NULL only
when referenced as a string (char array), not when referred to as a number. |
|
| Back to top |
|
 |
Eric Grange Guest
|
Posted: Tue May 23, 2006 10:14 am Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
| Quote: | C is often referred to as a high-level assembly language
|
In assembly however, there is no risk of mixing up a function call and a
retrieval of a function address by merely forgetting two characters...
Being bested by ASM on code clarity is nothing to be proud of ;)
Eric |
|
| Back to top |
|
 |
Roger Lascelles Guest
|
Posted: Tue May 23, 2006 12:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Mr. John A. Jackson" <j> wrote in message
news:447273fa (AT) newsgroups (DOT) borland.com...
| Quote: | Another way of putting it: "Save Me from Coding Cute".
|
So true. C is a pack of cute tricks from top to bottom. The brainchild of
very smart people, but a toy.
Roger Lascelles |
|
| Back to top |
|
 |
Brad White Guest
|
Posted: Tue May 23, 2006 2:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Eric Grange" <egrangeNO (AT) SPAMglscene (DOT) org> wrote in message
news:4472dc02 (AT) newsgroups (DOT) borland.com...
| Quote: | C is often referred to as a high-level assembly language
In assembly however, there is no risk of mixing up a function call and a
retrieval of a function address by merely forgetting two characters...
Being bested by ASM on code clarity is nothing to be proud of ;)
|
Touche.
--
Brad. |
|
| Back to top |
|
 |
Jon Shemitz Guest
|
Posted: Tue May 23, 2006 4:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
Roger Lascelles wrote:
Pretty ridiculous statement, considering the amount of industrial
strength code written in C and C-like languages. An antiquated design,
with too many sharp edges, maybe - but certainly not a toy.
--
..NET 2.0 for Delphi Programmers <http://www.midnightbeach.com/.net>
Delphi skills make .NET easy to learn
Being printed - in stores by June |
|
| Back to top |
|
 |
Dave Moore Guest
|
Posted: Tue May 23, 2006 5:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
"Roger Lascelles" <rogerlasAToptusnet.com.au> wrote in message
news:4472f022 (AT) newsgroups (DOT) borland.com...
| Quote: | "Mr. John A. Jackson" <j> wrote in message
news:447273fa (AT) newsgroups (DOT) borland.com...
Another way of putting it: "Save Me from Coding Cute".
So true. C is a pack of cute tricks from top to bottom. The brainchild
of
very smart people, but a toy.
Roger Lascelles
|
It's not a toy, it's *extremely* powerful. But it *is* akin to driving a
Rally Car - it will get you where you are going but the sharp steering,
horrible suspension and powerful engine will cause you no end of grief if
you are not careful.
Whereas Delphi is more of a Jaguar - sleek, powerful *and* comfortable, and
will get you where you are going in *style*.
Best,
Dave |
|
| Back to top |
|
 |
Mike Swaim Guest
|
Posted: Tue May 23, 2006 5:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lov |
|
|
Matt Jacobs wrote:
| Quote: | "Roger Lascelles" <rogerlasAToptusnet.com.au> wrote:
There is no good reason for NULL to be written as the number zero -
the representation of NULL in the machine varies between CPUs and
is not always a row of cleared bits.
You mean it varies by C compiler.
|
No, it can vary by CPU. IIRC there are machines that'll object to an
address that's all 0s, even if you don't dereference it.
--
Mike Swaim swaim@hal-pc.org at home | Quote: "Boingie"^4 Y,W & D
MD Anderson Dept. of Biostatistics & Applied Mathematics
mpswaim (AT) mdanderson (DOT) org or mswaim (AT) odin (DOT) mdacc.tmc.edu at work
ICBM: 29.763N 95.363W|Disclaimer: Yeah, like I speak for MD Anderson. |
|
| Back to top |
|
 |
Mark A. Andrews Guest
|
Posted: Tue May 23, 2006 7:14 pm Post subject: Re: eWeek: "Save Me from Cleverness" - One more reason I lo |
|
|
Relaxin wrote:
| Quote: |
or "Save me from having to think".
|
or "Save me from having to juggle 37 balls when the compiler can assist
me in doing so unless I *want* do it myself".
I'm sure the person who wrote the code in X was thinking. However, being
human, he simply made a mistake.
When working on a several million line program (or even several thousand
line program) I want all the compiler assistance I can get.
I'll take the compiler saying "Hey, you might want to take a look at
this..." or "I'm not going to let this pass unless you explicitly tell
me to do so" over "Whatever you want boss" any day of the week.
Mark |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|