by chrisweekly · 6y ago · 0 comments
- PHP doesn't deserve its bad reputation!
- Well, it used to be pretty terrible...
- Ok, so first let's talk about the relativity about the definition of "terrible". The Oxford English dictionary defines [...]
And from there it goes nowhere.
It is true that PHP improved drastically over the past decade or so, it is also true that it used to be a garbage fire of a programing language and ecosystem.
For the PHP proponents in the comments: I think you'd save you a lot of trouble if you didn't try to dismiss the history of PHP and pretend that it was just unfair criticism from haters. It was warranted. You can't win this one.
But who cares? If PHP really is good now you're way better off arguing about that, because while you'll never manage to convince me that it was a good language in 2005, you might end up convincing me (and others) to give it a try in 2020.
Being able to mix PHP and HTML code was brilliant and setting up PHP on a server was child's play compared to Java. Because state was stored in the DB and individual pages were ephemeral, we didn't have any issues with e.g. memory usage or performance. At that time I was already familiar with C, C++ and C# and I didn't find it worse to use PHP. It was a good match for the job.
Nobody should argue the utility of using php in 2005; just as nobody should argue that it wasn't also a superfund site of a language in 2005 as well.
Evaluating a language without judging what kind of projects it enables is nonsensical and leads to pointless language ivory tower discussions. I'm sure that also back then there were all sorts of awesome programming languages that nobody was using, but checked all the boxes that would make the average HN language enthusiast happy.
I think a lot of the misunderstanding around PHP's past stems from its accessibility. But real software developers had no problems creating real software with it even then, and since then the ecosystem has become startlingly better.
> …you might end up convincing me (and others) to give it a try in 2020.
It's been in the TIBOE top 10 since it's debut in 2001. If you haven't tried it by now, it seems unlikely you ever will (and that's absolutely fine).
PHP would have been abandoned years ago if not for Wordpress' worse is better success story.
"Fine" (as in "adequate") is not a high bar, and so is easily defensible. I get that it's fun to say that PHP was "stupid", but history shows that PHP's historic imperfections didn't prevent developers from building everything from web-scale apps (Facebook, Wikipedia, Flickr, Tumbler, etc.) to, yes, millions of blogs.
(Don't get me wrong, your favorite language seems nice too.)
However, after a couple of trials with other stacks, I ended up going with PHP, it does the job, was already on the ISP without me having the hassle of being a special snowflake, I was anyway the only one coding it and now get to enjoy a JIT compiler that Python and Ruby communities are still not fully embracing on their reference implementations.
And although I do mostly Java/.NET Web related projects, I do occasional PHP projects, because after I am done, I am sure that the customer is going to have an easy time finding someone else to take care of their issues, as I don't want to make a living out of it.
When PHP was first released it was dramatically better than the alternatives for it's intended purpose.
There were plenty of things to complain about, but none of them stopped you from doing useful things with it. It was never slow or inefficient compared to other scripting languages, it didn't lack functionality.
Over the decades the most popular complaints have been addressed as the language has matured.
That it's remained in active development for 25 years with no signs of that changing in the future is one of it's biggest selling points.
I don't blame people for having issues with aspects of PHP based on their personal preferences and experiences, I get that, but that doesn't make it a 'bad' language.
There's nothing wrong with purist perspectives on what programming languages should be and how they should work. That contributes to better design.
But in the real world the questions are simpler: can this tool be used to develop applications quickly? Is it reasonably efficient at runtime (in this case in the context of scripting)? Can we easily find affordable developers in the future? Is there community support?
PHP checks the boxes that people building things want checked as well as any language and better than many. Unless I'm missing something, 'bad' here is more of a philosophical stance.
“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”
The C++ Programming Language
https://www.goodreads.com/quotes/226225-there-are-only-two-k...
This was PHP 5 and it sent me running for the hills (Python, ES6). I am sure PHP 8 is an improvement and I’ve worked with PHP versions past 5.3 but it left such a bad taste in my mouth that yes I will avoid it if I can. Fixing what shouldn’t have been broken may make this language almost as good as something like Python but why would I reach for PHP when better things exist unless that decision is not made by me?
Having just started with programming, this is more feature than bug. It’s super easy to reason about PHP applications because the whole flow is linear from top to bottom.
<?php $MY_SOCKET_TIMEOUT = 5;
And file b.php has: <?php require(‘a.php’); $MY_SOCKET_TIMEOUT = 10;
That’s a problem. Same with every function and class name. Oh and requiring/including a file is not idempotent because it’s just string concatenation because they are not modules. None of that should be a part of a modern language. If they haven’t fixed that in PHP 8, then it’s still broken.I think that's going to depend to some degree on how you define that purpose. If it centers around having a low barrier to entry, then that's partly true, but some of the ways it achieved that involved making code written in it vulnerable to variable poisoning and SQL injection by default.
I've checked and feel misguided. "Fractal of bad design" is still applicable
strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] ) : mixed
It is not possible to use language without documentation, should name include underscore? Where to put string? I've switched to ruby, it is predictable.Mixed baggage of C, Perl, Java influences, no design. PHP 4 had design, PHP 5 made it total mess.
Borne shell good in gluing UNIX tools, AWK good in simple columnar data, PHP good in one page scripts.
You've described PHP as "useful" language.
My comment linked to a comprehensive answer to that question.
At some point — and boy, are we long past that point — it feels old when gramps goes off about the woes of PHP4 because, oh, it feels like it's just been yesterday.
Anecdotally speaking, the vast majority of PHP projects I've been exposed to have been horrific precisely because there's a laissez-faire or "get the job done at any cost" attitude to software development that's uniquely prevelant in these communities (this exists in all languages, but in my experience it's way worse and way more normalized within the PHP silo). The language improving will only be positive for new projects that are started today, or that have been maintained by dilligent and empathetic engineers. Often teams are not as united on this front as they should be.
I think using almost any other comparable language in 2020 (Python 3, Go, Typescript) is a better solution than starting a new project in PHP these days. I suspect the real reason many still reach for PHP first is because it is "easy" and PHP developers are ostensibly cheap and easy to replace. It's a false economy.
Most people talling about legacy php mean php5, which is much more sane than php4
I think just because something was bad before yesterday does not mean it cannot be used in good ways today or tomorrow. And I think everybody talking bad about PHP should not even think about JavaScript.
Todays PHP gets its job done in a really good way. It has very good frameworks, is amazingly fast and is easy to start with and quite easy to deploy. And it‘s absolutely not comparable to something that was many years ago. And I think too, PHP before something after PHP 5.5 was not „that good“ compared to C# or Java.
Javascript too, so what? In the end it's another tool with specific pros and benefits, and it got many things right (ease of deployment, no shared state, batteries included, etc).
I’d be interested in learning more about php’s evolution, and possibly even a follow-up to that article.
I also started with JavaScript a long time back, maybe something like 1998-1999. I've always found it a most loathsome language, and the anaemic standard library a huge barrier. It's not entirely the language's fault, of course - being the language of the web was always going to mean glacial progress. Recently I worked on a vanilla ES6 project (since browser support is finally there), and at long last I wouldn't quite describe it as "loathsome" anymore! Still, it's a far cry from the nicities of Typescript, and the tiny standard library remains an issue.
Having seen both PHP and JavaScript evolve over around 2 decades, I'd probably argue that PHP has evolved more as a language than JavaScript has.
If you want PHP, you install php, and you’re done.
What exactly was so bad in PHP that you couldn't also ignore?
PHP is 26 years old. PHP5.3 is 11 years old. PHP7.0 is 5 years old.
Where is your cut-off that make you claim "most of its existence"?
What other tech compared to PHP at the time?
If you know what you’re doing I don’t see any reason to not pick PHP.
This sentence really got me thinking. "Deserved" is some sort of moralistic word, I'm not sure how it applies to a tool, unless it means to apply to the makers and/or users of the tool.
And I guess it makes some sense. A bad reputation is a sort of social communication utilizing shame and stigma. Maybe it causes people not to use PHP without having to pay the cost of really understanding why, which is likely only accessible with lots of experience and/or study.
This is basically by definition an inaccurate bias, of lacking nuance, but perhaps a net good. If PHP was such a poor tool for productivity and security then it was probably good if shame and stigma were helping people to use better tools without paying the cost themselves first.
But it's always very frustrating if you actually know what's bad and what's good about a thing, or even just know that it has both bad and good parts (even if you don't know precisely which is which), and you see a memetic belief held up as truth rather than acknowledged as a useful heuristic.
And while it feels dirty, maybe this shame and stigma also serves to influence the creators of the language and its ecosystem to make it better. I don't know. I hope there are better ways than shame and stigma but I'm just a d00d writing a post on a web forum.
What does seem clear to me, though, is if is a good tool NOW, as a result of years of work by the people who kept at it, then a bad reputation is no good anymore; no longer a positive force but a negative one.
JavaScript has bad parts and design (and big community that claims it is fine language), Perl has great design and small community (and everyone can bash it), PHP has horrible design flows and a big community that does not address issues from "Fractal of bad design" but claims language is fixed.
As experienced developer I know what good design is. This article saved a lot of novices from trapping into badly designed language as a first one.
At least some PHP proponents makes fools of themselves:
> This of course is coming, like usual, from someone who spent a significant portion of their life in academia and then moved to R&D and still has yet to make a dent in the world, or likely their student loans [1].
Words of true believer. PHP can't transition to not bad language because of such believers. Those who can see faults left. And what's left is echo chamber. There would be no break of backward compatibility. I've checked, from design perspective nothing changed.
All I see is community discarding critique without addressing it or even understanding it.
What you're getting at is that people can be influenced by factors other than objective truths. I admit that I am someone who tries to avoid making decisions based on word-of-mouth or "reputation," but you can't deny that only considering objective truths takes a lot of work.
Sometimes I just want to buy a keyboard, not read and apply "The 50 Tenets of Keyboard Comparison" to find the objectively best (for me) keyboard.
It makes sense how this attitude can bleed into decision-making as a whole, even for higher-impact decisions like programming language choice. So I wouldn't discredit (or lower the reputation of ;) ) too much the folks who don't always go by objective truth.
I mean, people often say the same thing about C, C++ and Java. But these are also massively popular languages, so obviously they're doing _something_ right and the people complaining must be looking at the wrong metrics.
Don’t you think referencing something 8 years out of date, from when PHP 8 was PHP 5 may be a bit out of date?