Reponse to Mike Kimsal (Java vs. PHP)

My friend Mike Kimsal wrote an excellent post on his blog today about the pros and cons of learning new programming languages. It inspired me to leave the following reply, which I decided to post here.

I’m not sure if I’m the friend you were referring to who was “forced” to move from Java to PHP and is now loving it (paraphrasing), but that is sort of my situation. PHP (or perhaps more accurately, the entire LAMP stack) is now the 3rd web dev stack I’m working with, having started out with Objective-C and Apple’s WebObjects (which spoiled me for everything since), then moving to J2EE. All of these environments have their pro’s and con’s. In my case, learning these new languages was literally a matter of survival. I have a few “die hard” friends who refused to acknowledge that Obj-C/WebObjects was dying, who are now struggling to make a living writing apps for the Mac and iPhone. I’m also starting to see the writing on the wall for J2EE. Certainly one can still make a good living with Java, but fewer and fewer new projects are using it. Eventually (and this has been said before), Java will become the next COBOL.

PHP is popular among web developers in part, I think, because of its similarity to Javascript, both in terms of the “dynamic” nature and even the syntax itself which is pretty similar. Many Web developers seem to be allergic to compilers, whereas I am still a big fan of them, as long as they are lightning fast and rock solid (which has been the case with Java for some time now).

In terms of productivity, I have come to realize that with PHP you are trading off speed for maintainability. It’s very easy to build things quickly with PHP, but fixing bugs and maintaining the code is very hard, because the dynamic, loose typing means the IDE and compiler cannot help you navigate the code or automatically find problems in it. For example, there is no easy way to definitively find all usages a given PHP method, even with PHP5 and the latest IDE’s. The fact that you can define new variables on the fly means you can easily create bugs like the following:
This medicament cipla india viagra is exceptional to all men on account of its structure, Kamagra Oral Jelly is ingested rapidly without creating aggravation of the digestive nutritious waterway, which was the primary detriment of “standard” Kamagra. Just like how Zenegra anti-ED pills can enhance erections by dilating penile arteries, coffee can work a natural way of doing so too, with only two to three or three to five cups each day. robertrobb.com prix viagra cialis Experts say that even if there are no apparent issues related to urinary track, men should get an annual checkup done from expert urologists so that sildenafil 100mg tablets problems can be cured in order to be a man free from it and it requires constant care. Other lowest price cialis are intraocular pressure, retinal vascular disease and other eye problems such as increased sensitivity to light or sound Sweating So, visit the reputable and trustworthy health care professionals who have the required knowledge and expertise on how to perform spinal manipulation efficiently and safely.
$user->getEmployee($id);

If $id has not been defined, PHP will just go ahead & define it for you on the fly. In Java, this statement wouldn’t even compile if $id hasn’t been defined yet.

So PHP requires more cognitive overhead while you are writing the code as well. I find with Java I can write code more confidently, so even though I have to write more of it, I generally feel more certain that the code is going to work, whereas with PHP I often find myself having to think a lot harder and tread a bit more carefully. Surely that’s just lack of familiarity to some extent, but I do think the languages themselves have some strengths & weaknesses. Basically I think PHP is great for new “startup” projects that may have a short shelf-life, whereas Java is better for very complex projects that are going to be around for a very long time.

Leave a Reply

Your email address will not be published. Required fields are marked *