Hacker News new | past | comments | ask | show | jobs | submit login

Or if PHP were built into browsers, we'd all be using PHP.



And the world would be slightly dumber, and even more willing to accept shoddy design.

Shudder

(Yes, modern PHP is okay, but there are still a thousand and one bits of legacy baggage from a darker time that yet remain to be fixed - things like sane process control (PHP can't reliably access subprocess return values!), standard I/O support (can't read from stdin one char at a time, so sane CLI tools are broken), DB sanity (the SQLite3 extension will run all queries twice unless you code around bugs that have been known about for 10 years), etc), socket I/O (you physically cannot write rock-solid sockets code; the builtin streams functionality _and_ the socket extension do not provide enough surface area to handle all plausible error conditions, and it's entirely possible your script will hard-crash in certain obscure scenarios because the runtime doesn't give you the ability to trap all errors), and because of these longstanding issues PHP _does still have_ a sad culture of "it's okay, we'll just do this crazy horrible workaround", and nobody's fixing it.

I wanted to give a practical example, but unfortunately I can't find it. I was debugging some incredibly confusing socket behavior one day, and found where a major library/framework had hit exactly the same problem, and what they did - it was a remarkably well-engineered solution - was to setup a custom error handler, preg_match() the PHP error string (!) inside the error handler, then use some magic "if this is set to this and that var equals that value" derived from reading the PHP source code to detect a socket error condition. This code is still in place since PHP 7 hasn't fixed any of this, I just can't remember the library name or where to look for the code unfortunately.

</rant>




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: