I’d take Typescript over PHP any day, but not Javascript.
That's correct. It turns out that it's also bad, though. People don't like to hear it because I'm "just a hater", and maybe one or two of these issues isn't a deal breaker. And yes, you can write real, useful, applications in PHP, but it's a terribly awkward language with a lot of missing features and sloppy dynamic typing nonsense.
* No (real) async or threads (pthreads never worked on backend and is deprecated anyway for those who always mention it in response to me)
* No generics
* Interfaces must be complied to at class definition (leading to verbose nonsense like the "adapter pattern")
* No const or immutability
* `array` is a shitty hybrid of an actual array and a dictionary and it sucks at both
* No other native data structures beside the shitty `array` mentioned above
* No ability to typehint callable function params
* switch statements use loose equality checks, so you should avoid them
* foreach is broken and leaves a dangling reference
* `array` keys are automatically cast to int if they can be, which is broken and insane. (E.g., if I use `array` as a dictionary and one of the keys is the string "123", it will NOT store the entry as key-value pair: "123" -> $data. It will instead store $data in the 123rd slot of the "array". Iterating this `array` with an index will end in a bad way).
But surely someone will drive by and say that none of these things matter and that an experience PHP dev would never be bothered by any of these things, etc, etc. "You can write bad code in any language."
But... you can always just choose a better language if you have the choice. I feel like people get Stockholm syndrome over their tech choices. It all sucks, but some suck worse than others. Don't tie your identity to shitty stuff like programming languages: "I'm a PHP dev." "I'm a Rust dev." Give me a break.
However for people who have not invested this time and effort it is an objectively worse language than other web focused ones in many dimensions.
PHP is a workhorse for the web and still the most important language next to JS in that regard. But there is a reason it is declining (slowly) as well.