Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Binary Transformation from Knitting to Coding

A Binary Transformation from Knitting to Coding

Join me on a conceptual journey to understanding how programming concepts are a lot like knitting - and how learning to knit can help you learn to code, understand how code works, and help diversify your workforce! (It might also be good for your health!)

Teaser:
Wait, programming has something in common with knitting? Sure does! In knitting, the building blocks are Knit (K) and Purl (P). In coding, it’s also binary: 0s and 1s, true/false, if/else..
Knitting patterns are actually condensed, coded instructions for how to make a garment or knitted item. Just as code is condensed instructions that machines interpret to produce software, or control hardware, etc.
More complex knitting patterns, like the ones used to describe how to knit a sweater (i.e. top down in a single piece a.k.a. Raglan vs. in pieces that are seamed together), remind us of conceptually similar but distinct techniques in software architecture: mainly monolithic vs micro-service based architectures.

What this talk is about:
How knitting and coding are similar; How many things seem black or white or dualistic (or binary) but that the value is really in being open to the gray-area in between; How to mentally bridge the gap between things that we may be conditioned to believe or think are cut and dry.

What I hope you walk away with:
An expanded worldview, a less dualistic mindset, inspiration to teach yourself something new (whether that is knitting or coding or something else entirely that you didn’t feel like you had access to before), a change in your mindset, more flexibility and a fresh perspective.

Avatar for Genevieve Krzeminski

Genevieve Krzeminski

September 18, 2019

More Decks by Genevieve Krzeminski

Other Decks in Programming

