Posts for 2017/06/01

Python, Go and Rust bot comparison

2017-06-01 posts code

After implementing my bot in Python, I thought I'd try porting it to other languages as an opportunity to learn a bit of Go and Rust.

Both Go and Rust are statically typed and compile to a single self-contained binary, which is appealing as there is no need to maintain a virtualenv and install dependencies on the server.

The parsing code for "rain" messages is a good starting point to compare the bots. Each is using a "parser combinator" library to parse the messages.

Quick thoughts: Python & Go are both pretty sane. There's almost certainly a better way in Rust, but I found it considerably harder.

The tests are stored in different places in each version so the total line count is not comparable, and the Rust version includes "ignore case" code that is built into Python's parser combinators, and that I added into a fork of the Go parser library.

Blog architecture outline

2017-06-01 posts

  1. content in a github repo, initially directly in a single jsonfeed file
  2. posting to my bot would have a checkout of that repo and update the file, push it to github
  3. github webhook would call amazon lambda
  4. lambda would process the feed file into static html
  5. push html to s3
  6. set up nginx to proxy the blog/ path to s3
  7. profit