To each his own, I guess. I just find your position genuinely surprising.
The user-defined context is the only route into the application state and can be as wide or narrow as you need. So you can share persistent state deliberately, e.g. by having that context contain a pointer to a db conn, but this is always a conscious, opt-in choice, and errors like accidental reuse should be impossible unless you're doing something inadvisable like using global variables.
In 99.9% of cases in web development you want the PHP model of doing things. The 0.1% case is the asynchronous background job, that can be solved, maybe not as elegant as in other languages, but why optimize the edge case?
So anything that needs to be processed asynchronously, like say, sending out a few dozen emails or notifications, I just publish the task to the queue and that other container handles them.
This could be simplified even further if you use a pubsub service that can post data to a url as it comes in. Thus allowing the single php container to asynchronously process the tasks all in their own individual threads.
This didn't work for me as Google cloud's pubsub seems to absolutely flood it's target with requests seemingly ignoring 503 or any other error code and not backing off until it has dos'ed your server.
That said, I'll gladly take the guarantees of a type checker in exchange for giving up the guarantees of statelessness. It would be nice if there were a stack that could give me both.
Of course there are solutions in PHP-land, e.g. "run a job server" or "use Redis", but I find the overall cost of introducing more programs/services/components to be very high, in terms of learning curve, portability, maintenance and debugging.
I've spent the last few years replacing a crumbly, brittle, temperamental PHP/nodejs/Gearman/Redis/Nginx/Supervisor stack with a Go monolith so I'm sure that influences my opinion :-)
My understanding is that the go philosophy is very package independent and the availability of existing code to solve common problems is rather sparse.
I don't really agree, php routes are handled natively and very simply and easy to reason about using the .php extension.
Its the frameworkers that broke that design with clean urls and fancy complicated routers.
Php behind Apache or nginx is incredibly simple and easy to reason about.
Browser loooks up this file url, this file url runs as a script and its output is returned.
A bug in one file isn't propogated to all others so you can have highly reliable services with only partial failures from time to time.
Whereas a bug in one route of a golang server may take the entire service offline.
I do much prefer the deployment and shipability of a golang service, so much I am willing to give up the simplicity of PHP.
That said, having a Go service just be exposed to the wild wild internet may not be a smart idea. Take a look at this issue [1], it is perfectly clear that Go services (relying on net/http) still need babysitting by a competent reverse proxy. It is a case where Go's mantra about simplicity leads to leaky abstractions and just clearly immature solutions.
Also not talking about TLS certs, WAF and other concerns that also may bring nginx etc on board anyhow.
My guess as to why this issue is left open? Google has global timeouts set on all the network edges so they don't want each service to use its own. Whats good for Google overrides whats good for the supposedly open source project.
This is pervasive in most of their projects. Google open source is like the Reapers from Mass Effect series. They leave some crumbs behind to ensure the software ecosystem develops along desired paths. Not out of charity, they do it to ensure a successful harvest.
Another concern is that the lifetime of a PHP app is rather short, measured in milliseconds. This is actually a rather robust approach. Crashes, memory leaks, all sort of weird states are brushed away immediately to be replaced with fresh state for the next request. Apache/nginx is acting as a supervisor and allowing a lot of shit code live out it's days unnoticed.
Contrast that with long-running Golang processes. You won't get away with sloppy code there, raising he bar considerably. Running a Go executable without a monitoring supervisor is sketchy at best.
Networking is another example. And casting to interface while the built-in collections secretly use generics.
A good way to avoid all these problems is to use a language with great cross-platform support like Java or C#.
Running a PHP project isn’t as easy as
git clone
make run
because of the web server. Difficult to configure, hard to share configurations between machines, differences between operating systems (and Linux distributions) where to put configurations, different ways to hook into php.Projects starting to rely on specific web server configurations for different application behavior, e.g. htaccess files.
Hard to debug when you need to special request handling like terminating the request but continue executing or continuously stream data (web server response cache).
I guess that is the price you pay for separating the application from the web server.
Modern PHP projects will have a single entry point that handles all requests, with path-based routing done in code.
“Does this thing persist across requests” is ridiculously simple to answer in php because the answer is “no, unless you very explicitly told it to”.
In a go or java or whatever service you have to know if your “thing” is specific to the request handler, or if it’s part of shared state.
There is no reason that routing in a php app has to be done via mapping urls to php files, it’s a very common practice to have a front controller that bootstraps the app environment and in turn handles routing of the request to a piece of logic.
And so the eventual proxying Go behind Nginx or Apache comes with it's own cost since Go is nowhere near as tested as PHP when it comes to server integration.
I think that this vague definition, right here, is the source of disagreement. Are we talking about small blog with comments?
Or are we talking about one of the services of a medium-sized company, that needs to provide a platform-agnostic API, and real-time updates to subscribed clients with websockets?
That being said, I would still prefer a monolithic application for a small blog with comments because I think it's easier to manage, deploy, encapsulate, test etc.
The old-school style, where routes map to scripts or parts of scripts and a separate web server like Apache or Nginx sits in front of the app, feels harder to reason about (does this thing persist across requests?), harder to debug (where did that error message end up?) more brittle (did this fail because of my script or my web server config or something else?) and more dependent on configuration magic (i.e. various text files lying around governing the behaviour of things).
So although some of these changes look cool, I don't think it's the language itself that most needs improving.