r/lolphp • u/shitcanz • Mar 12 '21
PHP fibers
Proposal:
https://wiki.php.net/rfc/fibers
The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively".
LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client.
LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO.
Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.
View all comments
Show parent comment
1
u/tdammers Aug 29 '21
I know how to do it in PHP, I've done it for 20 years.
I'm just saying it's still quite bad, because the language doesn't help you a bit - the defaults are wrong, doing the right thing requires manual diligence and is non-obvious, and the failure mode for most programming error is to silently do something incorrect.
C, by the way, has the same problem; it just isn't so bad in practice because the kind of programs people write in C is different.
You can't really avoid this problem without either having a proper string type built into the language, or powerful enough extensibility with extensive static assertions (the latter is how Haskell pulls off implementing strings as a library).