NYCPHP Meetup

NYPHP.org

[nycphp-talk] Why do "cool kids" choose PHP to build websites instead of Java

John Campbell jcampbell1 at gmail.com
Mon Jan 14 11:22:44 EST 2008


On Jan 14, 2008 8:17 AM, Kenneth Downs <ken at secdat.com> wrote:
> Elliotte Harold wrote:
> > Michael Southwell wrote:
> >
> >> ah, no, these answers are exactly right, given that $a is an integer,
> >> $b and $c are strings, and $d is unset. $b and $c when converted to
> >> integers for the purpose of comparison in #1 and #3 turn into 0
> >> (zero) so the comparisons are true. #2 compares two different strings
> >> and so is false. #4 compares 0 to the integer of unset and so is
> >> true. #5 and #6 compare strings to the string of unset and so are false.
> >>>
> >
> >
> > Yes, this is what PHP does. It's just that what PHP does is insane. It
> > does not match any normal, logical thought process.
> >
>
> A content-free emotive statement.
>
> It would be more accurate to say that it follows a set of principles you
> do not share, namely, weak typing.  We would expect you as a java dude
> to prefer strong typing.  Strong typing to me is inappropriate in a web
> layer, and reduces my productivity.  Is it insane?  No, just
> incompatible with my design goals and methods.

I am with Rusty on this one.  PHP is insane in this regard.  Consider
the following statements:
1+1=2
if a < b and b < c then a < c
if a=b and b=c then a=c

I am a bit of a purist, and I hold these three rules to be
self-evident and violations of these rules put one outside the realm
of a normal logical thought process.   PHP violates #2 and #3,
therefore PHP is insane.  Other weakly typed languages do not violate
these rules.  This is not about weak vs strong typing, although it is
much easier to get basic logic right in a strongly typed language.

If you still don't understand the problem, then take this quiz:
what is the output of the following statements?
var_dump(true + true);
var_dump(null < 0);
var_dump(null < -1);
var_dump(null < 1);

Regards,
John Campbell



More information about the talk mailing list