Is PHP A Horrible Programming Language?

Is PHP dying anytime soon? No, with over 80% of market share in the web space, it’s nowhere near dying.

“WordPress? No way, I won’t waste my time coding PHP.”

I’ve heard that over 💯 times. More importantly… I used to rant against PHP 14 years ago.

Yes, I was young and stupid – and sadly, I am older now.

I was trained in a fairly traditional software engineering environment – computer science classes, algorithms, low-level systems, OS processes. PHP was suitable for none of this. Moreover, this was back in PHP 4 – a lot has changed since.

And now we have a hard time recruiting great talent over, what baby boomers may say, “political issues.” Failing to recognize the value in solving business problems in exchange for “syntax sugar” had been an obstacle.

Here’s my take on why developers rant against PHP.

If you are a software engineer, what annoys you the most in PHP?

Highlights

00:21 – Common questions when choosing a programming language
01:47 – Is WordPress a spoiled kid?
02:52 – Data over just anyone’s advice
04:15 – Why do people blame PHP?
05:32 – PHP development over the years
06:34 – Solving business problems using PHP
08:10 – Stability, Performance, Security

Transcript

Hey guys, Mario Peshev from DevriX here. Today’s topic is why is there so much hatred when it comes to PHP in the software development community? You know, there are a bunch of different programming languages out there. There are Java, C#, Python, Ruby, JavaScript, Visual Basic and tons of other different languages out there.

FAQs When Studying Programming Languages

And when it comes to people actually studying new languages, what they normally do, they look for available jobs or they ask people around them like, “Hey, should I learn this? Should I learn that? Or I found this framework or this CMS or something that is supposedly written in PHP. So is it a, you know, a good career path to dabble into the world of PHP?”

And for the most part, well at least a lot of different developers that are not really specializing in PHP, they’d say, “Abandon that, that’s a shitty programming language. You don’t really want to study it,” and so on and so on, “because it’s not a professional language. It’s a kid’s game. It’s only for website building,” and so forth.

And as a matter of fact, I shared the same opinion when I was an entry-level junior developer, I was also raised in a community of hardcore software developers who were normally using C++ or Java for building enterprise applications. And most of them were really opposed to using PHP for anything beyond a simple homepage. 

Fast forward a few years, I built a company building PHP applications first with CodeIgniter and Kohana and some other frameworks and then switching entirely to WordPress, and now being a team of 30+ people building high-scale applications for various small and medium enterprises.

So since I’ve also taught several trainings, some for WordPress and some for PHP, and also a lot of different kinds of lectures at conferences, there’s a very interesting backstory when it comes to programming languages and platforms. Since we specialize in WordPress, I’m going to start with this first.

Is WordPress a Spoiled Kid?

With WordPress, when you go to a PHP conference, there’s usually that laughter that WordPress is the spoiled kid that’s used to everything being done in a matter of hours and not really paying that much attention and so on and so on. When you go to a web development conference, PHP is getting laughed at because it’s not Ruby, it’s not Python, it’s not Java, and so forth. It’s actually a bit more complicated because Java developers laugh at .NET developers because they used too much drag and drop in Visual Studio, and on the other hand, .NET developers are usually more enterprise and they laugh at other scripting languages like Ruby and Python because they’re too simplified, not enough enterprise.

Data Over Random Advice

It’s a very complex topic. And that’s why I don’t advise anyone to pay too much attention to other people’s advice because it’s often coming from a different perspective.

The truth is, when you are talking about data, according to W3Techs, 83.4% of all websites out there are built with PHP, and you can validate that if you have a lot of free time and some available resources by crawling the top say 10 million websites out there by going to Alexa or some other like SimilarWeb or BuiltWith and so on, and just run a few queries and see whether this website is running PHP or not.

At the same time, WordPress is running over 30% of all websites out there. So WordPress is PHP based of course, and it’s only a fraction of the market share of PHP, even though WordPress alone is taking over 30% of the web. Right? So it’s obviously widely used.

Sure. A lot of the WordPress projects out there are simple blogs and five-page business websites. Nobody’s arguing with that. On the other hand, you do have Facebook, which is built entirely in PHP. Well, not entirely, but obviously the main framework, like probably 80% of their code is PHP. You have Wikipedia, which is in PHP. You have Yahoo, which has a lot of stuff in PHP. And a lot of other professional projects generating and serving tons of traffic with PHP.

