←back to thread

123 points jonfelsar | 2 comments | | HN request time: 0.001s | source
Show context
ksenzee ◴[] No.45188438[source]
This is a preemptive plea for people who last wrote PHP in 2012 not to opine on what writing PHP is like in 2025. It is not a hammer with two claws. It’s a modern language with types and tooling and package management.
replies(11): >>45188723 #>>45188743 #>>45188884 #>>45188975 #>>45189013 #>>45189047 #>>45189096 #>>45189217 #>>45189290 #>>45194060 #>>45197489 #
ekidd ◴[] No.45188723[source]
I've certainly seem some lovely PHP code. Even phpBB has been very clean for a long time.

But at the same time, you run into the same problems that you often see with C++. Yes, there's a clean, semi-modern dialect of the language that has 80% of what you'd ideally want. And 80% is often more than enough for practical engineering purposes. But the actual project you get hired to work on may not be written in that cleaner, modern dialect. The last C++ project I cracked open had gone almost 20 years since its last serious update. It wasn't terrible. But wow, did it take a lot of very tricky code to accomplish anything before boost and TR1 became popular.

And old PHP was one of the worst languages ever invented: the core C code was hopelessly insecure (I had to read it for a client during the dotcom boom), the database APIs were different for every single database (and all of them made SQL injection techniques too easy), the default configuration allowed hostile users to inject global variable values using CGI parameters, and I could go on for a week. Yes, I saw some ugly stuff in other languages during the dotcom boom. But ancient PHP was often on a whole other level.

And when a language's history includes that much ugliness, you need to be very careful about old production code bases. Maybe you get a nice Symfony app! Buy maybe you get mixed HTML/PHP/SQL with a hundred security holes inherent in the APIs being used.

replies(2): >>45188885 #>>45199159 #
pavel_lishin ◴[] No.45188885[source]
Not to mention, the people who've been writing code in 2012 are still writing PHP code like it's 2012, and plenty of people are learning to write PHP the same way.

I haven't seen too many PHP codebases in the past decade, but every one has been full of a mix of commits that are beautiful, clean, functional code... and just the worst mishmash of garbage I've ever seen.

PHP might be fine, but I'm still not sure if I'm ready to work with other PHP developers.

replies(4): >>45189071 #>>45189350 #>>45190473 #>>45191050 #
anticodon ◴[] No.45189071[source]
Last time I touched PHP in 2018. It was a website my company bought from a french developer. After many unsuccessful attempts to add even basic functionality to the site, I announced my employer that they paid for the domain and the audience, but the code has to be rewritten from scratch.

It was typical PHP mix of HTML and PHP code in one file, an unreadable sequence of several crazy long HTML lines, then several lines of PHP code, then again HTML.

Lots of copy paste.

SQL statements were created by concatenation of user input with the text of the query. In 2018.

Back then I promised I'll never ever touch any PHP code. Live pretty much happily since then. I know there's some typing added to the language and other modern features. Still pretty sure, that if I open any random PHP file from any random PHP project, I'll still find the same mess as ever before.

replies(1): >>45189231 #
goshx ◴[] No.45189231[source]
Skill issue.
replies(1): >>45193381 #
1. anticodon ◴[] No.45193381[source]
I don't understand. The point of my comment was that from my experience PHP code always has worse quality than code written in other programming languages. It's a broad assumption and I have no proofs. But it is my experience, I've never seen exceptions. Any PHP codebase I've looked at, had lots of issues with code readability, maintainability, robustness, security.

I think it was a huge mistake to allow mixing code and HTML. On the other hand, without this feature, PHP probably wouldn't become popular at all.

replies(1): >>45193816 #
2. ◴[] No.45193816[source]