PHP 8 maintains the relevance of the open source programming language
At the start of the web age, the open source PHP programming language was at the heart of all web development, and with its new version 8.0 is trying to become more relevant to a new generation of developers.
However, PHP has not been idle as other languages ââdevelop. PHP 8.0, which became generally available on Thanksgiving Day (November 26), comes with a host of new features, including a just-in-time (JIT) compilation engine that speeds up performance over previous versions of PHP.
Other improvements include language optimizations that will benefit developers, including named arguments and attributes.
âPHP remains one of the most common scripting languages ââtoday,â said James Owen, senior analyst at Evans Data. ITPro today.
The love / hate relationship with PHP
According to Evans Data GWorld Development Survey 2020, v1, 79% of scripting language users use PHP for part of their scripting language efforts.
âDespite some variations over the years, this usage rate has remained fairly stable among users of scripting languages,â said Owen.
Stack Overflow also ranks PHP as the eighth most used language, but it also gives PHP the dubious distinction of being the sixth. the most feared Tongue.
PHP was created by developer Rasmus Lerdorf in 1995, and the project has since benefited from a large community of contributors. One of the major contributors and business supporters of PHP over the past two decades is the developer tools company Zend, which is now part of Perforce Software.
“People praise me for PHP 8. It’s completely misguided,” Lerdorf wrote in a Twitter. a message Last week. “@nikita_ppv [Nikita Popov from Jetbrains] and @dstogov [Dmitry Stogov from Zend] have been the driving force behind PHP for years now. Countless others participate regularly. PHP 8 is much better because it contains a lot less of my code. “
What features developers will notice in PHP 8
PHP was created as a web-centric language, said Matthew Weier O’Phinney, product manager for Zend. ITPro today. Since the data is submitted to websites via forms, it all comes in the form of strings, which means that PHP tends to what is known as ‘loose typing’ and ‘type coercion’, where the code can make assumptions about what has been submitted. While a loose keystroke can be helpful, O’Phinney said it also leads to errors and potential security issues.
When PHP 7.0 was released in 2015, a number of activation features were added to the language to allow strict input; with PHP 8.0, these features are extended. PHP 8 provides what are called “union types” – a way to indicate that an argument or return value can be part of a set of types, O’Phinney said.
âIn terms of enhancements to the developer experience, the language adds several features that will simplify common models,â he said.
One of these common patterns is the practice of using a class constructor to assign class properties from the arguments supplied to it. In previous versions of PHP, O’Phinney said that developers had to declare the properties, then declare the arguments in the class constructor for each, then do the actual assignments of the arguments to the properties. A new feature called “class constructor property promotion” does all of this in one operation by setting properties from arguments using special syntax.
PHP 8.0 also benefits from an attribute system which O’Phinney says has been in the works for a long time. Many languages ââhave “attribute” or “annotation” systems that allow developers to define metadata about code artifacts, he said. These have been used by things like relational object mappers to enable the mapping of properties of a class to columns in a database, or to map a web server path to the code that will manage it. PHP had libraries to do such things, but PHP 8 now adds an attribute system that integrates it directly into the language.
PHP 8 is just in time
PHP 8.0’s new just-in-time (JIT) compiler may well help expand PHP adoption.
âJIT is fantastic for numerical calculations and things that are computationally expensive,â O’Phinney said. “However, PHP is generally used for web applications, which are neither.”
He noted that PHP tends to be related to input / output (I / O) where performance is mostly affected by things like querying a database, caching values, sending API requests or file system access. What JIT will do, however, is open the door to PHP for use in more computationally intensive applications.
âPHP celebrated its 25th anniversary last month and has seen eight major releases, and is still responsible for the lion’s share of what is deployed on the Internet,â said O’Phinney. “It is a stable and mature language that is constantly evolving, receiving features such as JIT that will allow it to reach ecosystems previously dominated by other languages ââsuch as ML. [machine learning], and due to the ease with which it can be deployed and the low barrier to entry for developers, it is not going to go away. If anything, look for PHP to keep growing. “