Put a software engineer and a fiber artist side by side and they look like
they're from different worlds. One stares at a screen and types; the other
hunches over a piece of fabric, looping yarn with a hook.

They have more in common than it looks. Both sit in ergonomic chairs, squint at
complicated patterns and sigh when something doesn't work. Both crafts are
creative and technical at once, and both feel great when things go right.

I've been crocheting for a couple of months now, and it uses the same part of my
brain as writing software. The basic moves map onto each other surprisingly
well.

1. The slip knot: initialising the project

An application starts with git init. A blanket starts with a slip knot.

It's the point where a ball of yarn, or an idea, starts turning into a real
thing, and everything after it builds on it. A messy slip knot causes trouble
later, the same way a chaotic repository layout does.

2. The chain stitch (ch): allocating memory and arrays

Before you can write logic, you need somewhere to put data. In crochet, that's
the chain stitch.

Chaining 40 is like setting up an array of 40 slots. Each chain is a placeholder
waiting for a stitch, and if you miscount the starting chain, your loop logic
throws an out-of-bounds error a few rows later.

There is an interactive demo here in the original post.

3. The basic stitches: primitive data types

With the foundation down, you start using the basic building blocks. Code has
integers, strings and booleans. Crochet has the standard stitches.

US Term UK Term Coding Equivalent Why it Fits
Single Crochet (sc) Double Crochet (dc) Boolean (True/False) Short, dense and rigid. It's either there or it isn't, and it makes a tight structure.
Half-Double Crochet (hdc) Half-Treble Crochet (htr) Integer A bit taller, used for everyday work and building bulk.
Double Crochet (dc) Treble Crochet (tr) String Tall and flexible, and it takes up a lot of space, so the fabric drapes and moves.

There is an interactive demo here in the original post.

4. Increases and decreases: control flow (if/else and loops)

A flat square is fine, but a 3D dinosaur or a fitted sweater needs conditional
logic.

  • An increase (two stitches into one loop) is conditional expansion: if shape == curve, call stitch() twice.
  • A decrease (two loops worked together into one) is closer to garbage collection or compression. It shrinks the fabric to get the shape you want.

Get the control flow wrong in a script and the program crashes. Get the
increases wrong in crochet and your amigurumi penguin comes out looking like a
deeply concerned potato.

When you work in the round, the increases decide the shape. Six a round keeps
it flat. Try a few others:

There is an interactive demo here in the original post.

5. Grannies and motifs: object-oriented programming

A granny square blanket is object-oriented programming in the wild.

You don't crochet one huge piece of fabric from scratch, which would be the
monolithic codebase. You make small independent squares.

[Square Component] -> [Square Component] -> [Square Component] || [Stitched Together] || [The Final App/Blanket] 

Each square is an instance of a class, with its own properties (colours) and
methods (the stitch pattern). Once you have 50 of them, you "import" them all
and join them into the finished blanket.

The squares are reusable, and if one gets ruined you swap it out without
touching the rest. Amigurumi works the same way: you make the legs, ears and
snout as separate components, then sew them onto the body as a final
integration step.

There is an interactive demo here in the original post.

6. Reading a pattern: compiling code

You can't type random characters into a program; you follow the language's
syntax. Crocheters do the same, and a crochet pattern reads a lot like a
technical spec.

A pattern opens with its global constants (yarn type, hook size and gauge), then
the instructions start, and they look like a scripting language someone made up
for themselves:

Row 3: Ch 2, turn. *Dc in next 3 sts, 2 dc in next st; rep from * to end. (30 sts) 

To a passerby, that's gibberish. To a crocheter, it compiles. There are
variables (sts = stitches), loops (rep from * = repeat) and an assertion at
the end that checks the output (30 sts = 30 stitches).

That's close enough to code that you can write an interpreter for it, so I did.
Change a number and see if the row still checks out:

There is an interactive demo here in the original post.

Debugging

Debugging might be where yarn and code overlap the most.

When a deployment goes bad, we run git revert and roll back to a known good
commit.

Crocheters call it frogging, because you "rip it, rip it, rip it". You notice a
missed stitch four rows back, pull the yarn, and watch hours of work unravel to
fix one bug.

There is an interactive demo here in the original post.

Then you redo the rows and the sweater fits, the same relief as a build that
finally passes.

The takeaway

I picked up a crochet hook to get a creative outlet away from screens, and ended
up with a physical version of programming.

Next time you're stuck on a nasty bug, step away from the keyboard and pick up a
hook. It works the same analytical, pattern-matching parts of your brain, and at
the end of the day you have something warm you can hold.

Whether it's bits on a server or loops of acrylic yarn, logic is beautiful in
every form.