Programowanie php

With dozens of extremely popular software offerings and millions of programmers, PHP is one of the most popular programming languages in the world. Especially in the world of web development, only JavaScript can match its ubiquitousness. Indeed, there are a lot of PHP lovers out there. But it’s also hard to deny that there are few languages that are so passionately hated. Is it a “they see me rollin’, they hatin” kind of thing, or perhaps there is some merit to it?

Do you know some PHP developers? If you do, you can be envious of them for at least one reason – they aren’t going to run out of things to do anytime soon. As of August 2016 PHP is the 7th most popular programming language in the world according to the well-known Tiobe index. It is also the 5th most popular technology (4th when it comes to languages alone) on StackOverflow.

And things look even better when you take into consideration popular PHP-based software. The CMS Usage ranking from builtwith.com is largely dominated by platforms written in this language. With way over 17 million implementations, WordPress’ popularity is unmatched. According to W3Techs, WordPress alone is used by “59.5 percent of all the websites whose content management system we know”. Just to give an even better sense of how popular WordPress is, take a look at the chart below that shows relative popularity of WordPress compared to popular web development frameworks written in other programming languages.

Relative popularity of WordPress, Ruby on Rails and Django Relative popularity of WordPress, Ruby on Rails and Django

 

What’s more, the PHP-based Magento is the most popular eCommerce platform in the world.

The popularity of PHP is impossible to ignore. But… neither is the hate it has received over its two-decade-long history. We’ll get to that. But since hate and popularity usually go hand in hand, let’s start by answering another question.

Why is PHP so popular in the first place?

The development of the PHP language can be traced back to 1995, when Rasmus Lerdorf wrote a set of programs in C and further extended them to provide support for some of the most common web features such as web forms and the ability to communicate with a database. The objective of this entire endeavor was to power his own personal website – an intent clearly reflected in the name of the very first version of PHP – Personal Home Page Tools (PHP Tools).

After Lerdorf publicized his software, it didn’t take much for it to gain popularity. Simple to use, equipped with nothing more than just basic tools to put together a website, PHP seemed like a less painful way to do web development than some more comprehensive and robust, but on the other hand providing a steeper learning curve languages such as Python or Ruby. Undoubtedly, the infamous dot-com bubble, which saw countless entrepreneurs in need of establishing their online presence, helped make PHP popular. Though funnily enough, in its early days it wasn’t even considered an actual programming language (even by its creator!).

As PHP’s reach grew, accelerated by the appearance of many popular pieces of software such as WordPress or Drupal, more features were added, including limited support for object oriented programming. But some of PHP’s defining features never changed:

  • specialized in web development, decreasing entry barriers for new students compared to the likes of Ruby, which were designed as general purpose languages from the start;
  • free and ubiquitous, support from just about any hosting provider under the sun;
  • supported by a large community of developers always busy building and refining new pieces of software, including a great variety of web-centered frameworks.

So, where is the hate coming from?

Sounds pretty good at this point, doesn’t it? A simple to use programming language heavily specialized in web development, originated from an actual web project. What more can a web developer desire? As it turns out, this very story behind PHP is exactly what caused it to become a nightmare for many programmers back in the day.

When you look at the history of some other languages commonly used for backend development such as Python, Java or Ruby, it’s easy to notice one big difference between them and PHP. Those three were… meant to be actual programming languages from the start! Consciously crafted as general purpose languages, only over time did they find their place in web development, especially thanks to web-oriented frameworks such as Ruby on Rails (Ruby), Django (Python), or Spring (Java).

The creator of PHP 1.0 Rasmus Lerdorf originally intended his work only to be a set of tools for making websites, not a programming language.

 

In comparison, the development of PHP was much less orderly. Originally intended merely as a set of web tools for personal use, new features and capabilities were added on the go when they were needed. This and some other circumstances led to the following:

  • Inconsistencies – there are few languages as inconsistent as PHP. Function names written in different conventions, random order of parameters that doesn’t have any rule to it – these are just some examples of minor problems that piled up, forcing the programmer to constantly refer to the documentation to be able to do the simplest of tasks. What’s more, the team behind PHP was always reluctant to improve in this area citing backwards compatibility as a reason.
  • Various performance and security issues – over time, developers accused PHP’s sloppy syntax of making it too easy to write code vulnerable to common attacks such as SQL injections.
  • Being a loosely typed language – that by itself doesn’t say much as PHP is hardly the only language that doesn’t force you to declare the type of your variables. But when you couple it with the previous point as well as the fact that PHP is a popular language of choice for new developers, it’s easy to predict that there is a whole heap of badly written PHP code out there. And what can be even more frustrating for some developers is…
  • You can’t get away from it! – with over 20 years of history, huge popularity and the presence of software that isn’t going away any time soon, working with PHP based projects isn’t something one can usually easily get away from.

The PHP developer’s responsibility

Indeed. There are some valid reasons why love isn’t all that PHP is getting. But even the biggest haters of PHP won’t deny two things:

  • PHP is getting (much) better – with each update, new features are added and countless improvements are made to make the experience of working with the language better and its object-oriented capabilities feel more natural. Among others, an optional support for strict typing was added in PHP7.
  • Since PHP is here to stay, we need great PHP developers to use its advantages and avoid its common pitfalls.

PHP powers some of the amazing and popular web projects out there. In the future, even more complex platforms will be built based on this language. To make them efficient and secure is the job of PHP developers. Skilled web development is always important. But PHP in particular shows just how essential it is. With good programming practices and attention to performance and security details, it is the PHP developer’s responsibility to produce quality projects that only inherit what is good about the technology.

Polcode Team