I am asked almost daily what programming language new coders should start with and I get a lot of flak from some folks for saying I think most people should start with PHP. I have a few reasons I think PHP should be a first language.
The first argument is simply a reminder that you should learn more than one programming language, and even if PHP is your first you don’t have to stick with it. Many coders act as if a programming language is like a wife, and you can only pick one. The reality is that you can learn PHP, and if you don’t like it you can move on and find a language that you prefer.
The main thing I like about PHP is that it is simple to learn. PHP was not originally developed for “real” coders, it was created so regular people could manipulate data. What this means is that you can create an awful mess of code that still works remarkably well. Many professionals argue this means that people who start with PHP will learn horrible coding practices, but I would argue it’s better to have new coders be able to play with something that works instead of spending weeks learning basic syntax. The faster a new person can create code they can show off the more likely it is they will keep coding and hopefully learn best practices along the way.
Beyond PHP being easy the great thing about it is that you really can make functional web apps quickly. You can pick up a PHP for Beginners book and be making something useful by the end of the day. Creating simple apps to collect user information, or send out email blasts is something that many people want to do. With many other languages you spend a long time writing code to print our arrays and such which simply isn’t that fun. Again I argue that keeping new coders motivated is a huge task and PHP allows them to feel as if they are building vs simply completing stupid workbook assignments.
Additionally PHP has been used to build so many web apps that new coders can look and play with other people’s code. Wordpress, Drupal, Joomla and countless other platforms that are used by millions of people everyday are written in PHP. Knowing how PHP works allows new coders to be able hack apps that have already been built and get a better idea of how they work. Additionally with the prevalence of WordPress knowing how to make simple modifications is a genuinely useful skill.
My final argument is the fact that knowing PHP can get coders paid. PHP is used in the real world and development shops are looking for PHP coders. Learning PHP isn’t just a tool to allow you to learn another language to get you a job, but rather it can get you a job itself. I know in the Baltimore area intern level PHP coders start at $40K per year which isn’t bad as a first gig.
These are my arguments for learning PHP as your first language. As I say, the great thing about PHP is you can learn it in 1-2 weeks, and if you don’t like it you can move on. You don’t have to buy a special computer to be able to build PHP apps, or learn complicated IDE’s. You can simply write some code in Notepad and then either upload it to a web server, or run it on XAMPP. PHP teaches you about variables, loops, if/else statements, functions and input/output without browbeating over being “perfect”.
T0 begin learning PHP you can checkout the track on CodeAcademy: http://www.codecademy.com/en/tracks/php