Hi all,
Is there any mnemonic for remembering C precedence rules????
I have just coined the word TUBSREBLCAC
where T --- top level operators
U ---- unary operators
B ----- binary operators
S ------ shift operators
R------- relational operators
E ------ equality operators
B ------- bitwise operators
L ------- logical operators
C ----- conditional operators
A ----- assignment operators
C ------ comma operator
how good is this mnemonic
or is there any simple mnemonic such as
"How I want a sweetened drink of course after the heavy lectures
involving quantum mechanics" which is mainly used by math pros for
remembering Pi value(3.14195265358979) 60 3764
Operator precedence is nothing like pi.
Practice, and it will come naturally which is higher/lower. vi****************@gmail.com wrote:
Operator precedence is nothing like pi.
Practice, and it will come naturally which is higher/lower.
Context?
--
Ian Collins.
On Thu, 01 Nov 2007 19:18:41 -0000, aa*****@gmail.com wrote:
>Hi all,
Is there any mnemonic for remembering C precedence rules????
Here's the one I use:
"If in doubt, use parentheses."
--
Al Balmer
Sun City, AZ
On Nov 1, 3:18 pm, aark...@gmail.com wrote:
Hi all,
Is there any mnemonic for remembering C precedence rules????
Use parentheses and it's impossible to forget the precedence
rules. :-)
I have just coined the word TUBSREBLCAC
where T --- top level operators
U ---- unary operators
B ----- binary operators
S ------ shift operators
R------- relational operators
E ------ equality operators
B ------- bitwise operators
L ------- logical operators
C ----- conditional operators
A ----- assignment operators
C ------ comma operator
how good is this mnemonic
I think I'll just stick to parens and not even try to remember that
mess of characters.
-Jul
Parentheses can be annoying and useless in code.
The solution is to learn operator precedence.
On Nov 1, 4:43 pm, vipvipvipvipvip...@gmail.com wrote:
Parentheses can be annoying and useless in code.
They can be, if you use them abusively. On the other hand, *lack* of
parentheses can be annoying and useless in code for the same reason.
The solution is to learn operator precedence.
Perhaps *you* have perfect memory, but *I* don't. I'd rather remember
a simple guideline than a slew of rules, because to be perfectly
frank, I have better things to spend my few remaining brain cells
on. :-) vi****************@gmail.com wrote On 11/01/07 16:43,:
Parentheses can be annoying and useless in code.
The solution is to learn operator precedence.
... and to teach the rules to everyone who will ever
read your code, which I think you'll agree is a bit of
a chore.
Even if Joe Coder knows the precedence rules perfectly
and can parse
if ( a && b | c && d )
without blinking, he may still wonder whether *you* were
entirely familiar with the rules: He knows perfectly well
what's being tested, but how can he be sure it's what you
intended to test? Did you really mean what you wrote, or
was it a typo? A few parentheses to set his mind at rest
are by no means "useless."
For myself, there's also the problem that C's rules
clash with those of some other languages I use or have
used. I recall a time, some years ago, when I worked in
C and Pascal on one project (the data aquisition piece
was in C, and the analysis in Pascal). The conflicting
precedence rules kept tripping me up: I'd write C as if
Pascal's rules applied, or the other way around. So I
formed the habit of using "unnecessary" parentheses -- in
moderation -- to make my intent clear both to the compiler
and to myself. And I've never regretted it.
-- Er*********@sun.com
<vi****************@gmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
Parentheses can be annoying and useless in code.
The solution is to learn operator precedence.
I use the parentheses rule too when in doubt, but when they become too
"annoying" in certain expression, only then I look up the rules in a book or
something to make that expression clearer. No need remembering the
precedence rules by heart
[comp.lang.c] Ian Collins <ia******@hotmail.comwrote: vi****************@gmail.com wrote:
>Operator precedence is nothing like pi.
Context?
>Alice wrote:
>>"One day, I was at the comp.lang.c tea party and someone in a funny hat asked me 'How is operator precedence like pi?', and I was perplexed. Can anyone help?"
(I didn't see the context either.)
--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
Eric Sosman <Er*********@sun.comwrites:
Even if Joe Coder knows the precedence rules perfectly
and can parse
if ( a && b | c && d )
without blinking, he may still wonder whether *you* were
entirely familiar with the rules:
With or without additional parentheses, I'd be inclined to think
that | should be || in the above. (In context, it would probably
be obvious whether | was correct.)
--
"Am I missing something?"
--Dan Pop
On Thu, 1 Nov 2007 22:28:13 +0100, "Serve Lau" <as**@n.tkwrote:
> <vi****************@gmail.comwrote in message news:11**********************@d55g2000hsg.googleg roups.com...
>Parentheses can be annoying and useless in code. The solution is to learn operator precedence.
I use the parentheses rule too when in doubt, but when they become too "annoying" in certain expression, only then I look up the rules in a book or something to make that expression clearer. No need remembering the precedence rules by heart
In such cases, you'd probably be better off studying your code to see
why it appears so complex.
“Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.” – Brian W. Kernighan
--
Al Balmer
Sun City, AZ
Ben Pfaff wrote On 11/01/07 17:48,:
Eric Sosman <Er*********@sun.comwrites:
> Even if Joe Coder knows the precedence rules perfectly and can parse
if ( a && b | c && d )
without blinking, he may still wonder whether *you* were entirely familiar with the rules:
With or without additional parentheses, I'd be inclined to think
that | should be || in the above. (In context, it would probably
be obvious whether | was correct.)
My point is that one would not need to rely on one's
inclinations or suppositions if the author had written
if ( a && (b | c) && d )
or even
if ( a && (b | c) != 0 && d )
As for obviousness: Yes, you can usually figure out
what the code *should* mean, but sometimes the project
becomes as intricate as a CSI episode (and less exciting).
Whenever I've had to spend time deciding that something
was really intended and not a typo, I've added parentheses
or a zero comparison or something of the kind so that the
next person won't have to sleuth it out all over again (and
maybe get it wrong).
Two kinds of readers peruse source code: computers and
people, and the latter are the more important readership.
-- Er*********@sun.com
Eric Sosman <Er*********@sun.comwrites:
Ben Pfaff wrote On 11/01/07 17:48,:
>Eric Sosman <Er*********@sun.comwrites:
>> Even if Joe Coder knows the precedence rules perfectly and can parse
if ( a && b | c && d )
without blinking, he may still wonder whether *you* were entirely familiar with the rules:
With or without additional parentheses, I'd be inclined to think that | should be || in the above. (In context, it would probably be obvious whether | was correct.)
My point is that one would not need to rely on one's
inclinations or suppositions if the author had written
if ( a && (b | c) && d )
or even
if ( a && (b | c) != 0 && d )
To me, your article quoted above raises two points: precedence
and correct choice of operators. I chose to comment on the
latter. In my opinion, the point about precedence could have
been made just as effectively using || instead of |.
As for obviousness: Yes, you can usually figure out
what the code *should* mean, but sometimes the project
becomes as intricate as a CSI episode (and less exciting).
Whenever I've had to spend time deciding that something
was really intended and not a typo, I've added parentheses
or a zero comparison or something of the kind so that the
next person won't have to sleuth it out all over again (and
maybe get it wrong).
Two kinds of readers peruse source code: computers and
people, and the latter are the more important readership.
I heartily agree.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Julienne Walker wrote:
vipvipvipvipvip...@gmail.com wrote:
>Parentheses can be annoying and useless in code.
They can be, if you use them abusively. On the other hand, *lack*
of parentheses can be annoying and useless in code for the same
reason.
>The solution is to learn operator precedence.
Perhaps *you* have perfect memory, but *I* don't. I'd rather
remember a simple guideline than a slew of rules, because to be
perfectly frank, I have better things to spend my few remaining
brain cells on. :-)
I limit my precedence memory to: Multiplicative ops, additive ops,
relational ops. If anything further is needed, make it clear (and
sure) with the appropriate parentheses.
You'ld be surprised how many languages this serves!
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com aa*****@gmail.com wrote:
>
or is there any simple mnemonic such as
"How I want a sweetened drink of course after the heavy lectures
involving quantum mechanics" which is mainly used by math pros for
remembering Pi value(3.14195265358979)
woopsie!
your "sweetened drink" should be "drink sweetened" to make the pi value
come out correctly
Tim
On Nov 1, 10:22 pm, Tim Brown <timbr...@rushmore.comwrote:
aark...@gmail.com wrote:
or is there any simple mnemonic such as
"How I want a sweetened drink of course after the heavy lectures
involving quantum mechanics" which is mainly used by math pros for
remembering Pi value(3.14195265358979)
woopsie!
your "sweetened drink" should be "drink sweetened" to make the pi value
come out correctly
Tim
Okay that's correct ,I quote wrongly aa*****@gmail.com wrote:
On Nov 1, 10:22 pm, Tim Brown <timbr...@rushmore.comwrote:
>aark...@gmail.com wrote:
>>or is there any simple mnemonic such as "How I want a sweetened drink of course after the heavy lectures involving quantum mechanics" which is mainly used by math pros for remembering Pi value(3.14195265358979)
>woopsie!
>your "sweetened drink" should be "drink sweetened" to make the pi value come out correctly
Okay that's correct ,I quote wrongly
So it wasn't that good (or that simple) a mnemonic was it?
Case proven mi'lud. Mnemonics aren't that much help. aa*****@gmail.com wrote:
or is there any simple mnemonic such as
"How I want a sweetened drink
drink, alcoholic
of course after the heavy lectures
chapters
involving quantum mechanics" which is mainly used by math pros for
remembering Pi value(3.14195265358979)
At least that's my recollection, and I attribute it to Sir James Jeans.
(fx:google) I still attribute (and spell) it so.
--
Chris "it stuck for thirty-plus years" Dollin
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
Richard wrote:
[...]
2nd note : if a system crashes I can guarantee that i can debug it to
the point of the crash quicker than you can read and understand 500000
lines of C code and run it through in your head with all possible data
input and come to a guess at where it might crash .....
I can guarantee you, on some systems others will find the bug faster
without a debugger, than you will.
Some of the C code I have written, "cannot" be debugged in production.
The binary is protected by hardware mechanisms, if a trigger goes off,
the current state of the program erased. :)
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Ben Bacarisse <be********@bsb.me.ukwrites:
Everyone know that * binds more tightly than +, so just remember that
&& and & are the Boolean and bit-wise analogues of multiplication
whereas || and | are the analogues of +. I.e. && binds tighter
than || and & beats |. (Many maths notations use AB or A×B to mean A
and B.)
Many programmers prefer to parenthesize uses of && and || that
appear in the same expression, to avoid needing to remember this.
This is what I usually do.
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Keith Thompson <ks***@mib.orgwrites:
"Debugging" doesn't mean "using a debugger".
I'd say that about half of my bugs I find with printf. Another
half, I find with valgrind. Another 5% are made obvious with
"git bisect". The last 10%, I find with a traditional debugger.
--
Ben Pfaff http://benpfaff.org
Ben Pfaff said:
Keith Thompson <ks***@mib.orgwrites:
>"Debugging" doesn't mean "using a debugger".
I'd say that about half of my bugs I find with printf. Another
half, I find with valgrind. Another 5% are made obvious with
"git bisect". The last 10%, I find with a traditional debugger.
Face down, nine edge first?
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Thu, 01 Nov 2007 12:50:58 -0700, Julienne Walker
<ha*********@hotmail.comwrote:
>On Nov 1, 3:18 pm, aark...@gmail.com wrote:
>Hi all,
Is there any mnemonic for remembering C precedence rules????
Use parentheses and it's impossible to forget the precedence rules. :-)
>I have just coined the word TUBSREBLCAC
where T --- top level operators U ---- unary operators B ----- binary operators S ------ shift operators R------- relational operators E ------ equality operators B ------- bitwise operators L ------- logical operators C ----- conditional operators A ----- assignment operators C ------ comma operator
how good is this mnemonic
I think I'll just stick to parens and not even try to remember that mess of characters.
This is the best advice I've seen in this newsgroup in recent memory.
I've come across this type of ambiguous nonsense:
if ( msg->i.xtype & _IO_XTYPE_MASK != _IO_XTYPE_NONE )
It should have been written like this:
if ( (msg->i.xtype & _IO_XTYPE_MASK) != _IO_XTYPE_NONE )
Best regards
--
jay
"Al Balmer" <al******@att.netwrote in message
news:22********************************@4ax.com...
>>I use the parentheses rule too when in doubt, but when they become too "annoying" in certain expression, only then I look up the rules in a book or something to make that expression clearer. No need remembering the precedence rules by heart
In such cases, you'd probably be better off studying your code to see
why it appears so complex.
clear code and complex code are not opposites, if an expression gets too
many parentheses it just looks a bit weird to me. That doesnt mean I find
the expression complex. On top of that, I cant remember getting into trouble
understanding code on a single line/expression. (obfuscated contest code
doesnt count) Complex code has more to do with the total structure and
dependencies on each other.
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
--
Al Balmer
Sun City, AZ
"James Kuyper" <ja*********@verizon.netwrote in message
news:Al%Wi.6919$9N6.487@trnddc03...
That's a weird interpretation! The quote is about debugging, not
debuggers. It's about the importance of writing code so it can be
debugged, which implies that debugging is important too, not that it's
unnecessary.
Who's saying this?
its in this thread.
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
Serve Lau wrote:
"James Kuyper" <ja*********@verizon.netwrote in message
news:Al%Wi.6919$9N6.487@trnddc03...
>That's a weird interpretation! The quote is about debugging, not debuggers. It's about the importance of writing code so it can be debugged, which implies that debugging is important too, not that it's unnecessary.
Who's saying this?
its in this thread.
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
Nope, Kernighan refer to debugging, which is a process not limited to
running a program in a debugger.
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Ben Pfaff wrote:
Keith Thompson <ks***@mib.orgwrites:
>"Debugging" doesn't mean "using a debugger".
I'd say that about half of my bugs I find with printf. Another
half, I find with valgrind. Another 5% are made obvious with
"git bisect". The last 10%, I find with a traditional debugger.
That pretty much matches my experience. Debuggers are
useful when I'm starting from a position of cluelessness,
knowing only the bug's symptom but having no idea about its
cause. (This usually means that I'm debugging a program I
know squat about, or I'm debugging a badly-organized program.)
Debuggers can also be helpful when you've reasoned your way
back to a cause that's really just a symptom of an Ur-cause;
stack traces (something you can't get from C) are very helpful
here.
'course, I'm biased. I started learning to program back
in the days when you handed decks of punched cards through a
window and got them back with a printout some hours later.
Interactive debuggers simply didn't exist, so one was forced
to learn other approaches. The interesting thing is that the
"primitive" techniques are plenty good enough for most bugs;
the more "advanced" tools push the debugging frontier a little
further forward, but not by an extraordinary distance.
--
Eric Sosman es*****@ieee-dot-org.invalid
Tor Rustad <to********@hotmail.comwrites:
Serve Lau wrote:
>"James Kuyper" <ja*********@verizon.netwrote in message news:Al%Wi.6919$9N6.487@trnddc03...
>>That's a weird interpretation! The quote is about debugging, not debuggers. It's about the importance of writing code so it can be debugged, which implies that debugging is important too, not that it's unnecessary.
Who's saying this?
its in this thread.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan
Nope, Kernighan refer to debugging, which is a process not limited to
running a program in a debugger.
Of course it isn't. But it would be fairly ridiculous to suggest that
any form of debugging an existing code base is NOT done with a
"debugger" of some description. People who advocate littering code with
printfs are plain wrong IMO. Yes, it might have its uses occasionally,
but any changing of the code to "debug" is generally considered a bad
thing.
From some of the comments I read here, I often wonder if the people
knocking debuggers have any idea whatsoever of just what they are, how
they work and the results they can achieve.
One of my favorite uses of a debugger is simply to step through code to
get a feel for the control flow. Ability to step over calls and just
examine the returned data etc is much easier than "imagining" it by
reading code no matter how well and clearly that code is written and
annotated.
Serve Lau wrote:
"James Kuyper" <ja*********@verizon.netwrote in message
news:Al%Wi.6919$9N6.487@trnddc03...
>That's a weird interpretation! The quote is about debugging, not debuggers. It's about the importance of writing code so it can be debugged, which implies that debugging is important too, not that it's unnecessary.
Who's saying this?
its in this thread.
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." - Brian W. Kernighan
I wasn't asking who was quoting that statement; I asked who was
misinterpreting it in the fashion that rg****@gmail.com described.
Richard Heathfield <rj*@see.sig.invalidwrites:
Ben Pfaff said:
>Keith Thompson <ks***@mib.orgwrites:
>>"Debugging" doesn't mean "using a debugger".
I'd say that about half of my bugs I find with printf. Another half, I find with valgrind. Another 5% are made obvious with "git bisect". The last 10%, I find with a traditional debugger.
Face down, nine edge first?
I'm not as old as CBFalconer.
--
"All code should be deliberately written for the purposes of instruction.
If your code isn't readable, it isn't finished yet."
--Richard Heathfield
Ben Pfaff wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>Ben Pfaff said:
>>Keith Thompson <ks***@mib.orgwrites:
"Debugging" doesn't mean "using a debugger". I'd say that about half of my bugs I find with printf. Another half, I find with valgrind. Another 5% are made obvious with "git bisect". The last 10%, I find with a traditional debugger.
Face down, nine edge first?
I'm not as old as CBFalconer.
Nobody is. I thought I was but have been convinced otherwise. That RJH
would allude to 'Face down, nine edge first?' makes me wonder how long
in the tooth he is.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
On Sat, 03 Nov 2007 15:28:00 +0100,
Richard <rg****@gmail.comwrote:
>>>>>>?Debugging is twice as hard as writing the code in the first place. >>Therefore, if you write the code as cleverly as possible, you are, by >>definition, not smart enough to debug it.? ? Brian W. Kernighan >This quote is maybe sometimes applicable. But not always.
Again, since there is a trend to try and twist things here : yes, in a
perfect world it would be nice to get the code right the first
time. However, its not always about the code. Its about sets of data
I get the feeling you might have misread the first sentence ofthe quote.
At least you see to be arguing as if it said: "Debugging is twice as hard
as getting the code right int he first place.". rather than what it
really says.
which might cause certain situations which were not considered during
the design and implementation of the code suite. This is where a
debugger is INFINITELY easier than "writing it all from scratch
correctly" since a debugger can be set to trigger during certain data
Again, this leads me to believe you've read something different to
what's actually written..
Martien
--
| All code should be deliberately written for
Martien Verbruggen | the purposes of instruction. If your code
| isn't readable, it isn't finished yet.
| --Richard Heathfield
On Sat, 03 Nov 2007 15:28:00 +0100,
Richard <rg****@gmail.comwrote:
>>>>>>?Debugging is twice as hard as writing the code in the first place. >>Therefore, if you write the code as cleverly as possible, you are, by >>definition, not smart enough to debug it.? ? Brian W. Kernighan >This quote is maybe sometimes applicable. But not always.
Again, since there is a trend to try and twist things here : yes, in a
perfect world it would be nice to get the code right the first
time. However, its not always about the code. Its about sets of data
I get the feeling you might have misread the first sentence of the quote.
At least you seem to be arguing as if it said: "Debugging is twice as hard
as getting the code right in the first place.", rather than what it
really says.
which might cause certain situations which were not considered during
the design and implementation of the code suite. This is where a
debugger is INFINITELY easier than "writing it all from scratch
correctly" since a debugger can be set to trigger during certain data
Again, this leads me to believe you've read something different to
what's actually written.
Martien
--
| All code should be deliberately written for
Martien Verbruggen | the purposes of instruction. If your code
| isn't readable, it isn't finished yet.
| --Richard Heathfield
Ben Pfaff wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>Ben Pfaff said:
>>Keith Thompson <ks***@mib.orgwrites:
"Debugging" doesn't mean "using a debugger".
I'd say that about half of my bugs I find with printf. Another half, I find with valgrind. Another 5% are made obvious with "git bisect". The last 10%, I find with a traditional debugger.
Face down, nine edge first?
I'm not as old as CBFalconer.
Who hasn't fired up a debugger in at least two or three years. For
me, printf seems to do the job when combined with head-scratching.
And yes, I am considerably older than the C language.
--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com
Richard wrote:
From some of the comments I read here, I often wonder if the people
knocking debuggers have any idea whatsoever of just what they are, how
they work and the results they can achieve.
We are old. Debugging a 300.000 line monster, wasn't very practical on a
VT100 terminal. Something like 24 lines of code on the screen... so a
program listing was usually nearby.
IDE is nice to have these days, but I mainly use the debugger before the
unit test phase is over. After that, the hard-to-find bugs, are usually
located via other methods.
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Tor Rustad wrote:
Richard wrote:
>From some of the comments I read here, I often wonder if the people knocking debuggers have any idea whatsoever of just what they are, how they work and the results they can achieve.
We are old. Debugging a 300.000 line monster, wasn't very practical on a
VT100 terminal. Something like 24 lines of code on the screen... so a
program listing was usually nearby.
IDE is nice to have these days, but I mainly use the debugger before the
unit test phase is over. After that, the hard-to-find bugs, are usually
located via other methods.
Yeah of course.
True programmers drink beer and use Fortran.
All others are pimps.
Or similar...
Let me present a dissenting view. For me, a debugger is essential.
Without it you can't debug a complex program, isn't it obvious?
A debugger lets you debug a program.
But of course I use a debugger because I have bugs, contrary to
the super heroes in this group that never do any mistake.
I remember a certain Dan Pop that would say that he never had a crash in
his programs... Of course he did not need a debugger then!
jacob navia wrote:
Tor Rustad wrote:
>Richard wrote:
>>From some of the comments I read here, I often wonder if the people knocking debuggers have any idea whatsoever of just what they are, how they work and the results they can achieve.
We are old. Debugging a 300.000 line monster, wasn't very practical on a VT100 terminal. Something like 24 lines of code on the screen... so a program listing was usually nearby.
IDE is nice to have these days, but I mainly use the debugger before the unit test phase is over. After that, the hard-to-find bugs, are usually located via other methods.
Let me present a dissenting view. For me, a debugger is essential.
Without it you can't debug a complex program, isn't it obvious?
A debugger lets you debug a program.
As others mentioned there are other ways to debug a program too.
Debugging is a name given to a collection of strategies for locating
and quashing bugs, one component of which is using a debugger.
Everything from printf to assert to good comments to static source
checkers to compilers to profiling tools to debuggers all have their
part.
The relative applicability of each method to a source code base depends
on many factors, not least of which is the design of the code itself. A
poorly designed program may render some debugging strategies useless.
<snip>
jacob navia wrote:
>
Let me present a dissenting view. For me, a debugger is essential.
Without it you can't debug a complex program, isn't it obvious?
A debugger lets you debug a program.
Maybe you should try using a language without a debugger, it does
wonders for your testing and debugging skills.
C developers are spoilt rotten with decent debuggers, they have their
uses and they are an excellent means of proving the cause of a problem,
but I think overall they blunt rather than sharpen ones skills.
But of course I use a debugger because I have bugs, contrary to
the super heroes in this group that never do any mistake.
We all make mistakes, we just use different strategies for fixing them.
I prefer my unit tests, if I have to use my debugger, I know my tests
are too coarse. A year of PHP development without a debugger taught me
that lesson.
--
Ian Collins.
jacob navia <ja***@jacob.remcomp.frwrites:
Tor Rustad wrote:
>Richard wrote:
>>From some of the comments I read here, I often wonder if the people knocking debuggers have any idea whatsoever of just what they are, how they work and the results they can achieve.
We are old. Debugging a 300.000 line monster, wasn't very practical on a VT100 terminal. Something like 24 lines of code on the screen... so a program listing was usually nearby. IDE is nice to have these days, but I mainly use the debugger before the unit test phase is over. After that, the hard-to-find bugs, are usually located via other methods.
Yeah of course.
True programmers drink beer and use Fortran.
All others are pimps.
Or similar...
Yeah, of course. If a couple of people describe their own personal
experiences and preferences, they must really be saying what all "true
programmers" do. Or maybe they were just speaking for themselves.
Let me present a dissenting view. For me, a debugger is essential.
Without it you can't debug a complex program, isn't it obvious?
A debugger lets you debug a program.
A debugger is one of many tools that can be used to debug a program.
It's certainly possible to debug a complex program without using one.
Debuggers work for you. That's terrific.
But of course I use a debugger because I have bugs, contrary to
the super heroes in this group that never do any mistake.
Your attempts at sarcasm are quite annoying. I don't recall anyone
here claiming that they never make mistakes.
I remember a certain Dan Pop that would say that he never had a crash in
his programs... Of course he did not need a debugger then!
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Ian Collins wrote:
jacob navia wrote:
>Let me present a dissenting view. For me, a debugger is essential. Without it you can't debug a complex program, isn't it obvious? A debugger lets you debug a program.
Maybe you should try using a language without a debugger, it does
wonders for your testing and debugging skills.
Debugging skills have nothing to do with a debugger.
A debugger lets you come quickly to a solution, but to
come to the solution you have to have some debugging
skills.
And this
"Either have debugging skills or use a debugger" is a non-issue.
This things aren't alternatives, and having a debugger doesn't
"spoil" your debugging skills.
C developers are spoilt rotten with decent debuggers, they have their
uses and they are an excellent means of proving the cause of a problem,
but I think overall they blunt rather than sharpen ones skills.
You see?
Sheer nonsense. But go ahead. You do not use a debugger.
>But of course I use a debugger because I have bugs, contrary to the super heroes in this group that never do any mistake.
We all make mistakes, we just use different strategies for fixing them.
I prefer my unit tests, if I have to use my debugger, I know my tests
are too coarse. A year of PHP development without a debugger taught me
that lesson.
Nonsense. Unit tests test each unit separately. They can't test a bad
interaction between two units because a flaw in the design. Each unit
works perfectly well but there is a situation the design did not
foresee.
But obviously only stupid people have flaws in their design and need
a debugger, I hear it coming.
The only thing you gain without a debugger is that you debug MUCH
more slowly.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32
jacob navia wrote:
Ian Collins wrote:
>jacob navia wrote:
>>Let me present a dissenting view. For me, a debugger is essential. Without it you can't debug a complex program, isn't it obvious? A debugger lets you debug a program.
Maybe you should try using a language without a debugger, it does wonders for your testing and debugging skills.
Debugging skills have nothing to do with a debugger.
Which was may point.
>C developers are spoilt rotten with decent debuggers, they have their uses and they are an excellent means of proving the cause of a problem, but I think overall they blunt rather than sharpen ones skills.
You see?
Sheer nonsense. But go ahead. You do not use a debugger.
Who says I don't? But that that use is more as a tool to investigate
legacy code and to confirm a hypothesis. With new code, if a change
breaks a test, just undo it and try again.
>We all make mistakes, we just use different strategies for fixing them. I prefer my unit tests, if I have to use my debugger, I know my tests are too coarse. A year of PHP development without a debugger taught me that lesson.
Nonsense. Unit tests test each unit separately. They can't test a bad
interaction between two units because a flaw in the design. Each unit
works perfectly well but there is a situation the design did not
foresee.
I've never had that problem, units build of what comes before them.
Attempting to mock every other part of a system is seldom a good idea.
>
The only thing you gain without a debugger is that you debug MUCH
more slowly.
Maybe, but you soon learn how to write code with fewer bugs. As I said,
try working without a debugger for a while, you'll be surprised how fast
you can go. There are many in XP circles who firmly believe resorting
to the debugger is a last resort and shows your tests aren't good
enough. My time with PHP showed me they are probably right.
--
Ian Collins.
In data Sat, 03 Nov 2007 01:12:54 +0100, Tor Rustad scrisse:
>Richard wrote:
[...]
>2nd note : if a system crashes I can guarantee that i can debug it to the point of the crash quicker than you can read and understand 500000 lines of C code and run it through in your head with all possible data input and come to a guess at where it might crash .....
I can guarantee you, on some systems others will find the bug faster without a debugger, than you will.
Some of the C code I have written, "cannot" be debugged in production. The binary is protected by hardware mechanisms, if a trigger goes off, the current state of the program erased. :)
in that case if the debugger for the proper assembly is not useful
change language (or rutines)
if a program is not debbuggable in assembly or in the language that
descrive all the states of machine afther each instruction:
that programme (or langugage) is irremidiable bugged because
programmer doesn't know what an easy instruction does
if some of you don't see what i see, some of you is too much young :)
jacob navia wrote:
Ian Collins wrote:
>jacob navia wrote:
>>Let me present a dissenting view. For me, a debugger is essential. Without it you can't debug a complex program, isn't it obvious? A debugger lets you debug a program.
Maybe you should try using a language without a debugger, it does wonders for your testing and debugging skills.
Debugging skills have nothing to do with a debugger.
A debugger lets you come quickly to a solution, but to
come to the solution you have to have some debugging
skills.
A debugger is like any other device; reliance upon the device gives you
less practice with the skills that would be needed to achieve the same
result if the device were unavailable. How important that effect is
depends upon how likely it is that the device might be unavailable. With
respect to debuggers, that depends entirely upon what kind of platforms
you're programming for. There might not be any debugger for some
platforms, or the only debugger might be one that is so different from
what you're used to that it might as well not be available.
If you work exclusively on one or two well-supported platforms, you
might not even notice this problem; that doesn't make the problem any
less real for those who do have to deal with it.
I say this as someone who relies heavily on the debugger when I can, and
relies heavily on inserting fprintf(stderr, ...) when I can't use the
debugger. I usually find both techniques a lot faster than desk checking
(which I also do). If I made a mistake that couldn't be caught by the
compiler when I wrote the code, I usually continue making that same
mistake when I re-read the code.
RoS wrote:
<snip>
Are you "aVb"? If so please don't keep changing pseudonyms. It's rude
behaviour.
On Sat, 3 Nov 2007 12:17:11 +0100, "Serve Lau" <as**@n.tkwrote:
> "Al Balmer" <al******@att.netwrote in message news:22********************************@4ax.com.. .
>>>I use the parentheses rule too when in doubt, but when they become too "annoying" in certain expression, only then I look up the rules in a book or something to make that expression clearer. No need remembering the precedence rules by heart
In such cases, you'd probably be better off studying your code to see why it appears so complex.
clear code and complex code are not opposites, if an expression gets too many parentheses it just looks a bit weird to me. That doesnt mean I find the expression complex. On top of that, I cant remember getting into trouble understanding code on a single line/expression. (obfuscated contest code doesnt count) Complex code has more to do with the total structure and dependencies on each other.
Exactly. That's why the OP should reconsider his coding effort. You
will note that I was commenting on why it *appears* so complex. Overly
complex code is usually a sign of bad design.
>
>"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan
-- Al Balmer Sun City, AZ
--
Al Balmer
Sun City, AZ
jacob navia wrote:
[...]
Let me present a dissenting view. For me, a debugger is essential.
Without it you can't debug a complex program, isn't it obvious?
You are maintaining a compiler right?
I can see why you find a debugger very useful for locating *known
problems*. A compiler, is like a complex batch program, where an error
case is easy to reproduce, just try to compile the same source again.
Now, imagine debugging a kernel module instead, or some other real-time
code, and no, you might not be able to reproduce the error condition in
your test environment.
Or, like I mainly work with, try to track down security bugs, before
anyone out there do.
A debugger lets you debug a program.
Not always, some programs *cannot* be debugged in production.
I can add, some programs, should be tested to death, before shipping.
It's, somewhat difficult to debug mission-critical control system, in
deep space, for example.
But of course I use a debugger because I have bugs, contrary to
the super heroes in this group that never do any mistake.
A debugger isn't always the best tool for the job. How many race
conditions have you tracked down via a debugger?
How could the Therac-25 accidents been avoided? Via a debugger?
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
"¬a\\/b" <al@f.gwrote:
In data Sat, 03 Nov 2007 01:12:54 +0100, Tor Rustad scrisse:
[...]
>Some of the C code I have written, "cannot" be debugged in production. The binary is protected by hardware mechanisms, if a trigger goes off, the current state of the program erased. :)
in that case if the debugger for the proper assembly is not useful
change language (or rutines)
FYI, I was talking about software in a TRSM (Tamper Resistance Security
Module).
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Martien Verbruggen <mg**@tradingpost.com.auwrites:
On Sat, 03 Nov 2007 15:28:00 +0100,
Richard <rg****@gmail.comwrote:
>>>>>>>?Debugging is twice as hard as writing the code in the first place. >>>Therefore, if you write the code as cleverly as possible, you are, by >>>definition, not smart enough to debug it.? ? Brian W. Kernighan >>This quote is maybe sometimes applicable. But not always.
>Again, since there is a trend to try and twist things here : yes, in a perfect world it would be nice to get the code right the first time. However, its not always about the code. Its about sets of data
I get the feeling you might have misread the first sentence ofthe quote.
At least you see to be arguing as if it said: "Debugging is twice as hard
as getting the code right int he first place.". rather than what it
really says.
>which might cause certain situations which were not considered during the design and implementation of the code suite. This is where a debugger is INFINITELY easier than "writing it all from scratch correctly" since a debugger can be set to trigger during certain data
Again, this leads me to believe you've read something different to
what's actually written..
Martien
Again, for the record, its not what I *read* or understood, its about
why and when this quote is trotted out. See other posts.
Tor Rustad <to********@hotmail.comwrites:
jacob navia wrote:
[...]
>Let me present a dissenting view. For me, a debugger is essential. Without it you can't debug a complex program, isn't it obvious?
You are maintaining a compiler right?
I can see why you find a debugger very useful for locating *known
problems*. A compiler, is like a complex batch program, where an error
Surely if its not a "known" problem then its, err, not a problem?
case is easy to reproduce, just try to compile the same source again.
Now, imagine debugging a kernel module instead, or some other
real-time code, and no, you might not be able to reproduce the error
condition in your test environment.
Or, like I mainly work with, try to track down security bugs, before
anyone out there do.
>A debugger lets you debug a program.
Not always, some programs *cannot* be debugged in production.
So what? It doesn't preclude it being useful in 99.999999999% of other
cases. Anyway I have frequently connected a debugger to live systems to
catch errors and certain watch conditions.
>
I can add, some programs, should be tested to death, before
shipping. It's, somewhat difficult to debug mission-critical control
system, in deep space, for example.
And it's not possible to hold your breath for 28 minutes either. I'm not
sure how this point about deep space in anyway takes anything away from
how useful a debugger is in the real world.
>
>But of course I use a debugger because I have bugs, contrary to the super heroes in this group that never do any mistake.
A debugger isn't always the best tool for the job. How many race
conditions have you tracked down via a debugger?
I would not use a debugger to unblock the u-bend under my kitchen sink
either. But I would use it to catch errors in a real world C program ....
>
How could the Therac-25 accidents been avoided? Via a debugger?
And a debugger can not cure AIDs or cancer either. No one said it was
the answer to the worlds problems.
The view of some of the regulars here is quite astonishing and makes me
wonder how many have really worked in Industry on large code bases
maintained by multiple programmers across the world. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jonathan N. Little |
last post by:
When doing a final check on my stylesheets the CSS Validator flag lines
like this one as an error:
ADDRESS A { color: gold; }
Error is:
# Line: 31 Context : ADDRESS A
Invalid number :...
|
by: Lex |
last post by:
I have a c# app that has a OwnerDrawn menu items.
Is there and easy way to use DrawString to draw the underline under
the mnemonic character?
BTW - I figured out how to detected if we should...
|
by: techievasant |
last post by:
hello everyone,
Iam vasant from India..
I have a test+interview on C /C++ in the coming month so plz help me
by giving some resources of FAQS, interview questions, tracky
questions, multiple...
|
by: Grant |
last post by:
Gday,
My form has a text box and a label. The label is next to the textbox and has
a mnemonic set for the first letter. My question is how to highlight the
textbox when the user selects the...
|
by: Valerie Hough |
last post by:
I have derived a class from MenuItem so that I can associate IDs of my
choosing with each item (a la C++).
I have created a ContextMenu in the constructor of an owner draw list box
and added a...
|
by: Donal Kelly |
last post by:
hi,
I'm building a GUI in C# and I want the buttons to have a mnemonic character
attached to the button. I cannot seem to do this in C#, where it was very
simple to do in Visual C++.
Thanks,...
|
by: Raith |
last post by:
I have a form with various mnemonic (accellerator) keys set up, they
all work fine except the password box ("&Password"). Is this perhaps
because that's a default for Print? Is there a way to get...
|
by: jacob navia |
last post by:
Mnemonic means trying to remember.
Mnemonic means making annotations that remind you.
Speaking about mnemonic I saw this message.
Tor Rustad wrote:
One of the problems with old people is...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |