Live data from Hacker News

PHP is worth learning and using

bulletproofphp.dev

171–180 of 468 posts

Re: PHP is worth learning and using

#171
post #163

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 try…

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.

Re: PHP is worth learning and using

#172
post #91

Earlier quoted context omitted.

But, what is, if not php? Do you shoot for what has had longevity, or what's rising?

It depends on what you want to do. The problem is that PHP is hyper-optimised for serving up HTTP. That was great in the 2000s when the web was eating the world and the other options were Java, Python, and Perl, but is less useful in the current climate where there's so many more platforms and web development requires javascript. By learning PHP, you are effectively locking yourself into the narrow niche of backend w…

Most languages lock you into one type of niche or another.

I'm quite happy with the Web niche, it's one of the longest lived, the stablest, the most open, and has some of the longest backwards-compatibility records around.

I can write a website today which will work in 25 years worth of client software! I think that's remarkable.

Re: PHP is worth learning and using

#173

Earlier quoted context omitted.

Because Elixir has transparent parallelism and trivially scales to 2000 reqs/second on a $5 VPS even though it's a dynamic language, oh and because it has LiveView which eliminates the need for most of the JS in a project (if latency isn't critical), so now a backender can take care of 100% of a web project. I worked with PHP 9-10 years ago. Still not impressed to this day. Why should I use it? Terrible type coercion…

If you're happy with Elixir, just use Elixir. But companies might want to use PHP, because it has a rich ecosystem, which handles corner cases. Chances are, if you want to send out bulk email, or connect to a payment provider, there's going to be a library in PHP that allows you to do that, often with long term support from an agency. A corner-case I recently had was needing to decode an email. There's a function for…

> If you're happy with Elixir, just use Elixir.

It's not that I never tried anything else. I got through 8 languages and made what I feel is an informed choice.

> Much of this can also be said of the Java ecosystem.

And yet, so many programmers and companies moved on from both Java and PHP to other tech and are managing very well. The company I work for has mere 6 backenders and we serve millions of visitors regularly without ever hitting >70% CPU on 3-4 servers.

Citing the entrenched state of affairs is not an argument either. It's an appeal to statistics (a good chunk of which are flawed as well).

I'm not going to try and convince anyone to stop using PHP or Java. Truth is, most programmers want stable predictable careers and there's nothing inherently wrong with that. I simply am not in that group.

Re: PHP is worth learning and using

#174

Earlier quoted context omitted.

The best part of PHP is the development model. You copy some files to a server, and load the page. That's it. It is really hard to beat how easy it is to iterate, even if the language is truly terrible.

I don't see how that makes the development cycle any better. I can just edit a file, press save, and it compiles and tests run automatically. If I'm doing something in interpreted languages, the code updates in memory. Furthermore if I'm working with JS/TS, hot reloading even makes it so I don't even need to refresh the page. I can even inject code into arbitrary places with the debugger (as if I'm editing the source…

[deleted]

Re: PHP is worth learning and using

#175

Earlier quoted context omitted.

Because Elixir has transparent parallelism and trivially scales to 2000 reqs/second on a $5 VPS even though it's a dynamic language, oh and because it has LiveView which eliminates the need for most of the JS in a project (if latency isn't critical), so now a backender can take care of 100% of a web project. I worked with PHP 9-10 years ago. Still not impressed to this day. Why should I use it? Terrible type coercion…

I haven't worked in PHP for years but 2000request/second doesn't sound unreasonable for PHP either? And that with a language that everyone can use.

All languages can be used by everyone.

Re: PHP is worth learning and using

#176
post #163

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 try…

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 s…

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.

Re: PHP is worth learning and using

#177

I have used PHP for years. Like it. Have accomplished some nice things with it. Think it's evolved nicely in recent years. Feel it's a great tool for particular problems. Will continue to use it. Will always be open to alternatives. Will never understand why some people find that so offensive and will tell you that you mustn't use it or imply that you are ignorant or stupid for using it.

Here's a choose your own adventure for people new to the field. Pick something you want to build, then see which languages are the best suited. If you want to build several things, see which languages are the most recurring and versatile: - Web frontend: Javascript/TypeScript - Web backend: Javascript/TypeScript, Python - Performant backend (where you manage threads and queues): Go, Java, Rust - Machine learning: Pyt…

You might also want to know a few languages were you're sure to get a job, and right now, it seems that Ruby on Rails and PHP are some really safe bets, compared to Python.

Sure, Rust is _fun_ but there's little demand for it right now in the market.

Re: PHP is worth learning and using

#178

Hey if you don't like PHP please don't use it. I 'd hate to bring the culture of tiny packages, fake compilers, transpilers and weekly trends to PHP. Personally I use php because it works well and fast and still supports my 10 year old websites, not because it's cool.

I like PHP and still use it today. But never in my life heard PHP is cool. Am I missing something?

If people call something "cool" - that's actually a red flag for me.

Re: PHP is worth learning and using

#179
post #43

I have used PHP for years. Like it. Have accomplished some nice things with it. Think it's evolved nicely in recent years. Feel it's a great tool for particular problems. Will continue to use it. Will always be open to alternatives. Will never understand why some people find that so offensive and will tell you that you mustn't use it or imply that you are ignorant or stupid for using it.

I haven’t used PHP in over a decade. I can never forgot how much PHP got wrong in terms of how application development on the internet would happen. The ergonomics of using it were just… bad compared to other frameworks that came on the market. I remember when rails came out and it was so mind blowing compared to PHP. The language was certainly useful for a time, and I’m sure the language has progressed since, but sw…

Php has developed a lot in a decade.

Lots of new good things in php7/php8. The typecasting is way better than before, but it still allows you to be more "dynamic" if you want to.

Re: PHP is worth learning and using

#180
As someone actually did (re)learn PHP (last time I used PHP was PHP4) last year for a gig, I would probably say no. Don't get me wrong, it is a much better language now and Laravel is a great framework. With the two you can no doubt build fantastic applications. But I didn't feel it was 'better' in any way than anything else. With Python, Go, Rust, Elixir, TypeScript etc. I can all point to a thing they do and say "if you are solving this sort of problem, then this language is the right choice because of X, and worth learning". With PHP I just couldn't find that.
Post reply on HN