Why I use PHP
December 2nd, 2004I don't have many friends that use computer programming on a daily basis to solve problems.
I have one friend, that I don't see often enough, that writes software for handhelds to handle remote reporting of things like job information, hours spent working, etc. Many of his problems are similar in design to problems that I try to solve on a daily basis. Talking with him is always quite insightful as we've shared many of the same experiences independantly of one another.
I have one "another friend":http://livejournal.com/users/crackmonkey/ who writes large pieces of software to solve problems that are vastly different from the problems I solve. From the amount of data, to the acceptable processing time, to the hardware devoted to the tasks at hand, the the complexity of the business model, his problems are quite different than mine. And while I respect his knowledge and experience and always look up to him for advice regarding system design, application flow, and object handling, it's difficult to communicate directly with him because his world is so entirely different from mine. I imagine it's similar to a commercial airline pilot and a navy fighter pilot discussing the features they like best of the various planes they've flown. There are very few features in a plane that are going to make both pilots happy. So while they can see the benefit of the vehicles preferred by eachother, it would make very little sense for a fighter pilot to consider a 777 as his plane of choice, regardless of how many guns you attached to it.
While not really a "friend", I've always looked up to "Evan's":http://livejournal.com/users/evan/ thoughts on technology and programming, because, in a lot of ways, he thinks like I do. So I was a bit shocked and confused and doubtful of my own choices when I read his post asking people to "explain php to him":http://evan-tech.livejournal.com/85802.html. He states, "From all of my (small) exposures to the language I conclude [PHP] rates pretty near 'horrible'".
Now Evan has quite a different background than I do. I started with BASIC around age 6. In the 6th grade I learned C for a science fair project I did and then never used it again except when debugging someone elses code. Then I moved on to dBase, then Clipper. I learned Pascal next, being forced to by my highschool. Next came a brief introduction to Perl, which I found quite powerful but hated the vagueness and unreadbale nature of the language. Soon I tought myself HTMLScript/Miva and enjoyed working with it despite its odd behavior and complexities. I learn a bit of ColdFusion, which I couldn't stand, and then went back to Perl for a few years. Then I found PHP.
For the kind of work I did, PHP just made sense. As my programming experience grew and the problems I tried to solve got more and more difficult, the way that I programmed changed drastically. In the beginning I loved the embedded nature of PHP, but learned to loathe it as time went on. Today, I use that feature of the language only when prototyping something quickly, and even then, it happens rarely. At first, I used PHP only for web stuffs. If I needed a command line or server based tool for something, I switched back to Perl. Today, however, PHP has taken over these functions as well.
Sure there are things about PHP that are less than desirable. There are things I wish it did, things I wish it had, and things I wish that it didn't do. It has it's own set of quirks and curiosities. But I've never found a *useful* language that didn't.
I've looked around a bit, now and then, at other languages since PHP. I've played with Java a bit, but couldn't get past the complexity and the requirements involved in doing simple things. Dealing with the memory and CPU requirements of the VM made it taste even worse. And, aside from a handful of very useful tools that weren't yet available to the PHP world, there was very little that I could see that using it would do for me that I wouldn't get out of PHP. Now, I'm not saying it doesn't have it's advantages. But, for what I do, very few of it's advantages made me jump and say "Wow! I could really use that. That would make solving problems a lot easier." So, my thought process has always been that using Java isn't worth the complexity involved in getting a working environment, the reduced usability (as PHP is just about *everywhere* in the server market and easily added on the client side while Java just isn't), and the hardware requirements to make things work. Having to compile code just adds another step in the process that I don't need to deal with. And, of course, even if I were willing to deal with all of those things, I still have to learn the language. The benefits just don't seem to outweight the costs.
I've also looked at Python. I like Python a lot. I used Python for a few unimportant tasks, just to help me get into it more. While I don't find it to be as readable as PHP, that's most likely due to my inexperience in the language. I'm sure that, with more time spent in it, it would grow on me. It's not nearly as available as PHP, but, it's available enough that I wouldn't let that stop me from using it if it offered an advantage over what I'm using today. From what I've seen of it, it offers quite a few advantages. First and foremost, the culture behind it is great. It has many users that solve problems similar to my problems. It allows me to think in ways that I am used to thinking in, and it has a large set of tools available to it the seems to grow daily. At this point, if I were to stop using PHP, it would be for Python. But, there are a lot of things about Python that seem unnatural to me. PHP was so easy to understand and grasp, line by line, what was going on. Even before I had a good working knowledge of the language. This was one of the things that drew me to it. Yet, there are chunks of Python code that I've seen several times and *still* don't understand exactly what's going on. Again, this is merely an inexperience thing, but, my philosophy right now is, if it's going to take that much work just to get me to a point where I can *read* pYthon, and I've yet to see a clear advantage to using it over PHP, then what's the point of switching and giving up all of the tools and constructs that I am already quite familiar with today.
I've also breifly looked at a few other languages, but not enough to really comment on them.
It's not that I'm unwilling to change. In fact, I'm pretty open to doing so as there are plenty of things about PHP that turn me off (the culture, being the biggest of them all). I just haven't seen anything *worth* changing to.
So I ask you these two questions:
1) What's so horrible about PHP? Is it too slow? Is the language too crufty? Does it not support functionality that you need to solve your provlems? Does it leave you trapped in a world that doesn't allow you to solve problems as easily as you can in another language?
2) What language would you recommend? Is there something about Java or Python that I'm seriously overlooking that would make it worth the effort? Is there another language (Ruby, perhaps?) that would suit me better, offer me the same flexibility I have today, give me new concepts and ideas that will make solving problems easier, and offer me less cruft and odd behavior than I see in my current environment?
I'm not asking so I can simply shoot your proposals down like a lot of PHP proponets do. I'm asking because I genuinely want to know. Any well thought responses will be considered. If you need any more information from me in order to help make my choices clearer, please ask.


















