Here’s something a little different, and not exactly code related… or is it? I’m going to tell you how I think knitting is similar to coding, and how I think you should give it a go!
For as long as I can remember I would sit in front of my Nan and watch her knit, listening to the knitting needles clicking together whilst she would speed knit. A few years ago, my Nan taught me how to knit, granted I wasn’t great at it and would end up in a tangled mess - I wouldn’t give up on trying to knit a pattern, though! Nowadays I’m doing that with code, and sometimes I do get into a (coding) tangle, but trying to master the art of ensuring that my code works - and not just on my machine.
How do they compare? Firstly, both have inputs, with code it uses binary (1s and 0s). Whilst knitting uses stitches (knit and purl). As well as an input, they both have an output, you might be thinking this is kind of obvious, right? With code, you can develop an application or website, (etc.) and with knitting a garment, such as a woolly jumper or a pair of cosy socks, amongst a lot of other things.
A knitted pattern is essentially binary. As I said above, there are two main stitches that are used in knitting, knit and purl stitches. Similar to computer code, knitting patterns are repetitive stitches which make up a block. The most common patterns are usually stocking (all knit), garter (all purl) and rib (knit, purl, repeated) stitch. There are of course many more patterns that knitters use and developing new ones as time goes on.
The below image demonstrates how a rib stitch pattern looks:
Sometimes knitting patterns can be complex, a set of instructions for you to follow. Similar to how we give a computer a set of instructions to make something happen on the screen, knitting patterns make humans follow set instructions to complete a block.
In some cases, instead of the author writing the pattern out and having pages and pages of instructions for the knitter to follow they would abbreviate logic, - can I also add, this would be using DRY principles, too. Below is a snippet of a pattern from a tea cosy I recently completed:
(RS). K2. *K2tog. P3. Rep from * to end of row. 22 sts.
Translated, this would be:
Knit 2 stitches.
Knit 2 stitches together.
Purl 3 stitches.
Repeat from * to end of row.
Finish with 22 stitches
Which does look a lot like pseudo-code and arguably a function (or a few, depending on how you’d write your code)?
Knitting has functions, but it doesn’t stop there! Knitting also includes loops, if you look at the pattern above it’s telling us to repeat the pattern from the * to the end of the row, which should end on 22 stitches. If this were to be executed it might translate to:
Knit = 1; Purl = 0;
*Answers on a postcard if anybody can translate this “binary?” into text/readable English.
If you’re wanting to create a pattern of your own @kosamari created this pattern language 64 stitches, which explores textile patterns, it’s a pretty neat tool! In addition to this Mariko has also created a sweaterify tool where you can add an image to a sweater.
Here’s one I made earlier… for Ladies of Code:
EVEN MORE SIMILARITIES
TDD - Test-driven development in knitting, or TDK, it’s a thing - honest! Let me explain why.
A lot of us will say we practice TDD, and a lot of us don’t actually do it. Whenever I would knit anything I wouldn’t bother with checking my tension, because… you know, I was impatient and wanted to get going with the full piece!
Don’t believe me? Well, in knitting most patterns come with a gauge so that the knitter can see how tight or loose the stitches need to be by using the correct tension. This gives the knitters a swatch size to allow them to stay on track and knit to the correct measurements, hence why TDK is important - nobody wants mittens that are big enough to put on your head.
Data visualisation - this one, to me... is fascinating. Using actual real-life data to create a knitting pattern, Tempestry, have created a project that stores climate change data, below is an example of how the items look. Every day from January to December, people would knit a row based on the temperature outside, as you can see the results were staggering. Using real data to highlight the issues with climate change, and knit those results… is a little mind-blowing!
TOOLS & TECHNIQUES
Since learning to code, I have found that there are many ways of writing code. Developers use different tools and techniques to write and execute their code, and this is no different from knitting. With knitting, there are a few different techniques, such as Eastern, Western, and Combination (of course there are additional methods used within this but these are the main methods).
As with tools, you can walk into any craft shop and be amazed by the number of materials and tools available for knitters. Knitting needles come in a variety of shapes, sizes, materials and colours. Nowadays it’s difficult to choose one, similar to picking a code editor or theme which ticks all of your boxes.
LAST BUT NO MEANS LEAST
I haven’t been lucky enough to have seen a programming punch card in real life, but I have seen a knitting machine punch card and I’m guessing the concept is very similar. Like the one below which lives at @DoESLiverpool, the punch card tells the knitting machine which stitch needs to be knit or purled, revealing a pattern after the instructed amount of rows of stitches have been completed. This is not too different from the programming punch cards, rather than it telling a knitting machine what pattern to create it tells a computer what digital information to print.
So, have I persuaded you that knitting is similar to coding? Fancy giving it a go? If you’re up for it, I recommend the WOOL AND THE GANG tutorials on YouTube.
Have a very Merry Christmas and happy knitting!
About The Author
Hey, I’m Jax, a Junior Frontend Developer based at Ph Creative in Liverpool. I’m also the Ladies of Code Liverpool chapter leader, and after leaving a career in Marketing I’m hoping to inspire more people into the tech industry. As you can probably tell by now I love to knit and experiment with code.