Working Here
Engineering

Code Like A Weaver

TextNow Developer

TextNow Developer

 

December 15, 2017

Code Like A Weaver

This article originally appeared on Code Like A Girl, December 6th 2017. It is reprinted here with the kind permission of the author.

My mom’s never written a line of software in her life, but she taught me how to program. She taught me arithmetic and fractions through baking, data structures through laundry, and programming and algorithms through weaving. Does that sound crazy? Let me explain.

Baking and Fractions

Photo by Mira on Unsplash

How one might learn fractions and arithmetic through baking is pretty obvious, if you’ve ever followed a recipe. Something requires 1 1/2 teaspoons? That’s half a tablespoon, if you’re in North America. Or three half teaspoons. And a half cup is two quarter cup scoops. Or eight tablespoons. Once you’ve got the hang of basic fractions, you start getting into halving or doubling a recipe. Eventually, you just know these conversions, but when you’re a kid, it’s a good way to learn how to multiply and divide.

I clued in early that this math stuff isn’t purely academic.

Laundry And Data Structures

My clothesline

A little while ago, I was hanging clothes out on the line, and it occurred to me that my mother taught me my first data structure concept: first in, last out. A clothesline is a physical manifestation of a stack.

If you wash the jeans first, and put them on the line first, they can stay out there the longest, because they take the most time to dry. If you hang up your quick-drying workout gear last, you might be ready to take them down and replace them with another load before your jeans have even thought of drying.

Alternatively, if you’ve got enough space on the line, so that you don’t need to cycle things on and off the top of the stack (closest to the house), you may want to hang your most wrinkle-prone clothes out first, so they end up on the top of the pile when everything’s folded in the basket.

As with data, the way you use things should dictate how you organize and store them.

Maker, Crafter, Or Simply “Having A Hobby”?

I went down the rabbit hole on a Twitter thread recently (usually a bad idea, unless it’s one of Sarah Mei’s insightful tweet storms about the hard problems of software [ie: people]), and ran into an argument around a distinction between the terms “Making” and “Crafting.” One side seemed to be implying that hobbies that involved fabric were Crafting, whereas Making applied to electronics, hardware, 3D printing, woodworking, etc. Say what?

This distinction has actually been codified in a couple of publications by Maker Media, Inc. You can see how Maker Media categorizes the two terms, if you compare Make Magazine and Craft Magazine.

Personally, I’d rather build BB-8 out of cake.

It doesn’t stop in print. At makezine.com, you can see that they’ve given that publication a full website, whereas the craftzine.com domain currently redirects to an old blog post on makezine.com that explains how to follow crafting authors via an RSS feed. Maybe they could just fully merge their two publications, and stop contributing to this type of nonsense?

Whether you call it Making or Crafting, I think it’s funny how language evolves. My parents’ and grandparents generations didn’t call themselves Makers. They simply had hobbies, like gardening and woodworking. My Grandpa John made furniture for his family & friends. Mom wove, and left many beautiful warm blankets with friends & family on road trips across Canada. My sister knits things like socks, following patterns of knit and purl stitches.

Maker, Crafter, or Fibre Artist, I’d call that a physical manifestation of an algorithm.

Code like a Weaver

Maybe somewhere in a history of technology class, you heard about a relationship between Babbage’s first concept of an analytic engine and a Jacquard loom. Do you know how the mechanism works?

A Jacquard loom has a series of punched cards. The holes in the cards tell the loom when to raise and lower the heddles. The warp threads have been threaded through heddles attached to the mechanisms of the loom, and raising and lowering those shafts creates the programming that makes the pattern in the finished piece. Clear as mud? Detailed pictures of a simpler loom might help.

The metal things are heddles. The threads that go through a small hole in them are the warp. Some go through heddles on the front shaft, some go through the second, some the third, and others the fourth. No thread goes through more than one heddle.
The different shafts of the loom are ‘tied up’ to different treadles, so the shafts can be raised or lowered by pressing the treadle with my feet, according to the pattern.
Pressing one of the treadles lowers the shafts connected to that treadle, resulting in rest of the shafts being raised. This creates an opening in the warp called a “shed,” where the weft thread is passed through on a shuttle.

Programming the Weave

