Re: [PATCH] Don't ignore write failure from git-diff, git-log, etc.

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Don't ignore write failure from git-diff, git-log, etc.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:12

Linus Torvalds [off-list ref] writes:
Also, PLEASE don't do this:
quoted
+		if (0 <= fcntl(fileno (stdout), F_GETFD)
That's totally unreadable to any normal human.

You don't say "if zero is smaller or equal to X". You say "if X is larger 
than or equal to zero". Stop messing with peoples minds, dammit!

Anybody who thinks that code like this causes fewer errors is just fooling 
himself. It causes *more* bugs, because people have a harder time reading 
it.

Maybe you and Junio have taught yourself bad manners, but you're a tiny 
tiny part of humanity or the development community. Junio can do it just 
because while he's just a single person, he's a big part of the git coding 
base, but anybody else who does it should just be shot.
Whew, that is a blast from the past.

cf. http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=3906

 (1) Maybe Jim was just being nice, trying to make the code look
     like surrounding code;

 (2) Maybe Jim and the person I learned the style from worked
     together for a long time and they picked it up from the
     same source;

 (3) Maybe I am not alone, and it is not native language -
     mother tongue issue as some suspected in the quoted thread.

In any case, I think my recent code have much less "textual
order should reflect actual order" convention than before,
because I have been forcing myself to say aloud "if X is larger"
or "if X is smaller" before writing my comparisons, in order to
match the "peoples minds" expectation you mentioned above.

This initially slowed me down and made my head hurt quite a bit,
and sometimes it still does.

Once you learn to _visualize_ the ordering relationship in "X op
Y" by relying on "op" being always < or <=, you will get the
"number line" pop in your head whenever you see a comparision
expression, without even having to think about it, and you "see"
X and Y on the number line:

        ... -2        -1         0         1         2  ...  
    ---------+---------+---------+---------+---------+---------
    true:                        0   <=  fcntl(...)


        ... -2        -1         0         1         2  ...  
    ---------+---------+---------+---------+---------+---------
    false:    (0 <= fcntl(...))

What the comparison is doing comes naturally to you, without
even having to translate it back to human language "X is larger
(or smaller) than this constant".  The ordering is right there,
in front of your eyes, before you vocalize it.

In a sense, just like it is hard to go back from git to CVS (or
it is hard to go back to not knowing the power of the index), it
is very hard to go back once you learn to do this.

Re: [PATCH] Don't ignore write failure from git-diff, git-log, etc.

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:12

On Sat, 26 May 2007, Junio C Hamano wrote:
Once you learn to _visualize_ the ordering relationship in "X op
Y" by relying on "op" being always < or <=, you will get the
"number line" pop in your head whenever you see a comparision
expression, without even having to think about it, and you "see"
X and Y on the number line:

        ... -2        -1         0         1         2  ...  
    ---------+---------+---------+---------+---------+---------
    true:                        0   <=  fcntl(...)


        ... -2        -1         0         1         2  ...  
    ---------+---------+---------+---------+---------+---------
    false:    (0 <= fcntl(...))

What the comparison is doing comes naturally to you, without
even having to translate it back to human language "X is larger
(or smaller) than this constant".  The ordering is right there,
in front of your eyes, before you vocalize it.
Well... it probably depends on how your brain is wired up.

I completely agree with your reasoning.  It _should_ indeed be natural 
and more obvious to always put things in increasing order.

BUT it is not how my brain is connected, and after many attempts I just 
cannot work efficiently with your method.  It simply doesn't come out 
logical for me and I have to spend an unusual amount of time on every 
occasion I encounter this structure to really get it.  To me it always 
looks backward.

And I suspect the majority of people who just cannot train their brain 
with the arguably superior representation are many, probably the 
majority. It appears to be the case for Linus.  It is definitely the 
case for me.


Nicolas, who apologizes for his defective brain.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help