Live data from Hacker News

How come PHP seems so much faster than Rust?

reddit.com

31–40 of 116 posts

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

#31

Earlier quoted context omitted.

PHP isn't popular because it's easy, it's popular because for a long while it was the only viable language for developing web applications.

>for a long while [PHP] was the only viable language for developing web applications. That is not what I remember. CGI existed before PHP (1994), and was used extensively for web apps (ebay still appears to use it to this day). Also, mod_perl and Java Servlets were introduced around the same time, circa 1996, so I don't think it's correct to say PHP had a monopoly on web apps "for a long while".

Not a monopoly, but it was the easiest and most performant option at lower price points.

Java required specialised or dedicated hosting ($$$). CGI was slow as hell. Mod_perl often was not available in shared hosting, for whatever reason.

PHP was cheap, fast, ubiquitous, and Good Enough™, for about a decade. Then VPS happened and the market changed.

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

#32
post #17

Earlier quoted context omitted.

> 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.

The reason for picking it is for memory safety as well as performance. If your problem involves a lot of regex and memory safety isn't as critical, then feel free to pick a language with good regular expression libraries. If regular expressions are a smaller part of your problem you're solving, looking at overall performance is better than benchmarks like this.

I'd never know that if this post didn't exist, so I don't think the investigation is silly at all.

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

#33

Earlier quoted context omitted.

PHP isn't popular because it's easy, it's popular because for a long while it was the only viable language for developing web applications.

>for a long while [PHP] was the only viable language for developing web applications. That is not what I remember. CGI existed before PHP (1994), and was used extensively for web apps (ebay still appears to use it to this day). Also, mod_perl and Java Servlets were introduced around the same time, circa 1996, so I don't think it's correct to say PHP had a monopoly on web apps "for a long while".

The friction involved in getting those other technologies up and running was not trivial though. That played a role in php's initial success, because it was trivial to get up and running.

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

#34
post #11

While this discussion boils down to the efficiency of the underlying regex engines for PHP and Rust, it does highlight (to me) why PHP is so popular: in the hands of average programmers, PHP is quick to write and fast (enough) to execute. I personally believe it's ubiquity is well-deserved, and I actually like it as a language despite all its quirks (which exist in almost every language I've come across)!

PHP isn't popular because it's easy, it's popular because for a long while it was the only viable language for developing web applications.

s/PHP/Javascript

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

#35

Earlier quoted context omitted.

>for a long while [PHP] was the only viable language for developing web applications. That is not what I remember. CGI existed before PHP (1994), and was used extensively for web apps (ebay still appears to use it to this day). Also, mod_perl and Java Servlets were introduced around the same time, circa 1996, so I don't think it's correct to say PHP had a monopoly on web apps "for a long while".

Coldfusion was also a thing around that time. Flash sites as well.

[deleted]

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

#36
post #31

Earlier quoted context omitted.

>for a long while [PHP] was the only viable language for developing web applications. That is not what I remember. CGI existed before PHP (1994), and was used extensively for web apps (ebay still appears to use it to this day). Also, mod_perl and Java Servlets were introduced around the same time, circa 1996, so I don't think it's correct to say PHP had a monopoly on web apps "for a long while".

Not a monopoly, but it was the easiest and most performant option at lower price points. Java required specialised or dedicated hosting ($$$). CGI was slow as hell. Mod_perl often was not available in shared hosting, for whatever reason. PHP was cheap, fast, ubiquitous, and Good Enough ™, for about a decade. Then VPS happened and the market changed.

Most people initially deployed php via CGI in my experience. I don't remember when mod_php arrived, but we'd been using PHP for quite some time at that point.

While CGI was slow-ish, alternatives like fastcgi were already around (and in fact running PHP via fastcgi was also quite common for a while.

By the time PHP became ubiquitous, most people had moved away from plain CGI regardless of language.

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

#37

Earlier quoted context omitted.

PHP isn't popular because it's easy, it's popular because for a long while it was the only viable language for developing web applications.

Indeed. I think most developers don't understand how amazing PHP was compared to the competition and just how fast it acquired new features during those early years. It was a scripting engine with a such a thin layer of C that it could easily and quickly incorporate the huge number of open source C libraries that existed at the time.

While your observation is true to some degree, I do remember ASP, Cold fusion, CGI and a few other more obscure technologies way back when.

Perhaps I was quite late to the party though - I only started programming in 1999 (got a computer for my 11th birthday!) - so I'm not sure what it was like before then.

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

#38
Theory.

The php script and the log in question are probably in the kernel's aggressive block layer cache. The new files created by rust are potentially new and uncached, mean that it must be loaded from disk. Therefore the rust version is probably just losing time on disk access.

Quick test: review whether or not the rust version runs faster on the second execution.

Also or alternatively: use a profiler or copy the rust program to an in-memory block device (ramdisk) prior to access.

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

#39
post #11

While this discussion boils down to the efficiency of the underlying regex engines for PHP and Rust, it does highlight (to me) why PHP is so popular: in the hands of average programmers, PHP is quick to write and fast (enough) to execute. I personally believe it's ubiquity is well-deserved, and I actually like it as a language despite all its quirks (which exist in almost every language I've come across)!

PHP isn't popular because it's easy, it's popular because for a long while it was the only viable language for developing web applications.

Not sure I agree with this. Here's why: new tech stacks crop up every few months, and they're all competing for the same developer brain space. If PHP wasn't easy, I'm certain the interest in it would have evaporated to a large extent. Yet even today, people are choosing to start their projects in PHP. I think it's simplicity has a lot to do with it.

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

#40
post #19

Earlier quoted context omitted.

This is more than a little silly, and simply shows that the self-proclaimed PHP developer (who is "not surprised that PHP is 'fast'") has little to no idea what is costly in execution time, even in such a tiny example of a program, and has no idea how to figure that out.

What's silly is that somebody asked a legitimate question in good faith with code samples and everything, and you responded with an ad-hominem attack with no useful information.

Didn't someone here say we should judge a language by its community? Well the Rust community is not very nice.
Post reply on HN