Logo 61e73bc61c0e1780102320e879dc3cac0e29303ea8894dd8f10c942f3ba8120f

otters.io

An adorable little blog

My Lesson Plan

Wednesday — December 30th, 2015

Continuing from my post on Teaching Swift. Here was my impromptu lesson plan for our first day.

Welcome To Xcode

Computers can do math. Like 1 + 1 and 2 * 2.

Computers have special words. Like print(). These words make up a programming language.

Sometimes we want computers to deal with people words. So we have to tell them that something is a people word and not a computer word. This is called a string. "It looks like this"

You can use computers to solve problems like you see in algebra class. Like x + 10 = 13. To a computer, x is called a variable (Yes it can be a constant but I’m dealing with a 12-year-old). You can use it like this:

var x = 12
x * 2

At this point he was excited with what he had learned but wanted to make something right now. So we saved our playground and opened a new empty iOS project in Xcode.

UI elementsI fiddled with Xcode to show only the Main storyboard and the editor bar. I showed him how he could drag things he wanted into the storyboard and we quickly put together a small app with a label and 4 buttons. We plugged his iPhone into the Mac and hit Build and Run on Xcode. His screen lit up and showed him what he had made.

He thought this was fun but was confused why we spent an hour learning a programming language if Interface Builder is really what development is. Screen Shot 2015 12 30 at 3 30 50 PMThen I pressed the magic Assistant View button and the door opened. The code for his view controller was shown to him. I showed him how to drag from a signal to an IBAction on one button and he followed suit on the rest. Not all of these new words made sense but they didn’t need to. He could see that he was making something and that was all that mattered. After an hour and a half he had made an app. He made something that ran on his phone.

On his interview with John Gruber, Craig Federeghi talked about making Swift the next major general-purpose programming language and something that people can learn. I have a feeling that this is what he meant.

My brother and I could have started learning Objective-C, message passing, and dynamic dispatch. I’m really thankful we didn’t have to. Maybe the real magic of Swift isn’t that it looks like some other language or that it lacks square brackets. The real benefit that I found when trying to share my interest was that I don’t have to explain the backstory and limitations of a Unix System from 40 years ago.

My little brother doesn’t know about functional programming, protocol-oriented design, or how unit tests/MVVM/XP/TDD/BDD/ABC are going to make him a 10x programmer. But after an hour and a half, my little brother knows how to open Xcode and make something.