Woman relaxing on a couch while knitting.

We’re a digital agency for brands such as Sainsbury’s, LUSH, Decathlon, and B&M, so an article about knitting might be a little unexpected… but bare with me!

Knitting is old; it originated in the Arab world, thought to be in Egypt between 500 and 1200 AD. It used to be a predominantly male pursuit until fairly recently. Mega knitting is a thing—you can burn about 100 calories an hour doing it—and it has a lot of similarities to coding. Bear with me…

Analogue data

Let’s start with data. I was recently driving to a meeting, and on the radio, a Canadian lady named Sue Montgomery, a city councillor and borough mayor in Montreal, was speaking. She had an interesting habit during the monthly executive committee meetings—she started to knit. She would knit with red yarn when the men spoke and black yarn when the women spoke. She created a data visualization of the male-to-female speech time using knitwear! It’s no surprise that the shawl she knitted was mostly red!

There are other examples out there in Googleland. I found Josie George who knitted a scarf that recorded the temperature of a whole year, and I discovered secret codes knitted into jumpers! During the Second World War, spies used to knit messages in Morse code into jumpers that were sent to the Allied forces. Picture an old French lady sitting at her window by the train station, knitting. It wouldn’t attract much attention from the Germans, but she was actually recording all of the comings and goings from the train station in code. Excellent!

Technology crossovers

So after learning about knitting being used as data visualisation, I dug deeper and found other links.

In 1804 the Jacquard Loom was invented. This invention simplified the process of manufacturing textiles with complex patterns, and it was controlled by a chain of punch cards that were laced together into a continuous sequence, with each card corresponding to a row of the design.

This design was said to later inspire Charles Babbage when he made his Analytical Engine, which was proposed to be a general-purpose fully program-controlled automatic digital computer. This was the first design for a general-purpose computer that could be described in modern terms. A century later, Babbage’s designs were read by, and said to inspire, the people who built the first computer.

Code and knitting patterns

Knitting patterns are basically a language that, for all intents and purposes, looks a lot like code.

Here’s a line from a knitting pattern:

k5, * ky0k, k4, p4, k4, rep from * around

So what does this line of “code” mean?

k5 means “knit each of the next 5 stitches.” This is an example of the D.R.Y principle: “Don’t repeat yourself,” which is a principle of software development aimed at reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.

The asterisk allows you to make a loop—They tell you to repeat a pattern a certain number of times or until the sock is a certain length, like counting and conditional loops.

kyok means “knit, yarn over, knit” all into one stitch.

People who knit from patterns have to learn this language and then read it to create their designs, much like learning a coding language. You knit one line at a time, like writing code. You have variables in knitting; pattern authors create one pattern and then you replace variables within it to make it a certain size. You have error handling; if you have to edit your code (add or remove some stitches in one row), most patterns tell you how many stitches you should have in your row when it’s complete. If there’s a problem, then you need to go back and debug it. Missed stitches or similar problems can affect the design much later on. And to save space, complex knitting patterns tell you how to do something once and then refer back to it when they need you to do it, which is pretty similar to a function in coding.

Finally, there are similarities in other ways. Both are fairly easy to grasp at a basic level but take years to master. The mindset is fairly similar; you need to figure out how to make a project work as you go, and to the uninitiated, knitting a jumper that actually fits or creating an app are simply mind-bogglingly complex.

Read more from Organic