Why PHP might just have saved itself, but is it in time?
Nowadays the popular opinion is to dislike PHP as a programming language. This is mainly because of itās past. Despite this hate itās by FAR the most used language out there for developing the web.
So whatās the problem people have with it and why might this not be as big of a deal as the angry bloggers of the world want to make you believe.
Hate from the past
PHP as we know it today is a far successor of a hobby project by Rasmus Lerdorf. Back in 1994 Rusmus was building his personal site in C, and he was in need for toolkit to make coding his website easier and more swift. Therefore he started building a toolkit which he called PHP/FI. One year after starting this toolkit he released the code as an oupen source toolkit. It looked something like this:
<!--include /text/header.html-->
<!--getenv HTTP_USER_AGENT-->
<!--ifsubstr $exec_result Mozilla-->
Hey, you are using Netscape!<p>
<!--endif-->
<!--sql database select * from table where user='$username'-->
<!--ifless $numentries 1-->
Sorry, that record does not exist<p>
<!--endif exit-->
Welcome <!--$user-->!<p>
You have <!--$index:0--> credits left in your account.<p>
<!--include /text/footer.html-->
Itās far from what weāre used to today. But hey, weāve got to start somewhere right?
From here PHP knows a steady- yet at times a bit turbulent history. Led by people as Andi Gutmans and Zeev Suraski (aka Zend; this might ring a bell for some).
I really donāt like programming. I built this tool to program less so that I could simply reuse code ā¦ I donāt know how to stop it, there was never any intention to write a programming language [ā¦]. I donāt know how to write a programming language at all, I just kept adding the next logical step. ā Rasmus Lerdorf
Inconsistent and questionable design
Probably most of the criticism which I -letās by honest- share to some extend is the fact how the language is not typed. From insiders thereās also a lot of criticism on the naming inconsitency of functions and classes. Part of this is what might make the language somewhat unpredictable at times.
If youāre looking for a good old bash at PHP, thereās probably nobody on the internet who burned it more than this guy. Or maybe this one, you pick.
PHP produces bad code
One of the most heard comments about PHP is that it produces bad code. How can a language on itās own produce bad code? And is this really true?
Is it possible that PHP is just used A LOT (over 80% of all web development) and that itās for a lot people the first language they learn?
Since PHP is used a lot, itās also a very accessible language for people who just get started. The freedom the language gives because of itās lack of type safety and restrictions really helps here.
If PHP would produce bad code would companies like Facebook, Yahoo, Wikipedia Flickr, etc. be trusting on it for their platforms?
Like with on any other language, you have to make it work.
Is PHP dying?
For over a decade people have been saying PHP is going to die and yet itās still at the top of the ranks. Yes thereās some new kids on the block, but theyāre nowhere near throne of PHP and neither will they anywhere in the near future. Will it be on the throne forever? Thatās a good question.
Whatās next for PHP
PHP keeps evolving, primarly fixing the major criticism on it not being type safe. Starting from the later PHP 7 versions, and building on this in PHP8 type safety is really taken on the next level by PHP. Iām personally really hyped about the latest PHP versions as I believe it really may secure theyāre spot in the market for the years to come. Will they make it another decade on the throne? Iām not too sure, but PHP is definitely not about to leave anytime soon.
Ps. PHP8.1 has some great stuff coming up too. Check it out here.