The developers have released the eighth version of the PHP programming language
A group of enthusiasts led by the Danish programmer Lerdorform Rasmus has released the eighth version of the PHP scripting programming language. The release took place on November 26, 2020, almost a year earlier than planned. Compared to the previous version, PHP 8 has received several serious improvements, including the use of a JIT compiler and a significant revision of the “syntactic sugar”, which allows reducing the volume of template code.
The PHP programming language has been developed since 1995. The main area of its application is the development of dynamic websites with code execution on the server side. At the same time, compilation of programs written in PHP is also available for execution on UNIX operating systems and in the Windows environment. Several programming languages, including C++ and Java, have had a significant impact on the PHP syntax.
The most significant change in the PHP 8 version was the use of a JIT compiler. It allows you to translate the program code into machine code in real time directly during the execution of the program. Thus, in some cases, it is possible to increase the speed of application execution. In the case of PHP 8, the greatest speed increase using the JIT compiler is achieved when performing mathematical operations.
Another practical improvement in PHP 8 was the addition of the match expression. In general, it works similarly to the traditional switch, however, unlike the latter, it uses a strict comparison of values. In this case, the result of the match operation can be saved to a variable and used in the future or returned, for example, using the echo function. Unlike switch, the match expression works with single-line expressions that do not require the break construct.
PHP 8 also introduced named arguments for use in libraries or associative arrays. This innovation, unlike PHP 7, uses self-documented arguments, which allows you to use them in any order, skipping optional parameters. This has a positive effect on the readability of the code and its volume, especially when it comes to using libraries that work with Boolean parameters.
Back in PHP 8, it became possible to use structural metadata with native PHP syntax instead of PHPDoc annotations. Thanks to this, for example, when writing metadata, you can use the hints of the development environment. In addition, in PHP 8, it became possible to simultaneously declare and initialize properties in the class constructor. In some cases, this allows you to reduce the amount of code by three times.
Finally, another significant change in PHP 8 was the use of a new Nullsafe operator, which is written by zank ? after the processed element. This eliminates, for example, the need to prescribe a null check for each variable, using instead a sequence of calls with the Nullsafe operator. In this case, if at least one element returns null, the entire sequence will return null.
A more complete list of innovations in PHP 8 and documentation on them can be found in the release message.
In mid-2018, British developer Dylan Beatty introduced a new dynamic programming language Rockstar. Its syntax is inspired by famous rock songs of the 80s.