Knitting Code: A Programming Primer
Teaching kids to code is a modern necessity. Knowing how to use a computer isn’t enough; it’s better to know how to tell the computer what to do.
Yet in spite of the hype to learn about and program computers, there’s a fascinating study that proves the advantages of taking notes by hand versus typing. A person gains “stronger conceptual understanding” and is “more successful in applying and integrating the material” when notes are taken by hand as opposed to typing them out on a laptop!
Learn with play
Kids learn with play. So if taking notes are better analog, why not apply this logic to the elementary principals of programming as well?
I propose that anyone that wants to teach a child programming fundamentals start with knitting or chess. Throw out the $450-a-week summer camps for 7 year olds that teach a proprietary set rules. Instead, take something like knitting and use it to build the foundations for coding principals.
A couple months ago I had one of my many Facebook annoyances, and vowed that I would take a break and use the extra time to knit my son a pair of mittens.
While knitting, I started thinking about the rows, the counting, and the repetition with slight variance. I only took one assembly language class in college, but it was enough to make me recognize the simple and straightforward snippets of instructions that the knitting world uses. In the wonderful nature of knitting and crochet pattern making, information is communicated in bits of symbols and descriptions.
However, the terms are not completely standard across the board (an analogy to various computer-y things, say assembly languages, kernels, even variable types? Is anything ever really standard?). Some patterns are better than others. Some people can’t agree. Some patterns haven’t been tested enough and have mistakes where on-the-fly corrections are necessary. The communication is an abstraction yet it produces a concrete end result.
Here is a small sampling of knitting code. Many times the words kind of imply what you need to do, but it’s best to learn from a teacher or a good set of YouTube videos.
— — — — — — — — — — — — — — — — — -
K — Knit (cool!)
P — Purl (got it!)
K2tog — Knit two together. (ok, we knit two stitches and abbreviated “together”)
ssk — Slip next 2 stitches knitwise one at a time. Pass them back onto left-hand needle, then knit through back loops together. (Hrm.)
st st— Stockinette stitch (there’s no description for this, it’s assumed knowledge. Some patterns might have a sub-navigation with a description. It’s like calling a different function or class, where you have to import that information back to where you are presently. )
Sl st — slip stitch
— — — — — — — — — — — — — — — — — —
Here’s a quick sampling of some knitting instructions:
Next round: Ssk, k 3[3, 4, 6,] stitches, k2tog (you are decreasing on the left and right side of the mittens), repeat once more on back of mitten.
I particularly like these examples because they look the most like some kind of programming language. A simple one, yes, but still something that a machine could use.
Here are some of the simple concepts that anyone could potentially learn from knitting as an analogy to a programming language.
Loops; Variables; Functions; Classes;
Debugging; Planning; Thinking ahead
Advantages of knitting
In addition to the mitten-wearing son mentioned earlier in this article, I also have a 7-year-old daughter. She recently took a knitting class and loved it. The entire group chatted and shared information while working on their craft. I think all of them were learning something even more valuable than knitting. They were learning to create something and laugh while doing it. To prime their minds to follow patterns, learn from mistakes, and gain the confidence to create something on their own using simple rules.