NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
comments suck (Score:1)
Strangely, I agree with Graham's point. Sparse, on-point comments are wonderful. Code that's too tricksy to grok should be rewritten. From my own experience, I find that my perl vocabulary has shrunk while making the programs easier for me to pick up months later. Also, debuggers work on code, not comments. That's to say, a reader needs to grok the code not what the comments say about the code. And the debugger is an excellent way to understand how the code really works. I recall exploring both Tk an
Re:comments suck (Score:2)
-Dom
Re:comments suck (Score:1)
I also agree with Graham, and I don't think that was quite what he had in mind, especially since he mentioned Perl, and the above type of commenting can crop up in any language.
One of the main reasons I love Perl is because of its expressiveness: the fact that the language is so malleable that you can craft the code to closely map to the underlying process that it's implementing. And that's what I alway
Re:comments suck (Score:2)
Re:comments suck (Score:2)
Code that's too tricksy to grok should be rewritten.
Sometimes code needs to be complicated. Some tasks are tough and impossible to oversimplify and that can justify comments. That being said, shoving that code into an appropriately named subroutine should make it easier.
However, there is one thing that code frequently cannot reveal and that is why something is being done. Maybe it's easy to see that the clone of the customer object does not include their Social Security Number, but that doesn't tel
comments and whipping (Score:2)
> but to document the state of mind.
Agreed. However, not all folks use comments in that manner.
If your code implements a diagonal proof at one point, Paul would probably be unopposed to a comment referencing what such a thing is (assuming that the expected maintainers of the code would not already know). In a mathematics department, the comment is probably uneccessary. If you found cause to use a diagonal proof in your flowchart layout generation code
Regexps and T-SQL (Score:1)
Regexps are usually very compact and opaque. Your comment about whitespace is spot on, so
Re: $_ (Score:1)
I think the exact opposite.
$_has a meaning in Perl: “the current ‘thing’ being operated on”. That's a well-defined convention, and it has the advantage of being the same in every program.In other languages when people want a temporary variable they often use
iornors, but they aren'Re: $_ (Score:1)
If the code block is very brief, like in
then I agree that it isn't necessary to alias it to a new name. But if the code block is longer than a few lines, it's indeed very useful to have an actual name connected to the entity you're dealing with.
Consider the followi
Misleading Subject (Score:1)
I'm not fond of seeing such misleading attributions. I'll try to give you the benefit of the doubt and assume that you actually think this is what he is saying, but I have a difficult time seeing how you (or anyone) can come to that conclusion.
If Paul had stated,
Would it make sense to summarize it as follows?
Re:Misleading Subject (Score:2)
Indeed it is poor logic, but it is what he uses to support that Perl is unreadable. I don't know why he connected those two. What do you think it means when he connects those two things?
Re:Misleading Subject (Score:1)
I don't think that's what he's saying at all (neither point, in fact). His point is that comments don't guarantee programs that are "written for people to read, and only incidentally for machines to execute."
I meant that your summary was poor logic. It's the classic logic problem. If A, then B. Does this mean
Re:Misleading Subject (Score:2)
The two statements I pulled out do not connect with each other, but Paul specifically and on purpose connects them. He's using one to support the o
Perl code needs more comments... (Score:1)
This is where you're getting tripped up. :)
Here's my version of Graham's logic:
Re:Perl code needs more comments... (Score:2)
As I've been thinking about this and trying to get into his mind, and I have the feeling he may be talking about people who tried Perl for a couple of days and then stopped. Six months later they can't remember anything from those two days. That's not surprising.
Or, he's talking about people who tried to understand somebody else's code and gave up after a couple of days. Well, I have that problem with a lot of code no matter the language.
Comments can't save bad code (Score:2)
Re: (Score:1)
It thought what he was saying was quite clear, if pretty silly. He's saying that Perl tempts people to write confusing code, which they usually react to by adding comments to hopefully later remind themselves of their mental pirouettes.
To which I reply “You are correct, sir, but it's a poor craftsman who blames his tools.”