News for hackers. Stuff that matters.
Re:PHP cheat: ==, ===, empty(),is_null(),isSet() by wvenable on Monday August 25, 2008 @09:31PM (#286655)
On the web, all the data comes in as strings including numbers. So the comparisons work well the numbers in strings. The rest of the weirdness comes from PHP copying C and Perl semantics.
Re:PHP cheat: ==, ===, empty(),is_null(),isSet() by cosmo7 on Tuesday August 26, 2008 @12:14AM (#286755)
Don't blame C. This is usually the point that programmers realize why statically typed languages are such a good idea.
Re:PHP cheat: ==, ===, empty(),is_null(),isSet() by time_management on Tuesday August 26, 2008 @09:39AM (#287049)
When I moved from Java to Python, I was sure that dynamic typing was the way to go, because the type system in the C/Java family is such a hindrance, while lacking the power of a mature type system as seen in ML or Haskell. When I moved from Python to ML, I was equally adamant about static typing being the way to go, because the ML type system is pretty awesome in terms of compile-time error-checking and documentation. Now that I'm learning Lisp, I'm open to the benefits of dynamic typing, or at least want to keep an open mind about the matter.
Re:PHP cheat: ==, ===, empty(),is_null(),isSet() by time_management on Monday August 25, 2008 @09:49PM (#286665)
This makes sense. I guess a programmer who does a string => bool type conversion desires different behavior than one who does string => int => bool, so the fact that they produce different results ("foo" => true vs. "foo" => 0 => false) is part of the design.