Live data from Hacker News

PHP 8.4

php.net

311–320 of 337 posts

Re: PHP 8.4

#311

Earlier quoted context omitted.

Others will use them and I will need to use their libraries. Get and set magic methods were a mistake too. Same with reflection. Again and again, deeper into the Java 6-land, while Java itself went away a decade ago.

> Others will use them and I will need to use their libraries. From the outside it's just a property access. The whole point is you don't need to worry about whether it's a direct access or a getter/setter with logic, even if it changes from one to the other between versions. > Get and set magic methods were a mistake too. They're definitely not ideal, and thanks to this change they're no longer required for the vast…

I need to worry about it if I'm using it in an app. In what job you don't need to worry about what code are you executing? This is the whole point. It makes my job much harder to do, much more hidden and arcane - not worth it to save few characters.

Yes, reflection is a mistake. It's a hotfix for problems caused by OOP. It's not actually necessary.

TypeScript is a good example. Some people write it like Java/C#, with classes, inheritance, reflection, dependency injection. Usually I can get that code down to 20-30% of original size after I cut out the last class (then I forbid the keyword in linter), and none of that is actually necessary or improved the situation.

Re: PHP 8.4

#312
post #273

Earlier quoted context omitted.

> More efficient processes and increase in productivity I'd have to see the numbers on those ones. But I am not a "gatekeeper" type, maybe you are confusing me for one. I'm a high school dropout with a GED, and have been staring up people's noses, all my life. I just believe that any job we do, should be a good job. Build on a sand foundation, and you'd better not go too high, or Bad Things Happen.

I agree that it’s especially sad then to see someone with your background taking that position then. While we’re busy discussing inelegant abstraction patterns in code, a bunch of founders have written the foundations of a successful startup with horrible code, creating work for better programmers (but worse founders) in the process. A good friend of mine has founded such a company, and boy, I loathe his code. But at…

So you know someone that is an expert at building sand foundations, and selling them? That’s a good thing, and something to emulate?

For a lot of folks (especially hereabouts), “makes money” is the only valid metric.

That’s not my experience or personal PoV. I’ve been shipping (as opposed to “writing”) code, for over 30 years. Pretty much everything I’ve written, has made it out the door (although not always to subsequent success). I’m fairly familiar with what it takes to ship. I agree that it’s a relatively uncommon skillset, but I’ve also learned to ship stuff with a future. One of the projects I developed, took ten years to come into its own, and it had to stay solid for all that time, until the right team could take it over. The fact that the code is well-written, well-supported, and well-documented, is the main reason that it finally took off.

I don’t like PHP, and one reason, has been alluded in other comments. It’s a sand foundation. Over the years, it has been massively backfilled, and is now pretty damn robust, but the sand foundation is still visible.

But it is a useful tool, if wielded correctly. If used incorrectly, though, that’s another story, and there’s a lot of bad PHP out there.

I have heard a quote, attributed to Stroustrop, that goes “With C, you can shoot yourself in the foot. With C++, you can blow your whole leg off.” I’m skeptical he’s the one that said it, but it’s a truism.

I have a friend that is an arborist (tree guy). He’s really experienced, and really good at it, and makes great money.

Watching him use chainsaws, though, is kinda terrifying. For one thing, every one of his saws has the safety guard removed, and he’ll go monkeying up a tree, with three running chainsaws, hanging off him. He uses them like you’d use a fork at the dinner table, and can take down a huge locust tree, in an hour or so, alone.

He makes it look easy, but I’m not so idiotic, as to think I could emulate him.

We have a running joke, every time he sees me, he holds up his hand, showing that he still has all his fingers, because I told him that he would end up chopping off a finger or two.

There now exists a huge base of very good PHP programmers. It took quite a while to coalesce, but it’s here. I don’t claim to be one of them, but I have used the language to ship some fairly ambitious stuff, for the last quarter century or so, so I can wrangle it reasonably well.

Re: PHP 8.4

#313

I find it pretty fascinating that what used to be a beginner-friendly language, with limited capabilities but that is very easy to get started with, has now evolve to a bloated monster full of advanced features that you can't expect to know entirely, with a complex framework and tooling ecosystem to support it. PHP lovers generally don't like acknowledge that, but the PHP we've learned back-end development two decade…

