It is one of the best choices (if not the best choice) for rapid prototyping of a program. Its damn fast to similar alternatives (Python, Ruby, Dart, JavaScript), and the standard library is huge.
It does have footguns. I am not a fan of the loose typing, but you can take some steps to mitigate. You can do "===", "strict_types" and type hinting for function input and output. It is similar to C in that the language itself doesnt really do much to stop you from writing bad code. Also the function naming is not consistent, and even function arguments are not consistent. However PHP 8 will help with that somewhat, as you can now do named arguments.
Also PHP has the best language documentation I have ever seen. I would prefer more examples, but its well above some other languages.
I'm with you on everything but the docs. More than once I've had to dive into the source when the docs tell me one thing but the behaviour in some edge case is different. PHP's docs are extensive, but not nearly as reliable as they should be. And don't get me started on the comments.
Regarding "best language documentation", wait until you meet Elixir. Used to do PHP before transitioning to Elixir. Elixir & community have basically taken documentation to a new level.
Other than that, PHP is rock solid when it comes to web stuff.
PHP, since version 7.0, has been a much improved language since when many people started hating on it. They have been consistently moving the spec forward and making improvements. It's not perfect, but no language really is after all. It is really nice just seeing issues that have been around for a long time being addressed and fixed.
I have to confess that I have a lot of prejudice against PHP after having to work with it at the time of PHP3 and 4. It seemed like even worse than Perl in the sense of how many things were just bolted on it as a way that the developers could claim "yeah, you can do that with PHP". After having a blog running wordpress hacked twice by mere virtue of being online, I dismissed it for good.
I keep hearing about how the language has improved, but to me it feels like even if the language gets rid of all its heaps of crap, it still is in a evolutionary dead-end. Is there anything that PHP is developing or adopting that can not be had at other established languages?
(Edit: I never had something downvoted so fast before. This is not concern trolling. I seriously would like to know if it makes sense for a non-PHP developer to look into it)
Most of the people who shit on PHP have a lot of love for other languages. A survey of the cryptography features the "favored" languages offer will almost certainly fall into two camps:
1. "We wrap OpenSSL"
2. "Go compile it yourself" (i.e. there is nothing baked in)
There's a lot of badness with OpenSSL's API design, especially with asymmetric cryptography. For a fun exercise in these languages, try encrypting with RSA with OAEP padding, but without using SHA1 as your hash function.
For completeness, PHP is one of the languages that wraps OpenSSL too! But it also wraps libsodium, and the community has been moving towards libsodium (unless they need something from OpenSSL for the sake of backwards compatibility) since early in the 7.x series.
If you're going to provide cryptography features in your language, but you aren't shipping modern cryptography in your standard library, you're underperforming what PHP has offered for years at this point. The easiest way to meet the standard that PHP 7.2+ establishes is to add libsodium to your language's standard library.
(There are salient arguments for "why even provide a cryptography feature as part of the language at all?" but most of the languages that see real world deployment are already doing that.)
> after having to work with it at the time of PHP3 and 4
PHP 5 was released 16 years ago and was a massive evolution of the language. The same is true for PHP 5.2, 5.3, and 7. It's safe to say that your conclusions about the language are no longer accurate.
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
No. I can't think of any reason to start a new project with PHP today. All of its best features are things that have been available in other languages for years. It's also not particularly popular outside of WordPress.
WordPress accounts for approximately 60% of all websites, PHP accounts for approximately 79% (knows server side sites). So I would say it is particularity popular.
I'd like to know more about that 79% number. I would guess it's actually the case that PHP backends identify themselves as PHP far more than backends in other language x identify themselves.
That doesn't make sense. If you test 100 sites and 79 come back as PHP you can't just claim that the 21 responses that came back blank somehow is a bigger number than 79.
Laravel is decently popular, has the most *s on github for a backend framework I believe (or it did at one point in time) and in a number of Fortune 100 companies.
May not be as popular as React/Flask backends, but it ain't nothing.
They said today. Those sites were not started today. Furthermore, Facebook literally invented a new language because PHP wasn't good enough. PHP has since adopted some of the features of that language.
I don't know how can you blame the hacking of your website on the language rather than your admin skills, there infinite number of websites built in PHP and never got hacked!
> infinite number of websites built in PHP and never got hacked!
If I look at the logs of my webservers and scan for bots trying to exploit some vulnerability, I would guess that 80%+ of the URLs would indicate a PHP-based webapp. So, yeah, there are many that never got hacked but there are certainly a good amount of PHP apps that have some vulnerability. Should we blame all the developers who were "doing it wrong" or should we at least make sure that the language is not facilitating such shots-in-their-feet?
Well, php is thought to power something like 80-90% of websites. So you are seeing either the same or disproportionately fewer php sites than you should if php were in fact less secure.
But php has been around on the web for a long time as well, so there are a lot of unpatched softwares out there like WordPress.
Probably near 99% of those compromised servers run on Linux, so by your logic, Linux is much more secure than windows servers, right?
> So you are seeing either the same or disproportionately fewer php sites than you should if php were in fact less secure.
You'd have to assume that there is an uniform distribution of vulnerabilities and exploits through the whole set of languages used for web development for that to hold. You are begging the question.
> 99% of those compromised servers run on Linux
If the exploits manage to give the attacker root access to the OS, then yes it would be the problem of the OS. But the attack is to get access to the application. So the issue is at the application, not at the OS. You can argue that this is not the fault of the language, though. However given that a whole lot of the PHP defenders here are using "it is the easiest one to deploy" argument, one has to wonder if a platform that makes it so easy to deploy apps should also be held up for the issue of insecure apps based on it.
Considering the number of vulnerabilities frequently found in Wordpress and its popular plugins, rglullis' admin skills would not be the first thing I'd personally put the blame onto.
By the way you phrase that question, you're dismissing that single key feature that PHP _already has_ that cannot be had at other established languages.
I know of no other language that lets you deploy a web app by dragging some files from the left to the right in FileZilla. No setup, No vendor lock in, no nothing. It just works.
Cross-cloud serverless frameworks that wrap AWS lambda + competitors get you somewhat close in other languages, but you still have a lot more setup to go through, and lot fewer hosting providers to choose from.
PHP's deployment and execution models really set it apart.
You cannot deploy a PHP app by just plopping a file on an unconfigured server.
Deployment is not that simple.
Or, if it is, then you have to allow me the same grace of just being able to plop my Go or Rust binary on that server and have it magically work. It might even work BETTER because I don't need to check if my php.ini matches my dev machine.
Right, but isn't precisely this "drag from left to right and get a website running" that leads to an endless stream of sites that get hacked because the developer was careless/ignorant enough to leave admin.php with executable permissions?
It's not "just" the language. It's also a matter of what the improvements bring in for possibilities of new developers and mindshare.
Python as a language hasn't changed much, but it made huge strides into the scientific community and got a lot of marketshare from ecosystems like R and Matlab. It's becoming king in the ML/AI side. Go is growing in the backend systems/devops stuff that used to be the realm of Python. Rust is getting more and more adoption as a systems language and focus on safety. Even Java seems to be adopting things that make it less bureaucratic while being general enough for the enterprise.
I am not saying that PHP has to go away or anything. It's just that I wished that new releases could have more interesting things to say besides "it's not as crappy as it used to be".
> It's just that I wished that new releases could have more interesting things to say besides "it's not as crappy as it used to be".
I don't think there are many people in PHP's orbit who want it to be a better Python, or a better Perl/Ruby/JavaScript.
PHP was written to be a good language for average web development, and I think that's where it will always shine. I'm perfectly happy with a gradual process of making it less crappy.
Having said that, I'd love some of Hack's features (e.g. reified generics, proper list/dict primitives) to make it into PHP.
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
IMO, no. The language is still near the bottom for both dynamic and "static" typed languages. HOWEVER, if you're doing web backend stuff, Laravel and Symfony are both really solid frameworks.
The direction PHP Is moving in right now is to emulate Java 7, but without generics or concurrency. It's definitely a dead-end unless they come up with something pretty novel and change direction (again).
> IMO, no. The language is still near the bottom for both dynamic and "static" typed languages.
Why do you say that? It's faster than Python and Ruby for most cases, still extremely simple to deploy, the package manager (Composer) is very predictable and easy to deal with compared to Pip or Rubygems, the documentation is good, etc.
It has clean lambda functions that you can pass around easily and has for more than a decade. Type hinting has been in place for a long time, too, as have enough OOP / reflection constructs to do just about anything you'd reasonably want to do in a language aimed primarily for web development.
The only downside of PHP that I can still point to is that it's sometimes hard to remember the function parameter order for some of the common string and array functions. Far from a dealbreaker, that.
I don't agree with the faster and extremely simple to deploy points, at all. Both objections have to do with php-fpm.
it spawns a new php interpreter for every request, which means for example that symfony framework setup (routes, controllers, service dependencies...) have to run before every request. Sure it does that faster than python, but python only needs to do this once.
deployment is my personal nightmare. try to set the max children or whatever so concurrency is ok but memory does not run out. I mean facebook did it so it has to be possible but damn, that was hard to get `right`. Setting up logging is a mess. There is the application, the admin and the fpm error log, I gave up trying to have every log event logged exactly once. Segfaults are a common occurrence, still. I heard it mentioned just before leaving for vacation.
To be fair the last time I seriously worked with PHP was back when mod_php was still cool. I was able to serve thousands of users on a dual-core Xeon box ~15 years ago - I can only imagine the performance is better in many ways now.
As a statically typed language, I feel like it doesn't even take much to explain why it's actually the worst, except for C. But at least C is necessary in some domains.
The type system is weaker than Java, which is a low bar.
It has no generics, which means no real containers, no generic functions without dropping all typing, no type-hinted arrays.
Arrays are also not objects, so they don't conform to any interfaces, which is related to the "no real containers" issue.
It took until version 7.4 to actually have covariance and contravariance! Before that it didn't even implement inheritance correctly!
You can't typehint for function-as-param beyond just writing `callable`. So if you want to use those nice lambdas and still be statically typed, you're SOL.
It's definitely fast for a scripting language! So, that's fair. But it's still way slower than many other good backend languages: Java and other JVM languages: Kotlin, Scala, maybe Clojure?, Go, Rust if you're feeling frisky.
I've never used Ruby and I'm generally biased against dynamically typed languages, so that's the background for my assessment. The dynamic languages I've used in anger are Python, JavaScript, Elixir, and Clojure.
The package manager is better than the disaster that Python was the last time I used it. Agreed. It's also better than NPM, but not enough to matter most of the time. It's not better than Hex or Lein. Also, managing packages is a) not the language, which is what I criticized, and b) not where you spend most, or even a large part, of your dev time.
Looking at PHP as a dynamic language, I'd say that the built-in array is still a huge disappointment and the API sucks compared to either of Python's dict or list. It's much cleaner in JavaScript, Clojure, Elixir, and Python to define and operate on new, untyped, objects.
Also, for a dynamic language, I'd at least want SOME benefit to it being dynamic. For JS, Clojure, Elixir, and Python, the REPLs are great. The PHP REPL is... primitive.
None of the things you mentioned in PHP are actually better than any other language I've used except for the package manager. Its lambdas are not even better than any of the languages I've listed. In 2020, decent lambda syntax is table-stakes.
> It has no generics, which means no real containers, no generic functions without dropping all typing, no type-hinted arrays.
These things are a little advanced for the likes of me. Any chance you'd be so kind as to give me an example of something I can't easily do because of not having this?
> It's definitely fast for a scripting language! So, that's fair. But it's still way slower than many other good backend languages
But those languages require compilation and deploy cycles that are way longer than just getting files on disk, so the total cycle time of development may end up being longer in many cases. It's a tradeoff. PHP probably shouldn't be used for performance-critical things, sure, but then neither should any other dynamic language.
Hardly. PHP-FPM is a confusing mess to set up, and you're still stuck working around the massive mistake of binding routing to the file system.
And I hope you don't try to just rsync up your changes afterwards without some form of blue/green deployments.
> the documentation is good
There is.. a lot of it, for better or worse. Let's compare the functions for concatenating lists between PHP[0] and Scala[1]. The PHP version is way longer and contains several examples.. that are only needed in the first place because the PHP's array type is so messy and tries to fill so many different uses. Meanwhile, Scala's gets to the point, describes how to use it, and uses the rest of the screen estate to help me navigate to anything else that might be relevant.
> It has clean lambda functions that you can pass around easily and has for more than a decade.
Looks like they did finally clean up their baffling closure binding syntax in 7.4... unless you want to bind anything by reference.
That said, it is pretty hilarious to me that they decided to make strings and arrays of strings callable rather than add some kind of first-class function reference syntax. Surely that won't have any confusing interactions with namespaces...
> Type hinting has been in place for a long time
Not of much use without generics. `array` isn't a particularly useful type. There does seem to exist an RFC[2], but it looks dead in the water (no voting table, and the stated vote goal was years ago).
> The only downside of PHP that I can still point to is that it's sometimes hard to remember the function parameter order for some of the common string and array functions.
It's not really PHP's fault itself, but Laravel is a miserable mess of implicit magic. The fact that people often seem to hold it up as the gold standard of PHP doesn't exactly inspire confidence in the community.
> Not of much use without generics. `array` isn't a particularly useful type.
No, but you can do function foo(SomeClass $x) {...} - doesn't that fulfill the use case for most people? Objects are basically fat types, in a sense, no? And since the OOP hierarchy is respected, I can use interfaces or abstract classes here and get basically what I want...?
My favorite thing about PHP is the documentation! The comments often have exactly the example I need to do whatever simple thing I'm trying to accomplish.
True, but I doubt I want to use that on a simple string function. I'd actually much prefer to see the introduction of methods on strings ala Ruby and most other natively-OOP languages rather than calling the C-style functions with the strings as a parameter, but hey, it is what it is.
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
I think for the vast majority of projects, this is not a question you'll be asking yourself when picking the language.
I think PHP is one of the best languages to pick when you want a quick MVP for an online service (one that doesn't require specific things PHP is not good at). The community is one of the largest, there are more developers than nearly any other backend language and Laravel is probably the most complete all-in-one backend framework out there.
So the question is often, is PHP good enough to develop a maintainable app with decent performance, where developers won't hate every minute spent on it. And the answer is pretty much yes with PHP 7+
"Is there anything that PHP is developing or adopting that can not be had at other established languages?"
One thing that PHP does better than any other language for web development is ease of deployment. It isn't really anything inherent in the language that makes it easier to deploy, it's simply that hundreds, probably thousands of web hosts have made deployment easy for PHP. Also, the PHP community has documented deployment and installation scenarios thoroughly.
Deployment might sound like a small piece in the overall picture of building a web app but it is actually hugely important. If you want your users to self-install your web app, or to give them the widest possibly choice of deployment hosts, then PHP beats every other language by a mile.
I always mention this quote from blogger and programmer Jeff Attwood on this topic of depolyment:
"If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option." [1]
Guess when he wrote it? 2012.
Sure, we've got VPS and even more hosting options, but in 2020 what other languages can match or even surpass PHP's ease of deployment? Can you give instructions to your relatively non-tech users and tell them how to successful deploy your web app with the same ease as PHP?
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
I feel like I can ask that question about most established languages and get the same answer back. It still has the easiest deployment and development flow of any language I've ever used. I don't know of a single language that does that right now, and makes going from 0 to 100% much easier, which for smaller pet projects, it's so much less hassle. Upload file, it's running on the web. That's it.
As for all the features it has that other languages have, PHP tends to merge them together. While this means the language is larger than most, it also means I can do things in ways I want to and try new features out.
This doesn't mean I'm not using JS or Go or Java or other languages. But if I'm building a web API, PHP is the one that gets out of my way and lets me build it quickly and easily.
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
Probably not, but that's the wrong question. The real question is: If you already know PHP, is there enough incentive/benefit to switching languages? Based on the experience of PHP devs I know (I personally haven't used it in years), the answer is "no" for many (most?) web dev cases.
> Is there anything that PHP is developing or adopting that can not be had at other established languages?
I would say no, but of course, the same is true of most other established languages. What's interesting about PHP is that it's shifting from being a dumpster fire that you would never pick over a real language like Python/Ruby/node/Java/whatever, to one that's honestly broadly comparable for many tasks.
Is it innovating or doing anything really unique? Well, no, but you don't tend to find much innovation or unique features in any of those languages (these days, anyhow). At best they copy them (eventually) from the innovative languages. :)
> I seriously would like to know if it makes sense for a non-PHP developer to look into it
No more or less so than any other big, mainstream, relatively popular language. Learn it because you need it for a job, or because you'd like to see how another language ecosystem solves common problems. Don't learn it thinking you're going to see anything especially new.
As a gross oversimplification, I would say that the vast majority of languages share the same core functionality, then there's a little sliver that sets them apart from others and makes them unique. I would probably say that what sets PHP apart is it's easy. It's easy to install, use, develop with it, deploy, find hosts that support it, and get help from the community.
It's a decent language and with frameworks like Laravel you can quickly build reliable CRUD apps, which is the vast majority of websites and development.
I think it is possible that PHP is still the best choice for web development in 2020.
I'm coming from an academic background and i was looking to learn a new backend language to create simple CRUD type, web applications. I already know c/c++, java, js and some python but after research it seems that Rails, Laravel and Django are the best options for this kind of projects as javascript on the backend is still a mess. So i've made a little comparison between them to choose what to learn.
Rails: It might be the best full stack web development framework from what i'm gathering, but it's declining fast and Ruby has a small market share outside the US.
Django: It's been always the 2nd or 3rd best option. Django 3.0 is going async which looks great on paper but in reality it needs work. It doesn't have a built-in asset pipeline for modern js development on the front-end. It needs plugins for basic stuff like social, api auth etc. Python has libraries for almost everything but the web is not always a first class citizen.
PHP: It is by far the most popular backend language. Libraries are tailored for web development and are probably well maintained because they are used by huge projects(wordpress, magento etc). For the same reason it won't disappear any time soon because it handles most of the information on the web and also billions of dollars in online commerce. Symfony has the most contributors than any backend framework and Laravel is probably the easiest framework to create an MVP with. Developers love Laravel and the community is huge. PHP is also improving and adopting new language features with a more advanced type system.
So the real question is why shouldn't someone learn PHP in 2020 ?
Maybe I'm not in the right circles but I see absolutely no renewed interest towards PHP. Is there any reason to believe that? Honest question - PHP was my first language (or second if you want to consider mIRC scripting) and I have not so bad memories but at least me and everybody I know moved away from it years ago and don't see people going back to it anytime soon.
There's been one big change in the last 5 years – the adoption of type-inferring PHP static analysis tools in CI.
As companies started adopting TypeScript/Flow into their Javascript pipeline, PHP developers realised the need for something similar in their ecosystem.
I work at Vimeo (which has a lot of business logic in PHP) and I took it upon myself to write a static analysis tool (which you can play with at https://psalm.dev). Other similar static analysis tools were developed at other places that use PHP, and together they have helped make modern-day PHP development a little more orderly.
I've used PHP in a realtime setting as part of Psalm's Language Server, but it's clearly not built for such workloads – the lack of native async support gets in the way.
If most of the stuff you're doing requires an event loop I'd consider other options before PHP, but if it's mainly serving web requests PHP is my go-to.
Your example is similar to a WordPress developer saying they adopted modern PHP - sure, they were on PHP already. But at least Vimeo still wanted to stick to PHP so that's one positive point.
Symfony was the backend framework with the most contributors in 2019[1], and Laravel is seeing some huge growth in the PHP community. I think there's a lot of hype for the modern improvements in the language, and it's quite easy to manage a stateless web server in production making it a safe technology to use.
Doesn't make it the best backend framework of 2019!
In all seriousness, I think this has more to do with the ease of PHP development comparatively to other stacks. Even Python (arguably just as easy to learn as PHP), has more overhead here.
For context for talking off the cuff, I’m not certain that this equates to a raw quality, having used Symfony professionally for a few years I found there where a lot of limitations, particularly around the dependency injection and event dispatch system, that required a lot of work to keep performant because of the inherited limitations of PHP as well as what I feel were not the best design decisions around this idea, but I’m glad so many others have had great success here
I mean surely that depends on the crowed you hang around with. Majority of people I interact with use PHP primarily. Anecdotal evidence isn't great at identifying trends.
To me it seems like the ecosystem is growing rapidly. There are at least three large conferences each year, a handful of established podcasts and an excellent video tutorials site. There are also a number of paid services like Vapor for running Laravel on Lambda, Forge for easier server management and Laravel Shift for automatic version upgrades.
You're looking at the bootstrap install repo. That's barely changed since 5.0 was released in 2015-ish. The framework repo[1] is still being maintained by many different developers and sees a significant new release every 6 months. Taylor still accounts for a significant amount of contributions, but it is his project afterall. Also worth noting that the framework has pretty much reached maturity at this point and updates are more focused on stability and bug fixes than new features. A lot of the work being done is on the ecosystem being built around Laravel (see "The Laravel Ecosystem" on [2]), with Taylor currently teasing another new piece to the ecosystem to be released with Laravel 8 in a few weeks that apparently involves inertia.js (whose maintainer is a speaker at the Laracon event too, if I remember correctly)
As an addition to this, it's also worth noting that Laravel has enough development going on to support at least 4 full time employees that I'm aware of, in addition to Ottwell himself working full time on it.
I don't think PHP _needs_ a renascence. It's already a widely used language, so I prefer it to keep growing the good parts and leaving behind the bad old habits.
I have seen no PHP renaissance anywhere (real life, Hacker News, reddit, or anywhere else), but I also checked TIOBE[1]. PHP's popularity peaked in 2006, when it was 500% as popular as it is now.
Some highlights are union types, a JIT compiler, named arguments, annotations, and match expressions.
The approach to named arguments is interesting. It's nice that you don't have to change the signature of existing functions, but the downside seems to be that you can't enforce the usage of named arguments on callers, as in other languages like Ruby and Python where keyword arguments need to be declared as such.
If the JIT for PHP ever becomes good enough it solves the memory leak problems PHP to this day is still plagued with, that might be enough to convince me to use PHP again, possibly, for some workloads.
I can't help but feel that PHPs popularity is mostly tied to Wordpress, and to a lesser extend Laravel (with Symfony coming in behind that).
Not really sure the rest of the ecosystem even matters, outside those core pieces. I'd love to see it fix alot of landstanding issues, and I love that the language has moved forward. I've worked with it professionally over the last few years in various places, and I don't particularly dislike so called "modern" PHP, but its only really good at very specified problem domains (mostly, you have a website, need to display said website. I always had scaling problems for anything other than using it in the context of a template language or very straightfoward database access. Real time APIs? nope. Just couldn't get it done, too much memory pressure)
I was under the impression that PHP's stateless nature, with a whole new instance of everything coming into being for each request, somewhat sidesteps the capacity for problematic memory leaks that could otherwise exist for processes that remain alive between requests.
> I was under the impression that PHP's stateless nature, with a whole new instance of everything coming into being for each request
A couple issues here.
1. Even if the PHP process exits after each request, memory leaks during the request are still an issue. If I'm looping through 1,000 elements of an array and leaking memory each time, I could end up with a peak memory usage of 100MB when 1MB would've sufficed. That forces me to scale vertically when I might not otherwise need to.
2. Most mature applications have worker processes that may be longer-lived than serving an HTTP request. If PHP leaks memory, it's less suited to those tasks. Maybe you write those in Go instead, but then you have to ask yourself why you didn't just write the whole application in Go.
1. This is likely user error due to a poor understanding of how PHP memory management works. Unless you're using poorly written extensions then memory management in PHP is quite straightforward.
2. There's a large amount of PHP libraries built to do exactly what you're describing. Long lived PHP processes are live in production across the world.
Note: I wrote PHP professionally for more than 10 years, and I still maintain several PHP code bases.
> This is likely user error due to a poor understanding of how PHP memory management works.
This is not what the comment I responding to was talking about. They were talking about memory leaks that were not in userspace. PHP's bug tracker has 943 bugs related to memory leaks[1]. That has nothing to do with understanding "how PHP memory management works".
> Unless you're using poorly written extensions then memory management in PHP is quite straightforward.
How exactly do you know whether an extension is poorly written? In many cases, it doesn't matter because there's exactly one extension that does what you need.
You could also be using poorly-written libraries.
> There's a large amount of PHP libraries built to do exactly what you're describing. Long lived PHP processes are live in production across the world.
I know. I use some, and I have several long-lived PHP processes running right now.
If a memory leak is in PHP itself, no library can fix it.
> Straight up misinformation.
Disagreeing with someone (or not understanding them) doesn't mean they're spreading misinformation.
My point was that memory leaks in the PHP virtual machine are still a problem even if PHP usually runs statelessly. Do you disagree?
Ok, but looking at that same bug tracker there are only a handful of memory leaks in PHP core (i.e. not related to an extension), the most serious of which is being actively worked on: https://bugs.php.net/bug.php?id=76982
This is true. As far as I understand, the only issue with memory leaks have been around super long running processes that create cyclical references that cause refcounting to not "notice" that something is free. I have never had a memory leak problem with a web service, and I wrote* the PHP backend for Grooveshark (45 million monthly users, averaging 2 hours per visit, running on half a dozen front end web servers. Sadly I don't remember RPS figures at this point)
*not to take sole credit. I created RPC framework and initial API, and oversaw a small team of very talented engineers who added a significant chunk of the functionality powering Grooveshark over the years
Most web workloads will use some sort of process cache, like php-fpm, simply because spawning a process for each request is very inefficient. So the process and any extensions used can leak memory over time across requests.
php-fpm is typically configured to restart those processes after some number of requests, just in case there is such a leak. But I have not seen those leaks happen between process restarts, state is still wiped clean between requests, so leaks should be rare/difficult and probably most likely the result of faulty extensions.
Manipulating complex data structures that are large and/or trying to manage long running processes cause memory leaks. I often find I have to jump through hoops I don't have to in other languages to deal with these kinds of problems, for instance.
I usually have to resort to queues, which just adds complexity where I typically don't want it.
> Manipulating complex data structures that are large
I do assume it's not the case, but one of the footguns with PHP is that assigning around large variables/arrays and triggering the copy-on-write can end building up the amount of duplicates of that data being kept alive. Pass by reference, unsets, generators and the like aren't used super often due to a lot of runs being small stateless requests, but sometimes they may be needed.
We resorted to only giving PHP ready to transmute data, so it didn’t handle any of the manipulation unless it was straightForward based on our own criteria, but anything involving too much searching or filtering (yes I realize there are other problems here, but our scale was large enough that these problems had to be tackled piecemeal, and aren’t relevant beyond that for this discussion)
Ultimately I’ve had less issues with Python for this type of workload and is eventually where we moved.
The best language is the one you can make money with or positively affect the world. Please grow up out of this old debate. You all sound like 3 year olds...
You're comparing COBOL with a language that has namespaces, traits, closures, reflection and just gained a JIT compiler, named arguments, annotations and match expressions.
I heard about PHP is really just used by wordpress and drupal to keep its popularity ranking these days, and new projects seldom adopt it based on google trends, is this true?
The new PHP7/8 is certainly exciting, is it too late?
It is one of the best choices (if not the best choice) for rapid prototyping of a program. Its damn fast to similar alternatives (Python, Ruby, Dart, JavaScript), and the standard library is huge.
It does have footguns. I am not a fan of the loose typing, but you can take some steps to mitigate. You can do "===", "strict_types" and type hinting for function input and output. It is similar to C in that the language itself doesnt really do much to stop you from writing bad code. Also the function naming is not consistent, and even function arguments are not consistent. However PHP 8 will help with that somewhat, as you can now do named arguments.
Also PHP has the best language documentation I have ever seen. I would prefer more examples, but its well above some other languages.