re: What's the deal with downing PHP development? VIEW POST

FULL DISCUSSION
 

Let me start with a blatant opinion: I'd rather use PHP than pre-await Node for writing a web application, because callback-oriented development is stupid. Node only became worth using when they added async-await, and even with that you end up having to write wrappers for outdated parts of the standard library just to write straightforward code. JavaScript just isn't that good of a programming language anyway.

Now with that out of the way, PHP has two big problems:

  • It's inconsistent. Like, blatantly inconsistent, for no obvious reason. Some functions have prefixes like array_map($arr, $fn), some of them don't like sort($arr), some of them are not actually functions like empty($arr), and PHP has method call syntax, but doesn't use it for any of the array stuff. And parts of the standard library use CamelCase, while others use snake_case. The classes stdClass and DateTime are both in the standard library, too, just in case you were wondering what type of case class names should use.

    • Because of this, WordPress and Laravel both have equal claim to being "the PHP way" despite having such different coding styles. The better-respected Python, for example, has "there should ideally be one clearly correct way to do it" in its core manifesto.
    • Even other old crufty programming languages, like Java and C, are still able to at least follow consistent naming schemes (C always uses snake_case, Java has lowerSnakeCase variables and methods and UpperCamelCase classes).

  • It has built-in affordances that are unusable in large, well-tested codebases. Superglobals, for example, make any functions that use them much harder to test, and php.ini is just one more piece of the environment that can affect whether a piece of code works right or not. And when PHP starts writing warning messages to the browser that get interleaved with the rest of your HTML, stuff can get really, really broken, so you have to turn that off, too, in production.

    • The last big PHP app I worked on had a bunch of wrappers to try to work around this, and shipped a "use this php.ini" in the source repo for the same reason.
code of conduct - report abuse