Live data from Hacker News

PHP in 2023

stitcher.io

211–220 of 285 posts

Re: PHP in 2023

#211
post #189

Earlier quoted context omitted.

Can you give me a few real life examples where you got bit by the "magic" conventions or ran into any serious issue from not explicitly setting properties on your models? Facades are not global glorified variables with magic methods. Usually they're just a way to instantiate and access a class with less code. People complain that facades limit testability. In fact, they're easily mocked. Etc. The docs do a very good…

> Can you give me a few real life examples where you got bit by the "magic" conventions or ran into any serious issue from not explicitly setting properties on your models? I shouldn't need "real life examples" to explain why using objects with magic dynamic properties instead of declaring the properties on the class is stupid. If I can't look at a model class and know what properties and methods it has, why is it ev…

You can look at a Laravel (Eloquent) model and easily see what methods it has. Nothing is hidden -- at least no more than any ORM that inherits from another class which gives it functionality.

As for properties -- yes, they're not explicitly described but mapped to the database schema. Other ORMs, like that in Ruby on Rails, also do not explicitly set model properties and just map to database columns. People have been upset about this forever, but everyone else has happily used Active Record and had no major issues, all while enjoying not having to add a dozen lines of code to annotate props.

In both Rails and Laravel you can define accessors and setters, either overwriting the magic property for the column or defining new properties.

If not seeing the properties on the model is a huge problem, there are plugins to generate them and put them in the model. My IDE gives me direct insight by inspecting the table.

I'm happy not to have to write out all the props twice when there's no tangible performance issue and I've never had any other problems with dynamically getting the model attributes from the schema.

You're taking a matter of taste and context-based tradeoffs and acting like those reflect unchallengeable principles.

Symfony is a great piece of software. So is Laravel. Github numbers alone will show you how compelling so many developers find Laravel. Of course, there will be haters who think they're all stupid, uneducated, bad, idiotic, lazy, etc.

Everyone makes trade-offs based upon taste or prior decisions. Consider Django. There, you explicitly define properties, but link them to the type of database column they'll use. Then, you can generate a migration based upon the model, and then run that migration. I really like that pattern. Removes tedium of writing migrations, preserves ability to modify the migrations, and makes things explicit.

When I used SQL Alchemy in Python, it completely allowed me to not write migrations, only models. That was very nice, until it wasn't. But then I just had to do a few things manually -- a reasonable price to pay for saving a bunch of time in the other 19/20 of cases.

These are all just different ways of getting to the same place. Each has benefits, each has drawbacks, the extent of each which will depend on the project and the developers' tastes.

Re: PHP in 2023

#212
post #187

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

PHP devs hate to admit that the only reason PHP is still relevant at all today is because of WordPress. If WordPress moved to a modern language tomorrow, PHP would cease to exist afterwards.

WordPress would cease as well I think.

There are dozens of alternatives better than WordPress, if upgrading it meant a complete tooling change I think many would take the opportunity to replatform to something else. The only thing WP really has over them is it's expansive plugin library, and buy in from clients.

But it's not really up to devs. I don't think many devs believe it's the best system, but it is desired by clients very often.

Re: PHP in 2023

#213
post #189

Earlier quoted context omitted.

> Can you give me a few real life examples where you got bit by the "magic" conventions or ran into any serious issue from not explicitly setting properties on your models? I shouldn't need "real life examples" to explain why using objects with magic dynamic properties instead of declaring the properties on the class is stupid. If I can't look at a model class and know what properties and methods it has, why is it ev…

You can look at a Laravel (Eloquent) model and easily see what methods it has. Nothing is hidden -- at least no more than any ORM that inherits from another class which gives it functionality. As for properties -- yes, they're not explicitly described but mapped to the database schema. Other ORMs, like that in Ruby on Rails, also do not explicitly set model properties and just map to database columns. People have bee…

> Symfony is a great piece of software. So is Laravel.

And to be clear, Laravel is a piece of Symfony software, and a good example of what you can do with Symfony packages and a bit of opinion.

There are 13 Symfony dependencies in https://github.com/laravel/framework/blob/9.x/composer.json alone, and many of the Laravel packages listed in there also depend on them; the Laravel Request class extends Symfony\Component\HttpFoundation\Request, the Response class extends Symfony\Component\HttpFoundation\Response, etc.

Re: PHP in 2023

#214

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

So dramatic. No one cares what you use, and I suspect you could just not read articles about PHP and voila your problems would go away. Choose your own destiny!

You have to ask yourself why such a large proportion of work gets done in two objectively bad languages, PHP and Javascript. They dominate the space. I think it tells us that it's not actually that important to have a 100% perfect language, when it comes to building stuff.

