Most active commenters
  • ksenzee(7)

←back to thread

123 points jonfelsar | 33 comments | | HN request time: 0.225s | source | bottom
1. 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 #
2. 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 #
3. Calavar ◴[] No.45188743[source]
I've heard that a lot, but my gripe with modern PHP is what's the hook? What feature does it offer that other scripting languages don't?

- Can you use the same rendering logic on client and server like JavaScript?

- Does it have the performance of Java or C# or Go?

- Does it allow for expressive DSLs like Ruby?

- Does it have an extensive, cutting edge ML ecosystem like Python?

Back in 2010, PHP's stand out features were very straightforward installation, good support for templating, and a large collection of C library wrappers (even if the interfaces were a bit raw). Those hooks were compelling enough to make people put up with the PHP4 core language.

But other languages have caught up on those three points, which leaves modern PHP utterly unremarkable. It doesn't have any feature that stands out enough to make me want to switch back.

replies(4): >>45188867 #>>45188892 #>>45189073 #>>45189258 #
4. Zarkaos ◴[] No.45188867[source]
- Kinda with templates, but I don't think this is a pro for JS tho

- Yes there is LLVM for example

- Have you heard of Laravel ?

- No, there is already python for that, use the right tool for the right job

Today PHP is a really really good language to get scalable apps up and running, moreover with frameworks like laravle that comes with tons of batteries included without tanking the performances. But so so many people remains on the good old PHP dead trend just because it's easier to ignore all the great evolutions pf the past decades

5. jjice ◴[] No.45188884[source]
PHP got a lot better. Their types are actually awesome and better than average. The problems are now about the developers more than the language. Legacy PHP is the majority of PHP and it'll still make you go insane since you'll have to deal with that awful, ugly code someone wrote in the Summer of 2004 when they were an intern that is now core to a business. The people that have been writing PHP and only PHP for two decades also don't usually have great patterns they follow, so when you step into their code base, there's hell to experience.

Had this at my last job where I wrote PHP full time for two years. There were so many bugs caused by things that PHP has since remedied. I updated everything we could and it was huge step up (the available linting and static analysis tools are very solid), but there's still some deep, dark legacy code there that no one wanted to touch. Hell, a good part of my problem with that code base was actually because of Apache and mod_php.

If you have a fresh PHP code base, it's not that bad anymore. It wouldn't be my first pick, but definitely not my last.

Edit: I never got to work with Laravel, but I've played around independently and read their docs and it seems like a good dev experience.

replies(1): >>45188936 #
6. 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 #
7. ksenzee ◴[] No.45188892[source]
That’s a perfectly valid argument. I’m not saying people shouldn’t make that argument. I’m just saying I don’t want to hear about mysql_real_escape_string.

To answer your question, I don’t know that modern PHP has big advantages over other modern languages. I’m not knocking on doors to spread the gospel of Symfony. But there’s no need to switch away from it either. And hosting is still easy and cheap. Prototyping your product as a Laravel or Symfony app is a reasonable choice.

8. ksenzee ◴[] No.45188936[source]
The developers come in all flavors, too. I spend my time writing Drupal code and the average quality is fairly high. (Code quality in the Drupal project itself has always been high, in fact, even when PHP was a disaster on wheels.) So it depends on what those people writing PHP for two decades have been working on.
replies(1): >>45189074 #
9. mcflubbins ◴[] No.45188975[source]
> It’s a modern language with types and tooling and package management.

Last I used Php (v4 to v8), it had type hinting, which was fine but I think its going to become harder for newcomers to approach as there stronger and stronger types, which is what made Php so special to begin with IMHO.

