NIX Solutions: Developers Released the Eighth Version of the PHP Programming Language

A group of enthusiasts led by Danish programmer Lerdorform Rasmus have released the eighth version of the PHP scripting programming language. The release took place on November 26, 2020, almost a year earlier than planned. PHP 8 has received several major improvements over the previous version, including the use of a JIT compiler and significant improvements in syntactic sugar to reduce boilerplate code, reports N+1.

The development of the PHP programming language has been going on since 1995. Its main field of application is the development of dynamic websites with server-side code execution. 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 PHP syntax.

NIX Solutions concludes that the most significant change in PHP 8 is the use of a JIT compiler. It allows you to translate program code into machine code in real time directly during program execution. Thus, for some cases, it is possible to increase the speed of application execution. In the case of PHP 8, the biggest speed gains with the JIT compiler are achieved when performing math operations.

Another practical improvement in PHP 8 is the addition of a match expression. In general, it works in a similar way to a traditional switch. However, unlike the latter, it uses strict value comparison. In this case, the result of the match can be saved into a variable and used later or returned, for example, using the echo function. Unlike switch, the match expression works with single-line expressions that do not require a break clause.

PHP 8 also introduced named arguments for use in libraries or associative arrays. This innovation, unlike PHP 7, uses self-documenting arguments, which allows you to use them in any order, bypassing 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 hints from the development environment. In addition, PHP 8 makes it possible to simultaneously declare and initialize properties in a class constructor. In some cases, this can reduce the amount of code in three times.

Finally, another significant change in PHP 8 is the use of the new Nullsafe operator, which is written with a ? after the item being processed. This spares from, for example, having to write a null check for each variable, using a sequence of calls with the Nullsafe operator instead. In this case, if at least one element returns null, the entire sequence will return null.