I am often asked why and sometimes criticized for my choice of PHP as my main Web development language and the fact that I do not spend time trying to learn, nor do I have much interest in learning other languages better. There are reasons why I have made these choices and I thought I would share them.
Built for the Web
Of all the possible programming and/or scripting languages there are for developing Web applications, there are only two that came about as a direct result of the Web and that were built specifically with the Web in mind. These two are PHP and ColdFusion. Everything else, as far as I am aware, had their roots outside the Web and have had functionality for the Web added later (sometimes with the use of a sledge hammer.) Since I am a developer whose main focus is on building applications for the Web I have to ask myself why wouldn’t I choose a platform to develop on that was designed specifically for what I’m doing. PHP does an excellent job at what it was designed for and, as of yet, they have not saw fit to try to hammer in functionality to make it anything more. PHP’s focus is the same as mine, the Web, and it does not dilute that focus by adding in the ability to develop applications that are not Web based.
Arrays are probably by far the main reason that I love PHP, but then again I love arrays. Many other languages make arrays and handling arrays a chore to be avoided. There are two main things that make arrays in PHP much easier to use.
- PHP is Untyped: What does that mean? It means that I can use a variable to hold any type of information that I want. I can put a string into a variable and later, if I choose, I can change the variable’s contents to a number. When it comes to arrays this means that one array can hold mixed information with some values being numbers and some values being strings and yet other values being any type of value that the language can use. Most other languages do not allow this freedom and require all data in an array to be of the same type. If you need to have an array that holds mixed types of data you must instead use multiple arrays, one for each type of data, or you need to store everything as a string and then convert it to the type of data you need each time you want to use it for something, if the language allows this conversion.
- Strings as Subscripts: In many programming languages array subscripts can only be numbers: 0, 1, 2, etc. So if I have an array of data I must remember what data I stored in what subscript. This may be good for simple, one dimensional arrays but if you start getting more complex then you need to keep a map to keep track of what’s going on and what data is stored where. On the other hand, PHP allows me to use strings as subscripts, so if I have data about a person I can use subscripts like: “first_name”, “last_name”, “address”. I no longer need to remember that I put a persons address in array X subscript 3, I can just use $X[‘address’]. If the data in an array that uses numbers as subscripts changes you may be talking about a large change in the way the application is built. With stings as subscripts there is very little that needs changing since I know that “first_name” will always hold the data I expect.
Arrays are one of those things in programming that make life as a programmer easier. I’ve spoken with developers that use other languages and most of the time they don’t particularly care for using them and find other more complicated ways of doing the job that needs to be done; they avoid them, some even hate them. I believe the main reason for this is that other languages have made them too complicated to use well.
You simply cannot beat the price.
- *Nix operating system: Free
- Apache Server: Free
- PHP: Free
- MySQL: Free
- Addons Required: None
Why focus on a single language?
The truth is that I do not focus on just a single language and I am not just a programmer. I’ve worked at places where everyone works in their own silo. The designer designs and (s)he has very little knowledge about HTML and CSS; The HTML/CSS guys/gals no very little about design and even less about programming; The programmers understand only the basics about HTML and CSS and may not know much about how to design a database and leave this up to the DB gurus.
While many of the things I’ve mentioned above are not programming languages, they are things that take considerable effort to understand and keep up with and I consider myself to be an expert in many of them and they do take a considerable amount of my time to keep up with. This time far exceeds the time that I spend at work actually performing my job. But then again, this is not just a job for me.
Programming is programming… Right?
I’ve heard this said by professors, and I’ve heard this said by non-programmers, but I’ve not heard many programmers say the same thing. “Programming is programming, only the syntax changes.” I personally think of this as a myth.
It is true, programming is programming. The logic involved is the same. However, as Yogi Berra said, “In theory, there is no difference between theory and practice. But in practice, there is.” Yes, that was a quote by a baseball player; however, it is just as applicable to programming as it is to baseball.
While the logic involved is the same, often times the syntax is so dissimilar that there is no way to equate one language with another. The steps involved in getting the same result to the same problem are often completely different. What makes sense in theory may not be practical, especially in the world of Web development. When building an application for the Web it not only needs to work and work well, it also needs to allow for rapid and easy changes in the future. This rapid, easy change comes from knowing everything there is to know about a single language and the only way to really know a language is to focus on it, to love it, to be devoted to it.
A note about frameworks