3 ms·
I've worked with PHP throughout 2020, and it is still the worst crap I know. Static typing: We're not there yet. Lack of generics means arrays can contain anyt
by sshine 4y ago
I've worked with PHP throughout 2020, and it is still the worst crap I know.
Static typing: We're not there yet. Lack of generics means arrays can contain anything. Not even close to TypeScript, and let's not compare to functional languages. Types in PHP is still duct-tape.
High performance: Nope. PHP is fast compared to what PHP used to be, but PHP is not fast compared to compiled, optimizing languages. I'm sorry, but this claim of PHP being a performant language is either delusional or unambitious. I basically have not been in contact with PHP in the last two years where performance wasn't a serious problem.
This isn't entirely because PHP performs bad, but largely because PHP programmers, on average, have a weak understanding of CS principles. I don't mean to bash any individuals; I saw a talk by a PHP programmer, whom I have great respect for, as late as yesterday. Incidentally, the talk was about how to make DSLs in Rust.
Maybe if all you did was PHP, PHP is pretty great.
The killer feature of PHP is that you can always find cheap labor.
- rboes 4y agoCouldn't agree more
- sergiomattei 4y ago> High performance: Nope. PHP is fast compared to what PHP used to be, but PHP is not fast compared to compiled, optimizing languages. Well, duh. It’s fast for its class of language. > but largely because PHP programmers, on average, have a weak understanding of CS principles Way to generalize and dismiss a whole class of programmers in the field. Do better.
- sshine 4y ago> [PHP] is fast for its class of language You mean loosely typed scripting languages? I won't disagree with that. > Way to generalize and dismiss a whole class of programmers in the field. I don't intend to be mean. PHP programmers have fewer years of formal CS training, on average. This isn't controversial.
- sergiomattei 4y agoCitation needed
- dabernathy89 4y agoYou can write PHP with generics via docblocks that are understood by PhpStorm, the two leading static analyzers (PHPStan and Psalm), and soon by the Intelephpense plugin for VS Code. Since the main advantage for generics in a language like PHP isn't at runtime, this is pretty good support. Outside of generics, what else are you missing right now in PHP's type system? > PHP is fast compared to what PHP used to be, but PHP is not fast compared to compiled, optimizing languages The real question is "is PHP fast enough", and for the vast majority of use cases - including many you might not realize - it is.
- sshine 4y ago> You can write PHP with generics via docblocks In other words: PHP almost has generics. If you lock yourself to an editor that makes a MacBook Pro 2020 seem weak. These were added to Java 5 in 2004. You don't have to use a specific editor. > Outside of generics, what else are you missing right now in PHP's type system? Besides generics on functions, generics on data structures, i.e. be able to define a data structure that specifically fits a parameterised type of thing into its fields. Type inference -- you need strong typing before this is possible, and PHP's duct-tape typing isn't enough (yet). Algebraic sum types. Rust proved that you can have these without going full functional. Pattern matching. PHP is trying to get there [2], but C#'s "value types" [3] just have better semantics for getting there in a decade. PHP doesn't just suck because it misses stuff. The things that it does include are made strangely bad. Traits (type classes) -- I don't mean "PHP traits", but traits as understood in Scala or Rust, or type classes in Haskell. They're more like interfaces. PHP traits are like C#'s extension methods. Reasons why those are not so good that also apply to PHP: It's not obvious where they're defined, extending 3rd party libraries breaks encapsulation, can't be mocked. PHP programmers will pure-heartedly explore their options and make worse code by applying PHP traits in any context other when you utmost have to. Which is pretty often. > Is PHP fast enough? No. Performance is something you gradually realise you need. Just because most people don't need PHP to be a performant language, does not make PHP a performant language. You're just lowering the bar. If you make real software with PHP, because, you know, it has really grown as a language, then you'll experience performance problems sooner rather than if you'd picked a compiled, optimizing language. [1]: https://stackoverflow.com/questions/312184/disadvantages-of-extension-methods/312275#312275 https://stackoverflow.com/questions/312184/disadvantages-of-... [2]: https://wiki.php.net/rfc/pattern-matching https://wiki.php.net/rfc/pattern-matching [3]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
- pluc 4y agoYou're wrong on all counts.
- upupandup 4y agoPHP is still very much in demand and used widely so I wouldn't call it crap. On a surface level it has shortcomings but most of these are non-issue for most of its use base. Lot of the points you described seem unrelated to PHP but just incomplete views based on your own premature judgements because you dislike PHP.
- sshine 4y ago> PHP is still very much in demand and used widely so I wouldn't call it crap. So is cocaine. PHP is popular because it is easy to get started with. PHP is in demand because popular software was made in PHP. Those are good qualities of PHP. PHP's insufficiencies as a type-safe and performant language are not among those reasons. > Lot of the points you described seem unrelated to PHP but just incomplete views based on your own premature judgements because you dislike PHP. I'm not sure what makes you think that my judgement is premature. I wrote PHP for a lot of years since 2004. I don't normally bash PHP. It is too easy, after all. But when some blog post says that PHP is a strong choice in 2022 because of strict typing and performance, I have to beg to differ. You will see commenters consistently downplay performance as "you don't really need performance on average", as if not needing performance constitutes having it. And similarly, you will see commenters say that it does have enough typing, which is of course subjective. But what is "fully typed", as the article refers to? If I have an array, can I say what kind of thing goes into the array, and will it be a type error if I stuff something else in there? Can I declare something as not nullable? If not, what's particularly "full" about this?
- nullfish 4y agos/php/node.js/g
- conradfr 4y ago> Static typing: We're not there yet. Lack of generics means arrays can contain anything. Not even close to TypeScript, and let's not compare to functional languages. Types in PHP is still duct-tape. I'll admit that I personally don't care about generics (and static typing), but I find types in TypeScript more cumbersome than in PHP. Maybe that's the price to pay for extended capabilities. Also I do Elixir professionally, which you'll agree is a functional language ;), and I would take PHP strict typing & type hinting any day over what we get in Elixir. Performance-wise I would say it's OK these days, in a web context most of the problems come from complex data layers, like nested data in a rest api, which caching can't always solve. It will never be as fast as Go, or Rust (or Elixir), for sure. On the other hand, PHP 8 + Symfony + PhpStorm give you an insanely productive platform and amazing DX experience.
- tweetle_beetle 4y agoWorking with a language (for first time?) in one context/project/environment for one year is enough to generalise about the average skills of many thousands of professionals?