Pseudocode

For the past few weeks, I've been working on a project I've dubbed 'pseudocode'. I was inspired by the expressive way I handwrite pseudocode in my notes and how I thought it was disappointing that I can be so much more clear in writing than I can in code, where I'm restricted to a limited glyph set.

As it stands right now, pseudocode is a live processor for source code in many languages that replaces certain operators and other language constructs with properly spaced, typographically distinguishable variants. '=' is replaced with '←', '==' with '=', '<=' with '≤', etc. I think the best way to get a feel for it is to actually try it, which is why I wrote this initial version of the interpreter in javascript (well, in coffeescript). There are a few other minor tweaks to the font (which is derived from the excellent DejaVu Sans Mono).

Here's the demo, hosted at GitHub. It should work in all modern browsers, but I've only tested it extensively in Chrome.

So, go, try it for a while. Type a few lines of code (solve some Project Euler problems if you're looking for something specific to write) or paste in something you're working on. It's particularly tuned to the languages I know and like, so you'll get to see more of it (and it will hopefully make fewer mistakes) if you use Python or a C-like language.

Unfortunately for myself and others who like pseudocode, this demo page is, for now, all there is. I spent a lot of time trying to wrangle pseudocode into vim, and it's proven difficult, to say the least. The closest I could get was to find some similar projects whose solutions don't conserve line length, which is a dealbreaker for me (they also cause text to jump around distractingly in MacVim).

Regardless, I remain enthusiastic about the idea, and I'll keep working on a good way to actually use it in practice. In the meantime, I'm going to stop focusing on this as much and move on to other projects. I've gotten pseudocode to the point where I'm happy with the overall feel, but can't stop nitpicking and second guessing myself on details. The full source code is available on GitHub (you'll need FontForge if you want to edit the font, CoffeeScript and Sass if you want to run the code).

Thoughts, opinions, and contributions are always welcome, either by email or in the comments. (Bugs can be filed at GitHub)

433 views and 2 responses

  • Jun 12 2011, 7:11 AM
    Andrew Hays responded:
    I think that this is an excellent idea with a lot of possibilities for expansion. If I can think of anything for bugs or improvement, I will let you know.
  • Jun 15 2011, 4:44 PM
    Andrew Hays liked this post.