My first programming crush was AmigaBASIC, it opened up a new world! Soon, I started going out with QuickBASIC and soon dumped QuickBasic for Visual Basic. We did wonderful things and amazed a lot of people. However, in collage I met C++ and realized what I had been missing with Visual Basic. I needed a more serious and meaningful relationship. C++ gave me that and made me into the programmer I am.

After collage, when it was time to settle, It was Java with which I started a serious and steady relationship. I took my time to get to know it inside and out. It was a relationship build on respect and dedication. We created big complicated systems and solved a lot of complex problem on Wall Street. It started becoming a part of my identity. We were becoming inseparable, that is, until I met Python.

When I first met Python, I wasn’t impressed. How can I respect a language which isn’t even compiled and doesn’t even declare types on its variables. Indentation as syntax was a bit interesting. I didn’t get what the big deal was? Why was everyone going nuts over it. I ignored it and enjoyed my life with Java. We were destined to live happily ever after.

Living happily required me to switch my job. I found an excellent one to switch to with two caveats. I loose 1 week of payed vacation and I have to work with Python for more than 50% of my time. However, I was going to get a lot more money, so loss in vacation was worth it and there is no harm in occasional Python tinkering to customize behavior. The company’s most important in-house solution were still written in Java.

Now, after almost 3 years after the switch, I’m in love with Python. I still love Java but I find myself looking for excuses to write any new system in Python. Most of the systems that I’ve developed professionally in the last 3 years have been a Java/Python hybrid. My manager loves the reliability of Java as a web platform. Hence, its almost a standard practice to create the webapp using Java/Spring MVC hosted on Tomcat. However, any business logic processing is delegated to a Python script. I am currently trying to convince my manager to let me write a new project entirely in Python using the Flask framework.

I’m surprised how quickly my sentiments switched on Python. However, once I thought about in detail, it seemed inevitable. The most important aspect is the fact that I didn’t really have to give up on anything that I loved about Java when I switched to Python. I only gained. My life with Java. We were destined to live happily ever after.

Nonetheless, here are the things that made me love Python

Things To Love About Python For Java Developers

Object Oriented Goodness

What I loved about Java was it’s strong Object Oriented principles. Everything had to be an object and hence you were forced to think in object oriented way. Object oriented-ness is almost a religion in Java.

Although not strongly enforced in Python, one can still be as Objected Oriented as they want. This is what I meant when I said I did not have to give up most of the things I loved about Java. In fact, Python takes object oriented-ness to another level, where things like modules and functions are also formal objects in the language.

Hence, 95% of the Python code that I write is all Object Oriented. I get object oriented-ness plus all of the benefits mentioned below.

Write Once, Run Everywhere

This is another aspect that I didn’t have to give up on when switching from Java to Python. Python runtimes are available on almost all platforms including my Android phone! The “Run Everywhere” aspects becomes even easier with the fact that one doesn’t really have to compile the code. However, it just doesn’t stop here, you also get a few more interesting capabilities.

With the CPython based runtime, it is possible to actually compile the code down to a more native level to increase execution speed and make it easier to deploy to other machines as a single package, without having to install the python distribution.

Its easy to integrate your pure Python based library with .Net using IronPython. The same can be done for Java using Jython. This give a whole new meaning to write once, run everywhere.

Interactive Shell

The interactive shell is useful for trying out things without having to write a whole program first. Sometimes, in the middle of development, my Python module is not in a runnable state. In such cases, the interactive shell is extremely useful to try various things out without having to spend time to get your program in a runnable state. It’s also useful for debugging to execute things line-by-line and see how things unfold.

You can use IPython to combine the power of an interactive shell with the power of an IDE. It has feature such as syntax highlighting & tab based auto-complete. This makes Python a really powerful interactive computing tool.

Less Verbose Code

I love the tersness of the Python language. The language constructs themselves are compact and so are the standard naming convensions. This makes the same code in Python much less verbose than when written in Java. I like how I can provide custom implementations of common operators for my objects. I think it makes code much more readable vs Java where you have to use functions like equals and compareTo etc.

The rich standard library, with a simple API also helps to keep the verbosity down. The following activities can be performed in Python with a fraction of the code needed in Java.

  • File and text processing, especially csv.
  • Working with regular expressions.
  • Manipulating lists, dictionaries and sets.
  • Working with XML and JSON data.
  • Even database communication looks trivial.

Indentation as syntax

This is something which I’ve always liked about Python. I’ve always valued readability of code and have always felt that the need to format your code properly can never be overstated. With Python, unlike Java, a developer simply cannot be lazy about it. If the code is not indented properly, it doesn’t run. I like that very much.

It also discourages you from writing really long code in if clauses and for loops. If they start getting long where you start loosing track of meaningful indentation, then maybe you should work on better modularization of your code.

There are things that I do miss though, but that would a topic best left for its own post!