I picked up php a couple of months back after 30 years of ignoring it, mostly after reading a comment somewhere about using php for shell scripting. Very easy to read the language documentation on php.net and get moving. Powerful standard library. I haven't found another language (not an exhaustive claim) that offers language documentation as helpful as php's for a beginner.

Re: PHP 8.4

#314
post #307

Earlier quoted context omitted.

An IDE can help you write the code, but does not make it easier to read the code.

Can you elaborate? I'm not sure what you mean, but IDEs definitely make reading code easier. IDE does code formatting, highlighting, argument hints, jumping to methods, declarations, and various hover effects on variables, methods, and classes. Some IDEs offer call graphs and other more advanced tools. Not to mention static analysis that works out of the box in PHPStorm (and I'm sure it can be set up in VSCode).

I mean that no matter what you do, the arguments will always be shown in an inconsistent order and you’ll have to mentally swap them around. You probably could configure your editor to visually swap them, but that sounds like a really bad idea.

Re: PHP 8.4

#316

Earlier quoted context omitted.

Some light weight ORMs do not require you to define all the properties ahead of time. They pull the field names from the table and generate the model record on the fly for you. This generally lets you prototype really fast. Laravel's Eloquent is known to do this. It's also useful for derived SQL fields when you use custom queries or join from other tables. Also kinda fun to do it for properties backed by a method. As…

Is it possible to dynamically define methods in PHP?

Yes.

Re: PHP 8.4

#318

Non PHP expert here, can someone explain to me the line get => \sprintf("%s_%s", $this->languageCode, $this->countryCode); in the first code example? Is it a lambda?

Yes, you can read about it the rfc under "Abbreviated syntax"

https://wiki.php.net/rfc/property-hooks

It follows the syntax of arrow functions

https://www.php.net/manual/en/functions.arrow.php

Re: PHP 8.4

#319

Earlier quoted context omitted.

> Others will use them and I will need to use their libraries. From the outside it's just a property access. The whole point is you don't need to worry about whether it's a direct access or a getter/setter with logic, even if it changes from one to the other between versions. > Get and set magic methods were a mistake too. They're definitely not ideal, and thanks to this change they're no longer required for the vast…

I need to worry about it if I'm using it in an app. In what job you don't need to worry about what code are you executing? This is the whole point. It makes my job much harder to do, much more hidden and arcane - not worth it to save few characters. Yes, reflection is a mistake. It's a hotfix for problems caused by OOP. It's not actually necessary. TypeScript is a good example. Some people write it like Java/C#, with…

> In what job you don't need to worry about what code are you executing?

Worry about? Or understand the fine minutia of how every property you fetch or store is handled?

> It makes my job much harder to do, much more hidden and arcane

I don't know how you do your job, but seeing a real (i.e. not a faux property handled by __get/__set) class member's implementation is literally 1 click away in any decent IDE. Clicking to see the potential hooks of a field vs clicking to see the getter or setter (which may or may not even be defined in the same class) is no different.

> Yes, reflection is a mistake. It's a hotfix for problems caused by OOP. It's not actually necessary.

Right. I guess that's why it's applicable to functional programming. To be a hotfix for OOP?

https://www-master.ufr-info-p6.jussieu.fr/2007/Ajouts/Master...

Re: PHP 8.4

#320
post #251

Earlier quoted context omitted.

How do you expect properties to interact with IDEs? The argument that C# choosing to offer features that lead to terser implementation seems orthogonal to where you write it. Behavior in property getters and setters may as well be completely hidden from the caller. But the standard expectation is that accessing and/or setting a property should be cheap and not involve much logic, which most of the code out there adhe…

> How do you expect properties to interact with IDEs? An IDE can highlight non-basic properties in a different colour from basic properties, or underline them or something. That would be difficult for an editor to do as part of normal syntax highlighting.

This is also a problem when reviewing changes through github-like workflows, and even more with patch-based workflows. It's probably either impossible or very difficult to fix that ever.
Post reply on HN