

It also allows for dynamic code such as variable variables, dynamic types, and so on, though care needs to be taken with these to avoid making your application difficult to test.

Debugging of runtime errors is made easier, because you can directly identify where they occur in the source code. There is less need to worry about garbage collection and memory use. It allows for shorter feedback cycles when developing – the results of changes to the code can be seen immediately without any compilation stage needing to be run first. Not needing to compile PHP can help with developer productivity in a few ways. The consequence of this is that performance is not as good as for compiled languages, but it also allows for features that compilable languages do not. PHP also has a share-nothing architecture, so on every request it interprets everything from fresh.

This means that it is not compiled to machine language but rather read at runtime. So why is PHP slow in comparison with some other languages? PHP is a dynamic, interpreted language. Thankfully, improvements in the speed of the language itself give us an improvement in these other areas for free. Trying to gain speed through profiling and optimising code can be a long and tedious process. For example, better caching, asynchronous processing and eventual consistency all help, but also make application code performance more important. So why worry about the speed of the language at all? Well, application architecture is improving and we are finding ways to avoid all those other bottlenecks. For example, communicating with databases, APIs, and message queues all take time. And in many applications the bottlenecks won't be in the application code instead, it's where interaction with other systems takes place. Developer productivity, for one thing, is usually more important. Pure speed of a language is rarely the main deciding factor for many projects.

PHP isn't the fastest language for writing web applications, yet we continue to do use it for many other reasons.
