Most active commenters

    ←back to thread

    116 points doekenorg | 21 comments | | HN request time: 1.256s | source | bottom
    1. pachico ◴[] No.44498693[source]
    I don't write PHP code anymore. I had a great time doing so for years but now I mostly write in Go for a company that writes a lot in PHP.

    What I see from PHP is a missed opportunity for not having any native lightweight multi thread capabilities not a robust HTTP server.

    I wish the situation changed.

    replies(4): >>44498763 #>>44498778 #>>44499135 #>>44499373 #
    2. beberlei ◴[] No.44498763[source]
    My hope is that the parallel extension will get more widespread adoption when its integrated into FrankenPHP: https://github.com/krakjoe/parallel
    replies(1): >>44498880 #
    3. cardanome ◴[] No.44498778[source]
    I work daily with PHP and honestly nearly all my code I write is synchronous.

    The shared-nothing architecture of PHP makes that really a non-issue for me. Requests never share any state with each other. Something like RabbitMQ can handle communication between systems.

    replies(2): >>44498884 #>>44501438 #
    4. 9dev ◴[] No.44498880[source]
    I still have flashbacks from working with the pthreads extension, which caused extremely hard to debug, non-reproducible segfaults sometimes; I realise Joe has probably started from scratch and improved a lot on that (and I know he's a generally awesome guy), but without a properly financed maintainer team to support him, I'm not sure I want to take that risk again before parallel has gained some maturity.
    5. zelphirkalt ◴[] No.44498884[source]
    That's in no way lightweight though, and most languages can easily do the same. Just launch multiple instances/VMs/processes. That's having multiple separate OS processes, each having everything that is needed to run PHP, and having no way to communicate with each other, other than what you implement. No channels, no task distribution, no queue on which to sync and take tasks from, no signaling of all processes being done and then accumulating the results. That is why you then need something like RabbitMQ or other things, and it does not mitigate the heaviness of the approach.

    It is kinda funny, that you mention RabbitMQ, which is written in Erlang, which is famous for its lightweight processes. But also compare the approach with thread pools built into the standard libraries in other languages. And even many of those are heavy weight compared to Erlang's lightweight processes.

    replies(2): >>44498943 #>>44499146 #
    6. ckbkr10 ◴[] No.44498943{3}[source]
    PHP is not about lightweight, it's about rapid development. A lot of implementations in PHP are dead simple and can be debugged even by beginners.

    You generally do not implement efficient systems in php, they are easy to debug, fast to code and quick to fix though.

    replies(1): >>44500074 #
    7. Cthulhu_ ◴[] No.44499135[source]
    It's better to build your app in e.g. PHP, prove its worth, then identify the bottlenecks, THEN determine if you need multi-threading. And if so, determine if PHP would be the best language for it or if you'd be better off going for a different language - one with parallelism / multithreading built into its core architecture.

    The first logical step after PHP is NodeJS, which has the fast iteration cycles of PHP without the low-level memory management or the enterprisey application server headaches of other languages, AND it has the advantages of a persistent service without needing to worry too much about parallelism because it's still single process.

    But if you still need more performance you have a few options. But if you're at that point, you're already lucky. Most people wish they needed the performance or throughput of a language/environment like Go.

    replies(3): >>44499558 #>>44500767 #>>44500930 #
    8. Klathmon ◴[] No.44499146{3}[source]
    PHP's approach is simple though, and in my experience that simplicity pays off when you do start scaling the systems.

    In other systems once you get beyond a single machine you need that external communication mechanism anyway, and now you have multiple classes of comms which introduces bugs and complexity and performance cliffs.

    In PHP you just throw another server at it, it'll act the same as if you just added another process. Nice linear scaling and simple to understand architectures.

    Man I miss working in PHP

    9. pier25 ◴[] No.44499373[source]
    The execution model is definitely the biggest issue with PHP these days.

    Although now that the PHP Foundation is officially supporting FrankenPHP maybe things will be evolving into a new paradigm.

    https://thephp.foundation/blog/2025/05/15/frankenphp/

    replies(2): >>44499436 #>>44500492 #
    10. todotask2 ◴[] No.44499436[source]
    There was a long discussion recently on FrankenPHP.

    https://www.reddit.com/r/PHP/comments/1lqpkfq/frankenphp_any...

    11. saghm ◴[] No.44499558[source]
    By this logic, it seems like it would make more sense to just start with Node rather than PHP for the prototype and save the potential rewrite. Node does seem more popular than PHP nowadays to me as an outsider to both, so maybe that's exactly what did happen.
    12. sroussey ◴[] No.44500074{4}[source]
    Most of the time you don’t really need to think about memory management either as the memory for the process is simply reset on every request.
    13. tored ◴[] No.44500492[source]
    But why pick PHP then? Why not use nodejs or similar where the language, application stack and the community is already in agreement on the execution model.
    replies(1): >>44500587 #
    14. pier25 ◴[] No.44500587{3}[source]
    I don’t use php but it’s extremely popular around the world. There’s also Laravel which seems a lot more productive than anything in js for full stack dev.
    15. mschuster91 ◴[] No.44500767[source]
    > The first logical step after PHP is NodeJS, which has the fast iteration cycles of PHP

    ... not really, you still have to deal with bundlers in real-world applications.

    replies(1): >>44507868 #
    16. 9rx ◴[] No.44500930[source]
    > Most people wish they needed the performance or throughput of a language/environment like Go.

    Most people do need the performance and throughput offered by modern languages like Go, though. Time to market is the most important consideration for most. Maybe at Facebook scale you can spend eons crafting perfection in a slow-to-develop language/ecosystem like PHP or NodeJS, but most people have to get something out the door ASAP.

    17. alganet ◴[] No.44501438[source]
    The shared-nothing architecture is great for some scenarios.

    Long running processes and async I/O are a great tool to have though. They are present in PHP for almost two decades now, and despite having many incarnations (select(), libevent, etc) and even frameworks (amp, reactphp, etc) the knowledge is highly transferrable between them if you understand the fundamentals.

    replies(1): >>44502716 #
    18. bornfreddy ◴[] No.44502716{3}[source]
    I agree, but I would always pick a different language (like Go) for long running processes. PHP is great for shared-nothing apps though.
    replies(1): >>44502890 #
    19. alganet ◴[] No.44502890{4}[source]
    Don't worry, we're not comparing languages here. You are free to chose the language and community that fits best to your approach to software development.
    replies(1): >>44504500 #
    20. bornfreddy ◴[] No.44504500{5}[source]
    Why, thank you for your generosity, you are too kind!
    21. sroussey ◴[] No.44507868{3}[source]
    I use bun and skip builds.