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.
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.
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.
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!
- 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.
- 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
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.
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.
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.
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!
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.
Back in the day I had one of those, even when I was broke, because the value was fantastic. There were tons of "self-hosted" type apps built with that stack (php+mysql), so you could have all sorts of apps running on there. I haven't checked in a while, but I guess nowadays that type of thing will be made for node, docker, etc.
In the endless framework wars where one day we are friends with server side rendering, the next with client side rendering and the next with eurasia, I keep seeing people reinventing what we already were doing with PHP long ago. I doubt it will happen, but I keep waiting for a PHP renaissance.
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'
(Vs. 8.4 was released Nov'24; 8.5 is scheduled for Nov'25.)
But if you want some small and simple framework as guidance you can also try out Slim Framework.
PHP and JS have been my favorite languages since I first picked them up. I know they have a bad rap which was more deserved back when I started with them but, like the author points out, they have come a long way since then.
Edit: Correcting “here, here” -> “hear, hear”
It's Hear, hear! as in, listen to what was said, I guess.
* 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.
I wouldn’t recommend them, though.
What if you need any kind of in-memory cache? Or in general, any kind of application maintaining state, for, say, performance reasons?
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!
https://www.php.net/manual/en/install.fpm.configuration.php#...
But what I've never liked about it is the big ini file. I don't really begrudge there being runtime settings for an interpreted language, but I've always found PHP to have waaaay too many settings, many of which have potentially odd defaults and/or can be asinine footguns by accident.
That said, I can't get myself to love JS no matter how much I use it. On some level not having separate numeric types for floating point and integers just annoys me a lot. It is obviously the interpreted language that benefited most from typing for a reason. I'm sure there's more to why I don't really love, despite using my whole career.
Me personally I've moved on from PHP unless I have to work on it, I'm now just full stack JS for my own projects.
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.
They need a language or IDE that can hold their hands. They need a code base that doesn’t require much thinking. This is all for good and for the better, BUT, they are all due to skill issues.
You hate PHP because you are not good enough to tame it.
Some discussion then: https://news.ycombinator.com/item?id=32325055
I still love PHP and JavaScript - https://news.ycombinator.com/item?id=32325055 - Aug 2022 (393 comments)
As for JS ... I like TypeScript, even love it in many ways. I can deal with raw JS, but I won't write full apps in it. Ironically, I'm favorably inclined to PHP's OOP features, but I avoid them like the plague in JS, where I stick to static closures instead.
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.
And I have never regretted it. PHP powers 80% of all web sites in the world, still today! And it is the only language and runtime out there that is shared-nothing for web serving. Eliminates all kinds of leaks, including of memory, and secrets etc.
PS: This was the early PHP framework that the platform grew out of: https://www.reddit.com/r/webdev/s/hETCmkpWFW and this is how long ago I posted on HN about it: https://news.ycombinator.com/item?id=2464112 !
kayaroberts•4h ago
user3939382•4h ago
Theodores•4h ago