Wrong Way, Right(?) Reasons (RC 11-14 July)

I didn't blog this week. So it goes. We forgive ourselves for these sort of things and move on. I am, however, going to cover the week in a single post here--which actually works out because I did mostly the same things every day.

The BitTorrent group started pairing on Monday, and we've made progress, though slow. We started this project because all of us are interested in networking but have very little experience, which means we're learning rapidly but also have no idea what we're doing.

We've managed to decode the relevant tracker information stored in a sample .torrent file, pull peer data from the tracker, and decode that data into an array of IP addresses, but are now stuck trying to initiate connections with those peers and send handshake messages. Yet I think we're all gradually getting a better grasp on the individual parts of the protocol, and we'll pull it together.

The vast majority of the past couple of days, however, I've been focusing on pushing the markdown interpreter toward the finish. The most difficult part, as it turns out, is actually the aspect of the project that I thought would make it easiest: the simple and loose syntax.

As it turns out, when you're designing lexical grammar, the stricter the syntax, the more straightforward the implementation. It may not be easier, exactly--the strictest language grammar can still be extremely complex--but syntax errors and single-use tokens make the conceptual structure so much easier to think about.

Markdown can't really have syntax errors, as anything the interpreter doesn't understand should just output as plain text. Markdown also gives the writer an obnoxious (or helpful, if you're just trying to use and not interpret it) amount of latitude with whitespace and tabs and blank lines, which means my grammar is riddled with loops that just eat space and tab tokens.

The solution, of course, is to not use grammar design methods intended for stricter languages, and instead base the interpreter on regular expressions or something better suited for looser interpretation. But, out of the (maybe unnecessary) difficulty of this project, I'm actually learning an immense amount about recursion and good program design, so I'm going to stick with it.

Stray thoughts: