Knit 1, Perl 1

Knit 1, Perl 1

Knitting and programming; a creative hobby with sticks and string, and writing complex logic in computer languages - could they be any more different? Actually, they’re not so dissimilar. Let me show you where knitting and programming intertwine!

F868a7d36323e80a7cf37e79d8e5c370?s=128

Katy Ereira

June 10, 2017
Tweet

Transcript

  1. @maccath | Katy Ereira | #PHPSC17 Knit 1, Perl 1

    Where Knitting & Programming Intertwine
  2. @maccath | Katy Ereira | #PHPSC17 Programming is... Writing a

    set of instructions that when run on certain hardware perform manipulations and calculations that produce a desired result
  3. @maccath | Katy Ereira | #PHPSC17 Knitting is... Following a

    set of instructions using certain needles and yarn to perform manipulations that produce a desired result
  4. @maccath | Katy Ereira | #PHPSC17 Seeing a pattern?

  5. @maccath | Katy Ereira | #PHPSC17 Ok; so knitting is

    more like computing than programming.
  6. @maccath | Katy Ereira | #PHPSC17 But like computer programs,

    knitting patterns are a set of instructions.
  7. @maccath | Katy Ereira | #PHPSC17 These can be represented

    in different ways; many of which draw parallels with computer code.
  8. @maccath | Katy Ereira | #PHPSC17 Unravelling the Mystery

  9. @maccath | Katy Ereira | #PHPSC17

  10. @maccath | Katy Ereira | #PHPSC17

  11. @maccath | Katy Ereira | #PHPSC17 Worked over even number

    of sts. Row 1: [yo, k2tog] rep. Row 2 & 4: k all sts. Row 3: [ssk, yo] rep. Rep rows 1-4 for pattern. Knitting pattern
  12. @maccath | Katy Ereira | #PHPSC17 Worked over even number

    of sts. Row 1: [yo, k2tog] rep. Row 2 & 4: k all sts. Row 3: [ssk, yo] rep. Rep rows 1-4 for pattern. Knitting pattern - variables
  13. @maccath | Katy Ereira | #PHPSC17

  14. @maccath | Katy Ereira | #PHPSC17 sts rows

  15. @maccath | Katy Ereira | #PHPSC17 sts = 12 row

    = 5 row 1 row 2 row 3 row 4
  16. @maccath | Katy Ereira | #PHPSC17 Worked over even number

    of sts. Row 1: [yo, k2tog] rep. Row 2 & 4: k all sts. Row 3: [ssk, yo] rep. Rep rows 1-4 for pattern. Knitting pattern - conditionals
  17. @maccath | Katy Ereira | #PHPSC17 sts = 12 row

    = 5 row 1 row 2 row 3 row 4
  18. @maccath | Katy Ereira | #PHPSC17 Worked over even number

    of sts. Row 1: [yo, k2tog] rep. Row 2 & 4: k all sts. Row 3: [ssk, yo] rep. Rep rows 1-4 for pattern. Knitting pattern - iterators
  19. @maccath | Katy Ereira | #PHPSC17 row = 5 %

    4 = 1 row 1 row 2 row 3 row 4
  20. @maccath | Katy Ereira | #PHPSC17 Worked over even number

    of sts. Row 1: [yo, k2tog] rep. Row 2 & 4: k all sts. Row 3: [ssk, yo] rep. Rep rows 1-4 for pattern. Knitting pattern - methods
  21. @maccath | Katy Ereira | #PHPSC17 Row = 5 %

    4 = 1 Row 1 Row 2 Row 3 Row 4 k2tog yo yo k2tog
  22. @maccath | Katy Ereira | #PHPSC17

  23. @maccath | Katy Ereira | #PHPSC17

  24. @maccath | Katy Ereira | #PHPSC17 Row = 6 %

    4 = 2 Row 1 Row 2 Row 3 Row 4 Row 5
  25. @maccath | Katy Ereira | #PHPSC17 Let’s Craft Some Code

  26. @maccath | Katy Ereira | #PHPSC17 function pattern(array $sts, int

    $rows) { if (count($sts) % 2 != 0) { throw Exception(“The number of stitches must be even!”); } // ... } Knitting pattern - pattern method, conditionals
  27. @maccath | Katy Ereira | #PHPSC17 function pattern(array $sts, int

    $rows) { // ... for ($row = 1; $row <= $rows; $row++) { // ... } } Knitting pattern - pattern method, iterator
  28. @maccath | Katy Ereira | #PHPSC17 function pattern(array $sts, int

    $rows) { // ... for ($row = 1; $row <= $rows; $row++) { if ($row % 2 == 0) { evenRow($sts); continue; } // ... } } Knitting pattern - pattern method, more conditions
  29. @maccath | Katy Ereira | #PHPSC17 function pattern(array $sts, int

    $rows) { // ... for ($row = 1; $row <= $rows; $row++) { // ... if ($row % 4 == 1) { rowOne($sts); continue; } // ... } } Knitting pattern - pattern method, more conditions
  30. @maccath | Katy Ereira | #PHPSC17 function pattern(array $sts, int

    $rows) { // ... for ($row = 1; $row <= $rows; $row++) { // ... rowThree($sts); } } Knitting pattern - pattern method, more conditions
  31. @maccath | Katy Ereira | #PHPSC17 function evenRow($sts) { foreach

    ($sts as $st) { k($st); } } Knitting pattern - even round method
  32. @maccath | Katy Ereira | #PHPSC17 function rowOne($sts) { for

    ($i = 0; $i < count($sts); $i += 2) { yo(); k2tog($sts[$i], $st[$i+1]); } } Knitting pattern - row one method
  33. @maccath | Katy Ereira | #PHPSC17 function rowThree($sts) { for

    ($i = 0; $i < count($sts); $i += 2) { ssk($sts[$i], $st[$i+1]); yo(); } } Knitting pattern - third row method
  34. @maccath | Katy Ereira | #PHPSC17 // Cast on 20

    stitches $stitches = array_fill(0, 20, new Stitch()); // Knit for this many rows $rows = 10; // Let’s knit! pattern($stitches, $rows); Knitting pattern - usage!
  35. @maccath | Katy Ereira | #PHPSC17 Charting a Course

  36. @maccath | Katy Ereira | #PHPSC17 Credit: Hedgehog Fibres -

    https://www.flickr.com/photos/29825916@N05/10784075824/
  37. @maccath | Katy Ereira | #PHPSC17 4 O 3 2

    O 1 O yo k2tog ssk k A Knitting Chart
  38. @maccath | Katy Ereira | #PHPSC17 4 O 3 2

    O 1 rows repeat pattern sts O yo k2tog ssk k key A Knitting Chart
  39. @maccath | Katy Ereira | #PHPSC17 The Future is Looming

  40. @maccath | Katy Ereira | #PHPSC17 Credit: Karen Blakeman -

    https://www.flickr.com/photos/rbainfo/5427088569/
  41. @maccath | Katy Ereira | #PHPSC17 Credit: smeech - https://www.flickr.com/photos/39554118@N08/13901738784/

  42. @maccath | Katy Ereira | #PHPSC17 Credit: smeech - https://www.flickr.com/photos/39554118@N08/14349266009

  43. @maccath | Katy Ereira | #PHPSC17

  44. @maccath | Katy Ereira | #PHPSC17 “ The term "Jacquard"

    is not specific or limited to any particular loom, but rather refers to the added control mechanism that automates the patterning. The process can also be used for patterned knitwear and machine-knitted textiles, such as jerseys.
  45. @maccath | Katy Ereira | #PHPSC17 “ [The] use of

    replaceable punched cards to control a sequence of operations is considered an important step in the history of computing hardware. Jacquard's invention had a deep influence on Charles Babbage.
  46. @maccath | Katy Ereira | #PHPSC17 Weaving Everything Together

  47. @maccath | Katy Ereira | #PHPSC17 There are challenges faced

    by knitters, which could be untangled through programming.
  48. @maccath | Katy Ereira | #PHPSC17 Formalisation of Knitting Patterns

    • Translation ◦ “I’d like this pattern to use abbreviations I understand.” • Charting ◦ “I’d like to convert this written pattern into a visual chart.” • Validation ◦ “Will this pattern work, or does it contain mistakes?”
  49. @maccath | Katy Ereira | #PHPSC17 KnitML - http://www.k2g2.org/wiki:knitml

  50. @maccath | Katy Ereira | #PHPSC17 Arithmetic and Calculations •

    Sizing ◦ “How many rows do I need to knit to reach my correct size?” • Shaping ◦ “What stitches do I need to make in order to shape this garment to fit my body?” • Adaptation and alteration ◦ “What size needles should I use in order to knit with this thicker yarn?”
  51. @maccath | Katy Ereira | #PHPSC17 Job Replacement • Test

    knitting ◦ Programmatically knit the pattern and analyse the output; does it work, will it fit? • Technical editing ◦ Validate the pattern; spot knitting mistakes and standardise terminology. • Knitwear design ◦ Create knitting charts and garment templates; easy design & create patterns.
  52. @maccath | Katy Ereira | #PHPSC17 There are difficulties faced

    by programmers, which could be ironed out through knitting.
  53. @maccath | Katy Ereira | #PHPSC17 Staying Sane • Stress

    reduction / avoiding burnout ◦ Participating in a meditative hobby such as knitting can help you unwind • Solving difficult problems ◦ Performing a different activity can free your mind to come up with crafty solutions • Brain training ◦ Strengthen your intellectual fibre by exercising your brain
  54. @maccath | Katy Ereira | #PHPSC17 Knit for Health and

    Wellness - http://www.knitforhealthandwellness.com
  55. @maccath | Katy Ereira | #PHPSC17 Indulge Your Geekiness •

    Mathematical/Geometric Knitting ◦ Moebius scarves, non-orientable surfaces, klein bottles, pi shawl • Coded Knitting ◦ Encoding data in knitting • Fandom Knits ◦ Dr Who scarves, cosplay, geeky motifs
  56. @maccath | Katy Ereira | #PHPSC17 Credit: birdfarm - https://www.flickr.com/photos/birdfarm/58097731

  57. @maccath | Katy Ereira | #PHPSC17

  58. @maccath | Katy Ereira | #PHPSC17 Give Knitting a Spin!

  59. @maccath | Katy Ereira | #PHPSC17 Yarning for more? Knitting

    Help: http://www.knittinghelp.com/videos/learn-to-knit Craftsy knitting classes: http://www.craftsy.com/classes/knitting Knitty - free online knitting magazine: http://knitty.com Ravelry - social network and pattern library: http://ravelry.com k2g2 - “the convergence of brains and crafts”: http://www.k2g2.org