PHP Thoughts

As a programmer I have been using PHP for over 4 consecutive years. Sometimes PHP tends to be an unappreciated programming language due to the exaggerated freedom it offers.

That’s the sense I caught on from Anthony Ferrara’s speech on PHP[world] in 2015. It is really an amazing presentation by Anthony Ferrara. You can watch the presentation in the video below.

So, I made the decision to present you with some of the most important parts as far as I am concerned, giving my opinion as well.

Through this presentation you are able to get the concept, to realize and gain a better insight of the PHP.

 

PHP Does Not Discriminate

I am quite certain that there are many times you are in front of a monitor reading insulting comments about PHP. PHP sucks, is slow, promotes spaghetti code etc.

Anthony Ferrara chose to start his presentation by saying that entire websites are dedicated to what PHP does wrong. Nevertheless, PHP is victorious, he maintains.

In my opinion, the truth is somewhere in between. Maybe the above comments are true but it doesn’t mean that PHP is doing everything wrong.

PHP is a language without a significant difficulty level of curve learning. Not only does PHP give the freedom to everyone to choose what they want to do, but also how they are going to do it. PHP serves everyone, from the most uninitiated programmer to the most senior. PHP doesn’t discriminate.

The fact that 80% of websites is written in PHP confirms Anthony Ferrara’s opinion.

It is appropriate either for small websites or big ones. For example, Facebook is written in PHP.

PHP is Forgiving

PHP is so simple that is not mandatory to be aware of how classes works, functions or even what type of variable a function must return.

It forgives many mistakes by a programmer in opposition to other programming languages. It’s not required to declare a variable prior to use it. Is that right? NO, IT IS NOT.

The entire website is not going to stop working in case that there is a little error in code. The functionality just breaks a little bit.

To be honest, PHP is one of the most helpful programming languages for every uninitiated programmer so as to get his first steps without focusing on the quality of his code. Anyway, when someone is at the very beginning is not able to write a code with a good structure.

On the other hand, it matters for everyone to learn some things right from the beginning. For example, a variable must be declared before being used.

PHP Bends To Suit You

PHP doesn’t give one and only way to follow on how to write your code. It just empowers you to do it. You are able to do it in your own way.

You may want to follow procedural style. Go ahead. You may want to write your code with OOP technics, no problem at all. Functional style is not an exception.

The drawback in this case is that, even though, you are able to choose the way that you want to work, there are much more languages more strict that allow everyone to do it better and more efficiently than PHP.

I am going to do some lessons for every one of the above programming styles in the future.

The Effect

Its advantage is its drawback at the same time. What sets PHP apart from other languages is also its Achilles’ heel.

It is a fact that there are uncountable tutorials and HOWTOs on almost everything on PHP. You are almost able to build an entire website just by copy-pasting from around the internet with subtle changes.

All the above have the effect of a significantly large number of programmers being in a low level and writing very bad code, without using any good standard. It really turns the code into a gloomy and blur one. It is impossible to be read by anyone who wants to improve or supplement a new feature in the code. Debugging truly becomes a headache.

Actually, reading a piece of this code is a challenge. Undeclared variables bolt out from everywhere, nonsense function names, or even functions that exceeds 200 – 300 lines of code. Comments are non existent. Ohh!! What a nightmare.

This freedom and lack of restriction doesn’t urge programmers to write good code, maintainable, extended, and easy for everyone to see a bug and solve it without affecting the rest of functionalities.

That means if you use and develop your code carefully, it is not going to have negative consequences.

It really depends on how a programmer will choose to write his code and if he has the ability to build a correct structure of his code. This is applicable to all languages but more in PHP because it doesn’t offer you a certain way to write your code, But gives you all the tools and freedom to use it however you want.

With great power comes great responsibility.

PHP Driven By Contributors

PHP is driven only by contributors, and as Anthony Ferrara said, there is not any road map how exactly PHP is going to be developed in the future.

HHVM + PHP

HHVM is an open source virtual machine designed for executing code written in PHP and Hack. The VM is maintained by Facebook.

This is a positive fact for PHP and a big improvement. HHVM is generally faster than PHP7. Also it supports full PHP 5 and partially PHP 7.

You can find more details about HHVM here.

A Quick Intro For PHP 7

PHP 7 has a lot of changes from its predecessor. One of the major changes that seems very interesting and essential for me is that the developer has the ability to choose if he wants to declare what type of variable the function is going to return. This feature is offered to you as an optional and not as a compulsory.

And yes, it’s true that PHP 7 is much faster that PHP 5.

Conclusion

To sum up, PHP is a language that provides everyone even the most amateur programmer with the ability to write code and enhance his productivity. Simultaneously its freedom can be turned into something destructive if the developer doesn’t have the experience and wisdom to keep his code into a structural pattern.

Also PHP 7 has changed and become even better so as to help everyone to build a better code structure.