I don’t know if it’s due to over-exposure to programming memes but I certainly believed that no one was starting new PHP projects in 2023 (or 2020, or 2018, or 2012…). I was under the impression we only still discussed it at all because WordPress is still around.
Would a PHP evangelist like to disabuse me of my notions and make an argument for using PHP for projects such as Kbin in this day and age?
PHP is not as shitty as it used to be. Additionally, it’s very approachable and it runs basicly everywhere.
PHP lost a lot of popularity yes. But developers still use the major PHP frameworks, those solve a lot of the issues many developers had with PHP. On the StackOverflow survey Laravel was still used by 7.5% of the responses and Symfony by 3.2%.
Currently I’m actually taking over a website that was written with Laravel and rebuilding everything in SvelteKit.
I’ll just say that my first thought when I read the subject line but before clicking into the post was, “Is kbin that old??”
deleted by creator
As far as I know PHP is still very active and a great choice for new projects. Lots of new projects get started every day in PHP, the language and tools are still in active development as well as frameworks like Symfony for example.
Sure there’s lots of legacy crap including WordPress, but there’s also no reason not to use it. Just because people wrote a lot of crappy stuff in PHP doesn’t mean it can only be used to make crappy stuff. It’s very much possible without a lot of trouble to create solid, good performing, easy to develop and maintain applications in PHP.
First off, any language/framework is just a tool.
Second, modern PHP is quite different than 2005 PHP which is about when people started moving to other languages for web development (Ruby, Python, etc.). What you can and should write in PHP today would be almost identical to what it would look like in those languages (i.e. MVC frameworks, ORM for DB access, dependency management with lock files). Many language features were added too such as namespacing which allow for better/modern code organization.
PHP has always had (and never lost) it’s dead simple capability to just package up a tar ball, ftp, unzip and just… run.
Would I use PHP today, not unless forced to or for a lot of money. But if it’s a language a team knows, there isn’t a benefit to switching to something else.
I’m a web developer of 25+ years. These days python, php, react, vue stack. Formerly, C, C++, perl and assorted other oddities.
Forget what you once heard about PHP. Modern php is nothing like its early days. Modern php has some great constructs that give language expressiveness and fluidity, and that really lends itself to concise and beautiful code.
PHP also has some brilliant web frameworks (eg: Symfony) that make build web apps (be it REST APIs or frontend backends) just a pleasant experience all around. It’s dead simple yet extremely powerful. This makes makes development and maintenance using PHP cheap. PHP’s testing suite is also ridiculously powerful.By comparison, I find python web frameworks (Django, flask etc), fiddly and finnicky to use. I also find Python a much less expressive language. By that I mean it will often take me several lines of code to do something that is otherwise a 1 liner in php. It just feels clunky and awkward.
Don’t get me wrong. I once hated and laughed at PHP with the rest of them. But PHP has really evolved over the past 10 years, much more so than python has. I look forward to the day Python has a good hard look at itself.
In the meantime, if I need a backend for a website and I’m given the choice between PHP or Python, I’ll choose PHP (symfony) every time.
Besides, PHP devs are cheaper.
Thank you for the detailed response and don’t worry: you don’t have to pull punches on Python on my account 😂 I’m a former Django dev and I have no intention of working with Python ever again. I see why it’s so popular for data analysis etc.: it’s a phenomenal language for non-programmers.
I don’t really focus on Web development (though I’ve done a little in various languages when it became necessary to solve specific problems), but over the years, for software development, I’ve become pretty conservative about adopting new programming languages, frameworks, libraries, and so forth when they come out. I have seen a very large number of things that were new and trendy vanish in the wind after people put a lot of effort into coming up to speed on them.
Once there’s a large installed base, though, they’re gonna be around for a long time to come, because software projects have committed to them.
None of this is to ding Rust, which Lemmy uses. I’ve never written a line of Rust myself, don’t know the ecosystem. But I don’t think that PHP is bad just because it’s pretty mature.
Also, related side note: Reddit was originally implemented in some Lisp variant, probably in part because Paul Graham, who was involved in some early funding, is a huge Lisp fan. There isn’t that much web dev happening in Lisp, and Team Reddit later had to go back and reimplement it in the more-widely-used Python, on the Pylons framework. That doubtless cost them a lot of dev time.
PHP isn’t bad because it’s mature. It’s bad because it’s PHP.
Still, it’s good for the right jobs.
While I haven’t tried symphony, my annoyance with PHP in general is that parsing any kind of data is tacky. In the end you have just as many lines as python but less readable.
Cleaner functions or cleaner data? Both languages have their strengths and can (now) be typed.
Well, this is true. It’s all about the right tool for the job. The PHP hammer is good at some things and bad at others. It is good for web development, it is bad for parsing [thanks to its truly awful regex functions], and it is way too bloated to be any kind of scripting language. Python is much better for parsing and transforming data, but its regex implementations are still pretty awful when compared to something like Perl. In fact, I still reach for Perl when I have to parse complex and unstructured text. Haven’t yet reached for Perl 6 though.
There’s a sister project at my work that still uses PHP. It did surprise me, but it’s very well written and easy to maintain. I reckon php will be around for a while yet.
Modern PHP is quite performant and nice to work with and it’s still improving! Also frameworks like Laravel is very established.
When comparing the time when I use PHP and JavaScript, I love the simplicity and versatility of JavaScript but PHP’s strongly typed (with runtime support) and object oriented language often make more sense imo.
I think the strong benefit of using JavaScript for backend comes down to being able to have unified full-stack codebases, one language fits all kind of thing.
PHP’s strongly typed and object oriented language
man, PHP has come a long way!
Funny that a lot of people responded by bashing on PHP, but I saw very little real arguments why PHP is so awful. What makes PHP that bad besides being the target of memes?
I mean “lame”, “old” or “dead” aren’t particularly convincing arguments.It’s a terribly designed (and I’m being very generous with the use of the word designed) programming language, but to its defense so is JavaScript and people are not bashing NodeJS apps.
Newer versions of PHP seem to be dealing with lots of past mistakes, but it will always have lots of warts due to backwards compatibility.
What are those warts? I’m not trying to be a dick, I’m just not educated enough on this subject. Is it more the ease of use (needing much more lines of code to do something or you need to build things yourself since there isn’t a function for it) or more the way the language is build (multiple functions doing the same thing or misorder of arguments)? Or is it just the performance?
I started with PHP years back, shifted to Android/Java and then to C# (Xamarin) to Javascript (node.js/React(Native)). All in a hobby/personal project form, so I didn’t bump into problems with PHP most peofessionals seem to have and I still use it for API’s sometimes.
You have things like type juggling which can hide nasty and hard to troubleshoot bugs. There are also inconsistencies because before 2014 the developers were YOLOying it instead if having a formal specification to stick too.
And then you also have older parts of the standard library that were done by people that didn’t know what they were doing, leading to things like
mysql_escape_string
which doesn’t properly escape strings in some charsets, meaning you should usemysql_real_escape_string
and that lots of beginners used the wrong, unsafe, function.Another thing that doesn’t help PHP’s reputation is that it used to be the language of choice of people that knew enough programming to be dangerous. I.e. people that know enough to do small applications, but not enough to take security issues or reliability in consideration. Which by the way, is still a big attitude issue in the PHP world seeing only 8% of PHP Websites use a supported version of PHP with security updates..
I was fortunate enough to meet Rasmus Lerdorf (PHP founder) long before I became a PHP programmer. At the height of the PHP hate back in the early 00’s Rasumus was bravely giving a talk to a group of us stuck up Perl programmers.
To be fair, we had good reason. PHP had borrowed lots of functions from C for familiarity (all those str* functions) and done stupid things that made life unnecessarily difficult, like naming some of them with underscores and others without, and making parameter order inconsistent across similar functions. So it did all these C like things but, it did them way, way slower.
Not only that, PHP also wanted to be like Perl because perl was also a bit like C but, unlike PHP, did things quickly and could parse just about anything you could throw at it. So, PHP also shoe-horned in a bunch of regex functions to give perl-like capabilities to their pile of poo. So now it also had perl capabilities, but was performing way, way slower than perl.
PHP was like that try-hard kid at school that wanted to please everyone, but everyone pretended not to know.
But, most impressively, Rasmus was very apologetic for what PHP had become. He said to us that PHP was never designed to be a programming language. It was designed to be a “Personal Home Page” templating tool. But soon people wanted to conditionally include bits of templates. Then they wanted to iteratively include bits of template.
And then he learned about lex and yacc, rewrote the whole thing. And finally, one stormy day, there it was. Hideously ugly and Turing complete.
And, when he said this, suddenly it all made sense and we had a whole lot of sympathy for where it and he was at.
He went on to say that they were putting a lot of working into looking at the worst bits of PHP and making things better. And, credit where credit’s due, that’s exactly what he’s done. PHP today really is a nice language to work with.
Thanks, great story (which I didn’t know) and some examples of why PHP is/was bad. Great write up!
Modern PHP is supposedly pretty alright but yes I was surprised and a bit disappointed, I would have liked to contribute but I’m not gonna touch PHP in my free time lol.
This is similar to how I feel.
PHP is pain to developers Jerry!
I joke about PHP being a dead language a lot but AFAIK modern time PHP is actually a pretty decent language. Haven’t coded one tho personally.
I know it sounds childish but PHP is lame as hell same as java. Rust or go would have definitely been a cooler choice. I mean PHP gets the job done, but still…
Fwiw Lemmy is written in Rust
Choosing a language for a project because it’s “cool” is so stupid
No it’s not. If I work on something in my free time / voluntarily, I want to have fun. I want to enjoy it. If PHP pisses me off but Rust thrills me, of course I choose Rust. That’s the freedom you have if you start a project. That there are more maintainers and even a bunch of contributors underlines that it was the right choice.
Let’s try not to insult other people’s preferences.
In a way though he’s right, picking a language because it is “cool” is the wrong reason to pick a language. You should be looking at other things like performance, scalability, security, functionality and see if those facets align with the requirements for your project.
When doing a project where those things matter - sure. But if it’s your hobby protect you can do anything
Yeah, that’s fair enough, I’ll agree to that.
I think the challenge arises when your hobby project gets funding and thousands of people start using it… But at that point the codebase is likely locked into many previously made decisions. Locked in as in - it would take too much effort to change it.
Yeah. People really should be allowed to make things in whatever technology they prefer, but at the same time I can’t help but wince when I see infrastructure such as Mastodon or Matrix Synapse being written in slow inefficient languages like Ruby and Python.
It’s really bad for the strength of decentralized networks like Fedi when I have a friend telling me “I wish I didn’t set up Mastodon because my tiny instance needs multiple gigabytes of RAM”. I might have set up a Matrix homeserver myself by now if Synapse wasn’t Python and notoriously slow. I immediately discarded Kbin as a choice (among other reasons) because it’s PHP and Lemmy is Rust.
Always easy to say “hindsight is 20/20”, but still.
As a single developer taking on a passion project you go with what you know.
Also it must have been near impossible to have foreseen the insane explosion of popularity that has happened here the last few days.
Even then if you build something for passion you choose something that make you happy to use, however esoteric or impractical that may be to others, or how it would be perceived. Most probably it was never thought to be exposed in such a massive way, and certainly not as soon after the project was started (we’re talking month(s) here).
Anyhow, for this project from the looks of it it is working fantastic.
Personally I’ve not used PHP for years but now I’m actually intrigued to take a new look at it.
It’s such an outdated meme to shit on PHP. PHP 8.3 is absolutely nothing like PHP < 5. It’s become a full-fledged, performant and secure language. I’ve been coding PHP since 2005, and I’ve seen it grow and become incredibly capable. Sure I do recognise that other languages are still more “popular” and respected, and as such I’ve been focusing more and more on Node/Typescript in recent years, but PHP isn’t going anywhere. And its package ecosystem is so much more reliable and stable than say NPM.
Not to mention that the defacto package manager (composer) blows NPM out of the water in basically all metrics. From what I understand most languages package managers now look up to or even model themselves on it.
I have worked with composer, npm etc. All of those out there, but why is composer superior in your opinion? wouldn’t be able to pin point anything