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?
It’s written using Symphony framework and seems to be using the latest best practice. Nothing to worry about here. PHP has its warts, which are being addressed since PHP 7.x. Modern frameworks like Symphony go even further by encouraging best practices when developing PHP WebApps, unlike the dark old days of PHP WebApps full of SQL injections and XSS issues (still is though in the WordPress plugins ecosystem).
I’m mostly a Python guy and used to look down on PHP, but changed my tune since the release of PHP 7.x. If Python has JIT half as good as PHP these days, I would die happy.
There’s still lots of problems with php like the type system exists now, but doesn’t let you put types on containers (arrays, hashmaps etc) so you still can’t use the type system to model your app in a way that invalid states throw compiler errors. And it’s certainly not ever going to be an algebraic type system. Nothing past the basics make it into php.
They’re trailing behind in every way, have you ever looked at a php feature and went “oh god, I want that!”
I don’t use PHP enough to comment about its type system, but at the very least it’s no longer a horrible language anymore. If for some reason you are forced to use PHP to greenfield a new project, at least you don’t have to worry too much about basic stuff anymore.
If there is one PHP feature I absolutely want, it’s the blazing fast JIT which put other interpreted languages to shame.
Modern PHP is much better than most people expect. It has very little to do with the PHP4 we all grew up to dislike for its quirks and inconsistencies.
That said, I wish more software was done in PHP. And for me it makes a lot of sense regarding the Fediverse. A PHP platform I can put on my existing shared hosting and connect some (sub)domain to it and call it a day. Most smaller/meduim businesses probably have that hosting constellation already around, idling around most of the time. The entry barrier is just so much slower than spinning up a VPS or renting cloud space somewhere just to test a small instance of something. Sure it scales not as good as your average cloudplatform but for most usecases that is not the biggest concern.
Different product but I love Matomo as a Google Analytics because I can just copy the files to a clients shared hosting, connect a subdomain to it and if it uses Sqlite (also better than it’s fame!), I am done already and don’t need to create a database even.
In my opinion, only the most elite (in all the wrong ways) people care how you build your app.
PHP has flaws, sure[1]. But unless you are working on the app itself (or again, you are horribly elitist) it does not matter.
What matters is that the app is good. If the app is good, it doesn’t matter that its done in PHP, what matters is that it works.
EDIT: I guess it also matters if you’re selfhosting the app.
[1] I think PHP is overhated. As a stateless language it lacks a lot of complex features (and thus, admittedly, might be questionable for a project as large and complex as kbin), it has some questionable design decisions, but it’s really not as bad as people make it out to be.
It’s not because of word press. Wordpress is complete garbage that should have died ages ago. The reason it hasn’t is because it still makes it easy for people to add a customizable site in a couple of minutes.
As for php, the php 5 days are long gone. Php has actually become a good a respectable language since the release of php 7, and things only continue to improve. Php is at version 8.1 and progress is not slowing down. There is even a dedicated full time dev team for php now. PHP is definitely not going anywhere any time soon and I’m more than comfortable with starting new projects using PHP. It happens all the time, especially with support from extremely good and well established frameworks like Laravel.
Honestly if you’re starting a new project today, what would be a joke is to start it in node.
I’m trying to get a website up and running, but I need to be able to self host it. Can your recommend something other than Wordpress that I don’t have to code?
Eventually I’ll have something cussing made, but for the time being, I just need something up and running.
Not sure if you’re familiar with the terminology but WordPress is a Content Management System (CMS). I honestly don’t know of many other than WordPress, I’ve heard of Joomla and Drupal but can’t speak to anything about them other than they’re CMSs, they’re FOSS, and I’ve heard them talked about.
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.
Same reaction. Rust is the future. Typescript is the present.
Lol, this dude literally just pulling feelings out of his ass
Does disappointment count?
After struggling my way through a broken MediaWiki upgrade today, I was reminded once again of just how awful PHP is, both to develop in it and to use applications written in it. What I had to deal with today would not have happened if it were written in a compiled language, because it isn’t possible in compiled languages.
Specifically, my MediaWiki settings file contained:
require_once( "$IP/includes/DefaultSettings.php" );
Apparently, this was once required in MediaWiki settings files. After upgrading, though, its presence causes an extremely misleading error message:
Fatal error: Uncaught FatalError: $wgBaseDirectory must not be modified in settings files! Use the MW_INSTALL_PATH environment variable to override the installation root directory. in /path/to/mediawiki/includes/Setup.php:237
My settings file does not contain
$wgBaseDirectory
. Moreover, adding$wgBaseDirectory = MW_INSTALL_PATH;
to my settings file does nothing.Only after a lot of web searching (and a fair amount of profanity) did I finally find out that the above
require_once
statement is the culprit.See the problem here? Interpreted languages like PHP encourage the extremely irritating anti-pattern of using an executable code snippet as a configuration file, which inevitably results in this kind of nonsense. In a compiled language, on the other hand, the easiest way for an application to load settings is by reading them from a data-only format like JSON or TOML, parsers for such formats tend to produce better error messages than this, and the vast majority of such formats don’t have an include directive at all.
Had MediaWiki been written in a compiled language instead of PHP, my morning would have been a whole lot less stressful. And this isn’t the first time that this configuration-is-code anti-pattern has caused me grief.
It’s not just that it’s interpreted. I code a lot of Python and I’ve never just read in another Python file as configuration and executed it. Reading a yaml or json file is like 2-3 lines of code. But I’ll bet it’s not that simple in PHP.
It is that easy in php:
$jsonConfig = file_get_contents('config.json'); $config = json_decode($jsonConfig);
Well in that case, it’s just bad coding.
I guess there’s a tendency for interpreted languages to attract more bad coders because trial & error is easier and you can get started in fewer steps. Also, fewer confusing compiler errors to deal with.
To be honest, the “configuration is an executed .php file” system does make some amount of sense in the context of PHP. When your app has to re-run everything to serve a web request, having to re-load the config (especially if it’s YAML, though JSON is less bad) is expensive. Re-running the PHP code, on the other hand, can be cached way better, in theory.
Of course, this is still all PHP’s fault in the end: the core problem here is that you need to re-run everything to serve a web request, without ability to pre-load state like configuration.
There’s still lots of active PHP projects, including new ones. PHP is actually a nice language and much of its negative reputation comes from the years of stagnation during the late PHP 5.x era. Which is long over. I definitely find PHP to be much nicer than JS for backend development, although I no longer use it professionally.
I see a lot of people quick to hate on PHP while not really knowing anything about it’s modern usage… but the thing I think of most is how people praise Lemmy for using Rust and diss Kbin for using PHP, but at the end of the day it’s HOW those tools are used that determines the quality of something. Language changes, but fundamentals stay the same, and in the end all anyone should care about is whether or not something works.
Programming language wars have always seemed a tad shallow to me.
more so surprised that it wasn’t written in {insert favourite language here}
that being said I agree that PHP isn’t anything like it used to be.
And here I am, just waiting on the next fediverse app to be written in Java so I can actually contribute code 🥲
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
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…
Choosing a language for a project because it’s “cool” is so stupid
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.
Fwiw Lemmy is written in Rust