When in the course of human events it becomes necessary for web developers to dissolve the programming bands which have connected them with another and to assume the powers of another framework, the resulting declaration of independence from the tyranny of a single platform can be downright liberating. At the very least, it doesn’t hurt to learn another set of tools.
As opposed to that of someone who went through a traditional, four-year undergraduate curriculum in computer science, my path to programming proficiency has been somewhat more circuitous — I meddled with Java in high school, flirted with C++ altogether too briefly in college, and didn’t really get cooking till I played with Python in my first job out of grad school at a startup in 3D printing (where I also revisited C++ for the purposes of programming open-source microcontroller breakout boards). When things started to click, it felt like cheating: interfaces at the intersection of software and hardware made controlling blinkenlights and melting plastic easy as scripting a few lines of code. The me of yesteryear was mad he didn’t know this kinda wizardry back then; it would have saved him hours of soldering analog circuitry together in the hopes of building a radio that would work or a homebrew telephone that could dial his friends (on that note, manual pulse dialing was fun and all, but the ring signal from incoming calls quite literally came as a shock).
All this is to say that I kind of fell in love with Python, preferring it to all the other programming languages, so when I enrolled in an immersive software engineering course, I was a little disappointed that we wouldn’t even touch it. Disappointment quickly gave way to excitement, though, as the new language of instruction, Ruby, proved to be perfectly capable, and the adjustment wasn’t bad at all — Ruby doesn’t totally forgo brackets, and Python’s a little more persnickety when it comes to proper indentation, but by and large their syntax is similar. Moreover, Ruby’s Rails framework was literally made for the web, and building websites in it is a delight. Its conventions closely follow RESTful principles and the MVC paradigm, and considering the long period of popularity it’s enjoyed, it’s very well supported and continues to be at (or close to) the bleeding edge of web development.
Still, a good programmer — or a versatile one, at least — isn’t afraid to try a few new things, and now that I know a thing or two about what it takes to build up a back end, it wouldn’t hurt to try the same with Django, the popular web framework for that other language that I know and love, Python.
What’s the difference, then, between Ruby and Python, between Rails and Django? The frameworks are about as old as one another, having both initially been deployed a dozen years ago, but Rails eclipsed Django for a while, there, while the latter was playing catch-up. Nowadays, however, Django is pretty capable, and data nerds and hardware enthusiasts alike tend to prefer Python. There are untold volumes of Python libraries for the Raspberry Pi, the darling of the DIY robotics world, and e.g. the City of New York uses the language to mine data to improve the distribution of resources to its citizens.
Another difference to note is Django’s slight deviation from the MVC model; it instead uses a model-template-view (MTV) framework. Its model does all the heavy lifting that its corresponding component in Rails does and then some: it also defines database migrations. (This arguably results in DRYer code, as the model’s attributes are defined in the same place as its methods and relations and thus not repeated.) The view in Django is responsible for deciding not how data is displayed — that’s the template’s job — but rather which data is displayed. (It also — gasp! — plays the part of the controller, deciding where to route incoming HTTP requests.)
I will say sticking my toe in and trying out a tutorial, etc. has been great and all, but I’m looking forward to diving into the deep end of Django in a blog post to come, and I hope you are, too. Think robots. Think of the web interfaces that will automate our collective future. Think toasters — toasters you control from your phone! In space. Maybe. This is only just the beginning…