2013-03-26

Gobble

A year or so ago I wrote my own blogging engine in C#, and then a while later pointed out some of the worst flaws in the system. The major one for me was the choice of platform:

…using C# means I have to maintain a Windows virtual machine, an installation of VMWare Fusion and a copy of Visual Studio. That’s far too much overhead for something that could be written in a few hundred lines of Go and deployed on any cheap Linux server.

I’ve rectified that with a new blogging engine called Gobble, written in Go. Although it blew away my initial estimate and ended up consisting of 6000 lines of code, CSS and HTML templates (etc), it fulfils my goal of being a blogging engine that:

  • Consists of a single binary;
  • Uses the file system for post storage instead of a database;
  • Supports comments;
  • Uses Akismet and reCAPTCHA for spam prevention;
  • Uses Markdown for post/comment formatting;
  • Can be deployed easily to a cheap Linux server/VPS;
  • Has a search feature;
  • Supports tags.

It has a lot of features that I like in WordPress that didn’t make it into BitBlogger, including search, self-hosted comments, syntax highlighting and more. It even retains the WordPress post ID-based URLs (as a secondary way to link to a post) to ensure that it’s a drop-in replacement as far as external links are concerned. It omits WordPress features that I don’t care about, such as categories, plugins, a fancy admin section and others.

Gobble uses a similar in-memory data storage system to BitBlogger, but this time there’s no enforced shutdown that kills the cache. I’d considered using MongoDB, CouchDB or RethinkDB for data storage, but in the end I realised that the entire textual content for this blog fits in 2MB. A database wouldn’t add anything but unnecessary complexity for managing that tiny amount of data. Posts are stored on disk on the same server as the Gobble executable. I can still use Mercurial and BitBucket to store the posts; I just need to SSH to the VPS in order to pull and update. In future I might add simple admin section that allows me to edit posts in a web browser and view new comments/spam.

I’ve got a complete copy of this blog running in Gobble on a VPS from Digital Ocean. It works well, but some of the formatting of the posts is a bit screwy (it got lost during translation from HTML to Markdown). Once I fix the formatting I’m intending to switch away from my WordPress installation to Gobble.

My only concern with migrating platforms is the fact that moving the simianzombie.com domain to the VPS means I’ll have to run my own mail server, which sounds thoroughly tedious.

More Thoughts on Go

In some ways I find Go a little awkward to write. Working with pointers is identical to working with values directly (unlike in C in which you have to manually dereference pointers) so it’s frequently hard to tell if you’ve got a pointer or a value. Sometimes it’s nice not to care; at other times it’s handy to know if you’re editing a copy of a struct or the original struct (via a pointer), and the language hides that information. Switching back to a more procedural rather than OO paradigm involves some extra thought in deciding how best to structure the app. I’m still of the opinion that Go’s naming conventions are ridiculously anachronistic, and some of the design decisions in the libraries are bloody stupid (sorting and comparison functions are defined on the container rather than the items being sorted and compared, for example).

At the same time, it has some very nice features. Compiling down to a single binary makes Go programs trivial to deploy. Defining structs with associated methods instead of objects makes a lot of sense, and hopefully it should prevent Java-esque program architectures. The concept of implicit interfaces is very reminiscent of Objective-C’s informal protocols and works well. I’ve found that I can write programs in Go extremely quickly, and I’ll get faster as I become more familiar with how to best structure programs and the available libraries.

2012-09-11

Blogging Engines

I’ve been looking for a replacement for BitBlogger. It’s a neat little blogging system, but it has two problems:

  • AppHarbor applications get shut down after 10 minutes of inactivity;
  • It’s written in C#.

The first issue means that my BitBlogger site usually takes far too long to respond. BitBlogger is designed to use the cache exclusively to store all of its content. BitBucket notifies it of any data changes, at which point it sucks the latest version of the blogpost repository into the cache. This works well if the cache doesn’t get wiped, but every time the app gets killed the cache goes too. The application has to rebuild the cache by reloading everything from BitBucket when it gets restarted, which takes time.

I designed BitBlogger in this way to avoid spending a fortune on AppHarbor’s data storage plans, but I didn’t know about the shut down policy until later.

As for the second issue, using C# means I have to maintain a Windows virtual machine, an installation of VMWare Fusion and a copy of Visual Studio. That’s far too much overhead for something that could be written in a few hundred lines of Go and deployed on any cheap Linux server.

With hindsight, having a blog that is stored in Mercurial and gets deployed on each commit isn’t as useful as I’d hoped. There’s no way to write a post on an iPhone, for example. Something I’ve been considering lately is using DropBox for storage instead, and it seems that a few other people have had the same idea:

My favourite implementation so far is Scriptogram. Getting a blog set up is completely painless. Creating a post is as easy as writing a Markdown file in a specific DropBox folder, and syncing them just involves clicking a button on the Scriptogram website.

Scriptogram was so frictionless that I seriously considered moving this blog - I even wrote a WordPress to Scriptogram converter - until I realised that Scriptogram doesn’t have a comment system. I could add Disqus to the theme files, but I find that the comments are the best part of this blog and I don’t want to outsource their storage. It looks like we’re keeping WordPress.