While I’m stuck in home for the foreseeable, I’ve been trying to make the most of my time by using it for some learning instead of simply setting new personal records for how many hours of Netflix and YouTube I can watch in a single month. One of the things I decided to work on was creating a Mastodon client. If you aren’t familiar with Mastodon, it’s a social network most likened to Twitter. Instead of being centralized, though, Mastodon is federated, meaning different people can run their own “instance” of Mastodon, and through federation they can interact with other instances. This is cool for a a few reasons, not the least of which is that if there’s an instance with terrible policies letting their users post all sorts of toxic garbage, an instance administrator can simply opt to not federate with that instance, meaning that users from the instances are effectively cut off from one another. You can check out my own Mastodon profile that I link to on this blog which is hosted by SDF.

As I mentioned in my last post, I’m not much for making frontend interfaces so it only made sense that I’d make a CLI-based client. Note that this is by no means an original idea; I was actually inspired by the tootstream client that I regularly use. tootstream is written in Python, and I thought about making my own client in Python as well given that it’s a super fun language. I also thought about writing it in PowerShell since I have a lot of experience with it. Ultimately, though, I did the exact opposite and started working on it in Go since it’s always seemed like a really interesting language that people enjoy but that I’ve never had cause to use. I thought it would be a good learning experience to work with a compiled, statically typed language instead of the interpretted languages that I’m already (decently) experienced with. This is why I ended up stumbling across JSON-to-Go. It’s also been good experience with work with a slightly lower level language than whta I typically use; to say the least, getting back a byte array from my first HTTP GET request wasn’t something I expected.

I kicked off development of the client this weekend since, being a long weekend, I have even more free time than usual. It’s been quite the learning experience, and while I’ve felt frustrated at times it’s also been very rewarding. Luckily there’s a good bit of documentation and resources out there for Go so that I could look up what I needed without too much pain. The one thing I struggled with finding was how to create an HTTP client in Go that I could POST with that had both headers and form data; that might be a good post for another day.

For my own sanity, I spun up a GitHub repository for my project. It’s still extremely early, and I wouldn’t recommend anyone else try using it yet. Right before firing up this post, I managed to get my first toot posted with it followed shortly by one with corrected formatting. I think next will be displaying the Home and Local timelines, followed by being able to favorite, boost, and reply to those statuses. Suffice to say, there’s a lot of work left to do.

I also think this has been a good experience so far with maybe tempering my expectations a little when learning new programming langauges (or learning anything really.) I often endeavor to learn a new language only to not make the progress I think that I should be making, get frustrated, and then give up since I’m doing it for myself rather than because I’m required to for my job or anything like that. In this case it’s been nice to just sit down for a little bit, work on a tiny piece of code, make some incremental progress, and take things at a leisurely paace. If I get stuck, I simply do something else for a little while. As I remembered being the case back in college when I was taking Computer Science classes, the best way to overcome a hurdle in programming often is to stop looking at the problem; I’ve had ideas for solutions pop into my head at all sorts of random times.

Maybe by the time the quarantine is over I’ll have a fully function client!