Hacker News new | ask | show | jobs
by yc1010 4217 days ago
I wonder how it would compare in performance to latest PHP/Nginx stack which is rather very fast with good code. And then there is major improvements in PHP on horizon and already alternatives like Facebooks PHP implementation
3 comments

Good questions. No answers, but I have this reflection to add. Over the past decade PHP has, by and large, put food on my table. Every year or so I evaluate my overall toolkit (ranging from languages to frameworks) and make sure I'm backing the right horse.

This year, I put a thirty-five dollar C# book on my holiday wishlist.

I'm gonna guess it would be around the same on a Linux server, because it's under a runtime, just like PHP. There's no reason to expect a drastic difference between one or the other.

On a Windows server however it's compiled and highly optimized. Which PHP/NginX/HipHop you also have a compiled environment and is just as fast or faster.

I have no data to back it up at all, but I'm going to guess ceteris paribus the performance differences are marginal at best.

Why the hell would anyone ever use PHP for anything?
I personally despise coding in PHP as much as anyone, but it has been used for a number of hugely successful projects, including Wikipedia and Facebook (that latter has even written a transpiler that converts PHP into C++). PHP is the bog standard on a LAMP stack so you know it will run on any environment, and there is a huge pool of programmers who know how to code it. Those are nontrivial reasons.
The P in LAMP stands for PHP, so it's the ONLY application language on a LAMP stack. Hope I'm not being too pedantic.

Symfony 2 is quality engineering. It's quite nice just to browse the source.

Times in the past that I've seen LAMP explained, I've read that the the P in LAMP was for PHP, Perl, or Python (any one of the 3).
If you consider Wikipedia a good example of what PHP can do, we have irreconcilably different quality standards.

I think the technical debt of PHP is a huge reason why development of the software behind Wikipedia hasn't fixed any of the huge issues in the last 5 years.

I cite Wikipedia as an example of a successful website built with PHP, not necessarily as an example of a well-designed site.

You don't need to convince me that PHP is a clunky, unpleasant language. My point is that there are still legitimate reasons to choose it.

The fact that there are successful website implemente in PHP is not a legitimate reason to choose it.
Oh, I don't know... Maybe because of easiest imaginable deployment scheme? Comprehensive stdlib and lots and lots of libraries and bindings for everything? Its forgiving nature, which makes it try very hard to do what programmer meant instead of dying with cryptic error messages? Or possibly because of bazillion other legitimate reasons people have for choosing to use it...

Languages are just tools. Some are better than others for a specific task. This is a fact. You choose the language for a given task because it fits the task better than other options. That's all there is to it.

I don't currently use PHP, but I acknowledge that there are situations where using it makes sense. I'm just not in one of those situations in present. Saying that PHP is a bad choice in every situation is worse than stupid: it's simply wrong.

"Its forgiving nature", like VB's "On Error Resume Next" and JavaScript's automatic semicolon insertion, is not an advantage. Debugging with cryptic error messages is better than having no idea that the program is silently doing the wrong thing.

Its standard library is no more comprehensive than those of comparable languages.

The only advantage left, then, is the same one all the sibling comments bring up: it's already installed on the server.

So the question remains: Why would anyone who has a choice and knows that other languages exist ever use it for anything?

Can we stop with this kind of comment, already? Yes it has its warts but like it or not a fair amount of people enjoy using it. Get over it.
I'm a ruby developer myself (and also a huge advocate of ruby) I use PHP to mashup quick weekend prototypes to test stuff like third party API's, mini dashboards, etc. Because, nothing beats the convenience of uploading a simple PHP script to a server via FileZilla. It's what you build with the programming language that matters more than the language you use. And no, I refuse to be shamed for my programming language choices.
Why the hell would anyone ever use anything for anything?

Because that shit gets the job done. Pick the right tool for the job, sometimes PHP is the right tool.

I know it's "cool" to hate PHP, but anyone asking this question obviously hasn't used it. It's a tool that solves problems fast and cheap. It's not for every application but it fits for some VERY well. And most of PHP's problems are the newb programmers it attracts, just like JavaScript. The language itself has tons of quirks but you can write good PHP just as well as anything else, and you can solve certain problems very fast with it.
The thing is there are better languages that solve the same problems PHP solves at the same speed or faster. This is why Ruby become so popular.

Javascript is a sad story though, it's an abysmal language (even with ES6, though that does make things better) but it enjoys a monopoly over the browser runtime space.

I think asking why anyone would start a new project in PHP is a very reasonable thing to ask.

If you want quick and dirty there is Ruby + Sinatra, Python + Flask or Go + Martini. All of which are safer, have less 'quirks' as you say and are all faster. None of them require any more work than the current PHP alternatives.

PHP may be superior to some languages in some regards, but it's definitely no longer the king of the hill of prototyping languages.