PHP Classes

PHP Current State and Performance in 2023

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Current State and...   Post a comment Post a comment   See comments See comments (9)   Trackbacks (0)  

Author:

Updated on: 2023-06-14

Posted on: 2023-06-14

Categories: PHP Tutorials, PHP Performance, PHP opinions

PHP is a modern and powerful language, but new language elements should be used with caution.

Please read this article to learn a few facts about PHP's current state and performance level according to the experience of David Tamas (that's me), a long-time experienced PHP developer.




Loaded Article

In this article you will learn about:

1. The Current State of PHP

2. Where is the Problem

3. What about PHP 8 Performance

4. Your Opinion is Wanted

PHP 8 Performance and Current State in 2023

The PHP 8 logo exibited in the image above is based on the work of Vincent Pointier.

1. The Current State of PHP

It is a fundamental truth that every programming language must be handled in its place and used for what it is best suited for. The same goes for the other way around. We should use the most suitable language in every project for the given task.

Therefore, we should not want to develop desktop applications or artificial intelligence in PHP.

Of course, what languages we know is an important aspect here. Node.js and the ecosystems created with it ride on this problem.

At the same time, besides their many advantages, React, Vue, and other libraries often run into problems that would not even happen if we used a traditional development and language usage method. Maybe I will write about this another time.

The PHP 8 series of versions are miles better than the 5.6 version on the shelf for a long time. Its syntax and the repertoire of modern tools have also expanded enormously. I believe that PHP 8 is a stylish and contemporary script language in all respects.

2. Where is the Problem

Since PHP is a relatively easy language to learn, you can quickly imagine yourself as a senior developer who can also easily cope with the development of company management systems.

Unfortunately, this is not true. Many years of experience and knowledge are needed to produce secure and efficient PHP applications.

Unfortunately, junior developers who think more of themselves are the majority compared to professional PHP developers. Therefore, it is unsurprising that people with only a superficial knowledge of the language mostly form their opinions based on the majority and the codes produced by the majority.

3. What about PHP 8 Performance

Since the object orientation of PHP has improved a lot, it is no longer cool to write code that is not based on objects. But PHP still remains an interpreted script language. While in a statically typed and compiled language, the compiler performs various magic, PHP still interprets and executes the code file by file and line by line.

A good example of this is dead code elimination. Let me explain this in more detail.

I have a file on which I define the "DEBUG" constant, and then in a function in another file I write out a debug message (or not) according to the value of the constant.

In PHP, the condition checking based on the constant and the commands to be executed are also stored in the opcode cache. The condition is checked every time when I call the function.

In a statically compiled application, this would to dead code elimination because part of the code would never be executed. Of course, even in PHP, if the definition of the constant and the condition using it are in the same file, dead code elimination work in this case.

The same is true for objects, interfaces, and abstractions. It is very cool to sprinkle our code with them, however, as long as in a compiled language, these are only used by the interpreter for type checks, and then the compiler and the optimizer generate an optimal code from them, PHP opens the file containing the interface, interprets it, runs it, etc every time.

Let's look at a modern PHP framework, template engine or middleware. It is filled with files that contain only abstract or interface classes. A lot of resources and runtime are wasted trying to interpret them. While they often do not improve the readability of the code either.

Of course, I am not saying that they are unnecessary and that we neglect them completely. You just have to avoid their excessive and unnecessary use if you want fast and transparent code.

4. Your Opinion is Wanted

What is your opinion? Please write a comment!




You need to be a registered user or login to post a comment

1,609,645 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

3. Optimizing projects to keep only useful code - Manuel Lemos (2023-06-16 09:03)
Simplify your rameworks so they have a great future... - 2 replies
Read the whole comment and replies

1. Just-in-time compilation - Ramesh Narayan Jangid (2023-06-15 18:30)
Involves compilation during execution.... - 2 replies
Read the whole comment and replies

2. Wrong best practices - Anthony J Marston (2023-06-15 14:21)
Newby programmers are being taught the wrong best practices... - 2 replies
Read the whole comment and replies




  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Current State and...   Post a comment Post a comment   See comments See comments (9)   Trackbacks (0)