You don’t have to venture too far into technical discussion forums or social media to see developers debating the pros and cons of different programming languages. Two of the titans of server-side scripting are PHP and Perl, so we have asked two of our server-side-scripting gurus to give us the low-down on which really is best:

CJ

Senior Principal Engineer at Fasthosts, who’s been a Perl Monger for 20 years.

Dan

Developer/Architect turned Product Owner at Fasthosts, who's been a user and advocate of PHP and Perl for 20 years.

Perl vs PHP: which is which?

What is Perl?

Perl, previously known as the ‘Practical Extraction and Reporting Language’, dates back to the late 1980s when it was created by Larry Wall. It was developed and implemented using the C programming language and is well known as being a general-purpose, interpreted language. These days it's got strong cross-platform operating system support, and excellent regular expression support.

Perl has also been called the ‘swiss army chainsaw’ of scripting languages. It’s very flexible and powerful, but can also be an ugly and destructive tool when used incorrectly. Perl was originally created for content preparation and text manipulation, but is now used for a wide variety of purposes including GUI improvement and web improvement.

Perl features

  • Supports HTML, XML and other mark-up languages
  • Borrows features from other languages like C, awk, sed, sh and BASIC
  • Supports third-party databases such as MySQL, Oracle, PostgreSQL and Sybase
  • Supports procedural and object-oriented programming
  • Open-source

What is PHP?

PHP is also a general-purpose scripting language, originally created by Danish-Canadian programmer Rasmus Lerdorf in the 1990s. PHP originally stood for ‘Personal Home Page’, but these days it’s now a recursive acronym ‘PHP: Hypertext Preprocessor’. It’s used by 78.9% of all websites with a known server-side programming language – almost 8 out of every 10 websites that you visit on the internet are using PHP in some way.

It’s a language that’s easy to learn and, due to its simple HTML integration, is a go-to choice for many developers in web design. Plus, PHP requires less coding and arrangement than Perl, and this simplicity and adaptability makes PHP a highly popular scripting language.

PHP features

  • Simple and easy to use compared to other scripting languages
  • Runs on Unix, Linux, Mac OS X and Windows
  • No compilation is required as PHP is an interpreted language
  • Open-source – can be downloaded and used for free

But does it web?

During the heyday of the dot com boom, both Perl and PHP were kings of the web. If a website needed to be dynamic, showing information that was retrieved from a database, your website was likely to use Perl or PHP to present that to the user.

Did I mention that PHP is used by 78.9% of all websites with a known server-side programming language…? - Dan

The difference between Perl vs PHP

Now the introductions are out the way, let’s get down into the details of what the difference is between Perl vs PHP.

1. Ecosystems and community

Perl

Perl's culture and community has developed alongside the language itself. Usenet was the first public venue in which Perl was introduced, but over the course of its evolution, Perl's community has developed a strong love for the language.

Perhaps its greatest asset is the CPAN repository for Perl modules. This community-led project has over a quarter of a million modules, meaning that for any specific task you want to achieve, someone has probably already written a module to help you.

PHP

PHP has Packagist and Composer. Packagist is the community-contributed PHP package repository, with over 340,000 packages containing everything from simple and useful polyfils, to serious frameworks like Laravel and Symfony. Composer is the de facto tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you - including those in Packagist.

2. Performance: the need for speed

As both languages are interpreted, rather than compiled, there is additional overhead during the execution that typically isn't present for programs written in C or C++. Bytecode generation and interpretation, memory management, and dynamic type-checking all add to this. However, this does make them both much easier to debug.

While you wouldn’t use PHP or Perl for nano-second time-critical applications, it doesn’t mean that they’re slow. PHP-FPM and mod_perl have both made usage of these languages for the web significantly better.

3. The popularity scale

Perl

Perl is a fantastic text-manipulation language. If you’re familiar with C, sed and awk syntactically, you’ll find it easy to get to grips with Perl. The dominance of Perl for text manipulation eventually led to other languages and applications offering ‘PCRE’ or ‘Perl Compatible Regular Expressions’.

Due to having different scripting languages capabilities, Perl makes the task of system administration very easy, and this is where it’s still strong today. However, it has dropped out of favour with younger developers in recent years, and is being taught less in Computer Science degrees, in favour of Python. If you want to learn more about this language, read our in-depth article on Python vs Java – two programming languages that are currently extremely popular.

PHP

Similarly, PHP had encountered a dip in its popularity around its 5.x versions. After the end of 2009 everything was, but soon after that PHP started going downhill from 10% to 5% market share. By 2014 it had halved again. So what happened to PHP? From its start, PHP was the Visual Basic for web design – easy to learn, easy to deploy. But, it was mainly used by web designers with a limited software engineering background.

The downside of PHP’s simplicity was that it was relatively easy to shoot security holes in it. It’s definitely in a much better place now, fuelled by the rise in popularity of Laravel and the PHP foundation - charged with supporting, promoting, and advancing the PHP language.

4. Documentation and learning

Languages shouldn’t just be judged on their features, but also on their support, documentation and release frequency.

A significant version of PHP is released each year and is fully supported for two years. During this period, bugs and security issues that have been reported are fixed and are released in regular point releases. After this two year period of active support, each version is then supported for an additional year for critical security issues only.

If you’re interested in starting to learn Perl, we recommend you check out learn.perl.org

www.php.net is the authoritative place for PHP documentation, and sites like W3Schools provide some great resources for learning PHP.

So which is better?

As always when it comes to technology, the answer is rarely black and white. So, really it depends.

Perl is great for system administration/automation, text processing and data manipulation.

PHP is great for dynamic web pages, API frameworks and being the engine room behind some of the largest hitters on the web like WordPress.

And the winner is...

PHP!

Both PHP and Perl are excellent languages, with a rich history and excellent community support. But PHP is often the go-to language of the two, being used by over 78% of websites with a known server-side programming language for good reason.

PHP is easy to use, adaptable, and is consistently updated.

Frequently asked questions

Is PHP faster than Perl?

PHP is generally considered to be faster than Perl, although there are ways to make Perl faster. Overall, speed and performance will mostly depend on the implementation of these languages, so either one can be slow if used incorrectly.

Is Perl a dead language?

Although PHP is more popular, this doesn’t mean that Perl is a dead language. In addition to being used to maintain legacy web systems, Perl can be used for tasks such as day-to-day system administration and text processing.

Is PHP becoming outdated?

PHP is still very popular, but it has faced some criticism over the years due to a range of factors, including its initial design, performance and security issues. PHP is now faster and more secure thanks to updates and frameworks like Laravel, so it’s unlikely to become outdated any time soon.

What is the latest version of PHP?

PHP is consistently updated, which means that security and performance issues are regularly addressed with each update. The latest version of PHP, PHP 8.2, was released in December 2022.


Want to learn more about scripting and programming languages? Check out the Fasthosts blog for more in-depth guides and comparisons.