3 ms·
Bad type coercion you can’t turn off with weird semantics. Powerful but confusing arrays/dictionaries. Inconsistently named stdlib functions with inconsistent p
by IgorPartola 6y ago
Bad type coercion you can’t turn off with weird semantics. Powerful but confusing arrays/dictionaries. Inconsistently named stdlib functions with inconsistent parameters. Little to no support for threading or concurrency models outside of making event loops or running multiple processes. Memory management that allowed for leaky memory all the time. Lack of proper support for stand-alone daemon processes (you could make it work but it was clearly not the main way PHP was meant to be run). Lack of namespaces or modules with all variables being global.
This was PHP 5 and it sent me running for the hills (Python, ES6). I am sure PHP 8 is an improvement and I’ve worked with PHP versions past 5.3 but it left such a bad taste in my mouth that yes I will avoid it if I can. Fixing what shouldn’t have been broken may make this language almost as good as something like Python but why would I reach for PHP when better things exist unless that decision is not made by me?
- megous 6y agoNot sure what you mean about global variables. PHP 5 had the same scoping rules like it has now. You couldn't access global variables directly from anywhere but the toplevel execution context.
- IgorPartola 6y agoRight. So if file a.php has: <?php $MY_SOCKET_TIMEOUT = 5; And file b.php has: <?php require(‘a.php’); $MY_SOCKET_TIMEOUT = 10; That’s a problem. Same with every function and class name. Oh and requiring/including a file is not idempotent because it’s just string concatenation because they are not modules. None of that should be a part of a modern language. If they haven’t fixed that in PHP 8, then it’s still broken.
- Aeolun 6y agorequire_once has existed since PHP5 at least (when I started using it).
- IgorPartola 6y agoThat’s a hack, not a solution. You still can’t import just class A out of A, B, and C that are all defined in the same file. And even if you require_once file x.php, you don’t have any guarantees that that file won’t require/include file y.php that you also intend to include. PHP files are treated as files, not modules and that’s fundamentally broken.
- megous 6y agoI guess you like modules. Someone else may like string inclusion, because it allows for some other forms of splitting the code that modules would not allow and fulfills the primary purpose of a PHP script, which is templating. Neither is fundamentally broken. You're just focusing on one aspect (organizing code), while ignoring the other.
- IgorPartola 6y agoAh and there it is. PHP is fundamentally a templating system with a programming language built-in. Imagine using Handlebars.js to write your business logic. I do think code organization is one of the primary jobs of a programming language/ecosystem. I want my tools to help me be better about that, not worse. Oh and given that most projects use a bunch of library code, I would very much prefer a system that has a consistent code organization pattern so I don’t have to guess how it all works. Take a look at the source code for something like WordPress or WooCommerce. These are mature projects. And yet it’s hard to shake the feeling that it’s all spaghetti inclusions. But also there are many other issues with PHP that I mentioned in a prior comment. Here, if you’d like for a better read on the subject than I can produce: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
- Aeolun 6y ago> I do think code organization is one of the primary jobs of a programming language/ecosystem. I want my tools to help me be better about that, not worse. Isn’t splitting up all your classes into separate files considered to be a good thing? Considering how huge we can make files in JS I’m sort of inclined to consider that a problem instead of a feature. I think any project that started around PHP 4/5 will look like Wordpress. Looking at more recent projects (after PSR’s became a thing) would be more representative.
- paledot 6y agoSo... don't do that? You're correct, it's possible to write blisteringly awful code in PHP. Ditto every other programming language ever.
- IgorPartola 6y agoBut PHP makes it way too easy and provides few ways to guard against it. Well technically now it does with namespaces but that’s still less than ideal. And my point is that they are just now starting to catch up to more sane languages.
- sneak 6y agoThere is an argument for judging programming languages based on the worst code possible within the language, due to the fact that with a wide enough ecosystem, you will regularly encounter lots of stuff in the median between that and your “just don’t do that” standard. This is one of the reasons I love Go: the worst code possible in it is still pretty readable. The worst code possible in PHP is scattered across thousands of files corresponding to individual routes, and isn’t indented at all.
- Aeolun 6y ago> Little to no support for threading or concurrency models outside of making event loops or running multiple processes. Having just started with programming, this is more feature than bug. It’s super easy to reason about PHP applications because the whole flow is linear from top to bottom.