Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Most arguments against PHP miss the point. You know why you should use PHP? Because it's fun and you can get something running much quicker than figuring out the Elixir, Ruby, Rust, whatever ecosystem and paradigm. Maybe PHP is not so good at WebSockets or async worker threads, but most projects don't need that. There's no shame in doing long polling, users can't tell the difference anyway!

PHP shines when you're trying to get a server-rendered web app off the ground. It's the VB6 of the web. Nothing else matches its development velocity, from keyboard to working code.



I used to believe this, but...

But that's just not true.

All the things you mentioned are a yum/apt/nix/pacman/ install away on Linux, and probably as simple to install on macOS. I'm sure Windows has installers for these, too.

So, it's no harder to develop in them than it is in PHP.

You could argue it's cheaper because you don't have to pay for a shared hosting provider to host your files. However that's a bit moot since even back in the day there were LAMP stack Vagrantfiles that would automate this local setup.

Also, when speaking about dev velocity or time-to-start: you forgot JavaScript, which probably has much greater development velocity than anything else.

Furthermore, PHP is rarely just PHP in production. PHP also comes with various runtime modes (CGI, FPM, etc), .htaccess rules (or nginx equivalents), a bunch of runtime language and feature toggles that are partially controlled by the system (ie your hosting provider), and some can be controlled by the application.

The ephemeral process nature of the language makes some tasks very difficult to do in a performant way (but there's caching, so that's at least mitigated).

I've seen so many developers (worked for a hosting company) come complain to us about slow servers when in fact they'd just be doing silly stuff. And it was hard to blame them, because the language encourages that model, and the "performant" was was usually orders of magnitude more difficult to implement (ie indexing, image resizing, or most types of batch processing).

I'll not go into the horrors of how easy it is to mishandle file uploads in PHP (there's plenty of those around) and how many times people got easily hacked this way.


I went on a rant, but didn't mean to. I don't have anything against PHP, it's got a valuable and relevant place on the the web. It's important to many people, and like you said you find it fun, which I think is important for our productivity as devs.

However, I think this recurring misconceptions how easy PHP is to develop in needs to stop. PHP comes with a lot of complexities. Worst kind of complexity to learn: hidden complexity.


I can't think of a single in-use tech/language that does not have a lot of complexities. And by definition, these will almost certainly be 'hidden complexities' for someone coming in to that ecosystem.

What's been useful about PHP (and many other stacks) is that the good ideas from other worlds usually get assimilated in over time. PHP is not always at the bleeding edge with respect to language development, but that's just fine. The PHP ecosystems often adopt/adapt useful ideas/techniques from other ecosystems relatively rapidly, and that's just fine too.


> I can't think of a single in-use tech/language that does not have a lot of complexities. And by definition, these will almost certainly be 'hidden complexities' for someone coming in to that ecosystem.

You're 100% right.

My original comment focuses on PHP because I was specifically addressing the "PHP is the easiest to develop in" idea.

I realise that it might seem a bit too critical maybe because PHP was the only topic in it, but I didn't mean it to come off like that. Hopefully I redeemed PHP a little bit in the follow-up comment! :D

At the end of the day: every ecosystem/language has its own "that shadowy place over there" :P


I think fun is important but I see nodejs and rails as equal to php in the easy and fun part. Maybe python too, have not used it enough.

If we are talking about building large web applications then performance, maintainability and other things may start to be more important than fun and then c#, java, go and others can be really good solutions.


One person’s complexity is another person’s valuable job skill. PHP and Apache aren’t hard to setup and configure if you know how it works.


I completely agree that being able to navigate an ecosystem's complexity is a skill.

I didn't mean to imply that other languages don't have complexities. All ecosystems come with their own boons and complexity issues (hidden or upfront). The thing I wanted to address is the general idea of "PHP is the simplest to develop in, it's just uploading a file" (paraphrasing) shouldn't be taken at face value, and that's why I pointed out some of the complexities when working with PHP that PHP developers tend to forget (or some ignore).

But, because PHP is so easy to get started with, a lot of the complexity initially gets hidden away, and sometimes people learn about it the hard way.

JavaScript used to be much the same, but it has gotten better in the recent years. Maybe PHP has gotten better in this aspect too, but I could be ignorant because I've not been keeping up with PHP as much


With a hosting provider that already has PHP installed, you can simply upload a file to a folder and serve it over the web with no special expertise.

PHP makes it easy for beginners and amateur programmers to get something working without knowing much.

