So I was wondering how people would feel about adding a coding convention for the use of is_null() in PHP code.
It's 10 times slower than doing === null, which is a bit trivial in context, but nonetheless a fact, and it's also a bit easier to read, especially when doing the inverse (i.e., doing !is_null( ... ) versus !== null). Also, there's no functional difference between the two.
Any objections other than maintaining the status quo?
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On 6/16/13, Tyler Romeo tylerromeo@gmail.com wrote:
So I was wondering how people would feel about adding a coding convention for the use of is_null() in PHP code.
It's 10 times slower than doing === null, which is a bit trivial in context, but nonetheless a fact, and it's also a bit easier to read, especially when doing the inverse (i.e., doing !is_null( ... ) versus !== null). Also, there's no functional difference between the two.
Any objections other than maintaining the status quo?
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Easier to read is debatable. !is_null( $foo ) reads directly like an english sentence "Not is null". Ok, maybe an english sentence with bad grammar, but I hardly find it unclear.
As for performance. 10x out of context doesn't mean much (How much slower is 10x. If we changed all 681 instances to the other one, are we talking about a difference of 1 microsecond in absolute time? Or is 10x an actually significant saving. For that matter is the benchmark being used actually reliable?)
I feel such trivialities should be left at the discretion of the commiter
--bawolff
On Sat, Jun 15, 2013 at 11:43 PM, Brian Wolff bawolff@gmail.com wrote:
As for performance. 10x out of context doesn't mean much (How much slower is 10x. If we changed all 681 instances to the other one, are we talking about a difference of 1 microsecond in absolute time? Or is 10x an actually significant saving. For that matter is the benchmark being used actually reliable?)
Yeah, like I said, it's pretty trivial. We'd maybe save a millisecond (if we're lucky).
Also, I'm sort of neutral on this issue. I personally prefer the binary operator, but I just want to get an idea of what everybody thinks so I can know whether to stop telling people to use === null on code review.
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Sat, Jun 15, 2013 at 11:47 PM, Tyler Romeo tylerromeo@gmail.com wrote:
Also, I'm sort of neutral on this issue. I personally prefer the binary operator, but I just want to get an idea of what everybody thinks so I can know whether to stop telling people to use === null on code review.
I'd definitely say to stop telling people to use === null at this point. Until we have more definitive information, it sounds like micro-optimization to me.
-Madman/ea
On 16/06/13 05:43, Brian Wolff wrote:
On 6/16/13, Tyler Romeo tylerromeo@gmail.com wrote:
It's 10 times slower than doing === null, which is a bit trivial in context, but nonetheless a fact, and it's also a bit easier to read, especially when doing the inverse (i.e., doing !is_null( ... ) versus !== null). Also, there's no functional difference between the two.
Easier to read is debatable. !is_null( $foo ) reads directly like an english sentence "Not is null". Ok, maybe an english sentence with bad grammar, but I hardly find it unclear.
I'd say it's easier to read because ! is the same size and shape as i so !is_null() may easily be overlooked as is_null(), while !== sticks out from ===
Hey,
On the colour of the bikeshed: !== generally reads better then !is_null. "$foo is not null" vs "is not null $foo".
I however object against constructing this shed in the first place. Seems like a waste of good mental effort, on which some much nicer buildings can be constructed.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. ~=[,,_,,]:3 --
Le 16/06/13 05:27, Tyler Romeo a écrit :> So I was wondering how people would feel about adding a coding convention
for the use of is_null() in PHP code.
It's 10 times slower than doing === null, which is a bit trivial in context, but nonetheless a fact, and it's also a bit easier to read, especially when doing the inverse (i.e., doing !is_null( ... ) versus !== null). Also, there's no functional difference between the two.
That adds more bureaucracy to our code review. Just get rid ofo is_null() where it is usage significantly harm performances (such as in an often called method or a loop).
wikitech-l@lists.wikimedia.org