Why I learned Python

April 7 - 2017

About eleven years ago, after finishing my first semester in University I decided to learn how to program in Python. In this post I will talk about why I found Python interesting at the time as well as how it felt to me as someone with little programming knowledge.

Why Python

My first programming language was Java. I could not really compare it with anything else, as it was the only programming language I had worked with, but I was happy with it as the code I wrote felt clear and there were IDEs such as Eclipse that really aided my learning process. At the time I had also done the switch to Linux and saw that a great deal of programs and tools I was using were written in Python. This caught my attention as it seemed that this language hitherto unknown to me was rather popular and from what some people said at the time pretty powerful and easy to learn.

It wasn’t until I saw a post on Planet Ubuntu that showed a very simple Python script that I decided to learn Python. This script would, given a directory, go through all MP3 files (including those in subdirectories), open them and read the ID3 data. While this program was not particularly useful for me, what really caught my attention was how short and clear it was. I had never seen Python code before, but I could pretty much understand everything that was happening.

That’s when I decided that Python would be the next programming language I would learn.

Learning Python

I decided I was going to start by reading a book about Python. I settled for Dive into Python as it was (and still is) free. I really liked the book, it was clear and went straight to the point so I was doing small Python scripts in no time. Another book generally considered to be excellent is Learn Python The Hard Way. The Hitchhiker’s Guide to Python is also an amazing resource that covers a lot of common topics, not just for beginners but also for people that already know the language.

What I did not like about Python

Coming from a statically typed language like Java, what was hardest for me was not having static type checking. It was tough at first and I kept getting errors left and right probably due to the fact that I was so used to having an IDE check everything for me automatically. I also fell victim to a few of the common Python pitfalls new programmers come across, such as mixing spaces with tabs or forgetting to use global when changing a module level variable form within a function. These are all things you get quickly used to, and a lot can be avoided by using something like PyChecker or Pyflakes.

What I loved about Python

The nice things Python provides far outweighed any issues I may have had. Again, coming from Java, list comprehensions and the way iterables worked with for loops was mind blowing to me as so much boilerplate code could be avoided. I was also blown away by how easily generic code could be written by using *args and **kwargs. Python’s power also comes from it’s comprehensive standard library as well as the vast amount of third party libraries available, if you can think of anything it’s probably already available for you. Finally, I found Python to be an incredibly fast language to prototype or program quick proofs of concept in.

For almost five years now I have been programming in Python full time at work and I couldn’t be happier with it, so I think deciding to learn Python all those years ago really payed off. If somebody asked me whether Python was a good language to learn, the answer would be a definite yes.