First Impressions of Python

I recently began working with the Python programming language. Python has been on my to-learn list for at least a year, but without a project to use as a vehicle (or enough free time to justify inventing one) I didn’t get around to it. Luckily, one of my tasks at work last week was to prototype a websockets server for an app we’re working on. I started with Ratchet because we typically use PHP for server-side work and Ratchet looked like the best of the PHP websockets frameworks. And it worked, up to the point when I began implementing a session validation handshake between the client, the websockets server and our REST API, which manages user authentication on a separate server.

PHP has been the target of a lot of justifiable criticism of late, but one of its weak points that doesn’t get as much attention is its synchronous design. Want to make an asynchronous request to another server and get the response in a callback? Good luck with that. Sure, you can recompile PHP with ZTS enabled and try to get pthreads running, but that’s the kind of long and painful process that should make you reconsider whether you’ve chosen the right tool for the job. It didn’t take long to come to the conclusion that PHP was a bad choice. Each synchronous request from the websockets server to the REST API blocked all other activity on the websockets server, rendering it useless for realtime communication.

Having ruled out PHP, I reviewed my options for server-side languages with built-in support for asynchronous operations (there aren’t many) and decided to give Python a shot. Python’s reputation as a flexible and programmer-friendly language seems to be deserved – within a day I had a basic websockets server up and running with Tornado. I have spent a few days since then getting comfortable with Python’s syntax and semantics while refining the server and forming my first impressions of the language. In short, I like it. A lot.

After nearly a decade writing JavaScript, one of the few good things I can say about it is that it’s flexible, relatively easy to learn and great for rapid prototyping. Python shares those qualities, but doesn’t appear to suffer from the awful design decisions that plague JavaScript. Python’s design seems to be directed by a well defined philosophy and the result is a very concise and consistent language.

Python eschews braces and line endings as a means of delimiting blocks of code in favour of indentation. A for loop that would be written like this in PHP…

for ($i = 0; $i < 10; $i++) {
    echo $i;
}

…would look something like this in Python:

for i in range(0, 10):
    print(i)

While rewriting my websockets server in Python, I was typically able to accomplish the same tasks with less code than the PHP version, and the resulting code was cleaner and easier to read simply by virtue of Python’s design.

Python supports subclassing and class methods, features I’m used to from Objective-C and often miss in PHP and JavaScript. It also supports class variables, which I haven’t encountered in any other language.

Python runs on Mac OS X, Linux and Windows, so it’s a good choice if you care about portability. OS X and most Linux distributions include it as standard (open Terminal, type python and press Enter, and you’ll launch a Python interpreter that you can use to run simple commands without writing a script) and Windows installation is easy.

I’m still very new to Python, but I expect it will gradually replace PHP as my server-side language of choice and quickly become my go-to for many general programming tasks. It’s flexible, consistent, portable, fast and fun.

Tony Wallace 2013 WordPress Theme

The theme I designed for this blog is now available on Github. I also set up a new profile to keep my personal work separate from my company (I don’t use the company profile much, because I’m unable to open source most of the work I do for clients).

If you like the theme, feel free to use it, fork it and modify it to suit your needs. Be sure to include the original Apache 2.0 license for the Bootstrap framework and my design in your distribution. Attribution is appreciated but not required.

WWDC 2013

I was lucky to be able to attend Apple’s Worldwide Developer Conference (WWDC or “dub dub” if you want to be cutesy/douchey about it) in San Francisco this year* and I can’t imagine a better year after 2007 to have been there. Seeing your primary platform recieve a massive design overhaul and then getting an entire week to soak in all the changes is something else, and the one-to-one time with Apple’s engineers is invaluable. If you’re an iOS or Mac developer and you haven’t been to WWDC, try to get there.

If you care about iOS and OS X at all and still haven’t seen the keynote, it’s worth a few hours of your time. If you’re an iOS developer, you need to bring yourself up to date with the new design language in iOS7, UIKit Dynamics, Multipeer Connectivity and SpriteKit (even if you aren’t a game dev) first. They will change how you design your apps. The session videos are available in the WWDC app now.

A lot of apps are going to have to undergo significant change to look and feel right in iOS7. Within a day of the announcement I started planning a ground up redesign of Taxulator, inside and out. A simple freshening isn’t going to cut it. It’s time to rethink how the app works and how users will interact with it. Taxulator was the first app I built for the “old” iOS and I’m excited to bring it to iOS7, hopefully in time for the official release.

*Thanks to the good people at Enable Training & Consulting, who also provide me with a nice place to work every day.

Enable Education Interview

I was recently interviewed for the Enable Education blog about my dual career path in music and technology. Read the full article at enableeducation.com.

Update: June 9, 2013

I have severely neglected this blog for the last 18 months. I’m going to try to stop doing that. For starters, I wrote this shiny new minimal theme on the plane from Toronto to San Francisco for WWDC 2013. I intend to write more about music and technology whenever I think of something worth writing about, but no crazy resolutions like the one I made in January 2012. Here’s to setting reasonable expectations for myself and my time.

Tony Wallace
San Francisco, California
June 9, 2013

New Year, New Site, New Plan

I started out as a professional musician, but now I’m mostly a software developer. Between nursing my fledgling company Heuristic Media Inc and helping to get yapAgame off the ground, I didn’t have a lot of time for music in 2011. I’m going to try to change that in 2012, and I’m starting by working on something to do with music for at least 15 minutes a day. It might be guitar practice or a composition exercise, or it might be some CoreAudio or Max4Live programming – whatever I feel like on a given day. When I come up with something worth sharing, I’ll write about it here and post the sonic outcome to my SoundCloud page. My goal is simple, but a little daunting: to find my place in music again.