6 ms·
> I used to work way back in the day on PHP too, This is your issue - PHP < 5.3 is very different to PHP 7+. Not just at the language level - but the community
by GeneralTspoon 4y ago
> I used to work way back in the day on PHP too,
This is your issue - PHP < 5.3 is very different to PHP 7+. Not just at the language level - but the community, frameworks and best practices too. No more random scattering of SQL statements in HTML files!
Modern PHP (with a framework like Laravel or Symfony) is probably one of the most productive ways to build web applications.
> It's not beautifully well thought-out the way Python is.
This is definitely an interesting take... Python hasn't even solved package management yet. And the 2.7 => 3 migration is probably the most famous example of making a mess of an ecosystem with backwards incompatible changes. In contrast PHP has Composer and 5.3 code is pretty much compatible with 8.0 (although ideally all code from the 5.3 era should be burned at the stake).
> and people who don't know any better keep championing it. I think people do eventually catch up with what's going on though as soon as they personally experience writing anything remotely serious (5-10,000+ LOC) that isn't a simplistic web-app.
You've basically just said that PHP devs are too inexperienced to be able to scale a codebase past 10k LOC? Pretty much every serious web dev using Symfony/Laravel would disagree with you.
- deleted 4y ago[deleted]
- makeitdouble 4y agoI'm on PHP 8 and I feel the same as parent. Sure, there's been a lot of progress since the PHP 5 days, but the core of the language has been left mostly untouched by design, and we haven't seen the kind of drastic moves like JS moving to ES6 syntax. It's a matter of taste, so there's no absolutr truth. I hate PHP's function and property access syntax differenciation and wildly prefer ruby's approach or instance. And there's so much more nice things coming in languages that have been designed from the ground up to be nice to use. I understand PHP's pragmatism, but can't find it pleasant to use TBH. PS: we got arrow functions, but they stay limited to anonymous functions for instance...
- afiori 4y agoThe one feature on PHP that I wish was more commonplace is the `use` keyword in function expressions as it is one of the few ways to limit what names are in scope at a given point in the code IIRC Rust's `mod` declarations can behave similarly.
- oblio 4y agoMaybe PHP can add a "stricter" mode that gets rid of all the cruft? Enable it per-file, allow it to simmer for 10 years, remove legacy support in PHP 12.
- makeitdouble 4y agoThis would really help in a lot of way IMHO. PHP has good aspects, getting rid of the weirder one, even if compatibility gets sacrificed, would be a boon for building new applications.
- paulryanrogers 4y agoIt already has one
- oblio 4y agoI called it "stricter", not "strict" for a reason.
- kugelblitz 4y agoUhm, how about PHP attributes, getting rid of comments / annotations? Named arguments? Constructor property promotion? Readonly properties (8.1) / classes (8.2)? Arrow functions or typed properties (both 7.4)? I'd say those are really cool things. Especially as a web developer, there's just so much boilerplate I can get rid of since using 8.0+.
- makeitdouble 4y agoI’m in agreement with you that it came a very long way. Now, most of those have been present in many other languages [0], often with less limitations. And as usual the old ways haven’t all been deprecated either, so it stays weird. For instance typed properties were a chance to reset the clock on type handling, but no, declaring a type will force cast parameters to that type instead of throwing an error (i.e. passing 0 for a string argument will convert it silently) [0] Constructor property promotion isn’t, but TBH I’m of mixed feelings about it. We get conciseness in exchange for weirdness as the properties aren’t declared outside of the constructor, where they would be otherwise. I wished it was done the other way round.
- kugelblitz 4y agoYes, the backward compatibility is a crux on the one hand, on the other hand it has made upgrading PHP versions a breeze. In the past 6 months I updated several code bases from PHP 7 / 8.0 to PHP 8.1 / 8.2, the PHP part was easy (just the deprecated dynamic properties in 8.2 caused a wall of text in our loggers), the framework was a bit more difficult. The most problematic were the exotic packages that the clients had installed ages ago and that are not properly maintained anymore, so I have to figure out a replacement for those code modules. Constructor property promotion is fine, I think. I think it ties in well with the readonly property. public function __construct( public readonly Company $company, ) { } There's just so much info & functionality + type safety crammed into there that wouldn't have been possible previously; it's really nice.
- jbboehr 4y ago> declaring a type will force cast parameters to that type instead of throwing an error There is `declare(strict_types=1)`[0] [0]: https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict https://www.php.net/manual/en/language.types.declarations.ph...
- codegeek 4y ago"Can't find it pleasant" is a personal preference and not why no one should use PHP which the GP is suggesting.
- makeitdouble 4y agoGP’s take was way too salty, but to be honest I understand where he comes from. Yes, it’s a matter of personal preference, but I also never worked with people that thought PHP was beautiful. Not that we look down on it, but it’s probably the same feeling construction people have towards their white vans. We value the good parts, hate the jagged parts, and if tomorrow it made more sense to ride Miata for whatever crazy reason, we wouldn’t look back. But I’m not holding my breath to have any decent reason to get out of PHP at my current job, and I appreciate the reasons why.
- philipwhiuk 4y ago> No more random scattering of SQL statements in HTML files! And yet you will still find this, because the long-tail of bad PHP is near infinite. > although ideally all code from the 5.3 era should be burned at the stake I guarantee you that a decent amount of real PHP coding right now is maintaining legacy stuff, not the new fangled 8. It is, of course, the same in the Java world - most of the day job is not using Java 17. It's just that Java 6 code forced onto Java 8 isn't as bad as PHP 4 code hacked into PHP 5 code still struggling along in PHP 9. (Especially because as a scripting language, it will more likely fail at runtime, not build-time).