70% of the world’s internet btw, but out-of-support deployments and little funding for permanent staff to manage the open-source project.

  • trompete [he/him]@hexbear.net
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    20 hours ago

    PHP’s selling point was basically being able to embed into html. That’s obviously possible with any language; it’s not hard at all really, I think you call that a template engine. But PHP had that as its core idea. Many a webhoster enabled PHP in the 90s, meaning it was easier to deploy than other languages, which would have to go through CGI (common gateway interface, a protocol for handing HTTP requests to scripts/binaries, which is how you traditionally interfaced a web request with e.g. a Perl or C program). CGI also spawns a process each time, which is slow, whereas PHP came as an Apache plugin.

    So PHP won over Perl, which had a head start in that space, I think mainly due to convenience and the because webhosters supported it.

    Perl is a better, more well thought out scripting language arguably, but was created as an alternative to Unix shell scripts, and not web-first. Also it’s more complex. PHP is more straightforward and C-like.

    The complaints about PHP, and I share them, is that PHP was not only for amateurs, it was created by amateurs. In some earlier version of PHP, for example, something like this:

    f(g())
    

    would have to be written as

    $a = g()
    f($a)
    

    which is just ridiculous. People had figured that out in the 60s, maybe even earlier, and that had worked in every language since then. The creator of PHP would have to have never read a book or attended a course on language design, garbage collection, compilers, parsing, or probably any other relevant topic. They were totally winging it. In versions 4 or 5, PHP copied, in a cargo-cult like fashion, various object oriented features from C++ without deliberate thought. The built-in standard library, while extensive, was notoriously inconsistent and easy to misuse, further exacerbated by the fact that PHP loves to convert types silently instead of throwing an error.

    It really deserves its place in the hall of fame of the worst languages. Most of the things up there (like Unix shell or BASIC) came way earlier, and at least you can see how and why they are as they are, but PHP is totally born from ignorance (or rather superficial half-knowledge) of what came before.

    It’s still around because frameworks like Wordpress, Mediawiki (Wikipedia) and various legacy websites have not transitioned to something else because it would be a monumental task to migrate all this shit.