logoalt Hacker News

jmyeet • today at 1:58 PM • 1 reply • view on HN

I'm honestly disappointed at the number of snark comments on HN about PHP. It's like posting 2007 memes. Yes, we all know the story of htmlspecialchars(). We can make fun of "global" when we don't realize "global" actually means "request scoped". We get it.

I've always viewed PHP as having these ideal features:

1. A stateless functional core. It's cheap to run and quick to start. Compare this to Java or even Python. There's no loading a bunch of class libraries;

2. Every request has an environment created then torn down. That means it's hard for a given request handler to leak memory or other resources. You compare this to, say, Java's servlet API (which only really existed because the startup costs were too high) where resource leaking is a real problem and then you get into GC and STW pauses; and

3. Every request is single-threaded. This is ideal. Async network/IO requests are handled via extensions. You should never need to spawn a thread in a request handler directly. You eliminate a whole class of bugs by doing this.

Is PHP perfect? No. The class separator as the backslash still offends me more than a decade later. I really wish Facebook's Hack had become PHP because it's got a vastly better type system, core collection classes (list, vec, dict) and it did things a decade ago that PHP is only added with this release (eg polling).

As for partial functions, the use case seems to be versioning? I actually prefer the Javascript polyfill method here where possible. Don't make users care about this kind of stuff.


Replies

ryangittins • today at 2:01 PM

As they say, there are two kind of programming languages: the ones people complain about and the ones no one uses!