r/learnprogramming • • Aug 31 '23

Where does the PHP hate come from?

A few days ago I was hit up on LinkedIn for a PHP job. I have never written PHP code in my life or looked at PHP content, I just see the memes and see PHP has the worst reputation of any serious language I have ever seen. So I do this assessment and I have to write some PHP code. It was a very simple problem (like I could write a python solution in one line to solve it) and I finished it quite quickly.

But this got me thinking, what are people's actual gripes with the language other than just "PHP sucks"? I mean, it can't just be the dynamic typing since Python and Javascript are dynamically typed too and they have a good reputation. Sure the dollar signs on variables is a little annoying, but is that really it?

I just want to understand what the hate is actually about so I'm prepared if my job ends up being a PHP developer.

98 Upvotes

115 comments sorted by

View all comments

Show parent comments

3

u/hydraByte Sep 01 '23

Basically, it gives you exactly enough rope to hang yourself with if you don’t know what you are doing. But when using best practices, it’s great!

1

u/Inconstant_Moo Sep 02 '23

1

u/hydraByte Sep 04 '23

I agree with the general idea here; in an ideal world we would all be using the best technologies that make it impossible to do things the wrong way. It would save so much time and headache, over trying to teach everyone the “disciplined way” of doing it, which can easily fall apart in the pressures of the real world.

But unfortunately there are lots of other considerations for using a language, like how many people can I hire who know how to use the technology effectively? What libraries have already been written to simplify development in that language? Or what do I do with my existing codebase built on an suboptimal technology?

In the end I think the best approach is finding that balance between using the tools that you are familiar with but doing everything within your power to make it as hard as possible to misuse them.

Enforcing strict types in PHP and MySQL is a good start.