15
AL1L
7y

Why does it seem like everyone here hates PHP. What did it do wrong?

Comments
  • 3
    How many other languages do you know besides php?
  • 4
    @Ratwerks 3 ish, Java, C#, and kinda JS
  • 4
    Security
  • 4
    @jbhelfrich a lot of languages have security issues, and there are ways to fix them.
  • 13
    If you took the time to actually learn PHP you would know what it does wrong.

    The list is fairly long but a few things that annoy me:

    1) The standard library is a f-ing mess. (inconsistent, functions copied pretty much as is from a wide variety of other languages)

    2) The execution model makes no sense in 2017, it was sort of sensible to have each request start from scratch with no persistent application in the 90s when people used shared hosting but in 2017 with containers and virtual machines it is just retarded. (It ruins the performance of otherwise great frameworks like laravel)

    3) switch statements use weak comparision in a language where you pretty much always want to do a strict comparison so insane constructs like switch(true) { case x===y: ...} are sometimes required)

    4) String handling is extremely low level which is a pretty bad idea in a high level web focused language, especially today when the web uses unicode almost exclusively.

    5) PHP Arrays ...

    no space left
  • 3
    @ItsNotMyFault ++ on the standard library. It's down right offensive.

    They published a new structure library with php7 that seems to be a bit reminescant of Java's (old?) List API, so I still need to look it up.

    Also, I'll need confirmation, but I think that they've manage to limit the overhead of individual requests with PHP-fpm
  • 2
    @paulwillyjean php-fpm removes the overhead of starting a process, it does not do anything for the overhead of executing bootstrapping code for a framework on each request.(Look at what laravel does on each request for example, it is insane and the amount of code it has to execute goes up as you add functionality to your system (you can't even add routes without increasing initialization time).

    You can partially get around it by storing a serialized application in a shared memory block (unix/linux only) or an in memory database (memcached, redis) but you would still need to deserialize the model and get it back into process memory before it can be used (the overhead then only depends on the size of the model rather than the complexity of initializing it)
  • 0
    I have a feeling more people here hate Java.
    And of course MacOS.
    ...
    ...
    ...
    And I primarily work with Java on MacOS...
  • 0
    @ItsNotMyFault

    My biggest issue is that there are a lot of features which seem to be implemented in a halfassed way, or make it easy to abuse them.

    Traits, reflection and magic functions are really cool, but you can mess things up badly with them. Laravel's models for example are easy to use on the surface, but often you wonder "where the fuck does that property come from".

    It also annoys me that I can tell a function to take an array or a closure, but not an [int] array, or a string -> int closure.

    I'd love to move to something with a more sensible typing system again, but demand for PHP is very high around here.
  • 1
    A good link is better than a 1000 characters explanation: https://eev.ee/blog/2012/...

    Do note though, that every language as problems. PHP is a language with more problems than the average.
  • 2
    I've been using PHP for 20 years now, and I still love it. I don't expect it to behave like another language, I expect it to be PHP. Of course there are some small annoyances but all ov all it is great. I don't use bloated frameworks that much as I've mostly written my own optimized frameworks, so performance hasn't been an issue.
    But I've also used other languages for almost as many years, like c#, C++ (on and off), and many others. And I've had more annoyances with all those other languages, and security issues. But this is all probably just because of experience, I know every corner of PHP which makes it easy to be secure and performant.
    Bottom line is, use the correct language for the correct situation.
  • 1
    This got more attention than I thought.
  • 2
    @AL1L Next time, don't assume, Google first.

    That's why I asked how many other languages you knew. If you were profificient in other languages that are commonly used in enterprise applications you'd be able to see what was wrong by comparrison.

    When someone asks what's wrong with php it either means they're trolling or they don't have much experience with anything else.
Add Comment