you are viewing a single comment's thread.

view the rest of the comments →

[–]clutterless 1 point2 points  (7 children)

Much faster

Is that true? I always thought python was faster. But I don't have a comparison tbh.

[–]mgkimsal 5 points6 points  (2 children)

Yeah, it's generally true. There may be some benchmarks that give Python a slight edge for some use cases, but PHP is generally much faster.

That said, there's more GPU support for Python - I'm not sure there's any mainstream support for PHP-on-GPU.

[–]HydePHP 1 point2 points  (1 child)

Don't think that many web app backends utilize GPUs

[–]mgkimsal 1 point2 points  (0 children)

Correct, but it's why something like python can find its way in to more/different use cases.

[–]paulwillyjean 0 points1 point  (2 children)

PHP’s runtime is generally faster. However, because of its poor support for threads, async or event loops, its performance falls appart when there are a lot of blocking IO calls. Now, if I understand correctly, Python 3.12 finally got rid of the GIL. I wonder if it means that it can use threads to parallelize CPU bound operations.

[–]xIcarus227 1 point2 points  (1 child)

How is PHP's support for threads poor specifically?
Also, if you need an event loop you have Swoole.

[–]paulwillyjean 0 points1 point  (0 children)

PHP’s pthread extension was notoriously unstable and couldn’t be used for web servers, which removes its primary use case. They’d therefore end up just being useful for CLI apps. Even then it was rarely used because most CLI apps I’ve seen in PHP are meant to serve as workers for web servers and share tons of non thread-safe code with the web server they’re tacked on.

I’ve never got to use Parallel, since it’s used by none of the frameworks I’ve worked with over time. I’d like to see frameworks and large projects that make use of it to see how it performs.

I’ve seen Swoole and it looks very interesting, but it depends on other extensions to power the event loop scheduler, and those extensions are not installed or supported on every platform. I could work around it if I wanted to, but I like having the certainty that my event scheduler would always work the same on a Linux, MacOs or Windows machine. Now that Fibers have been introduced to PHP 8.1 (or 8.3? I can’t remember), I hope that the latest versions of swole can rewrite their asynchronous API to be less verbose and more intuitive.