This article is more than 1 year old
Marmite of scripting languages PHP emits version 8.0, complete with named arguments and other goodies
Hallucinate, Desegregate, Mediate, Try not to hate: INXS of 25 years on, PHP liberates the number eight
Version 8.0 of the PHP scripting language is scheduled for release on 26 November, which coincides with the US Thanksgiving holiday.
PHP turned 25 earlier this year and its latest iteration brings a variety of improvements to those who enjoy the language, which certainly isn't everyone.
Type "is PHP" into Google Search box, in Incognito mode, and the first two auto-complete suggestions you'll see are "is PHP still used" and "is PHP dead."
"Despite still being one of the most used languages to build web applications, over the years PHP has managed to get itself a reputation of messy codebases, inexperienced developers, insecure code, an inconsistent core library, and whatnot," wrote Brent Roose, a PHP programmer with Belgian company Spatie, in a blog post at the start of the year.
Roose went on to argue that developers can write clean, fast, maintainable, reliable applications in PHP. As with other languages, ill-behaving code is often more a reflection of developer experience than language deficiencies.
In an interview with The Register, Mark Story, a principal developer at application monitoring biz Sentry and maintainer of CakePHP, acknowledged that PHP has some historical baggage.
"I would agree that PHP has a very mixed reception when you bring it up," he said. "And I think a lot of that has to do with how historically PHP has been used. Some of the very large PHP projects have not always had the best coding practices and then those projects have been kind of trapped in a stage where they can't really work their way out of that problem, because they have a huge community and a huge amount of inertia behind the existing code base. Replacing it is just really, really challenging."
Story added that he believes PHP has developed a bad reputation because, being easy to learn, it gets picked up by a lot of novice developers early in their careers. "So you get people who maybe don't have formal training or maybe don't know all the best practices and then they fall into the pit of success where PHP just does what they need to do," he said.
The thing about PHP is there's a lot of it – in websites where the server-side programming environment is known, 79 per cent of them use PHP. WordPress is written in PHP. And for what it's worth, Facebook was originally written in PHP, though the ad biz has since shifted to a dialect called Hack, in addition to other languages.
Among the noteworthy features in PHP 8.0, Story pointed to improvements in the type system, like the addition of union types, which allow variables to be declared to hold data of more than one type. For example, a variable could be declared to hold either floating point or integer data.
"Another big one is named arguments, which is a feature that's been basically stolen from Python," said Story. "One of the key things that people love about Python is being able to use named parameters and not have to worry about the position of the parameters as much and not have to wrap them in another structure like an array."
Story said while PHP makes sense for web servers and command line tools, it isn't great for other uses. And he doesn't expect the 8.0 update to change that.
"I think it doesn't open up any new opportunities for PHP," he said. "What I think it does is just improve the quality of life inside of PHP. Another interesting thing that could be beneficial in the future is the just-in-time compiler, the JIT compiler. It won't be super useful in most web stacks right now just because the code doesn't get hot enough for the JIT compiler to kick in. But it's promising. It's the start of something that could be really powerful in the future."
Those planning to upgrade to PHP 8.0 should test their applications before making the jump, said Story, who suggested waiting a few weeks or months until the library ecosystem and all the dependencies get updated. ®