My Favorite Language Has Changed to PHP
withinboredom.info
withinboredom.info
The downside is that the PHP service environment does't provide much of a runtime framework, so the PHP application itself needs to perform a huge amount of bootstrapping on every request (this builds up over time as you add stuff to the application). Comparing this to AWS Lambda with e.g. Node.js, Lambda can keep a lot of stuff pre-initialized in memory, and usually just directly execute a handler function. Also things like URL request mapping are externalized to a separate API Gateway. There used to be a lot of tweaking and running separate caching modules needed to make PHP bootstrap fast enough.
I've always been sad that AWS hasn't developed a fully supported PHP backend for Lambda. Combined with a lightweight HTTP gateway, it could be a nice way to keep running legacy apps like WordPress in modern serverless environments, without worrying about server costs and maintenance. You can do it yourself with Lambda layers, but there will be all kinds of small mystery timeouts and problems you have to deal with.
How does one manage that? How does it not break on every infrastructure change?
In any way, I have never met those people.
Or are you talking about exploring the OS primitives to share data between instances of your code? Because avoiding that shouldn't require a lot of care, and PHP has basically the same capacity.
You can't do that in PHP, you need to explicitly write to redis/memcached/file/database to be able to read values from another request.
However, this is not a problem at all. In Go you would have to get out of your way to share information between user agents just like you would have to do in PHP.
Intentionally writing to and reading from a global variable is the exact same as intentionally writing to and reading from your MariaDB instance.
I have no clue why you would render this process problematic. Maybe in Python everything is a global?!
As a benefit of PHP this isn't a new thing, and usually what is meant isn't that people are deliberately creating stateful HTTP applications (thought they may be!).
What it normally refers to is the way that with PHP every request gets a totally new instance of the interpreter to run in, as it is basically started up from scratch to service that one request, does it's work, then disappears again. There is no possibility of bleed across requests or of accidental shared state.
Whereas with Node, Go, C# etc, there is (by default) a long-lived 'server' process that handles all incoming requests and so doesn't have that automatic request segregation but instead relies on code (framework and/or application).
To rephrase, with PHP there are multiple requests each of which get their own one-shot instance to run in (guaranteeing segregation). With most alternatives there is one server instance which handles multiple requests and something in the stack somewhere has to manage that segregation.
PHP maps many requests to many servers. Versus many requests to one server. But of course this is all very much a simplification.
- Are long-lived per-process in-memory read-through caches "stateful"?
- Is per-connected-websocket topic subscription state "stateful"?
In both of these cases, nothing breaks when you hard-kill + restart one of these processes. People who add these things to a web-app backend don't usually think of themselves as making the backend "stateful."
But nevertheless, truly "stateless" technologies like CGI or PHP are defined by how they don't have access to things like this.
https://aws.amazon.com/blogs/compute/introducing-the-new-ser...
Also check out serverless Laravel…
But wow, this is not a convincing article at all. It's just an opinion with nothing to back it. If this was on a forum, I'd think it was a waste of space and ignore it.
But a blog post? And someone shared it here? What were they thinking?
Edit: I see the author shared it here. Wow.
> But a blog post? And someone shared it here? What were they thinking?
I honestly wasn't expecting anyone to care about my opinions but shared it here on the off-chance there would be an interesting discussion about PHP/C#. Though, it mostly just to seems to be people complaining about my opinions, so maybe that was a bad idea.
PHP was an utter mess. Has it changed? I don’t care. It broke my trust and I’ve moved onto languages that are more thoughtful and general purpose. Returning to PHP would feel like returning to an abusive relationship
It is possible to use PHP for CLI apps as well but this is a bit of an afterthought:
if (PHP_SAPI == "cli") {
# CLI-code goes here
exit();
}
It is the right tool for a lot of jobs - not for all jobs but what language is?The language at hand is often the best language for the job, just like that phone camera in your pocket is the best camera to snap that shot of whatever event you just happened upon. Sure, it would have been better if you could use a DSLR on a stand, shooting raw to be processed in some fancy tool but that DSLR and stand and tool generally complicate matters far more than they add in quality. Sometimes this is worth it, often it is not.
Also, to claim trust has been "broken" is just weird. Every software engineer should be well aware of the horrible mess that is the PHP language even if they had just had a cursory glance at it.
In any case. I would never pick PHP on purpose either. Even if it was the most appropriate tool in a given situation. It simply makes my blood boil, and I don't care if it's irrational.
Both development team and the community matured and learned a lot. The language lost a few of its footguns, but preserve a lot for compatibility reasons. The best practices evolved in good ways, but the old documentation is still around.
So, yes it changed. If it changed enough is a different question.
Can you elaborate on this a bit? What trust did you have in PHP, and what did it do to break that?
>When I learned Assembly, I think I broke my brain, permanently. ...when I came back to C#, suddenly, I felt too constrained.
Like, if he'd been talking about a functional programming language or Scheme or something like that I'd be nodding my head along.
I've certainly warmed up to PHP over the last couple of years as I've been maintaining a couple apps, and while it's nowhere near my favorite language, I do think PHP gets an unfair bad rap because of historical terribleness.
What does matter A LOT for me is the ecosystem, the tools, the editor support, the libraries, the frameworks, the community, etc. And PHP does GREAT at this. I'm using Laravel nowadays and it feels like a better Rails, with better tooling, better editor integration, more people using it, more community, more libraries, etc. Is the language a bit uglier? yes, but I don't care about the syntax, everything else matters a lot more to me.