June 15, 2008

Introducing Parchment

A few weeks ago, I started a small project to create a user interface for something called a Z-Machine: a virtual machine created by Infocom in the late 1970’s to run their text adventure games—the most famous among them being Zork, which is apparently what the “Z” in Z-Machine stands for. These games, as their name suggests, are completely text-based; Infocom’s 1984 masterpiece The Hitchhiker’s Guide to the Galaxy, for instance, opens with this passage: ... Read more

June 11, 2008

Python-SpiderMonkey Resurrected

Yesterday I found John J. Lee’s old Python-SpiderMonkey code from 2003, which creates a bridge between the Python language and Mozilla’s SpiderMonkey JavaScript engine—the same engine that powers Firefox. Lee mentioned on his website that it’s not currently maintained, and after downloading it and trying to compile it, I found that SpiderMonkey had changed a bit since the code had been written, so I made some fixes and, after discussing things with him, set up a new Google Code project for it at http://code. ... Read more

June 6, 2008

Python for JavaScript Programmers

I couldn’t find anything on the web that attempted to teach Python to readers who already knew JavaScript, so I thought I’d give it a shot, since a number of my friends at Mozilla don’t know much about Python but know JavaScript incredibly well. The languages actually aren’t that dissimilar—in fact, some of JavaScript’s latest features have been borrowed directly from Python. Aside from focusing on differences and similarities between the two languages, I also try to explain Python’s design philosophy a bit, to give readers a context for why things work the way they do. ... Read more

June 1, 2008

Enso: A Progress Report

Since moving to Mozilla, I haven’t had a ton of time to work on Enso, the commercial product turned open-source project that I worked on at Humanized. One of the things I’ve been learning about at Mozilla, though, has been getting into the habit of writing about what I’m working on. We didn’t do this much at Humanized, at least not until the first few months of 2008 when we started designing openly. ... Read more

May 28, 2008

Mozilla Weave: A Bird's-eye View

For the past week at Labs, many of us have been sprinting on getting Weave to release 0.2, which aims to be able to allow users to sync all their information between multiple browsers. This is something that Google Browser Sync has been doing for a while, but Weave’s adding an interesting twist to it all: because it aims to maximize user privacy, the data stored on the cloud is basically encrypted by a passphrase that only the user knows. ... Read more

May 21, 2008

Humane Code Highlighting and js2-mode

One feature of many text editors that I’ve always been a little skeptical about from a user interface perspective has been syntax highlighting. It certainly looks pretty and serves to make the process of reading and writing code more satisfying, but I’ve had a hard time justifying to myself that it’s something that’s truly useful in a concrete way. The few examples that always come to mind are when syntax highlighting alerts me to the fact that I’m using the wrong syntax. ... Read more

April 21, 2008

My Stuff, Open-Sourced

After hearing Chris McAvoy drunkenly wax poetic on how programmers should be more open with the stuff they write—McAvoy himself keeps a lot of his code in a public works repository on Google Code—I decided to work more openly too. So a month or two ago I set up a Mercurial repository at hg.toolness.com and have been regularly pushing a lot of my one-off projects to it. Most of the projects on there don’t mention anything about their license, though, and I’m not sure what to do about that. ... Read more

April 19, 2008

My First Mozilla Patch

Last week I decided to try my hand at contributing my first patch to the Mozilla source code repository, and I thought it might be useful to chronicle what went into it, as well as what I learned from the process. This particular contribution was actually motivated in part by a blog post by Mike Beltzner on the need for Mac-specific improvements to Firefox 3, and also by my own work on the Mac port of open-source Enso. ... Read more

April 14, 2008

PyOhio

I just found out that my hometown of Columbus, Ohio, is holding a Python conference. This is really cool. I encourage anyone in the area who is interested in computer programming or knows anyone who is to spread the word about this. Aside from being a really fun and easy language to learn and use—it’s simple enough to be taught to children—it’s also powerful enough to be widely used in the industry (for instance, it’s the flagship language of the recently-released Google App Engine). ... Read more

March 16, 2008

Python as a Platform

Something that recently occurred to me is that the only operating system that doesn’t come with Python pre-installed on it is Windows.

While Linux and OS X both view Python as essentially a first-class development platform–i.e., as something that shrink-wrap applications can be built on–Windows does not. Instead, it’s generally expected that a Python-based Windows application be “frozen”: bundled into a self-contained package that includes a copy of the Python interpreter and whatever libraries it uses, which are private to the particular application. While this ensures that the application will function as expected and not run into “dependency hell”, it also results in a relatively large download–distributing a simple “Hello World” program is at least a megabyte in size, and makes extending the program’s functionality more difficult.

During the summer of 2007, I made simple Python-based tool for some friends who played World of Warcraft; for those that played on the Mac, the situation was easy because their computers already had Python on them. For the Windows users, however, I was faced with the dilemma of either “freezing” the program into a fairly large download which would be difficult to test and update, or making my friends download the Python installer from python.org and running my Python script from source. Either solution seemed too cumbersome.

So instead, I opted for a different solution: I’d create a tiny executable that would first check for the existence of a Python installation on the end-user’s system. If Python was already installed, the executable would simply extract a Python script from itself and run it. That script was much like ez_setup.py; along with a few tricks, it essentially ensured that my friends would transparently auto-update to the latest version of the tool whenever they launched the program.

If there was no Python installation on the end-user’s system, however, the executable would simply transparently download the latest Python installer from python.org, silently install it on the end-user’s system without any prompting, and then proceed as outlined above.

So, in other words, a small executable file–only about 50k in size–was essentially responsible for “bootstrapping” my program by downloading and silently installing Python if necessary, and then downloading and running the latest version of my program’s source code. This ultimately meant that the user would be able to run a self-updating Python program from a tiny executable without having to click through any installation prompts or dialog boxes.

I’m glossing over a few details here and there are definitely some holes in my implementation–for instance, if the user uses a web proxy, they’re hosed–but I thought the general idea was interesting.

The source for the executable was compiled using the Nullsoft Scriptable Install System, along with its InetLoad plug-in. The source file is below for those interested.

... Read more

© Atul Varma 2021