, ,

                I do crocheting in my spare time. It produces beautiful things, allows me to work out stressful situations, and sets me firmly amongst the ranks of the makers. I’m also using CodeAcademy to learn how to comprehend JavaScript and other languages. One of the things that I’ve noticed is a connection between the form of code and the form of crochet patterns. For example, take this sample pattern for a scarf [1]:

Hook size needed:

I (5.50 mm)

Yarn needed:

Worsted Weight, color of choice, 200 – 350 yards

Stitches needed:


Half-double crochet (hdc)


  1. Chain 15. (Foundation chain. Also first row.)

  2. Chain 2, turn.  Half-double crochet two stitches out from hook.  Repeat until 15 hdc stitches have been performed total. (Second row.)

  3. Repeat step 2) until desired length.  (nth row.) This scarf is narrow and can be quite long.  If you want a ballpark length, say 48”, but it is really up to you.

Now that same pattern, written in pseudocode of the JavaScript variety, would look something like this [2]. For the sake of easier writing, I will pretend that the second row onward is composed entirely of hdc instead of those two chains at the beginning of each row:

// Beginning of scarf program in pseudocode

var Yarn = {

     Weight: “worsted weight”, //sets yarn thickness

     YarnLength: > 200 && < 350, //sets yarn length

     Color: “red” //sets yarn color


var HookSize = “I”; //sets size of hook

var row = 0; //sets initial rows to 0

var ScarfLength = 48; //sets desired length of scarf as the maximum number of rows

var chainstitch = 0; //sets initial chain stitch counter to 0

var hdcstitch = 0; //sets initial half-double crochet counter to 0

var chain = function (chainstitch, HookSize, Yarn){

              for(chainstitch = 0; chainstitch < 15; chainstitch++){

              *perform chain stitch using HookSize and Yarn*; //operations for performing a

               //chain stitch



var hdc = function (hdcstitch, HookSize, Yarn){

                for(hdcstitch = 0; hdcstitch < 15; hdcstitch++){

                         *perform half-double crochet stitch using HookSize and Yarn*; //operations for

                          //performing a half-double crochet stitch



function scarf(ScarfLength, chain, hdc, row, HookSize, Yarn) {

     for (row = 0; row < ScarfLength; row++){

                if (row === 0) {                                                 

                                chain(row, HookSize, Yarn); //foundation chain


                    else {

                               hdc(row, HookSize, Yarn); //each subsequent row after the foundation chain



}; //makes a scarf

                What can be seen from these examples?

                Coders: The literal notation of crochet patterns literally tell you how to make something: a scarf. Your object constructor constructs an object. The “for loops” are ACTUAL LOOPS OF YARN.

                Crochers: Coders use a program to repeat a simple task many times over to complete some function, very much as many simple stitches are repeated over and over again to make a scarf. “For”, “do”, and “while” loops are very helpful to help complete a task.

                Both groups: Beta testing is key. The author of a pattern or a program may be making many assumptions that for the author are automatic. Your newbie self didn’t know these things, so help a person out and test these patterns and programs before release.

                If you’re a programmer learning how to crochet, or a crocher looking to get into programming, go for it. There are enough similarities in between the two that you’ll pick up some parts of it quickly. No reason each group can’t learn things from each other.


[1] If you need to look up what given stitches are and how to do them, I highly recommend the guides available on the Lion Brand website.  Several YouTube videos are also available for how to do a given stitch. Live help can be obtained from relatives, friends, classes, or your local craft store.

[2] I am aware that this code would not run, that some of my wording is imprecise, and that parts of it could be tweaked to be more elegant. This pseudocode is provided as an example, not functional code.