Chris Fidao: PHP is Weird, Stateless, and Beautiful
- This topic is empty.
-
AuthorPosts
-
October 5, 2023 at 10:52 pm #8412AbigailGuest
fantastic, long overdue commentary on PHP and why it’s (hated) awesome
October 5, 2023 at 10:54 pm #8413AdamGuestJS gurus: the weirdo language! PHP sucks!
internet: ** shrugs **
October 5, 2023 at 10:54 pm #8414AbigailGuestlol not just JS gurus, pretty much all the cool kids trash talk PHP….
October 5, 2023 at 10:55 pm #8415JoshuaGuestChris also has a brief write up on this too:
October 6, 2023 at 10:51 pm #8426PeterGuestLanguage Comparison
In the video, we compare other popular languages and see how its possible to create a global variable that increases in value with each web request. In other words, there’s global state that that you need to worry about.PHP is different – even global variables are “reset” to their initial value on each request. (This is not to be confused with super globals such as $_GET, $_POST, $_SERVER, and so on).
Pros and Cons
This makes PHP much easier to use – the mental model of what your code is doing is much simpler when there’s no state that might be accidentally saved between web requests.However it also means we need to reload a lot of code on each web request. This is alleviated by PHP’s opcache, but it’s still not as efficient as having the framework/code loaded already when accepting a new web request.
Additionally, PHP can’t make use of things like connection pooling – each web request instead needs to make a whole new connection to databases, caches, and other external services.
This, luckily, is mostly just fine – PHP is still fast!
October 6, 2023 at 10:57 pm #8427LauraGuestyayyy PHP-FPM
October 15, 2023 at 7:16 pm #8525KyleGuestSpoken like only a true PHP fan could speak haha
-
AuthorPosts
- You must be logged in to reply to this topic.