Live data from Hacker News

How come PHP seems so much faster than Rust?

reddit.com

51–60 of 116 posts

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

#51

Earlier quoted context omitted.

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.

As one that has never, ever written a single program in Rust, am I part of a "Rust community"?

But I agree, I'm not nice at all, indeed.

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

#52
post #33

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

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.

How so? As someone that's set them all up - with Apache the setup for mod_perl, php, and cgi are like the same right - they are all essentially cgi.

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

#53

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

Specifically to that point, Rasmus talks here about the reason PHP succeeded where Perl failed https://youtu.be/wCZ5TJCBWMg?t=552

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

#54

Earlier quoted context omitted.

But plenty of those vulnerabilities are not the fault of the language but the frameworks written by others. You can just as easily create SQL injection attacks in a Rust program or Ruby program. You can just as easily introduce XSS/CSRF problems in any of them. Etc.

If the majority of frameworks for a language are vunerable it's the language's fault. Python definitely doesn't have that issue, Rust and Go don't either.

> majority of frameworks for a language are vunerable

Where's your proof? Modern PHP frameworks are secure by default.

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

#55
post #36

Earlier quoted context omitted.

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.

> 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: How come PHP seems so much faster than Rust?

#56
post #52
post #33

Earlier quoted context omitted.

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.

How so? As someone that's set them all up - with Apache the setup for mod_perl, php, and cgi are like the same right - they are all essentially cgi.

I remember it as a worse Perl, but with a bunch more web-batteries included. It's the latter that got me interested, way back in the day. Deployment story wasn't that different, aside from that cheap hosts were more likely to let you run PHP than Perl.

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

#57
post #39

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.

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.

It's more like, would someone else be able to maintain the code I write with language X? And would the person trying to run it be able to run in their environment without fiddling with SSH access?

If it's just me writing and deploying I use TypeScript but otherwise I tend to use PHP.

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

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

Two other big factors in PHP's popularity in the early 2000s were its inclusion in Dreamweaver as an option for building dynamic sites and the profusion of "Build X with PHP & MySQL" magazine articles.

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

#59
post #37

Earlier quoted context omitted.

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.

> I do remember ASP, Cold fusion, CGI This is the competition that PHP was so much better than.

I had a job 5 or 6 years ago where I needed to maintain/add to a website using ColdFusion. I actually kind of liked it, compared to PHP. That said I wasn't doing anything especially complex, which might have changed my mind.

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

#60
post #52
post #33

Earlier quoted context omitted.

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.

How so? As someone that's set them all up - with Apache the setup for mod_perl, php, and cgi are like the same right - they are all essentially cgi.

No, they are not the same as CGI. You can run PHP as a CGI, as many cheap hosts do, but for performance PHP is run as either Apache mod_php or php-fpm with Nginx. Mod_perl is not CGI and requires much more discipline to prevent shared memory leaks. Mod_perl allows content negotiation which CGI does not.
Post reply on HN