For the past couple of months I’ve been immersing myself in a new role at a new (to me) organization. There are a whole lot of new ideas to explore along with the well-known domains that I enjoy working in. One of the bigger new areas to learn is the language stack, which in this case consists of Python and Django. One of the harder parts about coming into a new language stack is being able to tell the language from the framework, at least in my opinion. Some would argue you should treat the pairing as a cohesive unit and not worry about the distinction, but I think that’s wrong. If you look at the two as inseparable you’ll find yourself wearing blinders when it comes to taking a fresh look at things. There may be justification for intentionally working outside the framework on occasion, for example. There may even be justification for using a different framework in some cases, or even wholesale replacing either the language or the framework in use. Would you insist on replacing the tires on your car with the exact same brand when the originals wore out? Only if they served you well, and if you expected to be driving in similar conditions for the next few years. If you were driving on performance tires and decided to move to Alberta you might opt for something different, though. Not that I’m advocating for any such change in my current environment, I’m just making the case that its important to separate the language from the framework in order to more fully understand all your options.
So I’ve done some work in Django recently, but have been more focused on learning some of the finer points of Python. Not just the syntax of the language itself, but the internals of how it works and handles things like memory management and threading. I’m really enjoying exploring this new language so far, because despite the fact that the syntax is very simple it takes a different way of thinking to do things the Python way. It’s pretty easy to take some complex code you’ve written in another language (likely C++ or Objective-C in my case; possibly Java if I was feeling lazy) and port it to Python, but if you only do that much you’re missing the point, and likely writing some horribly inefficient code even if you’d spent a great deal of time optimizing your algorithms for one of those other languages. To write efficient Python you need to understand the language constructs and the way things are handled internally. You want to let the built-in facilities do as much of the work as possible, because let’s face it, Python is interpreted and won’t be running a race with compiled C++ any time soon if all you do is a straight port. Taking advantage of built-in functionality, much of which is coded in C, is going to make a tremendous difference. In order to use that functionality you have to wrap your head around the new paradigms, and that’s where the fun lies. A different way of thinking! It’s been a long time since I worked with a language for anything more than a toy project that forced me to think in a different way. After almost 30 years of doing this sort of thing (20-something years professionally), that’s pretty refreshing and unexpected. As they say in Python circles, programming really can be fun again!
So what is “import antigravity” all about anyway? Fire up your handy Python interpreter, type it in, and get yourself a good laugh! Or if you don’t know how to do any of that, just type “Python” into Google and teach yourself. If you’re an experienced coder, get ready to enjoy the experience. And if you’ve never written a line of code in your life, stick with it a bit and I think you’ll find that you can have more fun and get more done with Python than that time you tried to learn some C and walked away with a bump on your forehead from hitting your head on the desk repeatedly. For starters, take a look at Learn Python the Hard Way or Google’s Python class. Once you’ve learned a thing or two and want to dive into some real code (you don’t need to understand it all at first, don’t worry) just poke around the Python projects on Google Code or Python projects on GitHub to learn some tricks and secrets.
One of my next big projects might be to try to teach my 9-year-old to code in Python. She’s actually expressed some interest, and there’s even a book out there specifically for teaching kids to program in Python. Hmmm, on second thought, maybe I should write my own. Or perhaps one project at a time is enough for now…