Turtles All The Way Down

What do you think this “code” does?


Well, it’s a ridiculously terse, stack-based Logo-like language with single character commands. Beginning with 0, it repeatedly (720 times) increments the top stack value and moves forward by that amount (leaving a rainbow-colored trail behind) and turns 89 degrees. Amazingly, the code draws this:


You can draw any number of astounding things and even do animation with a crazy-small amount of code:

Spiral2 Spiro Sun Flower

The beauty is that it’s all implemented in plain Javascript and rendered using HTML5 canvas, so you can give it a try here: http://www.lkjsdf.com/archive/turtle/?0(1adf89r)720x

My fascination with Forth-style stack languages isn’t dying down (see my earlier Ape post) and I still love the idea of using Logo as a teaching tool for children. I was rather inspired by Seymour Papert’s Mindstorms a while back and have more recently been enjoying Turtle Geometry by Hal Abelson (of SICP fame) and Andrea diSessa. I think that a bit of nice editing and stack visualization UI could make a concatenative-style Logo suitable for children with command “blocks” you snap together and interactivity as you edit.

I’ve been playing with this extremely compact Logo for a couple of days. Each character is a command directing the turtle, causing a stack effect, doing basic math, etc. I’m not going to go into great detail about how it works here in the blog. Just have fun playing with it. Try the demos. See if you can glean how it works. If all else fails, feel free to view the page source. It’s all there in a tiny amount of script!

Have fun, and if you come up with something really cool then post a link in the comments here!

Comments (1)

  1. It's been updated a bit since this post, and also here's a screencast demo: http://www.youtube.com/watch

Skip to main content