I don’t know if it’s due to over-exposure to programming memes but I certainly believed that no one was starting new PHP projects in 2023 (or 2020, or 2018, or 2012…). I was under the impression we only still discussed it at all because WordPress is still around.

Would a PHP evangelist like to disabuse me of my notions and make an argument for using PHP for projects such as Kbin in this day and age?

  • GioryJalino@kbin.social
    link
    fedilink
    arrow-up
    8
    ·
    2 years ago

    Funny that a lot of people responded by bashing on PHP, but I saw very little real arguments why PHP is so awful. What makes PHP that bad besides being the target of memes?
    I mean “lame”, “old” or “dead” aren’t particularly convincing arguments.

    • l3mming@lemmy.fmhy.ml
      link
      fedilink
      arrow-up
      5
      ·
      edit-2
      2 years ago

      I was fortunate enough to meet Rasmus Lerdorf (PHP founder) long before I became a PHP programmer. At the height of the PHP hate back in the early 00’s Rasumus was bravely giving a talk to a group of us stuck up Perl programmers.

      To be fair, we had good reason. PHP had borrowed lots of functions from C for familiarity (all those str* functions) and done stupid things that made life unnecessarily difficult, like naming some of them with underscores and others without, and making parameter order inconsistent across similar functions. So it did all these C like things but, it did them way, way slower.

      Not only that, PHP also wanted to be like Perl because perl was also a bit like C but, unlike PHP, did things quickly and could parse just about anything you could throw at it. So, PHP also shoe-horned in a bunch of regex functions to give perl-like capabilities to their pile of poo. So now it also had perl capabilities, but was performing way, way slower than perl.

      PHP was like that try-hard kid at school that wanted to please everyone, but everyone pretended not to know.

      But, most impressively, Rasmus was very apologetic for what PHP had become. He said to us that PHP was never designed to be a programming language. It was designed to be a “Personal Home Page” templating tool. But soon people wanted to conditionally include bits of templates. Then they wanted to iteratively include bits of template.

      And then he learned about lex and yacc, rewrote the whole thing. And finally, one stormy day, there it was. Hideously ugly and Turing complete.

      And, when he said all this suddenly it all made sense and we had a whole lot of sympathy for where it and he was at.

      He went on to say that they were putting a lot of working into looking at the worst bits of PHP and making things better. And, credit where credit’s due, that’s exactly what he’s done. PHP today really is a nice language to work with.

    • jmcs@discuss.tchncs.de
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      It’s a terribly designed (and I’m being very generous with the use of the word designed) programming language, but to its defense so is JavaScript and people are not bashing NodeJS apps.

      Newer versions of PHP seem to be dealing with lots of past mistakes, but it will always have lots of warts due to backwards compatibility.

      • GioryJalino@kbin.social
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        What are those warts? I’m not trying to be a dick, I’m just not educated enough on this subject. Is it more the ease of use (needing much more lines of code to do something or you need to build things yourself since there isn’t a function for it) or more the way the language is build (multiple functions doing the same thing or misorder of arguments)? Or is it just the performance?

        I started with PHP years back, shifted to Android/Java and then to C# (Xamarin) to Javascript (node.js/React(Native)). All in a hobby/personal project form, so I didn’t bump into problems with PHP most peofessionals seem to have and I still use it for API’s sometimes.

        • jmcs@discuss.tchncs.de
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          2 years ago

          You have things like type juggling which can hide nasty and hard to troubleshoot bugs. There are also inconsistencies because before 2014 the developers were YOLOying it instead if having a formal specification to stick too.

          And then you also have older parts of the standard library that were done by people that didn’t know what they were doing, leading to things like mysql_escape_string which doesn’t properly escape strings in some charsets, meaning you should use mysql_real_escape_string and that lots of beginners used the wrong, unsafe, function.

          Another thing that doesn’t help PHP’s reputation is that it used to be the language of choice of people that knew enough programming to be dangerous. I.e. people that know enough to do small applications, but not enough to take security issues or reliability in consideration. Which by the way, is still a big attitude issue in the PHP world seeing only 8% of PHP Websites use a supported version of PHP with security updates..