Live data from Hacker News

Why Developers Hate PHP

jesuisundev.com

111–114 of 114 posts

Re: Why Developers Hate PHP

#111

Earlier quoted context omitted.

its fun to trash talk PHP who cares if statements are accurate. PHP sucks because of the dollar signs everywhere. From a distance Wordpress code looks like Nigerian Prince emails. And crazy coding conventions like mysql_real_escape_string. Really PHP?

mysql_real_escape_string() comes from the MySQL C library binding: https://dev.mysql.com/doc/refman/8.0/en/mysql-real-escape-st...

this actually makes sense. Maybe I was wrong about PHP. But maybe not :)

Re: Why Developers Hate PHP

#112

Earlier quoted context omitted.

This clearly shows PHP's origin as a set of loosely related libraries and utilities ties together with a thin veneer of a language. When used as an actual language it's less than ideal. Who's to say curl will still be the default way it makes some requests in the core language later? What if the library changes it's API after deprecating the version that was originally used? Coupling things like that is a poor design…

Indeed, but modern frameworks get around this quickly. If you use Symfony, Laravel or Drupal, you will likely never use these functions, because they are packaged as a replaceable module with proper OOP interfaces and classes. Most people who pick PHP these days are doing that because these very mature frameworks. I see no alternative to Drupal with all its glory in any of the modern languages. I think PHP-s success…

I don't necessarily think PHP needs to be retired. It's obviously matured and has plenty of use. I was just pointing out the flip side to using similar functions to the underlying C libs.

I've come to view languages as a set of competing trade-offs that optimize for specific points in it's life-cycle, whether purposefully or accidentally. For example, Python's "batteries included" feature was extremely useful early on. Now a lot of the included modules are superseded by a better external module that's the de-facto standard. For example, the Requests library for Python. Originally batteries included was a feature, but now certain modules in the standard library are mostly useful for backwards compatibility and do little otherwise except confuse new Python programmers.

Perl went through the same with the CGI module, which was old, crufty, had an interface that made it hard to keep contained, and was almost universally considered a bad idea (except for when you needed it for backwards compatibility, or really actually needed a CGI). It was eventually excised from the standard library, and relegated to an external library, so the Perl core didn't have to worry about it and it wasn't considered the default method for created web pages in Perl.

And that's just one axis. There's also optimizing for ease of use for amateurs (i.e. ease of learning) or ease of use for laymen/professionals. One makes it harder to get new users, the other often makes it harder to retain existing users (because what a layman wants is often not the same as what an amateur wants). You could consider APL to be at an extreme end of this spectrum. I imagine APL laymen are happy with the concise format and features because they've developed the skills to accurately read and interpret APL programs. As someone that doesn't know APL (as amateur as you can get), it's extremely daunting to see.

Then there's verbosity vs conciseness. And any number of other aspects of a language. Each is usually imparting some specific aspect to the language, and isn't necessarily better or worse than the same aspect of different languages, but often just optimized for something different.

Re: Why Developers Hate PHP

#113
post #23
post #20

There is no web framework out there which comes with such elegant concepts, syntax and feature-richness like Laravel. I have seen them all - Laravel is incredibly good, especially for small - mid sized projects! And this statement comes from a python guy.

Why do you prefer it over say, Flask or Django?

Laravel performs way better than Django, I also prefer the migrations/model styles that resemble Rails a bit more.

Django might be better w/ 3.3 or whenever they fully integrate async into the view/db layer, but w/ laravel I can plug in swoole and go from 110 reqs/sec to 4600+ on my dev pc - w/ 12 threads and 200 connections hitting a post api logged in, updating the database and the caching layer, and queuing notifications.

Just ran some big benchmarks on laravel w/ php-fpm vs swoole last night...as an aside. I also don't like some of the ways django handles auth. If I were to use python, I'd definitely go w/ FastAPI, it seems much more joyful a framework.

I'd also love to do something like go for sessions/auth/jwt and hasura, postgraphile, or postgrest or some sort of api from postgres, and then most of the logic would simply be postgres functions/triggers/etc...there's also some nice 'built-ins/ecosystems stuff that even rails lacks'.

Auth is built in, vs devise (being almost a requirement). Message queues, notifications, .env, events/listeners, are also all built-ins. Eloquent is nice, though repositories using straight sql or the DB class are probably more performant, but you lose a lot of the magic that makes laravel nice, so there's trade offs. Also all the many drivers for caching/queues/etc and telescope is a very beautiful way to debug and so is ignite for error pages.

Horizon is nice to manage queues/etc. I keep trying to move to another framework just for the sake of 'something new' and boredom but after 8 years on laravel, I still keep coming back. Wordpress is a totally different story, I charge 35% markup on my normal rates just to touch wordpress because it sucks so bad and hurts my brain to work w/ it. Also, I don't really need to worry about how to setup vue or react, laravel-mix pretty much handles all the webpack stuff w/ a few exceptions if I'm using Tailwinds or creating aliases for paths, etc...

Post reply on HN