As programming languages researchers, we’re entitled to a certain level of mathematical rigor behind the languages we write and analyze. Programming languages have semantics, which are definitions of what statements in the language mean. We can use those semantics to do all sorts of useful things, like error checking, compiling for efficiency, code transformation, and so on. This blog post is about a programming domain that doesn’t yet enjoy the same level of rigor in its semantics: machine knitting. People write programs to control massive arrays of needles that manipulate yarn into useful 3D objects. In this blog post, I’ll run through the process of finding “the right” semantics for machine knitting, touching on why we want semantics, connections to traditional programming languages, and what we might use these semantics for in the future. In our search, there are a surprising number of guest appearances by fields of study outside of programming languages: algebraic topology, group theory, knot theory, category theory, and even quantum computing! I’ll motivate semantics with a toy problem: can two given statements commute with each other? Here’s an example where they can: By “commute”, I mean that if I swapped the order of the lines, the program would do the same thing. The commuting problem is important: a compiler might move around the order of instructions to optimize memory usage by batching related instructions together, an analyzer might want to see if two programs are equivalent, and we might also want to know whether we can run two instructions in parallel. In the above example, we know that the statements commute because of the implied semantics of the statements – they don’t have anything in common, so they shouldn’t affect each other! Here are some more examples. These statements don’t commute because there’s a data dependency: If we swapped those two statements, the statement assigning x’s value would use a potentially different value for y. Non-commu...
First seen: 2025-04-22 16:41
Last seen: 2025-04-23 15:46