184 points · by ashitlerferad · 7y ago · 129 comments
It is bad when working on a business-grade product with more than a dozen engineers. Bizarre language choices and an intrinsic tendency towards non-encapsulation seems to make even more spaghetti code than you'd find in Ruby, Python, Java, etc.
From working on numerous large Java projects, I can say with real-world experience that the logical equivalent to spaghetti code is very common with Java. The difference is where the spaghetti is -- in Java, it tends to be spaghetti inheritance and encapsulation.
Everyone may commence the throwing of tomatoes now.
Edit: Fixed some language errors and typos.
Speaking as an ex-hoster here who had to look after a fleet of shared servers running PHP (000's of sites) for 15 years, sadly life is not that simple in the trenches. The major problem with PHP is breaking changes. Even within the 5.x releases there were enough breaking changes such that upgrading from say 5.3 to 5.6 could break a site. The jump from 5.6 to 7.x has enough breaking changes to make you cry. I think there should have been a commitment to maintain 5.6 for the next ten years, if only for security fixes.
Now I'm not suggesting that developers shouldn't go back and fix stuff that breaks because the PHP folks removed/altered that functionality (with the good intentions of encouraging more secure programming, for example), but there's a labour cost and someone needs to pay for that time.
There's also functionality in PHP that shouldn't have been removed (register_globals) but should have been defaulted to disabled. Sure register_globals is insecure but what we saw were folks adding the same functionality back, just google for "php emulate register_globals".
And don't get me started about the annoyance that was removing mysql_* support. Those exact same insecure string concatenated queries are still being executed via mysqli_* and the PDO libraries. In my experience, binning mysql_* didn't make a damn bit of difference when it came to sql injection attacks.
Don't get me wrong, I admire the efforts of the PHP core team, but they made a rod for our already sore support backs whenever a new release of PHP shipped because of some fairly unnecessary BC's.
"Non-technical" people who don't plan for maintenance costs to their software (including maintenance to keep up with dependencies like PHP) don't get a ton of sympathy from me ¯\_(ツ)_/¯
It's not just PHP. But Python 2x / 3x as well.
Just to point something out: this is one reason why Java is so well liked for large enterprise code bases. They have been religious about backward compatibility in new versions.
A 2nd principle I would advocate is that if there must be a breaking change, it should be caught at compile time, not at run time. The project should fail to build, and the errors point you to exactly where the source code problems are.
Other language systems would do well to embrace backward compatibility and build time errors over run time errors. IMO.
But at least the python folks provided some tooling to bridge the gap between v2 and v3 such as backporting features from python 3. Also minor version updates generally don't break whole codebases.
Apropos Java backwards compatibility, Microsoft has been pretty good at ensuring strong backwards compatibility with .NET code. I've seen .NET 1.0 source compile and run just fine on .NET 4. Hell I've even witnessed .NET 1.0 binaries run just fine without recompilation in newer .NET environments.
Sure there's breaking differences between .NET Standard and .NET Core but they're two different products and that was made pretty apparent from the get-go.
That was one of the lowest effort upgrades I ever did for my company (backend services, no front end websites).
One of the other reasons Java is popular in big companies is the low effort it requires to find people who can work with it.
I mean, I agree with you. But Java benefits from well thought-out design constraints, ground-up IDE support, and an amazingly flexible bytecode interpreter. Normal people in the early 90s didn't have the resources to produce a language like Java.
It was for years! They deprecated the feature. It was default disabled in php.ini. And now, as you said, if you really still need it you can code it yourself (I had to).
> And don't get me started about the annoyance that was removing mysql_* support.
I'm pretty sure that library isn't supported by MySQL server anymore (it's their library) so that's why it was removed. You can even use it to connect to newer versions of MySQL as the protocol changed.
Of those PHP websites, most of them are probably wordpress. How many of those haven't been updated in ages?
That's way more dangerous than running PHP 5, taking into account all distros will backport security fixes for years to come.
PHP has adopted a strategy of rolling version upgrades with defined end points. They probably should have some "LTS (Long Term Support) type releases.
http://php.net/supported-versions.php
5.6 just reached eol. I think they've put out a securtiy patch since then so its (not quite) completely abandoned.
If people aren't forced to upgrade their sites, they won't. So there is huge incentive to just keep running the older versions.
Debian 8 (Jessie) still has a little over a year left, for example, and is on PHP 5. Ubuntu 14 is just nearing the end of support, and is on PHP 5. Same with OpenSUSE and CentOS.
I'm not sure what the Red Hat situation is, because the pages at Redhat that Google found that would probably tell me are in the knowledge base, and will only show me the question, telling me I have to be a Red Hat subscriber to see the answer.
This is one of the annoyances with some major frameworks. According to both the Symfony and Laravel requirements pages, they need PHP 7.1.3. As far as I can tell that's not included in any LTS release of any major Linux distribution, which top out at 7.0.33 currently, I believe.
PS: interesting oddity somewhere in HN. When on the "reply" screen for your comment, HN says your comment is 1 day old. However, back in the thread, or on a direct link to your comment, it says that it is 6 hours old. It does the same thing for all 6 hour old comments in this thread, but not 5 hour old comments.
Oh you cant run lib/framework/tool due to host deps? No problem, I will just replace you with a script.
For example by default the Website runs in PHP 5.6 and it is up to the site owner to change the local site version to a newer version via cPanel or similar.
So non technical users that just know a bit of PHP or use some CMS, end up being stuck with the default version.
Aside from that, I'm glad you've highlighted Laravel, which—despite being the most popular server-side Web framework on GitHub—gets virtually no attention from HN. It's typical to use Laravel in the old server-side rendered Rails paradigm (which is still probably best for some applications), but I've had success using it to develop APIs as well. Core features like the ORM, job queues, dependency injection, email templating, etc, are very solid, and the ecosystem of packages around it is phenomenal. I would recommend it to any Web developer.
Which are the "right extensions" because what I saw was not "fun" at all.
PS: I haven't used php for 2 years, let me know if there is an update on debugging.
I am not sure how well such a feature is supported in javascript, ruby, java or what not out of the box...
PHP can scale up or down, but some tools are harder to 'scale down' - by that I mean be able to be used for short one-off things (cli tools, etc). I'm not saying it can't be done, but people don't often write smaller supporting tools (quick text preprocessing before an import, for example) in Java, even when their main projects are in Java. Of course, IME, and YMMV.
[1] https://venturebeat.com/2015/11/08/wordpress-now-powers-25-o...
https://wordpress.org/news/2019/03/one-third-of-the-web/
That's the entire web. It is staggering.
I guess it's like how people trashed COBOL and Fortran when I was getting into development. Then later in life, I come to find out that Fortran is ubiquitous in engineering and is actually amazing for what it does.
Unlike many programmers, I don't pick one of the Turing-complete programming languages (PHP, Python, Ruby, Go, whatever) and try to write as much of my app as possible in it. Because they are Turing complete, you really can write everything in it. Because you can learn only so much, you are tempted to write more than you should in that language.
But like I said, PHP is just a part of my stack, and I try my best to make it one of the thinnest layers. The other parts are Postgres, Apache, and the user's browser. I try to use each of those as much as possible. The server operating system also plays a part, and I suppose my stack includes Bash.
Basically I try to do as much business logic as possible in Postgres. This leaves PHP to do little more than glue the output of Postgres to HTML templates.
Because we all abuse it, and is damn easy to make it work.
But at the end, we all feel dirty for using php.
they have tons of other metrics. To summarize PHP and Wordpress absolutely dominate the web.
Also php7 breaks most old projects
1. Bunch of up-and-forget sites on shared hosts
2. A metric ton of legacy codebases that plain don't work on PHP > 5.5
3. PHP 7 had quite a few breaking changes, like you mentioned
4. LazinessWell PHP 5.6 is unsupported aswell, but it was supported till december 2018..
End of upstream support is meaningless in a world where most servers run LTS distros of one flavor or another. I've been telling my clients that they should be able to rely on PHP 7.2 for a long, long time because it's the default version in Ubuntu 18.04 and RHEL/CentOS 8, both of which come with 10 years of support.
Heck, even with Wordpress these days you could use it as an API source and build a modern SPA website. It’s just getting over the inertia of intransigent stakeholders.
Or, a simpler definition: a webapp is any website that you can’t effectively host on your ca. 1995 ISP’s web hosting.
Many webapps where the “app” is purely in a CMS backend (e.g. most Wordpress sites) are websites. Unless they include comments, in which case they’re not. Unless those comments are JavaScript-embedded third-party (e.g. Disqus) comments, in which case they are. :)
Website: main focus is information serving, documents, designs, texts, assets, etc.
Webapp: users can create some kind of output from the service that's based on creative input.
The line is still blurry, but more narrow and contrasted.
It's currently taking #4 place in the famous framework benchmark:
This is why.
PHP scales down better than just about any other language out there since most of the rest of them have to boot up.
If you want to power some little dynamic things like blog comments you can run a custom microservice in a less awful programming language, or go with some hosted cloud option like AWS AppSync or Aurora Serverless.
We are building a Wordpress-like decentralized open source alternative to Facebook and Google.
What they're measuring isn't the number of websites that use a particular technology, but the number of websites that report they're using a technology. In the case of PHP that means expose_php is set to true in the ini file, and Apache is configured so use "ServerSignature On". Those are the defaults, and they're arguably bad defaults because gathering information about a target is Hacking 101. You definitely shouldn't be giving away version numbers unless you're really good at patching stuff on day 1.
What this survey means is that PHP gives away data about your web apps internal structure. Most other web technologies don't do this. The defaults are more sane. They're not adding x-headers to every request about what versions of which technologies the server is running.
If you dig a bit you'll see this line in the source data: "PHP is used by 79% of all the websites whose server-side programming language we know." (https://w3techs.com/technologies/overview/programming_langua... under "How to read this diagram")
tl;dr PHP server admin need to get better at security.
I do agree that exposing the version isn't a great idea.
Handy reference from the Wappalyzer browser extension for you.