replies(1): >>45189630 #
10. whalesalad ◴[] No.45189047[source]
The “PHP sucks” mainly comes with working with software built in PHP. Like magento, Wordpress, drupal… it’s such a miserable experience.
replies(1): >>45189157 #
11. anticodon ◴[] No.45189071{3}[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 #
12. jjice ◴[] No.45189074{3}[source]
Absolutely true - I can't group all of any kind of dev together
13. scotty79 ◴[] No.45189073[source]
Share nothing request handling. It's like lambdas but without cloud bs.
replies(1): >>45189194 #
14. chamomeal ◴[] No.45189096[source]
My problem with php is that I’ve never seen modern php with types and tooling. I’ve seen a lot of php, and it was all awful 2012 style nightmare magic stuff lol.

Which is probably because php isn’t the top choice for new web based projects anymore. I have nothing against modern php, but old php causes me lots of pain, and that’s the only php I’ve ever known!

15. ksenzee ◴[] No.45189157[source]
Working with Drupal as a user is not the same as working as a Drupal developer. If you know Drupal well enough that you’re not flailing around trying to figure out how to do things—if you actually know the framework and you build sites with it regularly—it’s remarkably pleasant from a code perspective. The main problem with Drupal is the learning curve. It’s much easier to get started writing, say, a Laravel app. But for the narrow case where you need a heavy-duty content management system with features like multilingual and robust cache integration, and you’re willing to put in the time learning it, Drupal is not a miserable experience. It’s actually good software.
16. ksenzee ◴[] No.45189194{3}[source]
That’s a really good analogy, thanks.
17. IshKebab ◴[] No.45189217[source]
Unless they broke backwards compatibility all the trash from the standard library is presumably still there.
replies(1): >>45192214 #
18. goshx ◴[] No.45189231{4}[source]
Skill issue.
replies(1): >>45193381 #
19. kmoser ◴[] No.45189258[source]
The appeal of something like PHP these days is not that it has any particularly unique features, but that it is ubiquitous, has withstood the test of time (meaning it's relatively bug-free), is well supported (meaning it won't disappear any time soon), and is relatively easy to find developers for. Those features alone make it a contender for projects that don't need a specialized language.
replies(1): >>45189510 #
20. epolanski ◴[] No.45189290[source]
+1.

I have recently had to delve in PHP and it was much better and more mature than what people painted it to be 10+ years ago.

A night and day difference.

Jira gave me the same experience. I hated it remembering the 2020 times, yet going back to it now...I actually liked it way more than the alternatives.

21. reconnecting ◴[] No.45189350{3}[source]
If you have a few minutes, I'm curious what will be your opinion about this code base: https://github.com/tirrenotechnologies/tirreno
22. Calavar ◴[] No.45189510{3}[source]
I don't buy that. You can't have it both ways. You can't discount PHP4/5 criticism because PHP7+ is good and then in the same breath hold PHP above other tech stacks for passing the test of time, not when PHP7 is younger than Rails, Django, and React (and even Vue). Those frameworks have passed the test of time more than PHP7+.
replies(1): >>45189647 #
23. paulryanrogers ◴[] No.45189630[source]
Your own PHP code doesn't have to use typing. It's opt in.
24. paulryanrogers ◴[] No.45189647{4}[source]
Those other projects have also had plenty of backward-compatibility-breaking major versions.
25. allthatineed ◴[] No.45190473{3}[source]
I'm in this comment and I don't like it.

More seriously I picked php because it lets me get away without having to strictly define anything and just get away with fuzzy logic. I want to jump on the bed god damn it!

26. trog ◴[] No.45191050{3}[source]
you can replace the word "PHP" in this post with any other language and it would still be true.
27. ksenzee ◴[] No.45192214[source]
They have, in fact, been willing to break backwards compatibility when it matters. mysql_real_escape_string(), for example, my personal favorite bugaboo from the early days, was removed in 2015.
28. anticodon ◴[] No.45193381{5}[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 #
29. ◴[] No.45193816{6}[source]
30. xigoi ◴[] No.45194060[source]
ŠDoes Šit Šstill Šrequire Šwriting Ša Šdollar Šbefore Ševery Švariable, Šmaking Šcode Šannoying Što Šread?
31. wink ◴[] No.45197489[source]
I get your point but I disagree with your timeline. 2012 was already past 5.3 which was a long-lived version with most of the quirks of early 5 fixed.

There was a lot of what people call modern PHP, basically just without the types. I'd say the PHP 4 days are the darker ages that most people reference, but maybe your experience in 2012 was like 2007ish. (TLDR: If you found it fine in 2012 it's probably still fine in 2025, but I don't see the huge wins. I stopped using it for reasons other than "dislike").

replies(1): >>45199077 #
32. ksenzee ◴[] No.45199077[source]
I picked 2012 because that’s when the claw hammer discourse was happening, but I agree with you. You could write pretty nice-looking PHP by 2012, and a lot of people did. The claw hammer thing was itself looking back at PHP from several years before.
33. port11 ◴[] No.45199159[source]
Does PHP have the tooling to lint/warn away the bad 20%? We do that with JavaScript, don't we…