Why I Knit: Similarities Between Knitting and Coding


January 11, 2019 4 min read

Overhead shot of hands knitting with magazine and coffee nearby

I like hobbies and crafts. I've dabbled in many, from scrapbooking to painting to writing. I even used to play the violin (I wasn't very good at it!). But knitting has stuck, and I don't think I'll be putting it down anytime soon.

I knit for the joy of it: the meditative, repetitive counting, the beauty of a pattern emerging slowly, stitch after stitch, the excitement of casting on and the high of binding off, donning a new piece for the first time that I created over hours of work... But deeper than that, I believe I gravitated toward knitting above other crafts specifically because it is a lot like coding.

Knitting is processing an algorithm. While knitting, you are the computer, and the pattern is the algorithm or program, and there is a lot of math. Knits and purls are like 1's and 0's. You are given a code and it is your job to translate that code, executing functions in the code line by line (or row by row) into an output. Paterns may even include looping instructions, similar to a while loop in coding. Sometimes mistakes (bugs) are made, and they need to be found and fixed (debugging). Patterns use a symbolic language with a unique syntax that is unreadable to non-knitters but that is universal to knitters and can be translated by knitters throughout time and space into similar results.

Designing knitting patterns is writing a program. Just like knitting is processing an algorithm, designing a pattern is writing the program. It is math intensive, there is a lot of iteration, testing and re-doing, using trial and error to figure out what works and what doesn't in this new "program" you are writing. There is refactoring and optimizing, with a goal of DRY (Don't Repeat Yourself) and a final program with as few, simple lines as possible. And at the end of it all, there is documentation and QA testing, or test knitters going through the pattern (program) you wrote and looking for bugs. Then there is a pattern release (production deployment).

Knitting is both technical and creative. Knitting is certainly technical: reading a pattern and translating it into something accurate is a technical skill. Knowing what types of yarn work and converting between them, knitting and measuring gauge, modifying patterns - these are all technical skills. But knitting is also creative. Interpreting a pattern in your own unique way, choosing yarn colors that go well together, tweaking the pattern here and there to make it more you - these are all creative, artistic skills. Coding is obviously technical, but it is also creative and artistic, and good programmers strive for beauty, in the code itself and in the end product.

There is always more to learn. I don't know if someone who has knit for decades continues to learn, but I can say that my knitting journey has been full of learning. Getting started with knitting only requires learning knit and purl stitches, casting on and binding off, and manipulating the needles using a knitting style like Continental or English. But after that, there is so much to learn! New stitches for lace or cables, all about the different weights and fibers for yarn, yardage, colorwork, reading charts, different knitting styles, fixing mistakes...there always seems to be more to learn. Coding is the same way. There is always more to learn within a coding language as well as more languages and frameworks and libraries to learn.

I love code: I live and breathe it and it gets me up in the morning excited for another day. Given how many similarities there are between knitting and coding, it's no wonder I picked up knitting as a hobby and a skill and then have kept at it. If you are a coder and have never tried knitting, maybe give it a go? Or if you are a knitter and have never tried coding... well, you never know, it may be something you'd enjoy!


Think others might enjoy this post? Share it!


I'd love to hear from you, let me know your thoughts!