The Future of PHP
medium.com
medium.com
I code mostly in node nowadays, not through choice but due to the language snobbery I encountered during the last few years. It’s a shame. I find myself far more productive in the synchronous model than trying to bend my mind backwards with closures and async issues in the node world.
Interfaces, hmm. PHP took its whole OO almost directly from Java, which is an odd thing to do given how different the typing disciplines of Java and PHP are. Python's OO system is much more in-tune with the dynamic aspect of the language.
That is absolutely not true. I didn't care about PHP at all when I didn't use it. Then I got a job where I had to use it (and the management didn't want to hear about changing it), and I started slowly disliking it. Then I got out of that job and again mostly forgot about it and curretly don't really care what happens to it.
Weird defences like yours resurge the dislike, so there seems to be some amount of lingering trauma. And of course there's the worry that the more popular PHP is, the more probable it is that I will have to face it again some day.
Yet you made an account here today for this story to tell people how you don't care and why python is better than PHP.
Are you sure you don't care?
I had a similar experience as you. I used it for a couple of projects for a 1-2 years. When I realized PHP was an overpowered template engine, I started to think that it will be dying and moved on.
I mean, I didn't coded much Ruby over the last months in professional projects, but I am still interested with its evolution because it was such a delight to use it with Rails.
Regarding PHP, well, I did some in the past, and my next professional project include to deal with a PHP code base. In the meantime, I didn't care to use it or look at how it was evolving, which is "as exciting as your toothbrush" innovations.
Also, the statement "that is absolutely not true" should probably be backed up by more than your single data point.
The more popular a language gets, the more critics it receives. Partly happens because you will see more mistakes and bad quality code which also reveals bad design decisions in the language itself.
Some languages have more quirks, especially if they are older and tend to stay backward compatible.
Scala was known as a well-designed language (I believe still is) but as the community has grown, the number of complainers also has grown at the same speed. we learned people can write horrible code with implicit conversions.
But you need those critics to detect anti-patterns, and bad APIs and hopefully either the language itself or some libraries will fix it for everyone.
The PHP hate never made sense to me in the context of the rise of Node.js:
* In PHP I've never accidentally combined 2 + 0.3 into 20.3
* I dislike the cowboy-ish over-use of ternary operators and short-circuiting by JS devs (random example from StackOverflow: var bar = data.bar !== undefined ? data.bar : 'default'; )
I appreciate that JS has functional-programming aspects that make it appealing though.
It's interesting that when PHP alternatives like Rails came around I saw a lot of anti-Java sentiment online, but now when Rails-based companies have to scale they end up using Java or JVM-based infrastructure. So trendy online sentiment shouldn't really inform best practices for various teams at various stages. (I notice that a lot of NoSQL hype seems to have died down since 2015...)
Perhaps the best commentary about why people succeed with PHP is this HN comment from a couple years ago: https://news.ycombinator.com/item?id=12704094
If you're programming in PHP, you're not running around talking about "convention over configuration" giving talks, or trying to make your code beautiful... You're incorporating feedback while the other guy is just starting to get to work. When he finally fails, he's used up half his runway, whereas you, the guy who didn't give a fuck about your code has gotten past that first failure, and are finally getting some traction.
But PHP thankfully combines `md5("PHP") + 1` into 3. Sounds legit.
I think Slack's own anecdote [1] is a better characterization of PHP nowadays. Hint: they don't disagree that PHP was (and to the lesser extent, still is) a terrible language.
[1] https://slack.engineering/taking-php-seriously-cf7a60065329
It also leads to stupid notions of thruthiness (google Gary Bernhard's WAT talk) and bad junior dev behavior. I've seen a popularish PHP framework document the return value of a function al boolean, but the actual return value was the string "0". It wasn't even a by prduct of the implementation. They just explicitly used return "0" for no good reason.
Personally I wouldn't want to use any language that does not have closure and function as a first class citizen. It makes programming fun and productive.
BTW, the 2 + 0.3 thing you are mentioning are all fixed by ES15 and ES6.
I've used PHP for about 15 years give or take, off and on. Before that I variously used Perl, ColdFusion or ASP for fairly routine Web services. Mostly I use PHP for straightforward CRUD work, for which it is very well suited. I'm currently using it for what is effectively a glorified CMS system. It's perfect for the task, I essentially never encounter something in PHP that causes me consequential problems within the lane that I'm using it. Although had they not dramatically boosted performance with the 7 releases, I might have opted for something else at this juncture.
Meaning that they broke a lot of code when they did that.
Not that it matters that much, since it often impossible to build a JS codebase that is over a year old without major refactoring.
But it's not the language it was, it's much better these days; and it was always very fast for an interpreted language.
I really cannot agree with you more that for all the hate PHP gets, javascript is a thousand times worse. I figure the major difference is the ecosystem surrounding javascript. The tools are super great and writing multi-threaded/async code is very easy.
But I say this as a person who avoids both PHP and Javascript, so I might be talking nonsense.
As much as everybody likes to hate on PHP, it powers a lot of services that are used all around the world - and a lot of internal systems.
With 7.3 it seems as though PHP has finally got to a point where it knows who it is and where it's going - don't get me wrong, it's paid my wage for the last 18 years - but it's also made it very easy to shoot myself in the foot.
With frameworks like Laravel and Symfony about now, I can only see it getting stronger.
(Although I'm moving to more Elixir and Phoenix, I still pick PHP for simple projects, or those that I can't use Elixir on - and obviously maintaining and upgrading existing things)
The number of php projects now is orders of magnitude more than cobol in it's heyday.
There are going to be plenty of php jobs for quite some time.
I've been reading a similar sentence for each version since 5.6. Is 2020 also gonna be the year of the Linux desktop?
Of course. Every year is the year of the Linux desktop! :D
- Is PHP dying in 2019? (25 Oct 2018) - Is PHP dying in 2018? (27 Apr 2018) - Will PHP die out in 2017? (24 Mar 2017) - When will PHP finally die? (13 Feb 2017)
I asked people at Metaculus (a forecasting website) "When will PHP die?". The current consensus out of 43 predictions seems to be 50% chance before Jan 2037, 75% before Feb 2051. Seems like a reasonable prediction.
If you are interested in making your own predictions: https://www.metaculus.com/questions/1691/when-will-php-die/
No, it’s not.
To me, it’s never been a better time for PHP.
I was fairly impressed with how easy it was to jump back to PHP, the documentation is full of examples, there is composer for package management and it has a strong community who meets up regularly.
My main gripe with Php is editor support. Jumping around a code base is hard when you introduce slightly abstract class loading. The more 'typed' the language is, I guess makes editor help easier, with auto completion etc. But that is a disjoint or me.
Editor support for functions is useful. I'm slightly embarassed still at the frequency of my manual lookups.
Class autoloading is nice, but functions are left by the wayside on the autoloading front, which is a bit gnarly.
The language is actually quite quick to learn, and you can hold a lot in your head. You can do a lot just with arrays and foreachs, without having to reach into convenience functions.
Most of my time is laboured over other frameworks and interoperability, rather than any really worry about Php itself.
If you are comfortable with IDEs, I strongly recommend PHPStorm. It is the one piece of software that I happily pay for each year. It increases my productivity and quality control to such degree that I wouldn't want to write PHP code without it.
> Editor support for functions is useful. I'm slightly embarassed still at the frequency of my manual lookups.
I've been writing PHP for 10 years now, and I still have to look up just about every function. I only recently discovered that PHPStorm supports displaying the PHP manual as you type, but that it is disabled by default.
At some point, I'd like to see a new major release that deprecates all of those old problems in order to clean stuff up. Even if it means breaking backwards compatibility a year or two later on.
It turns out, however, that such things aren't easy to handle. Python 2 to 3, anyone?
https://trends.google.com/trends/explore?date=all&q=python,p...
Python is on a quite strong climb, with PHP falling significantly over the years. But, it also says Javascript is on the same trajectory so that shows the real value of the data.
I feel that PHP is here to stay and future releases like 7.4 and 8 are going in the good direction. I'm pretty happy with the health of the ecosystem and how the language has improved over the last years.
JS is almost general purpose these day. Just a bit more push to optimizations on JS engines.
As long as there's legacy, PHP jobs are not going to run out for sure, that's a given. I wouldn't exactly mind carrying a project in PHP >= 7, but I wouldn't wish to get a job in PHP < 7 territory personally.
Some people are still using PHP just as a template language, but there are still issues with XSS, that one could avoid by default with dedicated template languages like Twig.
Current main selling point of PHP are great frameworks and ecosystems, easy to find developers, and share nothing architecture that removes whole class of problems related to memory leaks and scalability.
~ Batman
It is 4 time more verbose than rails and not fully compliant. Laravel is purefect for people knowing only PHP, it is a real nightmare for rubyist. ;(