One more kernel lead developer rant

merlyn on 2006-01-07T00:01:13

Only a few short weeks ago, Theo (of OpenBSD fame) said that I was "clearly not skilled enough to even compile code".

Now, Linus Torvalds joins the party:

I'm sorry, Randal, but you're clearly a totally different species.

I just hope you don't cross-breed. Shudder.

All I need now is Bill Gates telling me I'm an idiot, and I'll have collected the entire set!


Wow

sigzero on 2006-01-07T02:29:51

You are just not having a good run with them people.

gentle reproach

mr_bean on 2006-01-07T03:07:05

Perhaps it is supposed to be humorous. A shudder
is the same thing as a thrill down your spine.

Re:gentle reproach

merlyn on 2006-01-07T07:31:48

Yes, unlike Theo, this one is clearly tongue-in-cheek. However, I couldn't resist drawing the parallel.

Linus' attitude to perl

mr_bean on 2006-01-07T10:23:07

Actually I'm surprised he is allowing perl within
arm's length of git. I get the feeling perl is
widely regarded as (what's the right word:
computerly? computationally?) incorrect.

Re:Linus' attitude to perl

merlyn on 2006-01-07T13:20:26

From what I understand, Linus started git, but Junio seems to be maintaining it now, and Junio is a fair-to-middling Perl hacker. There's also a smattering of Python in Git as well. Talk about mixed up. {grin}

Re:

Aristotle on 2006-01-07T06:14:54

What silly complaints. for ( @foo ){ print "$_\n" } is fine but print "$_\n" for @foo; is not? The obfuscatory bit, if there is one, is Perl’s strange attractor, the $_.

I never followed the argument that trailing control flow constructs are somehow obfuscatory. What kind of retard does someone have to be if they understand if( $foo ) { bar( $baz ) } but is totally lost as soon as it’s written bar( $baz ) if $foo? I’m not using “retard” in the name-calling sense either; I mean that I believe that someone literally has to be mentally retarded to fail to understand the notion of modifiers. Even if someone has been writing nothing but C for the last 30 years, I don’t see how it is possible for them to fail to comprehend what’s going on.

To me, frankly, the suggestion that modifiers are obfuscatory is condescending. The thought process seems to go something like “uh, yeah, okay; I’ve never seen this, it’s weird, though I guess I get it; but what if the next guy who comes along is total retard?”

I’ll never understand this.

In contrast, I’ve often wished I could name my iterator variable in the modifier form of for (as well as map and grep) rather than having to use $_.

The Mark of a Great Programming Language

chromatic on 2006-01-07T09:30:25

Clearly the mark of a great programming language (if you're not a Lisp hacker anyway) is when a complete idiot who's never programmed before could maintain your code, not that that's pretty much the anti-pattern or anything.

(You should name your default variable $it so everyone knows it's a pronoun.)

renaming to $it

lachoy on 2006-01-07T17:45:18

The problem with renaming $_ to $it is that many of the confused people will assume you mean the acronym IT and complain angrily when the variable doesn't meet their expectations!

Honestly, defending Perl against people whose impressions of it were formed either by reading someone else's crappy code, or more commonly by reading the rantings of some dingdong who did so, is a FT job.

Re:renaming to $it

chromatic on 2006-01-07T21:02:36

My rule is pretty simple. Any so-called programmer who can use a pronoun correctly in English has no business writing code if he can't use $_ correctly in Perl. (It's okay if you have to explain the similarity; it's not immediately obvious to people.)

Re:renaming to $it

lachoy on 2006-01-07T23:38:49

your reaction is a lot nicer than mine, which is: "It's just effing syntax!"

Re:renaming to $it

perrin on 2006-01-09T19:47:41

The constant stream of bugs resulting from accidental changing of $_ inside a sub call are a pretty good argument against using it when you don't have to (i.e. outside of a map or grep).

Re:renaming to $it

chromatic on 2006-01-09T21:28:38

That's a fair point, as is the one about lexical declarations and postfix if. I was thinking about the whiny won't someone please think of non-programmers argument about readability instead of legitimate implementation bugs.

Re:

Aristotle on 2006-01-08T05:56:08

An entire paragraph written using “it” as the subject in every sentence isn’t very readable. There are good reasons to want to use a named iterator variable. Mind, I don’t think $_ is inherently obfuscatory and I have no qualms about using it, though I do consider each case carefully. If you’re iterating over a list returned directly from a somewhat complex expression, then a well-named iterator helps document intent. And there’s only one $_, so in those cases where need access to outer iterators in nested constructs, being able to name iterators allows you to get the job done directly. These are some examples off the top of my head.

The difference I’m claiming is that modifiers are obvious even if you don’t know Perl at all, whereas $_ needs introduction. Now, the non-modifier for form allows naming the iterator; but since that opportunity was passed up in the snippet in question, there is really no difference between either form.

It baffles me what it is about modifiers that makes them so dangerous-looking. I bet if you ran a survey with 100 programmers who have never seen any Perl code and showed them a simple statement with a modifier, not one of them would have trouble understanding it, and I further bet that every single one of them would express concern that that looks obfuscated. Heck if I know why that’s so, though.

Re:

chromatic on 2006-01-08T06:35:13

An entire paragraph written using “it” as the subject in every sentence isn’t very readable.

I agree. That also falls under my rule of "don't hire people who don't know what they're doing".

Re:

perrin on 2006-01-09T20:52:18

Postfix "if" can be quite dangerous. There's a significant bug you can hit if you write a line of code that defines a lexical variable and has a postfix if. It's very hard to spot these. Postfix "for" doesn't have any dangerous bugs like this that I'm aware of.

A Best Practice?

jordan on 2006-01-07T11:50:14

In Damian Conway's Perl Best Practices, this style is deprecated. The summary statement for the section titled "Other Postfix Modifiers" reads:
Don't use postfix unless, for, while or until.
You may more may not agree with this book here, and I have to say that there's a lot in the book that I find somewhat limiting, but one Randal Schwartz is quoted on the back jacket:
"As a manager of a large Perl project. I'd ensure that every member of my team has a copy of Perl Best Practices on their desk, and use it as the basis for an in-house style guide."

Forget Bill

ziggy on 2006-01-07T21:48:05

All I need now is Bill Gates telling me I'm an idiot, and I'll have collected the entire set!

Last I checked, Bill Gates was never a kernel hacker, nor was he ever a kernel lead developer (whatever that's supposed to mean).

If you're going for the tryptic, you'd be better off trying to get insulted by Bill Joy, Brian Kernighan, or possibly Dave Cutler.