Live data from Hacker News

Stack Overflow: Defend PHP - convince me it isn't horrible

stackoverflow.com

71–74 of 74 posts

Re: Stack Overflow: Defend PHP - convince me it isn't horrible

#71

Earlier quoted context omitted.

You want '0' == 0 and ' 0' == 0. But you also get '0' == false array('0' => 'x') == array(false => 'x') ' 0' == true array(' 0' => 'x') != array(true => 'x') which isn't even an equivalence relation. I have to try this or look it up every time I run into it, because it doesn't make any damn sense.

From the documentation: "A key may be either an integer or a string" So your boolean true is converted to the integer 1 and your boolean false is converted to the integer 0. Dump those arrays and you'll see they don't contain boolean keys. Then it's just a simple matter of '0' == 0 and ' 0' != 1. It's all perfectly logical.

Yeah, I can stare at the docs and work out the consequences of the ridiculous design decisions they committed to (such as array keys using an equivalence relation while equals does not, and some but not all strings being true yet converting to zero). But for me it's just too blatantly wrong to keep a good grasp on, and the experience of trying to resembles the Book from Anathem:

> crafted and refined over many centuries to be nonsensical, maddening, and pointless[....] The punishment lay in knowing that you were putting all of that effort into letting a kind of intellectual poison infiltrate your brain to its very roots.

Re: Stack Overflow: Defend PHP - convince me it isn't horrible

#72
post #32

Earlier quoted context omitted.

It's just as secure as any other language you can write insecure code in (i.e. all of them). That may be true; I've only developed two half-serious projects in PHP a while back. But given the amount of XSS and injection vulnerabilities we're seeing daily, I think that something is wrong with those web development guys. PHP is admittedly a widely used tool and I can't help but wonder: " Could it be just the language?…

Is there a possibility things would be better if PHP was abandoned? Nope. Beginning coders write vulnerabilities until they're otherwise educated. In PHP these are SQL injection and XSS holes. In C they're buffer overflows. Of course things would improve if we educated all PHP developers on the security implications of whatever it is they're programming. But so many years of coding have shown it's infeasible (for any…

You mean to tell me that in a world where anyone could take up on any programming language and start writing code on one's own, properly educating that someone is feasible?

Please. This isn't 1960 anymore. Code is not written by "scientists" exclusively anymore.

Re: Stack Overflow: Defend PHP - convince me it isn't horrible

#73

Earlier quoted context omitted.

From the documentation: "A key may be either an integer or a string" So your boolean true is converted to the integer 1 and your boolean false is converted to the integer 0. Dump those arrays and you'll see they don't contain boolean keys. Then it's just a simple matter of '0' == 0 and ' 0' != 1. It's all perfectly logical.

Yeah, I can stare at the docs and work out the consequences of the ridiculous design decisions they committed to (such as array keys using an equivalence relation while equals does not, and some but not all strings being true yet converting to zero). But for me it's just too blatantly wrong to keep a good grasp on, and the experience of trying to resembles the Book from Anathem: > crafted and refined over many centur…

I don't bother keeping a good grasp on it. The less you try and reason about it, the more likely it works as intended. You can concoct lots of scenarios where the type system in PHP breaks down yet in the average well-designed code those sorts of problems are rare.

Your example highlights some weirdness in the type system, but that could would never exist in actual product.

Re: Stack Overflow: Defend PHP - convince me it isn't horrible

#74
post #67

Earlier quoted context omitted.

That was exactly chromatic's point---language design and features do make a difference.

It's always easier to blame the tool for your failed craft than it is to be a good programmer, isn't it :) Putting PHP in the "inadequate corner" or trying to convince oneself that it is lacking in features is just an easy excuse.

It's always easier to blame the tool for your failed craft than it is to be a good programmer, isn't it :)

Do you object to the attractive nuisance doctrine?

Post reply on HN