Category Archives: Software Development

Kite: First Impressions

I wrote in Robotic Pair Programmers:

If search engines ever get eclipsed, I think it will be by something in the environment that just brings things to your attention when you need them. I want this most when I code, like a pair programmer that just tells me stuff I need to know at exactly the right time.

Kite, a code editing plugin, seems to be trying to go down this route. They have “AI powered code completions” for 16 languages in 16 code editors. Unfortunately, they don’t support Swift in Xcode yet. But, they do support Python, HTML, CSS, TypeScript, and JavaScript in VSCode, Sublime, and all of the JetBrains editors, so I could use it to work on App-o-Mat, which is a Django-based site.

In addition to code-completion, Kite also offers Copilot, which is a documentation pane that is synced to your cursor. Xcode already does this—the issue is that a lot of Apple’s documentation isn’t very complete. Kite only supports this for Python right now, but one addition to the standard docs is they link out to open-source projects that use the type or method you are editing.

Unfortunately, Kite doesn’t work on Apple Silicon, yet. It uses TensorFlow, which uses a particular instruction set that isn’t supported by Rosetta. Apple seems to be working on getting TensorFlow ported to M1.

So, I’ll have to wait to try it out. Very promising though.

NERD Summit 2021

The NERD Summit is going to be virtual again this year. It’s the weekend of March 19-21. There are tons of great sessions for beginners, so if you want to get into programming, you should take a look.

I spoke at the conference in 2017 about how to practice iOS development. As part of the talk, I open-sourced an app that could be used for conferences, which I forked into the conference app for NERD Summit. You can download it here (it’s been updated for 2021).

The source code for the conference app is on GitHub. Feel free to fork it for your conference. It’s easy to adapt — it uses a couple of google sheets as a data-source, so if you update the URLs to sheets in your account (make them publicly readable), you can show your conference events instead.

Programming Tutorials Need to Pick a Type of Learner

Note: If you got here because you googled “WCErrorCodePayloadUnsupportedTypes” I made a page called How to fix WCErrorCodePayloadUnsupportedTypes Error when using sendMessage which explains it better.

I’m working on an app to help me stay on an intermittent fasting routine. I wrote about it a little in Icon-first Development.

Fast-o-Mat is an iPhone app, but I want an Apple Watch complication to give me quick access to when my fast begins or ends. To do that, I need to get data from the phone to the watch.

I had never done this before, and I didn’t have the first idea of how it is done in modern iOS/watchOS development.

Here was my process

  1. Do a few google searches to find out the basics. I learn that this is called Watch Connectivity.
  2. Try to make sure that this is the modern way of doing things, since Apple changes things a lot and watch development generally change a lot in 2019. It is.
  3. Look for a tutorial. I pick this Hacking With Swift one because they are usually pretty good. (Here is Part II, the Watch app, if you need it)

Then, at this point, all I do is look for the import and the basic classes I need and see how far I get from just basic iOS knowledge.

This tutorial is good at facilitating that.

  1. The code samples are easy to skim for
  2. There isn’t much pre-amble before we start getting into it
  3. It’s focussed on just the code we need for Watch Connectivity

So, this is very unlike my idea for vague tutorials, but I am not really a new learner.

There isn’t a new concept here for me to learn on my own—I understand the concept of asynchronous message sending. I just need to know what framework and classes to use for this specific task.

The issue is that this same tutorial is what a new learner would find as well.

I believe a they would get this all working by following the instructions step-by-step, but would they have learned it beyond that? Could they troubleshoot?

One thing that is not clear from the API or this tutorial is that Any doesn’t really mean Any in the message parameter to sendMessage

func sendMessage(_ message: [String : Any], replyHandler: (([String : Any]) -> Void)?, errorHandler: ((Error) -> Void)? = nil)

I decided to just use one of my types there. It’s a struct with two TimeInterval parameters.

The documentation says

A dictionary of property list values that you want to send. You define the contents of the dictionary that your counterpart supports. This parameter must not be nil.

And running it says:

errorHandler: NO with WCErrorCodePayloadUnsupportedTypes

And now I see that “property list” values are things that you can store in a plist (so, not my struct, just simple types or NSArray or NSDictionary). And yada yada yada, it’s a little more complicated when you want to do this for real.

