4 ms·
The language is not beautiful, it is full of signature and func naming inconsistencies [1] it inherited from C. The devs are ultra-conservative and stubborn to
by leeoniya 10y ago
The language is not beautiful, it is full of signature and func naming inconsistencies [1] it inherited from C. The devs are ultra-conservative and stubborn to cause BC even at major version bumps (like the forever-incorrect ternary associativity [2][3]). But PHP7 is both fast and productive with many modern first-class features. You can in fact write excellent code without much effort that will handily outperform Python, Ruby and even Node.
The Wordpress codebase [plugin api included], though, is utter garbage.
[1] http://www.phpsadness.com/ http://www.phpsadness.com/
[2] http://php.net/manual/en/language.expressions.php http://php.net/manual/en/language.expressions.php
[3] https://www.mail-archive.com/internals@lists.php.net/msg71964.html https://www.mail-archive.com/internals@lists.php.net/msg7196... (yes, i asked for this in 2014)
- gravypod 10y ago> The language is not beautiful, it is full of signature and func naming inconsistencies [1] it inherited from C. It was consistent with the thing it inherited most of it's syntax from so that makes it inconsistent? > The devs are ultra-conservative and stubborn to cause BC even at major version bumps (like the forever-incorrect ternary associativity [2][3]) You shouldn't be judging the way operators work in one language with the way they work in others. Is lisp inherently bad since it's operators are prefix and not infix? No I'd say not, it's just different. On the other hand, the PHP devs changing the ternary would cause major problems for anything that uses it. The most the PHP devs have done is deprecate methods and add features. That's great. I think that changing something, that has been there since the beginning, to a new behavior is stupid. Much much much worse then having ternary work backwards. > The Wordpress codebase [plugin api included], though, is utter garbage. Yes, yes it is. That's not the language's fault.
- leeoniya 10y ago> On the other hand, the PHP devs changing the ternary would cause major problems for anything that uses it. If you read the thread, no one could actually recall having ever seen code that relies on the current behavior. It has been discouraged in the docs for years. The stop-gap proposal was to have PHP7 deprecate it with a warning rather than silently changing the behavior. Then change the behavior in a future version (say php 8). Disregarding any of that, this is an admitted language bug. It was not ever meant to work this way. Do you have a list of languages where ternary works backwards? PHP devs don't just work in PHP. Having one C-style language work this way and another C-style language (js) in another editor tab work the opposite way is a major PITA.
- totony 10y agoI'd rather they don't change it. I like my code to not stop working (python3, perl 6) when upgrading. Also it's not a bug, more like a design oversight that doesn't cause any problem if you rtfm
- leeoniya 10y ago> doesn't cause any problem if you rtfm unfortunately, that's PHP's mantra for unexpected/inconsistent behavior (of which there is a plethora)
- TheDong 10y ago> It was consistent with the thing it inherited most of it's syntax from so that makes it inconsistent? It is also internally inconsistent in so many ways. Half the array functions take arrays as the first arg, the other half the last. explode and implode have different argument order requirements (one is strict, the other works either way). Functions have a grab-bag of errors from returning null to false to 0 to strings to requiring error\_get\_last to even requiring an object specific error function (DateTime::getLastErrors). Functions were named to make them have more randomly distributed hashes (http://news.php.net/php.internals/70691 http://news.php.net/php.internals/70691). Functions randomly do or don't have underscores, sane order, etc. Some apis are in terms of objects (DateTime), some are not (getdate). The whole thing is far less consistent than C. Some inconsistencies are from C. Most are PHP shit layered on top. > You shouldn't be judging the way operators work in one language with the way they work in others. Is lisp inherently bad since it's operators are prefix and not infix? No I'd say not, it's just different. It's a C-like language. Every c-like language does it the other way. I will totally judge a language that makes a decision that makes programmer's lives terrible with no justification. In this case, it's different in a way that often leaves to bugs and surprises.
- gravypod 10y agoC++ is a C-like language but C++ muddies up the difference between some operators due to operator overloading. This is an inconsistency. Do you support that? No one will ever be able to convince me that "<<" and ">>" make sense to be read and write.
- __david__ 10y agoThat's not the same thing and you know it. C++ didn't just randomly change the associativity of one of the operators. PHP screwed up ternery in a way that makes zero sense (ie, it's wrong in 99.99999% of use cases). It still catches me (and my colleagues) off guard even though we have years of collective PHP experience.
- TheDong 10y agoIt doesn't matter, we're talking about php not C++. But yeah, "<<" and ">>" are at fairly internally consistent within C++ and don't generally confuse programmers or cause significant bugs in my experience, so I don't find them problematic. They did seem a bit weird at first, but they didn't cause significant problems. Perhaps they do for you, and I accept your complaint about those operators as valid actually, but it's on a whole different level of badness than php, and again, we're talking about php. Just because "other languages suck" doesn't mean php doesn't, so that's not a valid argument against anything I said.
- spraak 10y agoIf what it inherited from was inconsistent, why wouldn't it be too?
- TazeTSchnitzel 10y ago> The devs are ultra-conservative and stubborn to cause BC even at major version bumps Well, breaking backwards-compatibility comes at a cost. Avoiding another PHP 4/5 or Python 2/3 situation is the goal. It doesn't mean nothing gets changed: PHP 7 has a long list of backwards-compatibility breaks.
- matthewking 10y ago> The Wordpress codebase [plugin api included], though, is utter garbage. I've always heard this and never actually used Wordpress myself. Has anyone ever studied WHY its garbage? and how did it get to that state? is it getting better or are the latest additions and changes still garbage code?
- e12e 10y agoPopularity. WordPress is popular, php is accessible (you need notepad and an ftp client to start hacking) - combine the two, and you get a lot of "scratches my itch"-code. It probably doesn't help that WordPress is an ancient code Base with a goal of running on the cheapest webhosts (who are slow to update to newer php releases). So you get a lot of beginners that learn from messy old code, that generate more of the same. It's a mess of global and file-wide variables, an unholy mix of poorly structured procedural code married with the odd "OO" abstraction. There are good, even great php code bases - WordPress - and its plugins are not that. To be fair, WordPress itself, and the core plugins are at least somewhat consistent, and after years of security holes follow a somewhat reasonable defensive coding practice. The terror lurks in popular third-party plugins, inspired/forked from older hacks. As is evidenced by a quick look at full-disclosure where seemingly every week someone's managed to make a plugin that's broken in some novel manner. I've not been following closely lately, but for a plain php cms, one could do worse that cmsmadesimple. It's (was) pretty old-school simple php, but much simpler than something like Drupal.
- matthewking 10y agoThe part that I didn't really understand is people accepting pull requests should be gate keepers for code quality, so amateur or not hopefully this shouldn't pollute the codebase. But you've touched on the core being reasonably decent and the real mess being with third party plugins so that makes more sense.
- dsl 10y agoOne of the responses to your mailing list post hits the PHP nail on the head: "Don't piss off users for purety."