Transcript

  1. DIVERSITY, EQUITY, INCLUSION & ACCESSIBILITY At Denver Startup Week we

    strive to make all of our sessions a space where attendees can connect, learn, and grow — regardless of gender identity, gender expression, race, ability, sexual orientation, and the combination of those identities. As you leave today and throughout the week, introduce yourself to someone who doesn’t look like you or who may identify differently than you. #DENStartupWeek
  2. British Consulate Charter / Spectrum Checkr The Commons on Champa

    Cooley CTRC Ford Smart Mobility Fremont Economic Development General Assembly Hilton Garden Inn ImageSeller Nanno CoastalCloud Formidable Granicus Hogan Lovells Iterable Name.com Plante Moran Slifer Frampton Starry Swiftpage Syntropy Partners Yoonit Wine HEADLINE SPONSORS PARTNER SPONSORS MEMBER SPONSORS Nix Media Officescapes Procare Quizlet Ridg Segment SimpleBooth Slalom Tendril / Uplight Test Double Two Parts / The Passport Program
  3. What is knitting? Knitting is NOT the same as: •

    Crochet • Needlepoint • Cross-stitch • Embroidery • Chopsticks #DENStartupWeek #KnittingToCoding
  4. Who knits? Not just grandmas… • 28.8 million Americans (2016)

    • While 18% consider themselves experts (one of the highest percentages of any craft) the other 82% rate their skills as beginner or intermediate (2018) • Age ranges: 34% are 18+34, 36% are 35-54, and 30% are 55+ (2018) • 71% of knitters and crocheters are female. 29% are male (2018) #DENStartupWeek #KnittingToCoding Source: Knitting stats - anthony thomas blog
  5. Why knitting and coding? • Create a product from a

    specification or pattern • Use specific, varied tools • Build with an end-user in mind • Requires: specific configuration or skills (some barrier to entry) ….. Also: Humans and something Binary. #DENStartupWeek #KnittingToCoding
  6. Knitting Coding Messages “Knitting used by the Belgian Resistance during

    World War II included dropping a stitch, which forms a hole, for one sort of passing train, and purling a stitch, which forms a bump in the fabric, for another, which helped the resistance track the logistics of their enemies.” “Non-spying knitters make gloves and scarves from the Dewey Decimal system, Morse code, and binary programming language for computers, treating knits and purls like zeros and ones.” #DENStartupWeek #KnittingToCoding Source: The wartime spies who used knitting as an espionage tool
  7. Phyllis Latour Doyle: The Forgotten Spy Whose Knitting Helped Pave

    the Way for D-Day “She took advantage of the fact that the Nazi occupiers and their French collaborators were generally less suspicious of women, using the knitting she carried as a way to hide her codes.” “... she worked for a year as a spy using the codename Genevieve” #DENStartupWeek #KnittingToCoding Source: A mighty girl: Phyllis Latour Doyle: The Forgotten Spy Whose Knitting Helped Pave the Way for D-Day
  8. Knitting and Coding : Two different worlds? • Product/ Design

    • Tools • End-user • Human Implementer #DENStartupWeek #KnittingToCoding Knitting Coding
  9. Knitting & Coding: Binary Operations At its core, knitting is

    binary. The binary code of 0s and 1s represented by knits and purls. Computers operate in binary, meaning they store data and perform calculations using only zeros and ones. #DENStartupWeek #KnittingToCoding
  10. What Knitting and Coding Have in Common • Create a

    product from a specification or pattern • Use specific, varied tools • Build with an end-user in mind • Requires: specific configuration or skills (some barrier to entry) ….. Also: Humans and something Binary. #DENStartupWeek #KnittingToCoding
  11. The Product: What are you making? Goal of knitting is

    to make something ... that someone will wear or something that looks cool. #DENStartupWeek #KnittingToCoding Goal of software is to make something that someone will use or something that does something cool.
  12. Knitting Patterns Are Like Code “When writing a pattern, I

    believe knitting pattern designers must bear similar things in mind to programmers writing a computer program. “ #DENStartupWeek #KnittingToCoding Source: Knitting is Like Coding
  13. The Foundation: Design patterns #DENStartupWeek #KnittingToCoding Code Design Patterns •

    Creational - Are all about class instantiation or object creation. • Structural - Are about organizing different classes and objects to form larger structures and provide new functionality. • Behavioral - Are concerned with the assignment of responsibilities between objects, or, encapsulating behavior in an object and delegating requests to it. Source: Sourcemaking Design Patterns • Creational - Cast on methods, bottom up vs top down. • Structural - The different stitches and their integration used to compose the unique pattern that develops the final piece. • Behavioral - The different styles of knitting. → Knitting
  14. Microservices vs Monolith & Sweater Construction #DENStartupWeek #KnittingToCoding “Monolithic” sweater

    = Raglan - Knitted top down - All in one piece - Change design as you go - No assembly required - Limited decisions about construction or end shape “Microservices” sweater - Knitted in pieces - Seamed together - More construction options - More effort - Ensure consistent pattern(and tension) across all pieces - Thoughtful assembly - Construct individual parts into whole Structural Patterns: “organizing … to form .. structures and provide .. functionality”
  15. Right vs Left handed knitting - Binary • English, American,

    also called “Throw” method, wrap yarn with right hand • Continental method, wrap yarn with left hand #DENStartupWeek #KnittingToCoding Behavioral Patterns: “assignment of responsibilities between objects, or, encapsulating behavior”
  16. The Tools Coding • Programming language Considerations • Technological Fit...

    business or technical requirements that lend themselves to a particular language. ... • Overall Client Fit • Mobile App Development • Web App Development Ex: Node.js: server side runtime environment vs Angular JS: Client side MVC framework #DENStartupWeek #KnittingToCoding Knitting • Yarn Considerations • Thickness • Fiber content • Fit • Availability
  17. The Tools Coding • Framework or libraries • Code Examples:

    • Open-source vs Proprietary • Source or community ◦ Ruby gems ◦ JS Frameworks: ▪ React ▪ Vue #DENStartupWeek #KnittingToCoding Knitting • Patterns Examples: • Free vs Paid for • Source or community ◦ Online ◦ Books vs Magazines vs Singletons
  18. The Tools Coding • What the code runs on: Hardware

    or Cloud support (Google, AWS, etc) • Supporting tools: Keyboard, mouse, monitor, servers #DENStartupWeek #KnittingToCoding Knitting • What you knit on: Knitting Needles • Supporting tools: stitch markers, scissors, yarn needle, cable needle
  19. The Tools Coding • Human implementer / coder Software Product

    = language + (framework) + hardware + coder #DENStartupWeek #KnittingToCoding Knitting • Human implementer / Knitter Knitted Product = yarn + needles + pattern + knitter
  20. The Process: How do you build it? Gauge Swatching =

    Prototyping #DENStartupWeek #KnittingToCoding • Finding “fit” • Throw away
  21. #DENStartupWeek #KnittingToCoding Hello World is a simple program that, when

    run, displays the message: Hello World . Fittingly, the Hello World program has long been the new programmer's induction into a myriad of programming languages. Source: Whatis.techtarget
  22. Hello world: Kid’s Programming Language (KPL) // 99 Bottles of

    Beer in KPL (Kid's Programming Language) Program BottlesOfBeer Method Main() Define word As String = " bottles" Define B As String = "99" Define n As Int = 99 While n >= 1 ConsoleWriteLine(n + word + " of beer on the wall, " + n + word + " of beer.") n = n - 1 B = ConvertToString(n) If n = 1 Then word = " bottle" End If If n = 0 Then B = "no more" word = " bottles" End If #DENStartupWeek #KnittingToCoding Source: 99-bottles-of-beer.net / KPL ConsoleWriteLine("Take one down and pass it around, " + B + word + " of beer on the wall.") ConsoleWriteLine("") End While ConsoleWriteLine("No more bottles of beer on the wall, no more bottles of beer.") ConsoleWriteLine("Go to the store and buy some more. 99 bottles of beer on the wall.") End Method End Program
  23. Hello world: Knitting Patterns // Increase Hat – Knitted in

    Rows (flat) and then Seamed Gauge: 4 sts/inch Yarn: Encore Worsted Weight Needles: Size 8, or size needed to obtain gauge Sizes: Medium, (Large); approx 22” (24”) in diameter, with lots of stretch in the ribbing. Directions CO 16 sts. #DENStartupWeek #KnittingToCoding Begin Increase: Row 1: purl across Row 2: kfb into each stitch across (32 sts) Row 3: purl across Row 4: (k1, kfb) repeat across (48 sts) Row 5: purl across Row 6: (k2, kfb) repeat across (64 sts) Row 7: purl across Row 8: (k3, kfb) repeat across (80 sts) Row 9: purl across
  24. Programming Languages = Knitting Patterns “A programming language is a

    formal language, which comprises a set of instructions that produce various kinds of output. Programming languages are used in computer programming to implement algorithms. Most programming languages consist of instructions for computers” #DENStartupWeek #KnittingToCoding
  25. Knitting code: Abbreviations = Variables Abbreviations: K = knit P

    = purl kfb = knit into front and back of stitch (increase) CO = Cast On BO = Bind Off RS = Right Side WS = Wrong Side St st = Stockinette stitch 1x1 Rib = 1 by 1 Rib, or *K1, P1*. When ribbing in this pattern: RS: Begin *K1, P1*, repeat to end WS: *K1, P1*, repeat to end () = repeat symbol. sts = stitches #DENStartupWeek #KnittingToCoding
  26. Knitting patterns are D.R.Y. Knitting patterns may tell you to

    “K5” => “knit each of the next 5 stitches.” Better than writing: “k, k, k, k, k” - Easier to read! - Saves space (and sanity!) #DENStartupWeek #KnittingToCoding Source:Knitting is Like Coding (0..4).each do |stitch| k stitch end
  27. Knitting Patterns Are Like Programming Languages “We want to reduce

    our instructions to their simplest, most logical form in order to avoid redundancy, promote efficiency, and reduce the potential for glitches to occur. “ #DENStartupWeek #KnittingToCoding Source: Knitting is Like Coding
  28. Knitting patterns and Code: Regular Expressions “Regular expressions use a

    special notation to precisely describe what must be included, what might possibly be included, what cannot be, and how many times things should be repeated.” #DENStartupWeek #KnittingToCoding Source: Knitters and coders: Separated at birth? Seed St: Row 1: *k1, p1; rep from * Row 2: *p1, k1; rep from * or Row 1: (K1, P1) rep to end Row 2: (P1, K1) rep to end Repeat these 2 rows for length desired. Represent each repeat of knit 1, purl 1: (kp) Repeat that 10 times: (kp){10} To the end of the row: (kp){10}\n Next row (purl 1, knit 1): :(pk){10}\n For 20 rows: ((kp){10}\n(pk){10}\n){20} Fill in variables for any length: ((kp){x}\n(pk){x}\n){y} Ribbing (similar to seed st):: ((kp){x}\n){y}
  29. Loops and Counters! Knitters use “row” counters • To keep

    track of rows in a patterns • To track repeats Knitting patterns contain loops • For x rows, knit pattern y #DENStartupWeek #KnittingToCoding
  30. Knitting patterns contain While loops Hat decrease instructions: Row 1:

    (k10, k2tog) rep around Row 2: knit Row 3: (k9, k2tog) rep around Row 4: knit Row 5: (k8, k2tog) rep around and so on… until you get down to Row 21, at which point you k2tog all the way around, or (k0 k2tog) rep around. #DENStartupWeek #KnittingToCoding Source:Knitting is Like Coding While loops are instructions that are repeated until a condition is met (such as a variable finally equalling 0). • # of total stitches decreases after each row
  31. Lots of reuse: A note about Copy/Paste Most code doesn’t

    start out as original • “Boiler-plate” code • Templated code • Copy/paste from another source or previous iteration Neither do most knitting patterns • Composed of existing stitches • Differ by ordering and composition #DENStartupWeek #KnittingToCoding
  32. Debugging and Knitting “Knitters are very good at debugging patterns,

    as it turns out. Not only are there a lot of knitters who are coders, but debugging is such a regular part of knitting that the complicated math becomes second nature. Notation is not always consistent, some patterns need to be adjusted for size, and some simply have mistakes.” #DENStartupWeek #KnittingToCoding Source: SkyKnit: When knitters teamed up with a neural network
  33. Crochet vs Knitting | Single-threaded vs Multi-threaded “Knitting uses a

    pair of long needles to form the loops, moving a set of loops from one needle to another. The stitches are held on the needle or “live”. Crochet uses a single hook, to hook the loops together directly on the piece.” “Single threaded processes contain the execution of instructions in a single sequence. ... The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time.” #DENStartupWeek #KnittingToCoding
  34. What Knitting and Coding Have in Common • Create a

    product from a specification or pattern • Use specific, varied tools • Build with an end-user in mind • Requires: specific configuration or skills (some barrier to entry) ….. Also: Humans and something Binary. #DENStartupWeek #KnittingToCoding
  35. Gender split: Knitting vs Programming “May 9, 2018 · 71%

    of knitters and crocheters are female. 29% are male. 37% are employed full-time. Like we mentioned, knit and crochet age ranges are fairly even across the board: 34% are 18+34, 36% are 35-54, and 30% are 55+.” - https://blog.anthonythomas.com/knitting-and-crochet-today-statistics-trends-and-more #DENStartupWeek #KnittingToCoding “2017 - 78.6% of Computer programmers are Male, making them the more common gender in the occupation. “ - https://datausa.io/profile/soc/151131/
  36. Knitting Benefits Your Health “Knitting is both process- and product-oriented,

    encompassing repetitive tasks that can exercise physical and cognitive skills, as well as creating an output that provides a sense of satisfaction.” “Another potential health benefit of knitting is chronic pain relief, possibly as a result of knitting serving as a distraction and psychologically causing a reduction in pain” #DENStartupWeek #KnittingToCoding Source: Medical Bag
  37. Health benefits of Knitting #DENStartupWeek #KnittingToCoding • Lowered blood pressure.

    • Reduced depression and anxiety. • Slowed onset of dementia. • Distraction from chronic pain. • Increased sense of wellbeing. • Reduced loneliness and isolation. Source: Mental Health America
  38. Health benefits of Knitting #DENStartupWeek #KnittingToCoding • Gives you a

    sense of pride • Same benefits as meditation • Alleviates symptoms of anxiety, stress, and depression • Helps improve motor functions • Slows cognitive decline • Helps prevent arthritis and tendinitis Source: LifeHack
  39. Key Take-aways #DENStartupWeek #KnittingToCoding • Knitting & Coding are similar,

    and translating between them could help us to close the gender gap in tech • Knitting is good for your health, and could help address the high rate of anxiety and depression in tech • The world isn’t binary (as we lazily believe) - build a habit of seeing how you can translate your skills
  40. Action Items #DENStartupWeek #KnittingToCoding • Learn something new a. Learn

    to Knit b. Learn to Code • Introduce yourself to someone who isn’t like you • If you make mistakes while learning, just “knit through it”
  41. References • A Mighty Girl • Knitting is Like Coding

    • The 10 types of a knitter • The science of knitting, unpicked • The wartime spies who used knitting as an espionage tool • Purls before wine • What is an API? In English, please • How Knitting is like Coding • SkyKnit: When knitters teamed up with a neural network • Knitters and coders: Separated at birth? • 99-bottles-of-beer.net / KPL #DENStartupWeek #KnittingToCoding