This is all to say, sometimes you just want the code (like me) and sometimes you are trying to learn a new concept from first principles, and the same tutorial can’t deliver both (or should even try).

Review: Building a Princess Saving App

Having a driving question helps me find interesting, less-mainstream content that can help shape my thinking. One question I am exploring is how game-design can drive app-design (not via gamification). The presentation, Building a Princess Saving App, describes it perfectly.

This talk is about building learning and fun into your applications. If you’ve ever wondered how games work and how they can help you build better apps, this is the talk for you. Along the way, we’ll discuss a new philosophy of interaction design that is already creating a major competitive advantage for innovative application developers.

The slides describe how typical enterprise and Web 2.0 application designers might approach the problem of saving a princess vs. how Super Mario Brothers does it.

Along the way you learn the language of game-design and the STARS model. Well worth a read if you are interested in this topic.

Robotic Pair Programmers

If search engines ever get eclipsed, I think it will be by something in the environment that just brings things to your attention when you need them. I want this most when I code, like a pair programmer that just tells me stuff I need to know at exactly the right time.

When I’m in Xcode, there are so many times when I need information I don’t have. To get that information, I need to initiate a search. It breaks my flow to do this.

What I want is that information to just be in the environment.

One way this already happens with with code comments. In my source, I trust all of the editors, so I would like to see all of their comments and commit messages. This is actually possible if I turn on the Authors sidebar in Xcode.

But, what more could I get? Let’s say I index every Xcode project in GitHub, every iOS tutorial, every iOS question in Stack Overflow. Could that be distilled somehow and then shown to me at the right time?

One way that seems fruitful to me is rare API calls. There will be times when I am using an API that appears very infrequently in the corpus or my own repositories. In that case, it should infer that I probably need more help than usual and offer up a tutorial or the top Stack Overflow questions.

Another trigger might be my new comments. If I comment before I code, then it should be interpreted as a search query:

// Parse the JSON I get back from the data task

That should bring up links to likely API classes in the help pane (just like it would if I already knew the class). Maybe offer up imports to auto-add. Maybe offer a snippet. In Xcode it would be similar to the auto-suggested fixes for compiler errors.

This is just the beginning, and we can do a lot more. Whatever we do, we need to make sure that nearly every suggestion is useful, because we risk knocking the developer out of flow. Conserving flow should be the driver for how this works.

Soundtracks for Apps

A few days ago, I wondered about soundtracks for books. I had an aside where I mentioned that game soundtracks are synchronized with the player’s actions (like a book’s would have to be).

That is also true of a non-game app. If an app had a soundtrack, then it would also be synchronized with behavior, state, situations, etc.

Apps often use system sounds. So, if you do something that isn’t allowed, you could get an error beep. Alerts similarly come with a sound. That’s been around probably since the first GUIs. Those aren’t soundtracks.

But, I’ve been trying to think about all apps as potentially games, or having game design drive the app design. So, that means sound design has to be part of it. In fact, I think it’s a tell that not being able to conceive of sound design for an app means that it isn’t using game-driven design. What’s the soundtrack to MS Word?

In Pokémon Go vs. Apple Workouts, I said that game-design doesn’t drive the Workouts app—it’s slapped on. And even though I play music while doing a workout, that’s not a soundtrack either.

But every workout app could have a sound layer to let you know what is going on. in Sprint-o-Mat, I give you a ding when it’s time to start sprinting. Apple workouts have pace alerts.

But, what more could you do? In AR opens up playability, I said that even mundane apps could become games with AR (e.g. Grocery List vs. Zombies). We have a kind of AR right now with just headphones, so maybe the right sound-design (more than music or system sounds) could make a workout more like a game.

So, if the game in Sprint-o-Mat is a race, here are some ideas for a game-design driven soundtrack:.

  1. Crowd sound
  2. Have the crowd yell out your name
  3. Give a sense of the location of the pace-setter
    1. Footsteps
    2. Heavy breaths
    3. Friendly banter: “C’mon keep up, don’t let me pass”
  4. Add in band music that you pass (is at a physical location that you approach and leave)
  5. Have an announcer yell out your name and final time at the end

Sprint-o-Mat 2020.2 is Released: Run in KM

From the beginning of Sprint-o-Mat, I always internally represented distances as an enum with an associated value:

