Live data from Hacker News

How come PHP seems so much faster than Rust?

reddit.com

111–116 of 116 posts

Re: How come PHP seems so much faster than Rust?

#111
post #107

Earlier quoted context omitted.

That PHP only got where it is today because of cheap hosting, down to the level of free beer, nothing more.

That doesn't explain how it beat a number of other technologies at the time -- including well established ones, like Perl.

Sure it does, cheap hosting. Many ISP only offered Perl with mod_perl, or telnet/cgi access, in the more expensive variants.

The cheapest of them all was PHP with files being dumped via FTP upload.

Re: How come PHP seems so much faster than Rust?

#112

The top reply says "Don't underestimate PHP when regexes are involved." and linked a benchmark [1]. But in that benchmark apparently Rust is faster than PHP (The slowest "Rust #2" is 2.45 sec. while PHP is 2.80 sec. He also mentioned "PCRE", but the ones with Perl in name are even much more slower [the fastest being 14.95 sec.]). Did I miss his point by linking that benchmark, or did I interpret the benchmark wrong?…

Being within a factor of 2 of perfectly optimized C code is excellent performance for a program in any language, including C :) Note that the fastest Java and JS programs are 4x slower than this, and Python and Perl are even slower.

That said, I am surprised that Perl does so poorly. It might just be that no one's submitted a perfectly optimized solution for Perl?

Re: How come PHP seems so much faster than Rust?

#113
post #110
post #101

Earlier quoted context omitted.

Because to be superior, the tooling and libraries also have to be superior. PHP was only free beer with a clunky language and 3rd class DB support. MySQL couldn't hold a candle to real RDMS back then, versus what was available with ODBC connectors.

> Because to be superior, the tooling and libraries also have to be superior. Perhaps that is your definition, but the dictionary disagrees.

Your dictionary definition I guess.

https://dictionary.cambridge.org/dictionary/english/superior

I don't see definitions about being cheaper as sign of quality, quite the opposite.

Maybe you would like to share your dictionary as well?

Re: How come PHP seems so much faster than Rust?

#114
post #17
post #5

This is a little silly. The two programs are so simple that it's probably just testing the speed of the regex engines used by the two languages. Since PHP uses PCRE (a C library that has been around for quite a long time), you'd expect it to be fast. I'm impressed that marshaling back and forth across the FFI boundary isn't causing more slowness, but perhaps it is, and the real issue is that rust's regex engine is ju…

> This is a little silly. Is it though? I interpreted question the following way. "Rust is a tool in my tool box, when the reason for picking it over other tools isn't demonstrably true, what am i doing wrong?" I agree with the rest of your comment, just not with calling the OP or their question silly.

You're right, and in hindsight I regret my tone there.

Re: How come PHP seems so much faster than Rust?

#115
post #3

This code is mostly just testing the regex engine?

Is the Rust regex engine slow because it's written in Rust?

Not really, it's mainly because it hasn't been optimized over many many years yet. Also, everything in Rust is implemented in Rust. Unlike interpreted languages like PHP, it's self-hosted.

Re: How come PHP seems so much faster than Rust?

#116
post #55

Earlier quoted context omitted.

> in fact running PHP via fastcgi was also quite common for a while. Mind clarifying how this is different from the current hotness (from what I can tell, due to a decade-old shortcoming that no longer exists in mod_php/Apache MPM options) where folks are running PHP via the Fastcgi Process Manager?

I don't think it is very different, other than hopefully maturity of the implementation. I've not had to set up any new PHP stuff for about a decade so I haven't kept up with what the current setups look like.

Re-reading it it sounds like it swung from fastcgi because Apache didn't have PHP support, to mod_php, and back to fastcgi (FPM) because Apache had poor concurrency support. It no longer does, but from someone who has to deal with this at their day job I can tell you that the current PHP ops wisdom is still stuck on not using mod_php.
Post reply on HN