Internet Tubes

Meeting strangers online so your audience can talk to tubes.

There was a recent post on HN asking users to show the website what they are working on. I try to always have a side project in progress and I'm currently neck deep in the Daily Story project (season 2).

I posted that I was working on a short story podcast and went on my way. Enter Mitchell. Mitchell reached out on twitter, he wanted a guinea pig to test his own project on Amazon Echo (Alexa). His project, Fourthcast, is to add your podcast as a skill to Alexa so your audience can listen to your podcast with a simple invocation.

I don't own an Alexa tube. I've never developed a skill or app for any Amazon platform. Didn't matter, Mitchell had me covered.

So after following some simple instructions my podcast is now on Amazon. That's nuts! I was just sitting around, never even considering that as an option or a possibility, and a lil internet community back-scratching did something really cool.

So to Mitchell, to HN, to my fellow nerds out there who are working on neat projects: Thank you! Like anything, the internet has its flaws, but it's a really cool place.

Macs of 2017

The Mac isn't going away. Apple just spent huge resources getting the Touch Bar launched. Resources both on the software side and the hardware side. Both are massive undertakings, I'd like to especially point out the Touch Bar hardware in that it's effectively a tiny iOS computer living and working inside the Mac.

If that's not a vote of confidence for the Mac's future, then nothing is.

The retina MacBook launched in 2015 gave us a small hint at where Apple is taking their notebook line. The MacBook Pros launched late in 2016 offer a clearer look.

Touch Bar improvements:

  • Force Touch is a gimme, in fact I'd be surprised if it wasn't the first improvement rolled out.

Track Pad improvements:

  • I think the larger trackpads are a clear sign that Apple Pencil support is coming to the Mac. Depending on how good Force Touch becomes, the writing surface could become quite reactive to the Pencil input. I'm curious if there will be an adapter sold to charge the pencil from one of the MacBook's USB-C ports.

The Desktop:

  • Mac Pro: CPU improvements have stagnated, I'm not so worried about Apple keeping their Pro devices on the latest Xeons from Intel. Where the Pro needs some love (if it's to continue at all) is in steady GPU updates. If this line is sunsetted I think that would be okay, so long as the "iMac Pro" has a an option for a powerful GPU.
  • iMac: Taking my cue from the MacBook naming in 2015, it might be time to rename the iMac. The new name would be Mac, you're shocked, I can tell. Form factor would be similar to the existing iMac, with smaller bezels.
  • iMac Pro: If I'm right about the renaming, this would be just the "Mac Pro". It would be similar in form factor to the new iMac/Mac (i.e. an all-in-one with a great display). It would have a Xeon processor, ECC RAM, and a beefy GPU from AMD. If we're lucky, it will get regular GPU updates.
  • Mac Mini: Discontinued.

The Notebook:

  • MacBook: Revved with new processors, no Touch Bar.
  • MacBook Pro Escape: No updates, it is now on the MacBook Air track.
  • MacBook Pro: If it's ready, Force Touch Touch Bar.

I wouldn't be surprised if there was a small price drop on the Touch Bar Macs.

Between the Touch Bar and my predicted Apple Pencil support, it's pretty cool that the Mac is potentially about to get two new interface paradigms added to it. That's where the gains are to be made now, not just spec bumps.

These are just my predictions, my reading of the tea leaves.

Developing Seam: Thoughts on Swift

Seam & Swift

I recently released Seam: Relax Your Mind, my first game to the App Store. It's a procedurally generated puzzle game wherein you rotate and snap together puzzle pieces. I have minimal experience writing iOS apps - Seam is a small project, but it's my biggest yet.

Seam is written in Swift and uses Apple's SpriteKit game engine (I'll talk about SpriteKit later). Here are a few things about Swift I think are interesting.

Getting Swifty

The type system: I prefer statically typed languages, especially if there are strict speed requirements (like with a video game). I'd like to specifically highlight the syntax for dealing with types, which is beautifully consistent. This is a subtle thing that I think has a massive impact on a vague feeling ("code feel") that makes reasoning about the typing easier.

// this is an integer
var score: Int = 0

// this is an array of integers
var dailyScores: [Int] = [0, 10, 19]

// this is a function that takes an array of ints and returns an int
func bestDaily(dailyScores: [Int]) -> Int { ... }

// this is a function that takes no args and returns a function
// can you infer the type signature of that function?
func funcMaker() -> (([Int]) -> Int) { ... }

The Swift type system has too many features to discuss in a blog post. It's not perfect though, the type inference fails too frequently. I rely on type inference only in the simplest cases.

Optionals: This might be Stockholm syndrome because there's almost no way to avoid dealing with optionals if you're writing against iOS libraries, but my arc (pun intended) with optionals was "these are annoying" to "these are completely sensible (but still a tiny bit annoying)".

That tiny annoyance is well worth the incredible confidence reasoning against optional values gives you, you check if the value you're interested in manipulating is nil or not, and you're off to the races. It enforces good habits and it gives you a hook to bail out early if something isn't quite set the way you were expecting.

func getUser(_ username: String) -> User? {
    // this function looks for a User by username, it returns
    // an "Optional User" which can either be a valid user or nil
}

func sendLateFeeNotice(username: String) {
    let user = getUser(username)
    if user == nil {
        return
    }
    // now that we've checked if no user was found, we can now
    // assume our user object is safe to use and manipulate
    ...
}

That's a slightly contrived example but once you get comfortable with using optionals (and if you're not yet, just keep at it, you can do it!) they genuinely inspire confidence in your code. Confidence is a great thing in programming because it clears your head, you don't have to hold as much logical spaghetti in your head, freeing you to think about the problem at hand.

Optionals are not magic though, they reduce the need for some types of error handling but not all. Additionally, there is a feature called optional chaining that allows you to safely drill down a deep data structure and get at the underlying optional - this feature is totally necessary but at times you might see something that looks like this:

let vpOperationsEmail = company?.operations?.vicePresident?.user?.email

This is a very useful feature, but sometimes it looks and feels clunky. As a rule of thumb I think you should avoid force unwrapping basically any long optional chain (using the ! operator) and do your nil check (or use guard) right after.

I could wax poetic about the merits and shortcomings of Swift for a long time, but let me wrap up with one more.

Memory management: Swift uses Automatic Reference Counting (ARC) to manage almost all memory for you. There are some technical implications due to that but for most programmers the biggest will be managing reference cycles using the weak keyword. Thinking about cycles can get tricky if your data structures are complex. On your journey to deeper understanding about reference cycles and why they happen: favor using things passed by value, like enums & structs, which will help you avoid reference cycles entirely.