Because of the low-barrier to entry and simple hosting setup people have written a lot of crap PHP code over the years. I know, I see it and work with it.

Amateurs and well-meaning power-users can get some web pages up and running easier with PHP than with almost anything else, so while inexperienced programmers can write bad code in any language a large number of them choose PHP.

None of those facts mean PHP is not suitable for "real" development and "real" programmers. It is not obsolete or dying. A professional programmer who knows how to build production-quality web sites can get great results from PHP. That requires putting in the same time and effort needed to learn any other language and set of tools.


> The ephemeral process nature of the language makes some tasks very difficult to do in a performant way (but there's caching, so that's at least mitigated).

I'd rather say that this is actually one of the biggest selling points for PHP. Opcache and JIT works great, and reduces the overhead, but ironically, PHP is great for serverless applications.


Your comment on file uploads in PHP reminded me of the remote code execution via automatic file metadata parsing vulnerability built into PHP that happened a couple years ago.


If you don’t manage your own servers I don’t think you can call yourself a professional developer. “My hosting provider doesn’t let me do X” is a lame excuse with cloud servers in the $10/mo range.

I do a lot of work with PHP, both legacy and new code. The number one mistake I see with PHP sites set up by amateurs or cheap hosting services is running Apache+PHP on the same server as MySQL or Postgres. Separate those and performance and stability problems go away. That’s because relational databases consume as much memory as they can get, not because PHP is inherently slow or unstable.


This is the classic "everyone who does not know how to X is not a real Y". Every single software dev can make such a list. Very few reflect on the fact that no two of those lists look the same.

You can't know everything. Programming is about abstraction; so abstracting away devops is a feature (in some contexts), lack of that is a downside (in some contexts).


No one can know everything. We can all learn things we need to know. Or we can post about how something we don’t know is gross, complicated, broken.


That sounds about as nonsensical as saying "If you don‘t draw your own icons I don't think you can call yourself a professional developer". Very few developers actually do both of those things. If you said "If you couldn‘t learn how to run your own servers…" I could possibly see that.


The distinction I was making was between companies, teams, developers who use cheap hosting services and then bash PHP when the problem is they don’t control the hosting environment. “I can’t change my PHP or Apache config because I pay $5/mo to HostGator” is not a good reason to complain about PHP.


> If you don’t manage your own servers I don’t think you can call yourself a professional developer. “My hosting provider doesn’t let me do X” is a lame excuse with cloud servers in the $10/mo range.

Hosting (as a service, and shared hosting) is a very complicated business if you want to do it right.

Also, when picking hosting providers, there are many things that factor into this. Social, political, and economic status are one thing (of the dev and the client). Another thing that comes to mind is the client's (or sometimes even dev's) location/jurisdiction (or the website's audience).

The availability/locality plays a giant role in selection in non-western countries. For example, some European countries/ISPS have super-fast internet within them or up to the closest IX (internet exchange), but horrendous speeds towards anything beyond the IX; sometimes these are intentional (alas, curse politics) sometimes they're not.

We had many clients that would migrate to us because they had these issues with previous providers because we were different from other hosting providers.

Disclaimer: I used to work for a hosting company


Yes, hosting can get complicated. A production web site should run in a production-quality environment, not on some $5/mo shared setup that doesn’t let you control the PHP/Apache/nginx environment. If that’s your setup you will run into issues eventually, just like you would if you couldn’t change the settings on your work computer.


Surely you also have to figure out the PHP ecosystem and paradigm if you don't have experience in it? In any case, I fail to see how PHP is more fun than, say, Python. I have done a few projects in PHP and I would take Python in a heartbeat. To me this seems like a clear case of Stockholm syndrome, but what do I know... Maybe I'm missing something.


There are other solutions to long polling now. You can use Pusher, ReactPHP or Amp (https://amphp.org/) to use websockets with php instead.


Until someone implements long polling in wordpress and has to load the whole framework for every poll. This can never be the right approach


I've noticed some good bits in PHP, there's indeed a low level thing to it; it's not trying to find the new paradigm. Their cli tools are often nice and to the point (rare quality). But the language per se doesn't seem to bring a lot compared to python in terms of expressiveness, and the regular bugs are still worrisome to me.


I would guess nodejs has the same development velocity. And you can just copy js files into a server that has node to build a web application.


You mention it in passing, how much ruby on rails experience have you ?


That made me laugh, thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: