5 ms·
I'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 untouc
by makeitdouble 4y ago
I'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.