/tinyletter

The Programs of the Last Week of 2016

This Week’s Program: Dec 26 - Dec 30

This is the last Tinyletter I’ll be sending in 2016. Happy New Year! 🎉

2016 in Review

In 2016, This Week’s Program hit its one year anniversary.

In the first half of 2016, I continued the previous year’s experiments in Clojure and Overtone with sonic-sketches, picking up spare bits of Music Theory along the way. On New Year’s Day, I wrote code to generate a version of Auld Lang Syne. I learned to use core.async and Communicating Sequential Processes. I wrote a macro. I survived a blizzard named Jonas and attended IndieWebCamp. I made drum machines and generated music based on the weather in NYC. I got lost in the weeds setting up Vagrant and running sonic-sketches in Linux. I wrote a bunch of Bash in provisioning steps. I dabbled in Vagrant and Packer. I was lost for months in the waters of AWS and declared that “DevOps is the Kale of programming.” I learned to love CloudFormation. In mid-August I released @sonic_sketches: a Twitter bot that procedurally generates a daily song based on the weather in Manhattan with an accompanying video. I reflected on its launch and got to demo it in September at the wonderful XOXO festival.

In 2016 I left my job at Rent the Runway and joined the team at Harry’s. I gave a talk at the wonderful !!con about pseudo-random number generators.

In 2016 I spun up a FreeBSD server on Digital Ocean. I didn’t do all that much with it, but I was able to get Emacs up and running and commit some code.

In 2016 I picked up the Elm programming language to create hive-city, my first game.

2016 was a difficult year for a lot of different reasons. In 2016 I wrote a lot of code and learned a lot of new things. I hope 2017 is better.

Here’s my review of 2015, for the curious.

I took this Monday off from writing code. I made a bunch more progress on Hive City’s Campaign module and refactoring. Here are some of the highlights from the commits:

9567bb7d0ff6aeac781c869cff367adbcd11283e

I create a new module: View.Controls. This is my first time using a subdirectory to organize the modules in the game, and my first time moving view concerns into a separate module.

In the new controls, I always display four buttons. Those buttons are assigned a key: Q, W, E, or R. I was inspired by the controls of a MOBA. Those keys are joined to a Maybe Action from the list of available actions of the Player through a clever (if I do say so myself) use of the foldl, head, and drop List functions. There’s probably a more concise way of doing this pairing, but I found it to be delightfully Lispy.

2698889215680ff7e24a8e85956aef4e7b4cc60b

I wire up my new View.Controls to the Campaign and do a bit of refactoring. Now the keys are represented by a sum type called ActionKey.

89945f4c155a6fcf89419749dbbfef4027e48267

Back in Campaign, I bring back the Rolling and DiceRoll functionality, but a bit more refined. Now the Player.execute function always takes a Dice argument.

Having learned a few things from my work in Elm’s Task module, I feel like this approach is a lot more elegant than what I had in the previous Main module.

28a0ff28980a23c89dbebbbd7f7feb50475e0c3e

I wire up keyboard controls here. Because of the ActionKey type I created earlier, key presses just become as simple as

takeAction Controls.Q

This maps back to the pairing of action keys and actions from the View.Controls module and returns a Cmd Msg that will call the Command message with the associated action.

Here’s what Hive City looks like now:

A screenshot of Hive City with new layout and controls

Thank you for reading my writing and my code in 2016. I am so grateful that you give me this space in both your inbox and in your day.

Wishing you the best in 2017,
🍾 Mark