For the past month or so, I’ve been having another go at learning Python, partly prompted by the fact that Sublime Text editor plugins are written in Python. My first attempt was probably about 14 years ago. I had some (self-taught) programming experience with BASIC, Arachnid and Pascal, but hadn’t encountered an object-oriented language before. At the time, I managed to learn the basics, but never really got to grips with object-orientation, and so I was consequently not getting the most out of the language. It also felt — and this is tricky to explain precisely — uncomfortable somehow. Like wearing ill-fitting clothes, Python just didn’t quite sit right on me for some reason. One aspect was the semantic role of whitespace, but I’m not sure it was just that.
Since then I’ve become an enthusiastic learner of programming languages for the sheer hell of it. Soon after my attempt at learning Python, I tried Perl, then I picked up the then new-and-shiny Ruby and something just clicked. Ruby is a lovely language1, and it has a nice implementation of object orientation, but I suspect that it was as much the fact that I must have reached some threshold of understanding after trying to learn the same kinds of concepts implemented in slightly different ways. At any rate, I reached a reasonable level of competence and comfort with Ruby: I’m by no means an expert, and I still have to look things up a lot, but I can cobble together simple and functional Ruby code without too much trouble.
I suspect that it is partly this general increase in programming experience that has made my return visit to Python-land much more successful and rewarding than the first. Concepts that seemed impossibly difficult before now seem much more tractable or even familiar, and when I come across a new construction or piece of syntax, I can relate it to what I already know in other languages. Oddly, the semantic use of whitespace no longer bothers me. In fact, not having to close a loop or function with an
end statement feels nicely efficient, and the required indentation makes it easier to see where you are jumping between different levels of nesting. If you use a Python-aware text editor, it handles the indentation for you anyway. Python is older than Ruby and is a very mature language with an extensive ecosystem of useful libraries and so on. I’ve also found that Python libraries (and Python in general) tends to be very well documented, which makes life easier when you are learning. There are still some things that I find easier and more elegant to implement in Ruby, but I am enjoying my Python programming, and I have been putting together little scripts and starting to build some small web applications for personal use (Flask is brilliant). I’m also really enjoying tinkering around with Pythonista, which is an iOS app that lets you write and run Python scripts on the iPhone or iPad. Federico Viticci wrote an excellent and very detailed review explaining the power of Pythonista that you should definitely read if you are curious. I still marvel at the fact that I can write short and fairly simple scripts on my telephone and make things like games or virtual pianos. In fact, it’s the same sort of feeling I got when I first found out I could control a white line on my TV3 and use it to bounce a white dot across the screen, or when my brother and I laboriously typed BASIC on the dead flesh keyboard of the Spectrum and made the TV flash seizure-inducing colours. It’s the future, it’s exciting, and it makes you feel powerful.
And it may be shallow to say it, but it looks pretty too. Those
__init__magic objects, ugh. ↩︎
I am certainly not a natural mathematician, unfortunately. ↩︎
Technically, my godmother’s TV: we never got Pong, much to my disappointment. ↩︎