If the world’s biggest social network was built today, what tech would be powering it?
If Facebook were being built today, what programming language would Zuckerberg and co. use?
If we were asking this question even just a few years ago the answer would be simple: PHP.
Why is that?
Facebook, Wikipedia, Flickr, Tumblr, WordPress—all of these are developed on a foundation of PHP, meaning that PHP programmers have had no shortage of work for a number of years.
Released over 21 years ago, PHP remains one of the most popular server-side languages in use. It has evolved through a total of 7 versions (including one unreleased), fought off its major competitor ASP.NET, and slowly shifted from a mostly procedural language to a mostly object-oriented one.
But it’s showing its age.
And like everything in the world of technology, there’s always someone eyeing up the throne.
This wouldn’t be the first time a major scripting language was supplanted, either.
In the early 1990’s, the server-side scripting language of choice was Perl through CGI (Common Gateway Interface). Today, Perl makes up less than 0.4% of the server-side market share, even though it is still actively updated and maintained.
Could this be the fate of PHP? And ultimately, is PHP the right choice for your application?
Out with the old?
When it comes to technology there is the feeling that the second a tech is deemed ‘old’, it is essentially obsolete.
In truth, the value of PHP is not up for debate. Not only is it still the most popular server-side scripting language, but it’s the most popular by a fairly wide margin.
But because of its age and pedigree, so many websites already inherently use PHP, which can give a skewed perception of the languages being used for modern development.
If we get rid of sites that use a CMS like WordPress, Joomla, Drupal, and vBulletin—which are all using pre-built solutions that were developed in PHP—the number drops to 54.3%.
Still a significant lead, but it’s hard to deny that a downward trend is starting to appear.
Why is PHP losing popularity?
Just because PHP is popular doesn’t mean that it doesn’t have problems.
Though PHP is a robust and flexible language, it has often come under criticism for being too flexible. Compared to other programming languages, PHP has a laissez-faire attitude when it comes to syntax and structure; anything goes.
This makes PHP very easy for programmers to pick up but makes it very difficult to optimize and lock down. It also leads to a proliferation of spaghetti code—code that is loosely structured and conceptually twisted and tangled like a bowl of cooked noodles.
“As of 2016, PHP comprises more than 80% of the websites on the Internet.”
Not exactly how you want your product’s core code to be set up.
Compare silly putty to Lego blocks and you’ll understand the difference between PHP and more traditional languages. While too much freedom might not seem like a bad thing, it renders PHP mostly unsuitable for very large scale applications—applications that have to be extremely conscientious about their security and resources.
And even the accessibility of PHP can become detrimental.
There is enough pre-built code for PHP available that many new PHP developers simply copy-and-paste their feature set. This leads to sloppy and inconsistent coding and has created a general culture that lacks discipline.
PHP is dead; Long live PHP
Enterprise-level applications have already been shifting away from PHP and towards other technologies.
One option is Coldfusion, which isn’t exactly a server-side language, but rather a web application server that includes its own scripting markup. ColdFusion developers use CML (ColdFusion Markup Language), creating dynamic web and mobile apps without the need for under-the-hood programming.
When it comes to more conventional options, Python is considered to be a far more powerful language than PHP. Part of this lies in its consistently object-oriented approach as opposed to the primarily procedural approach that plagued previous iterations of PHP.
But in other ways, Python is still fairly similar to PHP, with a fairly low barrier to entry and flexible code. PHP developers can move easily towards Python, and the reverse is also true.
Another alternative, Ruby on Rails, is an MVC framework that is designed for rapid application development. Ruby is the language itself, while the ‘on rails’ part refers to the framework that completes it. Rather than selecting from a multitude of frameworks, such as in PHP, a Ruby on Rails developer is given a single structure through which to build.
Ruby on Rails automates many basic tasks and has a suite of integrated testing tools. Similar to Python, it has a stronger object-oriented background than PHP.
But none of these languages came without a response from PHP.
PHP7 was released in December of 2015 and sought to address many of the language’s issues with modernization. Among other things, PHP7 removed many of its deprecated features and extensions and optimized its performance. Errors in PHP7 were replaced with object-oriented exceptions rather than the legacy error handling utilized before. And PHP7 also included new features such as support for scalar types and return type declarations.
So, just what is PHP best used for?
So the question remains: If Facebook were being built today, would it be built on PHP?
The answer isn’t clear but our best guess is an unsatisfying probably.
Mark Zuckerberg was still in college when he began building Facebook, and PHP is still undeniably the easiest server-side language to develop in.
“On the other hand, if Facebook was rebuilt today from the ground up by an experienced software company, it probably wouldn’t be developed in PHP.”
Instead, it’s very likely it would have been developed on a back-end of Java or Ruby on Rails such as modern high volume sites like Amazon.com and Twitter.
This isn’t to say that PHP is useless for modern companies.
Not only is it still the most popular server-side scripting language, but it’s the language of commonality for many critical web services.
Nearly every leading web platform is programmed in PHP, and PHP developers are still in high demand throughout the programming industry. PHP is just too ubiquitous to go away over night.
Though PHP is falling out of favor for high volume sites and large scale commercial infrastructures, it remains vastly more popular for small to moderately sized websites.
Moreover, it’s still the backbone of nearly all of the popular websites today. No one is going to shoot themselves in the foot by building on a foundation of PHP.
With the release of PHP7, PHP has shown a commitment towards developing its technology in the new direction that users need. This is a sign that PHP may be able to maintain its relevancy even with its new competition. But it would also be disingenuous to say that there aren’t more options out there than there used to be, or than other scripting languages may be superior for your specific application.
That’s why a truly experienced programmer will have multiple server-side languages in their arsenal and be able to pick and choose between them depending on the project.
If a programmer needs to rapidly deploy a web application, Ruby on Rails may be their best solution.
If a programmer needs to throw together a moderately sized website on-the-fly,PHP may be ideal.
On the third hand, if a programmer needs to code something a bit more resource intensive and elegant, Python may offer better object-oriented capabilities and a stronger structure.
In programming, it’s all about having the tool set to do what you need.
PHP is not dead and it isn’t dying. But it is shifting away from being the only major server-side scripting language to one of many viable server-side scripting languages. And for a talented and versatile programmer, that’s a good thing.