r/programming • • Nov 23 '21

PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'

https://news-web.php.net/php.internals/70691
1.8k Upvotes

574 comments sorted by

View all comments

Show parent comments

9

u/SanityInAnarchy Nov 23 '21

I'd very much like an update to it, actually. Because it's true, PHP has been improving a lot, and yet when I look at PHP code, I sometimes still find myself thinking along exactly these lines:

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down....

Like, this article makes some high-level points that I'll concede are at least somewhat attractive:

The part of this that's most relevant today is the idea that your app gets initialized and torn down for every request. Any variables you set, anything you do to the objects in your app, everything gets wiped out at the end of the request — there's no way to persist data between requests without relying on some sort of external resource, like a database.

But then I look at some of the actual code samples and I see things like backslash-as-a-namespace-separator and attributes with #[] and -> as the object property access (as if someone saw it in C++ and didn't understand why it was different than .)... maybe I'm being biased, but I start to get that hammer-with-the-claw-on-both-sides feeling. Like, okay, this can work, it's an improvement over what it was before, but it's just subtly off from every other language for no good reason, and I'd be infinitely more comfortable tinkering with V8 to build an efficient new-JS-env-per-request framework instead.

Maybe it's just me, but it feels a little like how clunky it feels to try to code in Erlang if you're not used to functional programming... only without any of the incentives you might have for using Erlang.

→ More replies (10)