public enum Distance {
  case mile(distance: Double)
  case km(distance: Double)
 
  static let kmPerMile = 1.60934
}

So, adding kilometer support in Sprint-o-Mat was mostly about adding in some UI.

I added a button to flip the units, but I didn’t want a straight conversion. I wanted it to round to the closest tenth.

public func flipUnitsAndRound() -> Distance {
  switch self {
  case .mile(let d):
    return .km(distance: round(d * Distance.kmPerMile * 10) / 10)
  case .km(let d):
    return .mile(distance: round(d / Distance.kmPerMile * 10) / 10)
  }
}

I do the same for paces, and round them to the nearest 15 seconds.

With this done, it was mostly hunting down all of the places I was lazy—mostly inside of my HealthKit code that is getting running distance from the Watch in miles.

I left that as is, but made all of the mathematical operators for Distance work for mixed miles and kilometers, so I could could construct a .km Distance and then += .mile distances onto it, and the conversion would be automatic, keeping the units of the left-hand side.

public func + (left: Distance, right: Distance) -> Distance {
  switch (left, right) {
    case (.mile(let ld), .mile(let rd)):
      return .mile(distance: ld + rd)
    case (.km(let ld), .km(let rd)):
      return .km(distance: ld + rd)
    case (.km(let ld), .mile(let rd)):
      return .km(distance: ld + rd * Distance.kmPerMile)
    case (.mile(let ld), .km(let rd)):
         return .mile(distance: ld + rd / Distance.kmPerMile)
     }
}

func += (left: inout Distance, right: Distance) {
  left = left + right
}

If you run in kilometers, check out the new version.

Programming With the Joy of a Thirteen Year-Old

One of the exercises in How to Make Feeling Good a Priority by (my running coach) Holly Johnson is to list out the things that gave you the most joy at different stages of your life. For my teen years, I listed programming. I also listed it for later stages, but thinking about it, it was a different activity.

Programming as a teenager had no real point except to do it. At fifty, I still program nearly every day, but mostly as a job. I love it, but it’s different.

Most of my teen programs were unfinished—many times I just wanted to accomplish one effect and then moved on. Many of them were assignments in programming classes, but outside of that, they were unshipped.

I ship way more of my work now, but I wonder what I would make if I had no intention to ship.

Combining Identities

I have been programming since I was 13. I am a programmer in a very deep way. I do it nearly every day, and it brings me joy.

I have tried to be a runner for the past 15 years and had some success, but never was able to make it a permanent part of my life—I was not really a runner.

Two years ago, I did a few things to take up the practice of running more seriously. One of my tactics was to combine my programming identity with a nascent running identity.

My coach, Holly, assigns me several programmed runs every week. They are of the form: Warmup for 15 minutes, then do 6×3:00 at 5k pace, with a rest interval of 2:00, and then do a 10 minute cooldown. There are a few different patterns.

I made Sprint-o-Mat, an Apple Watch app to guide me during these runs. It has template patterns that you can customize and then buzzes/dings my wrist to let me know to start a sprint, a rest, or whatever is next.

I want to run to play with my app. I want to program to help my runs. In 2020, I ran two marathons, so I do really see myself as a runner now.

The next thing I am tackling is how to tie a writing identity to programming as well. Unlike running, I don’t think I want to work on a writing app. But to combine programming and writing, I do need some kind of project that uses both.

Note: I released a major update to Sprint-o-Mat. See a post about its new interface and how that influenced its icon design.

Make a Game out of an App

I’ve been exploring the intersection of games and things that aren’t really games, and using playability to make books and apps better. In past articles, I’ve talked about how this is not gamification, which I view as a tacked-on layer. I gave the example of Pokémon Go vs. Apple Workouts to illustrate the difference.

I recently made a major update to Sprint-o-Mat that made the UI more of a visualization. My goal was to make it easier to get the most important information at a glance.

But, running with it today, I realized that it’s also now a game. Instead of showing this:

I show this:

The white dots are pace-setters, and so now it’s a game—a race. It’s a rudimentary one, but racing is fun, and I think this now is a fruitful direction for making it more and more like a race.

In a real race, one of the most fun parts (to me) is when you are close to another runner and have to compete. This is where I think I can add some functionality in the next version.

I could do even better if Apple Glasses are real.