I still love PHP and JavaScript (2022)
79 comments
·September 9, 2025ksenzee
ekidd
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.
pavel_lishin
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.
allthatineed
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!
trog
you can replace the word "PHP" in this post with any other language and it would still be true.
reconnecting
If you have a few minutes, I'm curious what will be your opinion about this code base: https://github.com/tirrenotechnologies/tirreno
anticodon
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.
jjice
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.
ksenzee
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.
jjice
Absolutely true - I can't group all of any kind of dev together
IshKebab
Unless they broke backwards compatibility all the trash from the standard library is presumably still there.
chamomeal
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!
epolanski
+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.
mcflubbins
> 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.
paulryanrogers
Your own PHP code doesn't have to use typing. It's opt in.
Calavar
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.
kmoser
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.
Calavar
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+.
ksenzee
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.
scotty79
Share nothing request handling. It's like lambdas but without cloud bs.
ksenzee
That’s a really good analogy, thanks.
Zarkaos
- 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
whalesalad
The “PHP sucks” mainly comes with working with software built in PHP. Like magento, Wordpress, drupal… it’s such a miserable experience.
ksenzee
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.
dingdingdang
The point made in the article:
* resource leaks are non-existent
Can not be emphasized enough imo. The amount of absolute ridiculous levels of pain instigated by expecting a core code loop to run -forever- and doing so well while being written for some web project or other is just too much to fathom. Just use PHP and serve the request. Then let it die. Then serve a new request.
nedt
It‘s called „shared nothing“. Also makes scaling easier and you can restart processes anytime without impact, because every request starts at zero anyway.
donatj
It also makes scaling across multiple servers an absolute breeze when there's no shared state across requests to worry about.
ksenzee
This is, indeed, my favorite feature of the language.
majorbugger
This has got to be a joke.
What if you need any kind of in-memory cache? Or in general, any kind of application maintaining state, for, say, performance reasons?
EGreg
PHP has apcu as the in-memory cache
And it’s not a joke, PHP is actually the most secure runtime environment out there for web hosting, PRECISELY because of the shared-nothing architecture.
Faster runtimes exist, like Swoole and recently FrankenPHP, to do evented programming like Node JS. But let me tell ya — you risk all kinds of leaks, both of unfreed memory and of secrets, across requests. It ain’t worth it most of the time!
frizlab
Where I worked we had to reboot the php-fpm servers periodically because they had a leak…
hu3
There's a configuration to cycle php-fpm workers every X requests:
https://www.php.net/manual/en/install.fpm.configuration.php#...
frizlab
Good to know!
mekazu
Agree that it’s good to get the certainty of zero memory leaks (assuming there’s no associated bugs in apache) but it’s not that hard to write code that doesn’t cause memory leaks for stateful apps as long as you are able to follow certain simple principles and avoid bugs in the third party libs you use.
al_borland
I often reach for PHP or JS, because anything more seems like over-engineering a simple problem. I'm usually looking to make simple, quick, internal tools that just run without much maintenance or support. PHP has been perfect for this. A lot of them are just single files and run for years without me doing a thing.
GavinAnderegg
Over the last few years, I've found that most sites clients want can be built with static site generators and JavaScript. PHP is also great and easily hosted! But most times when there's a sprinkling of dynamism needed, it's OK if its happens at build/run time rather than when the page is rendered on a seever. This leads to faster page load and less to worry about security-wise. No shade! I've just been finding this has lead to good outcomes for me.
miladyincontrol
You mean to say some basic company site, blog or photo gallery that only gets updated once/twice a month, with zero dynamic content otherwise doesnt need a whole LAMP stack?
Honestly though with GH/CF pages type hosting and how simple static sites can be its a direction I'm ever thankful things have been moving. Just seems so much less painful for those who arent here to be security experts and just want a bloody site that 'just works'
scotty79
Your static site generator can generate PHP instead of html and have some server-side dynamism sprinkled in your mostly static site, same way that generating JS can sprinkle some client side dynamism.
LamaOfRuin
This is not the definition of a static site.
scotty79
Definitions are blurred. PHP file can be almost HTML file.
CM30
I don't think it can be emphasised enough how big of a deal the ease of deploying applications written in these languages is. The fact you can just upload the files with FTP, SSH, by pulling them from version control, etc makes learning so much easier than it'd be otherwise, and really speeds up deployment for software using these languages.
Like, this genuinely might be one of the big reasons that scripts like WordPress, MediaWiki and XenForo still use PHP. The people installing these things don't have to be technically minded in the slightest, and can get their sites running on a 5 quid a year shared hosting service without the need to understand the command line, shell scripting, containers, server management, etc.
Is it secure? Probably not. Is it best practice? No. But you can test your changes near instantaneously, and it takes like 30 seconds to get set up. Ease of use is huge.
poidos
Where would one get started with PHP without picking up Laravel or Drupal?
nedt
Every PHP file can work without frameworks. The route is your filename, PHP by itself can do templating and input data is handled by the super globals.
But if you want some small and simple framework as guidance you can also try out Slim Framework.
miladyincontrol
I dont have to touch php too often these days but frankenPHP is one the best things to happen to php in a long time, especially now that the php foundation has decided to officially support it.
kayaroberts
Its so easy to just get things done in php, even if its in an ugly way that you would never show to another developer.
user3939382
And with strict types and Psalm used right, I’d be happy to show it to anyone. The OO paradigm in general always has its valid criticism but modern PHP written correctly for its usual problem domains is perfectly fine actually it’s great at what it does.
Theodores
...but you have got working code and a nice refactoring job where you do everything to the agreed on coding standards, learn a bit from your colleagues in the peer review and end up with something that is done the right way that you can take pride in.
epolanski
OT, but I wish other languages had the templating power php has.
I've recently worked on an ecommerce written in php after years of Vue/React and it was surprising to me just how much convenience and performance your websites have out of the box as opposed as the monstrosity of single page applications, island, server components, etc.
null
dmitrijbelikov
I started working with PHP back in 2002, it was cool, the first code I had to study was phpBB. By now I have made about 10 applications that have survived to production. I learned how to configure Linux servers, understand the front-end (sometimes), architecture, security, management and do a lot of things that now usually require a whole team to do.
bovermyer
Refactoring a PHP application is very satisfying.
dang
Discussed at the time:
I still love PHP and JavaScript - https://news.ycombinator.com/item?id=32325055 - Aug 2022 (393 comments)
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.