Why Learn Python? Because It’s FUN!

After leaving my job in a big american corporate, I spent some time thinking about how I want my next job to look like.
Browsing job description I came to a conclusion that I must learn a scripting language in order to find a job I like. Seems like most consumer web apps are written using some kind of scripting language. More structured languages like Java are used mainly in corporates (they are calling it Enterprise Java for a reason).
OK, so which scripting language to learn?
I looked for:

  1. A language that would help me find a job I like – it should be used in companies I find interesting
  2. A language that makes it easy to write consumer web applications – Java, for example, does not make it easy to write web applications. It is very good for writing code that interacts with other code but it’s verbosity makes it very hard to write code that interacts with humans
  3. It should be fun to use the language and it should have decent tools and libraries – IDE, web frameworks, etc.

Three very popular scripting languages are – Ruby, PHP and Python.
Javascript is another popular language and with the advent of node.js it can also be used for server side programming. But we’ll not look at Javascript since you must know javascript if you’re planning on doing any web programming anyway.
Ruby is very popular due to Ruby on Rails.
PHP is also very popular. A lot of very popular open source content management systems are written in PHP. Two very known examples are WordPress and Drupal. Facebook also uses PHP extensively.
Python is a little less popular for web applications. But I chose Python. Why? Read on to find out


The PHP Logo
Well, I tried PHP and didn’t enjoy it. It didn’t feel consistent. It didn’t have a small closed set of rules that I could learn and then apply in order to infer how to do stuff. This made me constantly refer to the documentation in order to find out how to do stuff.
PHP is so not structured that the IDE’s I tried were never able to truly understand my code. They kept on spewing lots of unnecessary warning and the auto-complete almost never worked.
The web frameworks I tested (CakePHP and Yii) used so much magic to do what they wanted that I found it really hard to understand what’s going on.
Eventually I felt that even though it was very easy to write web pages, it was very hard to write good reusable code in PHP and to implement meatier stuff.
Bye bye PHP!


The Ruby Logo
I admit I didn’t inspect Ruby very closely. I just felt that any web development in Ruby was very coupled with Ruby on Rails. It is so popular that it seems most people use Ruby in order to use Ruby on Rails. And I did not want to restrict myself to a single framework.
Bye bye Ruby!

Enter Python

Python is Fun – Image from xkcd.com

The Python LogoPython is a little less popular for writing web applications than PHP and Ruby.
If you search job descriptions you will find much more mentions for PHP and Ruby than Python.
So why did I choose Python? Because it’s FUN.
It was so much fun that I didn’t care whether it has the best web frameworks or that not many famous sites use it. I just enjoyed learning it and using it.
Python let me write code that is fun yet still simple. It has a small set of builtin commands and types that is very easy to understand and use. I found myself easily getting used to list comprehensions, writing decorators and using named function parameters. Powerful stuff that makes it so much easy to manipulate data and write readable, usable code.
After spending a couple of days learning the basics of Python, I was able to leave the manual and start programming. I am sure my code is not the most elegant but it is solid, simple and it was very easy to write it – I felt I’m really harvesting the benefits of using a dynamic scripting language instead of Java.
It seems that people that use Python not only use it, but love it. I can understand why.
So if you also want to learn Python I can recommend the following 2 books:

  • If you are new to programming I recommend the Learning Python book. It is very comprehensible and does not assume any prior programming knowledge. It explains Python and also basic programming concepts such as variables, loops, control structures, and so on. I found its pace too slow. But if you’re new to programming it has a nice learning curve
  • As an experienced programmer I found Dive Into Python to be a great book which jumps right into teaching the language using real world examples. And it’s also free!

JetBrains released a community edition of PyCharm, their Python IDE. I love IntelliJ. I think it’s the best IDE for Java and now that I’m using PyCharm I can say that it is also great for Python development.
After you get a good grasp of Python, you can quickly start writing web apps using the Flask framework. It’s got excellent documentation and tutorial.
If you want a more comprehensive framework (with MVC, ORM and other stuff built in) you can check out Django.
OK, so learn Python, check out the web frameworks and enjoy!
Here is a list of people smarter than me1 that feel that same about Python:

  1. False modesty. Nobody is smarter than me!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s