247 points · by mg · 6y ago · 262 comments
Firstly, PHP has always been around, WordPress based websites still have like 1/3 share of all existing websites.
Secondly, in the recent years it got a very mature language, got loads of improvements and performance optimizations. With PHP 8 being planned to be released by the end of this year, it will be another major step forward.
Thirdly, Laravel, Symfony and other open source stuff are awesome.
I think if PHP does a major comeback as a decent platform for development and somehow gets rid of the undeserved reputation, those PHP devs who stayed with PHP and didn't switch to RoR, Django, Node or other platforms will be winners, including me :)
- 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.
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).
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?
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.
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.
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"?
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?
That reputation is a competitive edge for companies and people who embrace PHP. They get shit done for the business and grow revenue while the rest of the tech community is rewriting basic tooling for the 50th time in Rust on a Kubernetes-powered back-end with a React front-end powered by a GraphQL API layer.
To make things worse, this cannot easily be fixed because the implementation is a hodge-podge of ideas and functions. You cannot find good architecture people who want to work in PHP to clean it. It cannot easily be re-architected because it captures a lot of business wisdom. And business people (rightly) suspect pitches for a new built-from-scratch solution: sure, it will be fast and maybe it will be reliable; but will it solve their problem? will employees need to be re-trained? etc.
It reads like you're talking about a specific project and trying to generalize?
The “framework du jour” and the set of best practices have changed way more often in PHP than in any other language, perhaps as much as, or more than Javascript.
That has not been my experience. When I used to work with that tech stack, the major framework choice only ever had 3 options:
Zend Framework, Symfony and Laravel.
From what I hear Laravel is the industry leading and there's no sign of that changing.
Sure there are other less popular frameworks just like in other languages.
> The “framework du jour” and the set of best practices have changed way more often in PHP than in any other language, perhaps as much as, or more than Javascript.
PHP have had a published standard specification for framework and component interoperability for long time now:
huh? that sounds like a contradiction in terms.
*We didn't re-run benchmarks after fixing edge cases
I'm going to assume it's a decent modern language now, but what's the argument for using it instead of another mature dynamic language like Ruby or Python?
Thirdly of course the shared hosting providers (by what I've seen in the past) usually support PHP almost always - this is not the case for either Ruby or Python.
> There's no consideration of what we call technical correctness, only business value, and on the whole that is a good thing.
That's called technical debt. Taking some on may not always be a bad decision, but if there's a short-term gain (and I'm skeptical PHP provides one), it may come at a cost of future development slowdowns, downtime, a full rewrite, or a data breach.
A massive body of existing code that you can leverage.
I keep putting off picking up PHP, but when you look at the number of off-the-shelf easily-extensible solutions for CMSs, CRMs, and e-commerce platforms, there's no contest. PHP wins.
If anyone can point me at a Python e-commerce solution that will let you deliver an MVP in an afternoon, and your first original feature within a week, that would make my month.
The other advantage over ruby (python too?) is the server models bootstrap and trash everything on each request, meaning way less weird memory issues and more predictable behavior.
Nowadays nobody’s gonna run a php server ad hoc, so it will be wrapped in a container anyway, but IMO it’s still easier to manage than ruby/puma.
Last but not least, it’s very subjective but I think php has better enterprisy trade-offs than ruby: you’re not free to rewrite the whole language but have a decent degree of freedom in writing code with few boilerplate. Ruby gives way more freedom which is not always an advantage depending on the work culture.
I say that having left php for ruby.
I think PHPs biggest feather in its cap is Composer.
I can't even line a single script without it now. It really changed the usefulness of the language for me by many times.
I love the patches package that can be combined with it, allows me to patch contrib modules or Drupal core in a controlled and transparent manner. This alone has changed my developer life.
There are people who use all that stuff to deploy PHP-based apps too, though. One doesn't preclude the other.
I can't do that with a node app by default without restarting it, killing all connections, etc.
The biggest surprise was that on Linux one cannot call an external process directly. At least with PHP 7.0 one always has to use an intermediate shell and one has to use extra functions to escape strings safely.
So yes, PHP works, but defaults are insane and to make things secure and robust one has to use extra libraries.
I don't normally do a 'ha ha' sort of post on things like this but... 'ha ha'. WTF?
That's a future with one hell of a long past that has not even begun to take over a small subset of mindshare. Python/Django is not 'the future' for anyone except current Django/Python devs.
Most people talk about PHP the language but not its surrounding ecosystem. Yes The language run time went through lots of improvement, proper JIT landing in PHP8. But That is like talking about Ruby on Web Development without talking about Rails. ( Like it or not Rails easily represent 80%+ of Ruby's Web usage )
Laravel took everything that is good on Rails and its surrounding Ecosystem, ( Auth, SearchKick etc ) and packed it together. And the productivity I saw from those using it as a whole were amazing.
There are also a lot less ideology with Laravel. And try to provide decent usage in all usage scenario. Compare to Rails which is more of an DHH / Basecamp's framework.
I mean if Elixir and Phoenix LiveView dont pick up some mainstream usage I did imagine PHP with LiveWire will be making a come back.
I sometimes wonder if anyone had made something like CooffeScript, or Scala or some other language that runs on PHP run time with some sane syntax ( Excluding Hack )
Php allowed my team to move amazingly fast and deliver what the business needed very quickly. In e-commerce and dealing with Amazon specificity, rules and methods change monthly and you always have to be able to quickly pivot to remain competitive and I think php was a big factor in allowing this to happen.
Now... this was naive ASP - all the session state was kept in memory. There probably would have been a way to not do that, but no one where I worked knew how to do that (or even thought in those terms - it was just "set a sticky bit on the load balancer!".
The PHP code was slower than the ASP, but because the session state all went to disk, the memory usage never got too high. We still ended up using the sticky bit on the load balancer, but there was far less concurrent memory usage (IIRC servers had either 256m or 512m). We could serve more - slightly more slowly - via PHP.
The upside was that it was a known user-based - contractor/dealers buying from the company - so we didn't have to deal with "well, we might get 40,000 browsing visitors tomorrow because of a TV ad". The user base didn't fluctuate wildly, so it was easier to manage against.
By comparison, in the same company, another team of people were working on a Java web app. It would often take them 15-20 minutes to recompile/redeploy something to a test server to try out an idea to get feedback on something, whereas with the PHP, I could put code on a test server for feedback in a few seconds. (could usually do that with the ASP too). Yes, no doubt, the Java people were "doing something wrong" and someone can say they'd have known how to do it "right" in the year 2000, but... it was what it was.
It has no compile time, the development cycle is crazy fast, the stdlib is good for the web, every problem is solved so they’re all googleable, it has a good package manager now, great frameworks, good testing stuff, there’s a lot of positives atm
And because you don't need build tools you can deploy it as easily years later.
Also while developing you can just hit F5 or rerun a PHP script in your console compared to waiting for a build.
Note: I am not saying they should use C# and Java - just that they do. I was a Python dev for 15 years before doing this, and I was very surprised to see how dominant those still are in companies over 10 years old and over $10M in revenue. And the bigger the company, the more likely it is be on C# or Java. I think every one I've seen going for north of $100M was at at least mostly on them (i.e. they might have a few services in Go or Node or something too, or some model engine in a niche language). Once a company is into the land of bankers selling it to other bankers, a lot of decisions get made for "safe" reasons, like ease of hiring good developers, enterprise infrastructure support, well audited security, and so on. And from the perspective of the investment firms, that frankly makes a lot of sense. By the numbers, most successful tech companies are not particularly exciting places to work anymore.
If the F in FAANG doesn't qualify, then I don't know what does.
At Gnod, we are heavily invested in PHP. And it continues to look like that was a good choice.
What I would like to see discussed more is PHP's decision of not having an import system but to instead use a "namespace" directive in included files. This puts the burden of avoiding name conflicts on the included file rather then on the including file. While in Python and Javascript it is the other way round. Which in my experience makes things more logical and requires less tooling for an enjoyable coding experience.
However, C has the a similar convention [2] (though the convention is — as far as I’m aware — for the sake of maintainability/readability as the compiler has no problem telling the difference between to things named the same, the person reading it probably will. While, as I understand it, PHP will just overwrite anything with the same name in the file/lib you include).
It seems like PHP is heading in the right direction, but I have no idea why anyone would pick it up or start anything new with it these days, I don’t care how well done and the nice and new stuff is, it’s the decade of utter mess it’s built on top of that has uninterested me. Don’t get me wrong, since “acquiring” the Wordpress sites I’ve gone from a blind PHP hater, to at least understanding/appreciating it (but still won’t actually touch it with a 10ft pole). PHP is brain dead easy to deploy and scale up, compared to ruby/python/node (which aren’t _that_ difficult to deploy), PHP is basically the web equivalent of a static binary, in that you can just drop in and it’s basically ready to go. PHP also actually really fast, it’s seriously impressive how fast it can render WP pages especially when you consider the absolute spaghetti/thrown together/clusterfuck code it’s running — Wordpress itself is pretty yikes from the code I’ve seen, but the plugins, Christ, the 50 million sloppy buggy poorly coded plugins — PHP can absolutely run laps around other a decently coded site in other languages (at the cost of having to use PHP I guess ).
If you write a class "Http" you might start your file Http.php with
namespace Buttons840;
class Http {
...
So a file that includes your Http.php can instantiate the class via $myHttp = new Buttons804\Http(); use My\Full\Classname as Another;
https://www.php.net/manual/en/language.namespaces.importing....Would I build something new with PHP? Now, I wouldn't. It is not that bad as a language to hack on Wordpress or small websites with Laravel but beside that, it is hard not to choose JVM or Node as platforms for your future projects.
Maybe a PHP implementation built on GraalVM will enable PHP to call into JVM libraries. GC and other things will be provided for free, though I think it will be some work since the majority of PHP is native code and its syntax is quite messy.
Since you mentioned GraalVM, I'm also pretty excited about the Graal nodejs runtime. I'm a fan of using JS/TS for quick projects, and unifying the runtime would be huge, I hope it will continue to be supported.
> 2020 was a good year to be an entry-level candidate for technology jobs
Not sure what's others' experience here, but from what I hear in various markets (mostly within EU) is that fresh grads generally struggle this year, no matter the technology.
Companies put hiring on hold and if they resume it's primarily for more critical roles (read: senior positions); it's harder to get a job or even internship as a junior developer.
Am I in some kind of negative bubble?
The problem is the runtime of the language, on which PHP, the language, runs. That could be easily improved on porting the language to a VM like Facebook did with Hack or to something like GraalVM. Runtimes over languages.
PHP is a language among many languages which can be used on the backend. JS, Java, C#, Python, Ruby, Elixir,hell even Perl has a web framework. Not really a fair comparison.
I wouldn’t be surprised if there was a shift in job listing behavior that caused a sudden influx of php job listings on indeed. So it isn’t as if the jobs didn’t exist before, they just weren’t posted on Indeed.
The salaries discussed (77k) doesn’t suggest that a surge in demand is pushing up pay.
(And I am not the only one, I know lots of people which switched from PHP to other languages)
That's probably the reason for a pay rise - many developers switched from PHP to other languages and now companies which still use PHP have to pay more for the few PHP developer
The largest problem with PHP is how objects use arrow notation, arrays use arrow notation, strings use dot concatenation, and variables use dollar notation. Then I switch to JS or Java and it's all different.
As far as the stack for FPM and process managers, I think it works well, but I do enjoy the elegance of Node's event-driven environment.
I think those are PHP's smallest problems. Semantics more important than syntax.
Programming languages that everyone hates and programming languages that no one uses.
C++ - too complex/brittle, template hell which can't be solved on any practical timescale
Javascript - stuck at the dead end of the async branch which we later learned was an evolutionary dead end, can only approximate functional programming but at its core is brittle and impossible to future-proof
Ruby - too opinionated, solves the easiest problems with syntactic sugar but doesn't touch the real conceptual challenges of imperative programming in any meaningful fashion
C# - too much like Java, inherits all of the flaws around null for example
Java - solves the programming problems of the 90s that we later learned were better solved by JIT compilers, immutable data and such, it's biggest flaw being that it's object-driven instead of function-driven
Rust - the highest expression of imperative programming, whose problems are better solved via immutable, declarative, data-driven and functional programming using copy-on-write
Python - killed by the version 2 to 3 transition, unfortunately never really found clarity around string handling, cute at first sight but painful to use beyond a certain level of complexity or code size
Perl - perhaps the most adventurous language in the 90s for blurring the lines between all programming paradigms, but succumbed to not having a single source of truth in its style or conventions (I want to love it as much as PHP, but it's write-only nature will forever limit it)
Lisp - best language conceptually but unfortunately write-only because it clings to old ideas like abbreviations and byzantine academic abstractions that we've now learned are anti-patterns (the assembly language of functional programming)
This list grows forever, with each new language having a very specific/acute kind of shortcoming which profoundly limits some use case. Which is why I'm especially fond of PHP not trying to be the best at anything. It's the only language I know of that is one conceptual step away from all the others. We can tell C++ or Javascript programmers that PHP is the same but with a $ in front of variables for string interpolation. Shell scripters recognize everything it does immediately.
Now PHP does have a lot of problems, the largest being that it's starting to succumb to design by committee and cargo culting. I have not been especially happy with the direction it's gone since PHP 5 and classes. There are some small wins like ternary "?:", but for each of those, there are major flaws like "\" in namespaces. Great shame has befallen PHP at times. But I know of no other language as forgiving, or that tends to "just work" in a REPL, or that has such a vast system library built in. I often find myself thinking in PHP and then having to translate whatever crappy language or framework I happen to be using that day.
As far as the future goes, I would very much like to see PHP incorporate some of the newer declarative and data-driven methodologies that have sprung from languages like MATLAB and Julia over the last 10-20 years. I'm not especially happy with TensorFlow because the forest of elegance is lost in the trees of byzantine concepts like with Lisp. But I really think that if PHP skipped over SIMD and went straight to MIMD with with some kind of simple, easy to understand vector handling that didn't break convention, and could be executed synchronously in parallel across many cores, it would really have something. I think this could combine many of the advantages of how Python is being used for data-driven research, without the friction that Python introduces. I could see something like this eventually replacing React/JSX if it also got browser support.
Writing this out is kind of hilarious and you can laugh if you want to. I agree that PHP is nowhere near ideal. But I know exactly what I need to get real work done on a daily basis, and PHP is the only language (by a wide margin) that even comes close to giving me the leverage I need across many disciplines of computer science.
Where CAD = computer aided dispatch, not computer aided design.
I have a hunch whatever code they used create this wasn’t vetted too closely and therefore this should not be trusted.
fta: "The national average salary for this role is $144,752 and job listings for these roles have grown 278% over the past year."
The projects I get directly are of much higher quality that the public offers, but I also ask myself how much such numbers reflect reality. I mean the dark figures could be totally different.
I would avoid Jobs maintaining legacy PHP 5 or earlier like the plague.
The main migration argument I see is usually along the lines of "50% of all COBOL progammers today will be DEAD by 2025!"
Rather than about technical/financial merit (anyone willing to migrate on those grounds, and believed it was even possible for their infra, will have already done so)
Please, let's move on, it is really time to move on :)
It's even more suspicious when there are multiple non-niche categories with near 1000% or more of change.
But then, if this happens at some time, this year is the best candidate. I'm personally hold any conclusion for when I see independent confirmation.
Anyone can create a program with it, cheaply and easily. You end up with a lot of terrible code this way.
And as the years went on, the products matured into something decent that you COULD write recent code in, but it usually didn’t happen.
It’s a good sign that a project will be a terrible mess if it’s in PHP or VB, but a delightful surprise when it isn’t.