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?

  • l3mming@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    28
    ·
    1 year ago

    I’m a web developer of 25+ years. These days python, php, react, vue stack. Formerly, C, C++, perl and assorted other oddities.

    Forget what you once heard about PHP. Modern php is nothing like its early days. Modern php has some great constructs that give language expressiveness and fluidity, and that really lends itself to concise and beautiful code.
    PHP also has some brilliant web frameworks (eg: Symfony) that make build web apps (be it REST APIs or frontend backends) just a pleasant experience all around. It’s dead simple yet extremely powerful. This makes makes development and maintenance using PHP cheap. PHP’s testing suite is also ridiculously powerful.

    By comparison, I find python web frameworks (Django, flask etc), fiddly and finnicky to use. I also find Python a much less expressive language. By that I mean it will often take me several lines of code to do something that is otherwise a 1 liner in php. It just feels clunky and awkward.

    Don’t get me wrong. I once hated and laughed at PHP with the rest of them. But PHP has really evolved over the past 10 years, much more so than python has. I look forward to the day Python has a good hard look at itself.

    In the meantime, if I need a backend for a website and I’m given the choice between PHP or Python, I’ll choose PHP (symfony) every time.

    Besides, PHP devs are cheaper.

    • WatTyler@lemmy.sdf.orgOP
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Thank you for the detailed response and don’t worry: you don’t have to pull punches on Python on my account 😂 I’m a former Django dev and I have no intention of working with Python ever again. I see why it’s so popular for data analysis etc.: it’s a phenomenal language for non-programmers.

    • tal@kbin.social
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      1 year ago

      I don’t really focus on Web development (though I’ve done a little in various languages when it became necessary to solve specific problems), but over the years, for software development, I’ve become pretty conservative about adopting new programming languages, frameworks, libraries, and so forth when they come out. I have seen a very large number of things that were new and trendy vanish in the wind after people put a lot of effort into coming up to speed on them.

      Once there’s a large installed base, though, they’re gonna be around for a long time to come, because software projects have committed to them.

      None of this is to ding Rust, which Lemmy uses. I’ve never written a line of Rust myself, don’t know the ecosystem. But I don’t think that PHP is bad just because it’s pretty mature.

      Also, related side note: Reddit was originally implemented in some Lisp variant, probably in part because Paul Graham, who was involved in some early funding, is a huge Lisp fan. There isn’t that much web dev happening in Lisp, and Team Reddit later had to go back and reimplement it in the more-widely-used Python, on the Pylons framework. That doubtless cost them a lot of dev time.

      • Bipta@kbin.social
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        PHP isn’t bad because it’s mature. It’s bad because it’s PHP.

        Still, it’s good for the right jobs.

      • Thorry84@feddit.nl
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Totally agree, people seem to be always searching for the next hot thing, claim it’s better than everything else and start porting stuff to it. A couple of years later they choose the next hot new thing and ported their old stuff over to that. And so the cycle continues.

    • scarcer@kbin.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      While I haven’t tried symphony, my annoyance with PHP in general is that parsing any kind of data is tacky. In the end you have just as many lines as python but less readable.

      Cleaner functions or cleaner data? Both languages have their strengths and can (now) be typed.

      • l3mming@lemmy.fmhy.ml
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Well, this is true. It’s all about the right tool for the job. The PHP hammer is good at some things and bad at others. It is good for web development, it is bad for parsing [thanks to its truly awful regex functions], and it is way too bloated to be any kind of scripting language. Python is much better for parsing and transforming data, but its regex implementations are still pretty awful when compared to something like Perl. In fact, I still reach for Perl when I have to parse complex and unstructured text. Haven’t yet reached for Perl 6 though.

      • operator@kbin.social
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Use the right tool for the job. If you need extensive data parsing and handling, it might be better queuing that off to another service. Even python libraries are usually written in C…