I recently received the email below. At the risk of starting a flame war, I'm posting my response here.

Hi Matthew,

Sorry to bug you, but I was reading your blog and was hoping you could help me with some advice. I am new to programming and can't quiet make up my mind on which programming language to start with? I started learning php, but have also looked at a bit of java.

I am interested in building web based applications that and am wondering whether I should focus on php, java or python? I have recently read a fair bit about python and some exciting things happening using python. Python seems like an easy , fast and powerful language to use.

Do you have any advice or thoughts on the pros and cons of these 3 languages and what might be the best to start with?

Thanks for your help- and the great blog!!

My response:

Hey Sean-

PHP, Java and Python are all good languages and each has it's strengths and weaknesses.

For web development, php is going to be the easiest to start out with since it was designed for creating websites. However that easiness is going to be lost once you start trying to do more complicated things and inevitably your code will probably turn out quite messy. Lack of support for classes and name spaces for older versions of php tend to aid people in programming sloppily. On the other hand there are a ton of great applications written in php (drupal, mediawiki, sugarcrm, etc), so it is possible to use. If for example your website was based on drupal, you could get a lot of functionality out of the box, and only have to write a small amount of code for missing functionality.

Java has a few things going for it, a big company with marketing dollars and great tools. However the reason it needs good tools/IDEs is because the there is so much syntax that you really want the computer to write all that code overhead for you rather than your fingers. If you are going down the java route make sure to use an IDE like eclipse since it will make your life much easier. I've done a bit of struts programming in my day, and actually don't miss it so much. There's a lot of overhead involved with configuration files that you don't find in php, but that tends to help larger teams coordinate their efforts better. Since moving away from java, I'm not sure what the MVC stack de jour consists of, likely it will include spring and hibernate, as well as other packages.

I'm sure you realized that reading my blog I'm going to favor python. Python is a multiparadigmatic language, so one can program in an object oriented, functional or imperative style. The advantage of this is that there are cases where objects are overkill and get in the way. Sometimes functional constructs just make sense for dealing with some data structures, while an imperative style like C is often the most straightforward solution. Python lets you mix and match that, so with that flexibility also comes power and the ability to program in a way that suites your style. Java is strictly object oriented and PHP until recent versions was imperative with poor support for objects.

Setting up an web development environment is relatively straightforward in python. Both of the web development frameworks I would recommend in python, Django and Pylons, come with built in servers so you can get up and running pretty easy. In java land, struts setup to start a project was a major hassle, but new frameworks might have simplified this. In the php world, one needs to install apache and php, which may or may not be so easy (xampp can help here).

For python development I use emacs, but if you are an IDE type person there are plugins for eclipse, or IDE's such as wing or komodo that have pretty good python support.

I've known quite a few php/java heads who upon learning python haven't looked back. I don't know of any who have gone the other way. Though the lack of static typing/IDE support has proved to be an annoyance to some java developers who have grown accustomed to the niceties of eclipse (code completion, refacoring, error marking).

As far as the Django or Pylons question, Django is probably the best bet for you if you are learning to develop web apps. It has great documentation (plus a good book, that has a free online version), and a great community. It's nearly ideal for greenfield applications, and the admin app is really cool for adding/editing your web models. Django gives you everything you need out of the box.

Pylons on the other hand let's one pick and choose which components to use, rather than forcing one on you. Though the recommended defaults are pretty good. I'm currently using Pylons at work because I have to tie into an existing database, which SQLAlchemy supports wonderfully (and the django ORM just plain wouldn't work with it). So while Pylons gives one the power of choice, that also has an effect on documentation and other factors that make Pylons not quite as integrated overall as Django.

Hope that this (biased) answer helps to bring one more python programmer into the world.