News for hackers. Stuff that matters.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by jat850 on Friday January 07, 2011 @11:09PM (#2082155)
Faster is not even the most relevant reason why one should (and would) choose 0 == flag.

edit http://news.ycombinator.com/item?id=2082165 hit on it perfectly.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Friday January 07, 2011 @11:54PM (#2082275)
It's still hard to read.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by bd_at_rivenhill on Saturday January 08, 2011 @12:10AM (#2082317)
Not when you get used to it.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @12:26AM (#2082354)
That's what they said about Lisp and Perl.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by ehsanul on Saturday January 08, 2011 @12:52AM (#2082404)
I can't tell whether you're just being tongue-in-cheek, or perfectly serious. I hope the former.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @01:00AM (#2082421)
Little of both, really. I actually think Lisp is beautiful, although it can be difficult to read. As for Perl...

http://www.foo.be/docs/tpj/issues/vol3_2/tpj0302-0012.html

No excuse.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by natep on Saturday January 08, 2011 @01:47AM (#2082485)
I don't think you're supposed to be able to get used to obfuscated anything. By that metric, C is equally unreadable: http://ioccc.org/

I've seen very readable perl code, although I won't use that to make sweeping generalizations about the entire language.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @01:53AM (#2082498)
To be fair, I never said C was pretty. I have no real problem with Perl aside from its overabundance of punctuation.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by wnoise on Saturday January 08, 2011 @01:06AM (#2082430)
It is for those that haven't fully internalized the symmetry of ==. Is it a lack of effort, or a lack of ability?
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @01:18AM (#2082439)
That's a pretty condescending thing to say. To answer your rhetorical question, we are taught from elementary school to say, "x = 3", not "3 = x". Yes, it's the same, but it's jarring.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by Jach on Saturday January 08, 2011 @02:22AM (#2082542)
I remember getting marked off once in either my algebra 1 or geometry class for leaving some answers in the form "3 = x". (What, you gave me an equation of "5 = 3x - 4"! It's harder to follow the work you make me do if I suddenly swap everything.) Anyway, I never found it jarring, though I can see why others might. (And if you've never had exposure to TI basic.. 3->x.)
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @04:47AM (#2082753)
TI BASIC kinda reminds me of assembly in that way.