Re: PHP in 2023

#215

Earlier quoted context omitted.

You can quote yourself ad nauseam but that does not turn your incorrect statement into a correct statement. If you spent any amount of time looking at a modern PHP codebase, you'd discover that the type of code people write today is radically different to the type of code you'd have seen at the time A Fractal of Bad Design was written. There are still aspects of modern PHP that stand to be improved, absolutely, but t…

Your argument is basically: "Yes, yes, the footguns are still there front and center, but we added more guns that don't shoot you on the foot." If I was using PHP, I'd be livid that the cruft is never removed. Just deprecate and remove it

No, my argument is that most of the footguns described in A Fractal of Bad Design have been long since fixed and those that remain are being removed as and when it's feasible and the PHP community has matured a great deal to the point where the remaining footguns don't really apply in modern codebases because of libraries, static analysis and testing.

Spend any amount of time actually using PHP and you'd discover that it is meaningfully different to what it once was. It's far from perfect, and still has a long way to go, but if you reflect on where it was and what had to change to get where it is today, the improvement and progress has been excellent.

Re: PHP in 2023

#216
post #187

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

PHP devs hate to admit that the only reason PHP is still relevant at all today is because of WordPress. If WordPress moved to a modern language tomorrow, PHP would cease to exist afterwards.

I don't get how people can say that. WP is almost ~50% of all websites. PHP is ~80% of the websites. There is a whopping 30% in between.

And moving WP to a 'modern' language (whatever that modern means) is not something possible. ~60,000 plugins, similar number of themes, 30% of all ecommerce websites, billions of dollars of businesses with dependencies ride on it.

Re: PHP in 2023

#217
post #212
post #187

Earlier quoted context omitted.

PHP devs hate to admit that the only reason PHP is still relevant at all today is because of WordPress. If WordPress moved to a modern language tomorrow, PHP would cease to exist afterwards.

WordPress would cease as well I think. There are dozens of alternatives better than WordPress, if upgrading it meant a complete tooling change I think many would take the opportunity to replatform to something else. The only thing WP really has over them is it's expansive plugin library, and buy in from clients. But it's not really up to devs. I don't think many devs believe it's the best system, but it is desired by…

> The only thing WP really has over them is it's expansive plugin librar

The expansive plugin library that WP has is due to its ease of use, stability and the extent it goes to acommodate users, developers and businesses at the same time. Its no small factor, its no small feat.

Re: PHP in 2023

#218
post #214

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

So dramatic. No one cares what you use, and I suspect you could just not read articles about PHP and voila your problems would go away. Choose your own destiny! You have to ask yourself why such a large proportion of work gets done in two objectively bad languages, PHP and Javascript. They dominate the space. I think it tells us that it's not actually that important to have a 100% perfect language, when it comes to b…

tbf, TypeScript has taken over a huge part of the JS ecosystem, and while doing so has fixed lots of common "meme" gripes with the language. It has also introduced new issues, but alas, the web is typesafe.

Learning PHP though is exactly as the article describes. I had to do it in college and even using a modern version of PHP, the language felt as if it had been written by 3 first semester students under pressure to meet a deadline.

> You have to ask yourself why such a large proportion of work gets done in two objectively bad languages

I did ask myself that, and I came to the same conclusion as the author of "Fractals of bad design": The majority of work gets done by amateurs and amateurs, per definition, don't know any better.

Re: PHP in 2023

#219

Earlier quoted context omitted.

I hope you realize that "fixing" these types of early mistakes is almost impossible for PHP, a language which tries hard not to break things, especially something that's going to be used everywhere. But if this is such a deal-breaker and your IDE is dumb as a stump and can't remind you nothing prevents you from wrapping the stdlib or using something like psl to do it for you.

> I hope you realize that "fixing" these types of early mistakes is almost impossible for PHP I do, yes; which means early mistakes stay in the language forever; same as in javascript. More's the pity.

If its powering 80% of the internet, 30% of all ecommerce websites, its not a mistake.

Re: PHP in 2023

#220

Earlier quoted context omitted.

It feels large to you because you are in it. Other language communities feel small to you because you are not in them.

PHP is still above Go, Rust, Ruby, and Perl in at least the TIOBE index: https://www.tiobe.com/tiobe-index/ Are those all small communities too?

> The ratings are based on the number of skilled engineers world-wide, courses and third party vendors

https://i.stack.imgur.com/Jteqd.png

I'm sure theres also still tons of skilled engineers for Perl around. Or Fortran. Definetely Java. But the TIOBE index looks more like taking inventory of existing skill throughout the industry and less like it tracks disruptive trends.

Post reply on HN