| > it doesn't have generics It doesn't need them IMO. It brings no benefit to the language, really. They would need to be type checked at runtime, which can become quite expensive. Static analysis is a better option for an interpreted language. Read this answer from Nikita (one of the top PHP contributors) https://www.reddit.com/r/PHP/comments/j65968/ama_with_the_ph... > doesn't have real data structures Untrue. See https://www.php.net/manual/en/book.spl.php It's usefulness is limited though, because it's rare that you need those types of data structures for web applications. > no threads or async Untrue. All kinds of projects like Swoole (gives you a runtime similar to Go) and ReactPHP (runtime similar to Node) and https://github.com/krakjoe/parallel for lower level concurrency. There's also pthreads https://www.php.net/manual/en/book.pthreads.php But again most of these aren't necessary for most apps because of PHP's request-response model. Useful for one-off services though. > typed function parameters Completely untrue. https://www.php.net/manual/en/functions.arguments.php#functi... > no method/function reference You do those like this: [Example::class, 'someFunction'] I hate it when people write such blatantly misinformed comments. Sigh. |
Right. You need to use something like Psalm if you want the benefits of generics, which is basically a tacked on type system. Having static checking is absolutely beneficial. I'd be willing to bet good money that you don't write PHP without typehints and/or Psalm/PHPstan.
> Untrue. See https://www.php.net/manual/en/book.spl.php It's usefulness is limited though, because it's rare that you need those types of data structures for web applications.
You're totally right. I was thinking that you still needed to explicitly enable SPL, but that hasn't been true for a long time, IIRC. So, fair enough. I was wrong here.
> Untrue. All kinds of projects like Swoole (gives you a runtime similar to Go) and ReactPHP (runtime similar to Node) and https://github.com/krakjoe/parallel for lower level concurrency. There's also pthreads https://www.php.net/manual/en/book.pthreads.php But again most of these aren't necessary for most apps because of PHP's request-response model. Useful for one-off services though.
pthreads was never worth much. It never worked on web servers and is now deprecated. Parallel is a PECL extension, which may or may not be considered part of PHP, IMO. I believe it also doesn't use threads unless you use pthreads (which you should/can not). So it's just multiple processes- not threads or async. I don't know much about Swoole, etc, but those are frameworks- not PHP itself. Also, I believe Swoole is process based, not thread or (true) async. I could be mistaken. So, again, AFAIK, PHP does not have threads or async.
> Completely untrue. https://www.php.net/manual/en/functions.arguments.php#functi...
That's not what I meant. My wording was poor. I meant specifically `callable`. You can't typehint the inputs and outputs of `callable` parameters. So passing around lambdas, etc, is not robust/safe.
> You do those like this: [Example::class, 'someFunction']
Yeah... an array of two strings. Again, I should've been more clear. I know that's how you refer to functions in PHP. But it's not the same as actually getting to write Example::someFunction and knowing that the inputs/outputs line up with whatever you're doing. If you're lucky, your PHPStorm or whatever can tell where you're trying to refer to a function and maybe point to it for you, but otherwise, it just thinks you're passing some strings around, because you are.