6 ms·
"Intolerable for real-world use. A toy language. Alas, PHP, we hardly knew you..." Have you been out on the internet the past decade? Do you have a tendency to
by hackermom 14y ago
"Intolerable for real-world use. A toy language. Alas, PHP, we hardly knew you..."
Have you been out on the internet the past decade? Do you have a tendency to make extremities of things and trying to stand the needle on its tip?
- ctdonath 14y agoIt throws away data on an obtuse, obscurely-documented, whim. Making extremes? My medical application would fail FDA approval in minutes if ported to PHP precisely because of this issue.
- luser001 14y agoAll languages have their idiosyncrasies. You can pick out some obscure aspect of any language and say $LANG sucks. Btw, PHP's behavior doesn't totally make sense to me either. But I'm willing to assume that its users and designers have thought this through and it makes sense for PHP's intended use cases, because I don't know PHP. Javascript (which most people on HN seem to like) also has similar issues (null vs. undefined, == and === etc). It got so bad that "Javascript: the good parts" had to be written to define a de-facto sane subset of the language. People are actually writing in Coffeescript (in part) to avoid Javascript's pitfalls. YMMV.
- Groxx 14y ago"obscurely-documented"? That seems pretty clear to me, given that it's a fundamental feature of the language, and documented (floating point problems too) in an obvious location.
- tedunangst 14y agoWould your medical application fail FDA approval if you used a language like C or C++ that contained strncmp? Because that function throws away data, too.
- ctdonath 14y agoThere's a difference between strncmp existing precisely so you can specify how many characters to compare, vs. throwing away trailing characters in a string just because, by sheer chance, it contains only numerics.
- eli 14y agoYour medical application should probably be using === for comparisons. I'm not defending PHP's language design, but I think it's pretty well known among professional PHP developers that you should almost always use === and avoid implicit type conversions.
- jrockway 14y agoHow does one ensure that they do not accidentally use ==?
- eli 14y agoGot me. How do old-school C programmers ensure they don't accidentally use = when they mean == ? There are actually some decent commercial PHP IDEs, believe it or not. I wouldn't be surprised if some of them are able to Warn on loose equality comparisons. I don't have much direct experience with them though.
- jrockway 14y agoHow do old-school C programmers ensure they don't accidentally use = when they mean == ? By making the constant the expression's lvalue. But they don't have to do this anymore; gcc warns when you accidentally use = instead of == now.