I haven't tried writing a knitting interpreter, even though that it extremely within the Venn diagram intersection of my interests. I have spent some time thinking about trying to formalizing knitting pattern notation. Right now, it's, like mostly there, but every pattern tweaks things in ways that are often arbitrary and confusing.
Knitting patterns are an interesting programming language. Ignoring the resulting fabric for a moment, one way to think of them is that they are an encoding of a linear series of steps the knitter is supposed to perform.
As any programmer knows, there are a whole bunch of possible programs that produce the same output:
print(1)
print(2)
print(3)
print(4)
print(5)
Versus: for (i from 1 to 5):
print(i)
One of the challenges of designing a knitting pattern is coming up with a good encoding for the series of stitches to be created. You might think that the shortest encoding is best, but what you're really trying to optimize for is how easy is it mentally keep track of where you are.A knitting pattern that, say, has deeply nested loops, can require the knitter to hold multiple indexes in their head (or using external counters) and increases the odds of making a mistake. Unrolled some of those loops manually might be more verbose but less error prone. Or not! Maybe the extra verbosity of the long list of stitches makes it easier to lose your place.
Even things like choosing where to place stitch markers can have an effect on how user-friendly the pattern is.
It's an interesting design problem. You're trying to design a set of instructions to produce a good object, but you're also trying to design a set of instructions that yield a good experience producing that object.
I've also been thinking about what constitutes a "good" encoding, and it definitely comes down to individual preferences, even preferences in a given moment. Today you're reading off a sticky-note and want to optimize for size, tomorrow you're laying out 3 notebooks for a huge project and want clarity.
I like the idea of a creator making the base pattern, and then sharing a link that lets the user customize the output encoding.
That customization could be visual (I want a different random seed that is used to parameterize different aspects of this pattern, so it's totally unique to me) or in the notation.
I think it'd be awesome to have a recursive notation editor. So you'd click on a variable and it expands to the verbose representation, which might include other nested variables that you can further expand (or not).
(side note, I hope you don't mind: Game Programming Patterns made a huge difference for me early in my career, thank you for bringing that into the world.)
* Which has really cool construction, and I thoroughly recommend
Interested to know if you've ever tried something like that? I also get that knitting is a hobby many people do to escape computers for a minute.
Anyways, that got me into approaching the problem from a different angle (https://madhatter.app). A visual editor for hat patterns with layering, repeats, shapes, overstitching markers.
Some stuff is broken right now and it doesn't look great on mobile, but I'm building it in real time whenever my partner expresses frustration in some aspect of existing paid software ;-)