Learning to program is hard, really hard. Advanced programmers forget how hard it was for them to learn, and beginners aren’t often aware that the language they choose to program in has an effect on their learning. In this article, I’ll make the case that PHP is the best language to use when learning to program.
Quick Feedback Loop
As PHP is an interpreted language, such that its engine evaluates the code on every run with no compile, you can literally change the file and then run the code to see if the change has worked. Having this quick feedback loop is a major plus for learning a language. This is shared with other languages which are interpreted.
Being able to quickly see if code has worked or not is a massive benefit of PHP.
Super Easy to Set Up
Even way back in the 2000s, PHP was super easy to set up. That remains true today regardless of your operating system including: Windows, Mac, or Linux. Having a stack set up so that you can create a PHP website on your computer is effortless, even without having learnt docker or vagrant (although, I do highly recommend that programmers use one or the other).
XAMPP will allow people to create a PHP install locally, easily, and without any confusion.
Typing is how the programming language handles different data types. These include a series of letters and numbers (strings), numbers (integers, floats), and lists (arrays). Languages can be weakly typed, which was originally the case with PHP, whereby developers don’t need to pay attention to the data types in order to make things work. In addition, languages can also be strongly typed, whereby there will be an error if you use a string when you should have used an integer.
PHP offers both. This is beneficial for beginners as they can start out and ignore the different data types. This makes learning a language easier, as you don’t have to worry about a variable being “100” or 100 when dealing with the results from the browser. Then as the beginner progresses, they can learn all about the benefits of a strongly typed language.
In this way, beginners can progress from not caring about data types to understanding the benefits of different data types, all within the PHP ecosystem.
A while ago, PHP was missing a good deal of features including: namespaces, traits, and type hinting; however, those days are over.
PHP is now one of the most feature-rich languages on the market. To be fair, I haven’t looked into this properly; but, every time I use a different language there is nearly always a feature missing. I then find that the cool feature offered by this language has either been added to PHP or is about to be added to PHP.
When I was learning to program, I had to go from PHP, C, Python, Scalae, Go, to Kotlin, in order to learn how to use different features and their benefits to my code. With the development of the Core PHP, all of the features of these different languages are mostly available on PHP. The fact that you can use and learn about all of these features and benefits within the same programming language, shows why PHP is top notch.
In this way, PHP allows people to use the majority of programming features available without having to change their entire language and ecosystem.
One of the areas that PHP dominates compared to nearly every programming language is tooling.
This has allowed our company to take cool features from other areas and improve them. It has also enabled us to have not just one, but two top-end web frameworks in Laravel and Symfony. This really allows us to stand on the shoulders of giants.
Other installers include: Packagist which seems miles ahead of other package installers using different languages. This is especially the case now, as they have released a private Packagist option at packagist.com, which allows people to level up their package distribution. In comparison, Monolog allows you to create detailed logs which can provide you with all the information you need to understand your application’s outputs. Has anyone seen the Java logger outputs? I actually feel sad when I have to deal with them.
The list of options goes on and on, but overall I think the PHP ecosystem rocks.
Here is a summary of the reasons why I think PHP is one of the best, if not the best, programming language for beginners:
- Easy to set up.
- Quick feedback loop makes it easier to test code.
- You can start without knowledge of the different data types and progress in PHP.
- You can progress from ultra beginner’s code to high-end code all within PHP.
- PHP has amazing tooling which allows you to create cool things and improve them.