Why Do People Blame PHP?

So it’s obviously not that bad. So where does that come from? Why do people blame PHP so much? Well, first off, back when Rasmus created PHP in the first versions of the PHP documentation, you can find several references stating that PHP was not really… Well, it was built for non-developers who can easily tinker with websites and do basic changes. And you can think of VBScript or something else or operating and processing with Excel tables, or just running some basic operations.

That was the initial purpose, but it’s worth noting that PHP was designed in 1994, which was about 24 years back in the day. In 1994, Java didn’t exist, C# didn’t exist, Ruby didn’t exist. A lot of other languages didn’t exist.

And most people do say, “Hey, there’s too much shitty story when it comes to PHP,” and so forth, but case in point is PHP is evolving with time, PHP is getting better with time and of course, there’s some history that’s making it appear as an unprofessional language, because other people weren’t even around back then when PHP was. So that’s something that’s definitely worth considering when it comes to the programming language.

PHP Programming Language Development Over The Years

PHP wasn’t object-oriented by default, it was a weakly typed language, which means that variables don’t really set a specific type, whether they’re integer or string or double float or something else, which is something that you can enforce right now if you want in the future over the past few years. But it started at search.

And it posed some bad programming practices out there. Over time with PHP 5 it became fully object-oriented with 5.3, it introduced namespaces and late static binding and some other things, making it a bit more robust and a bit more professional.

PHP 7 was a major improvement, both in terms of performance, language syntax, concert defining and so on. So it’s much better than it used to be a decade ago, or let’s say 15 years ago. But when you think about the popularity of PHP as a programming language, consider the past 15 or 20 years, if you have been around, or at least if you know what happened 15 to 20 years ago. 

Solving Business Problems Using PHP

What I remember back in the day when I was a young kid playing with tech, we wanted to set forums because forums were the thing after bulletin boards and some other things.

So in order to set up a forum, what you’d normally do is go and install phpBB, vBulletin, Invision Power Board or something else to set up the forum. You want a gallery? No problem. Gallery2. You want a CMS, there were PHP DotNetNuke or something like that. E107, a bunch of other platforms, Mambo, which was the predecessor of Joomla and so on. Drupal showed up, WordPress showed up at some point after being PHP B2/Cafelog and so on.

So almost all platforms out there that were solving business problems were based on PHP because PHP was easy to learn, it was easy to tinker with because those platforms were open source. It played extremely well with MySQL, which was the most popular open-source, well free database platform out there. So there was a good symbiosis, hosting was extremely easy. Virtually every host out there supports PHP applications and there’s a good reason for that.

And when you think of it, lots of available platforms, easy to customize, easy to set up because trust me, try to set up a “Hello, World!” in Java with JSF or even with ASP.NET. It’s extremely complicated when compared to just uploading a few files and running a PHP script.

So in a nutshell, all of those things led to the adoption of PHP. The reason people hate it, first off, again, in terms of language syntax, there are inconsistencies. And that’s true. Function naming, library naming, class naming, setting up everything under the same namespaces, it doesn’t really work in the same way it works with .NET or Java or even with Ruby and Python.

It just doesn’t, it’s a bit more chaotic. Conventions aren’t really adhered to everywhere. And more importantly, most tutorials, and that’s where the bad fame of PHP is coming from, most tutorials out there don’t necessarily care about security or performance. They say, “This is the easiest way to solve a problem,” but they don’t say, “Well, that’s easily exploitable if you just put this in the URL and essentially break the database by dropping a SQL injection there. Or this is easy to do if you have 10 records, but try doing it when you have 10 million records because it’s going to break a toe.”

So that’s the biggest problem. But in terms of performance, in terms of stability and so on, PHP has been proven to work and obviously all the platforms that are running it and the fact that it has 83% of the web website market share out there is proving that. It’s a bit tricky to start, you don’t have one single correct path. Even though frameworks like Laravel and Symfony, and Zend are trying to put the conventions there. Also tools like Composer for package management, object-relational mapping, and active record libraries, and frameworks.

Everything is getting better with time, but you really need to start doing it and you need to keep learning and keep reading, and keep experimenting until you also learn all the concepts of stability, performance, and security.

Aside from that, it’s a great language. It’s very dangerous. You can shoot yourself in the leg, but if you know what you’re doing, it’s a fairly decent one. So give it a shot.