> I’m really interested in hearing from startup companies today why they would pick PHP instead of more modern alternatives such as Scala, AngularJS, React, ExpressJS, Meteor, or even older platforms such as Django or Rails.
The only “alternative” you listed that is an actual alternative — meaning a language that runs on a server and interacts with a database — is Scala.
Django and Rails are frameworks and not languages. Django is a framework for Python and Rails is a framework for Ruby. PHP has powerful frameworks as well, most notably Laravel and Symfony. You can argue all day about which of these frameworks is best, but they are all great. Ruby and Python can be compared to PHP. I happen to like all three languages, preferring different ones at different times and for different reasons.
> there are many more idiomatic options available, in which you don’t have to mix syntax with a legacy of over 20 years.
Same arguments surround C++, and the basic answer is the same: the language works spectacularly well and there are a lot of experienced, talented developers who specialize in it.
If you want an OOP language that allows you to squeeze every last bit of performance out of the hardware, C++ is a great choice. It is also, due to its legacy, a clusterfuck of a language.
If you want to rapidly develop, and later rapidly modify, a web application that is mostly interacting with databases, PHP is a great choice. It is also, due to its legacy, a clusterfuck of a language.
Before diving into what makes PHP a great choice for database web apps, I want to point out something important that, again, applies to both PHP and C++ programmers: once you master the language, the problems with it become much less noticeable. In CompSci classes, the downsides to a quirky language seem huge. But in the real world good PHP developers can write expressive, easily maintainable apps, and they don’t get surprised by, for example, the type system, because they know how to work with it.
So what makes PHP good? I won’t dive into a head-to-head, but here are some of the reasons I think it could be a great choice for a database web application:
For one thing, it is over 20 years old. You seem to view this as a negative, but I tend to trust established technologies over new ones. There are a lot of bugs yet to be found in young technologies.
Once more, due to its age, finding a good, experienced PHP programmer is easy. They are everywhere. Finding an experienced team of Scala developers would be, umm, a bit more of a challenge.
While we are talking about the benefits of an older language, there are many PHP packages, and a lot of them are better than other languages offer. Drupal, as one random example, is easily the world’s most powerful and extensible CMS. Many startups want Drupal as the foundation for their web application for its query builder, or queue system, or bulk operations, or reusable fields, or multi-lingual support, or all the e-commerce options, or the token system, or the hook system, or […]. If you want Drupal, well, it runs on PHP.
PHP scales marvelously.
Code written quickly when an app is young can later have type hinting added in, to allow the best of both worlds: flexibility and speed of development when you are small, and safety and performance when your app has grown to need it.
PHP doesn’t have memory leaks. Period. That whole class of bugs, which can bring a webserver to its knees, are avoided by PHP’s request == thread model. Some people complain about this, but if you absolutely need multiple threads in a single request (you probably don’t) then you can still do so in PHP.
PHP doesn’t get enough credit for this, but it is a somewhat expressive language. Variables start with $. Function calls end in (). In PHP, these are two very different things, and they are easily identifiable. The way PHP handles scope means that you know if your variables are global or local. These examples may sound trivial, but in some languages it can be difficult to tell what is what.
Dynamic type systems, although apparently falling out of favor, do have benefits. I love being able to treat 423 as an int, string, or float, without doing any work. You can always force strict types or strict comparisons if you want, but there are advantages (particularly when the project is young) to embrace dynamic typing.
I assume you read the article that you are replying to, and are aware of the awesome PHP development cycle: think, edit, reload page. No compiling, no restarting a server. So fast.
There is more that I like about PHP, but I think you get the idea. It isn’t such a popular language for no reason. Despite what a lot of people seem to very much want to believe, there are reasons to choose the language.
I am not saying it is the best choice for every project, but PHP is often a good choice. The cutting edge cuts you, being on the bleeding edge makes you bleed. PHP may not be shiny and new, and it certainly has its warts, but it is a well tested, highly performant language for building web applications. And it works spectacularly well.