My loom is a fairly simple 4-shaft, 6-treadle counterbalance. I’ve currently got it programmed to weave Swedish lace.

To decide how to thread the loom and what treadling pattern to use, I took the basic structure of Swedish lace, and fed it into a google spreadsheet. The first 4 rows across the top define the threading: which warp threads go through the heddles on which shafts. I used the first 8 columns in the spreadsheet to play with treadling & tie-up patterns until I got an overall fabric structure that I liked. It turned out that I only needed 6 of the columns for the patterns I wanted to do, which is great — because I only have 6 treadles.

It’s a bit of a hack, but I figured out a formula I could use in every cell to trigger an on/off pattern to colour the cells, and get a sense of what the finished weave would look like.

Without changing the threading of the warp, a different treadling pattern (algorithm, really) in the columns on the left results in a substantially different structure to the weave.

With this treadling, I’m able to get a windowpane effect, rather than the all-over lace weave in the previous example.
This is what the two patterns above look like, woven up. I haven’t changed the fundamental programming (the threading), just the algorithm (the treadling).

With a Jacquard loom like the one at the Royal Ontario Museum that I pictured earlier, you can weave much more complicated patterns. This is both because this loom can handle way more warp threads for a wider & finer weave, and because the punch card system & associated mechanism allows for individual heddles to be raised and lowered independently, instead of as a pre-programmed unit per shaft.

A Jacquard loom allows for complex programming where patterns can easily be created that aren’t purely linear along the warp.

Building out a beautiful piece of weaving means coding the thread into the loom properly. That code base is then manipulated by changing how those threads are moving to create the pattern.

The Analytic Engine

The earliest version of a machine designed for computation directly borrowed the punched card mechanism of the Jacquard Loom. Babbage’s Analytical Engine (an iteration on his earlier difference engine) used several sets of punched cards, providing both the data and the instruction sets, in order to compute complex mathematical formulas. Instead of determining when to raise and lower the warp threads like the loom, in his machine, the holes in the cards were to be used to define the binary programming.

A portion of the originally proposed design for the Analytical Engine

You know what I think is the coolest part about the association between the loom, the analytical engine and my hobby? Ada Lovelace is the one who took a look at a loom, and the art that it could produce, using the same mechanism as the analytical engine, and was the one to identify that the proposed analytical engine could someday do far more than just number crunching.

In 1842, an Italian mathematician published (in Italian) a detailed description of Babbage’s analytic engine, which was translated into English by Lady Ada Lovelace, daughter of Lord Byron. This is a quote from her extensive ‘notes’ that accompanied the translation, in the Bibliothèque Universelle de Genève, October, 1842, №82:

“ The operating mechanism can even be thrown into action independently of any object to operate upon (although of course no result could then be developed). Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine. Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent.”

The mental leap from single-purpose mathematical engine to programmable multi-purpose computer was made by the first woman in tech —and the daughter of a poet.Since I originally published this article for the Code like a Girl publication, I came across this compelling tribute to Lady Ada Lovelace’s contribution to this field, from the original author (Luigi Menabrea), and wanted to share it here.

I thought this writing was forgotten; but since it has served as a point of departure for an effort undertaken with the English Government to realize the invention of Mr Babbage, I thought it appropriate to take this opportunity to pay homage to the memory of the daughter of the great poet and to attract the attention of scientists — not so much to my own work, in fact rather modest — but to the notes and comments accompanying the translation, which are able to make known the purpose and power of the Analytical Engine.
This invention looks like nothing ever imagined before, and I could not, within the limits of a simple letter, explain its principles. Suffice it to say that, thanks to it, you could perform the series of analytical and numerical operations needed to solve a given problem, in the same way that the Jacquard loom, using perforated cards, executes designs on brocade.

The most transformative types of innovation come from collaboration between a diverse group of people bringing their unique perspectives and insights to the conversation. Babbage brought his mechanical expertise, Menabrea brought a detailed mathematical perspective, but it was Ada Lovelace’s insight into how the whole could be much greater than the sum of its parts that made all the difference.

Can you bring a diverse perspective to TextNow’s engineering team? Do you want to help us create the future of communication? Check out our current career postings and apply to join me!

Related posts