Throughout the 1970s and 1980s many children's first experience of computer programming came from Logo, a general-purpose interpreted language most-famous for its graphical capabilities. With these, students could instruct a graphical "turtle" (or a physical hardware robot) to draw straight lines and turn corners.
Logo is little-used today, but I thought that it could benefit from a modern, web-based reimagining. And because I apparently never got over Web 2.0-style names, it's called TRRTL. (Here's the full story.)
This site works on modern desktop browsers and some mobile browsers (mobile Chrome has
reduced functionality because it does not support keypress events).
Type commands to the turtle to tell it what to do. Commands are case-sensitive. For example:
forward 100fwd / fd
backward 50bwd / bd
right 90rt
left 45rt
pen up / pen downcolour 'red'lightblue, rebeccapurple) or a hex
code (e.g. #ffb6c1).
Alias: color
turtle show / turtle hideclear()().
home()().
reset()clear() followed by a home().
Note the parentheses (). You can also perform a reset()
by clicking the "reset" button near the bottom right of the screen.
Additional drawing commands include:
moveX 100moveY -50setAngle 180arc 90, 120arc 360, 50 draws a complete circle around the turtle with a radius
of 50 steps and arc 180, 30 draws a smaller semicircle only to the right
of the turtle.
print 'hello, turtle'print 4+3), or variable.
Every command you execute is recorded in an array, commandHistory, and this
is encoded into the address bar. This allows you to save yor state and carry on where you
left off simply by bookmarking the URL, or
share your work with a friend by sending it to them.
When you reset(), this information is discarded.
When you program TRRTL, you're actually writing CoffeeScript, a lightweight language language atop JavaScript. In addition to writing code a line at a time into the TRRTL terminal, the capability exists to write longer problems in a more developer-friendly way. Leveraging CoffeeScript gives you loops, arrays, conditional logic, arbritrary variables, and more. See the samples below for some ideas.
Clicking the "code editor" button near the bottom right of the screen pops up a large box into which you can write or copy-paste a multiline program. Click the green "play" button to run it. The program will remain in the code editor if you want to return to it.
Alternatively, copy-pasting code directly into the TRRTL terminal will result in that code being put into the code editor and executed immediately. You can also drag-and-drop files from your computer into the terminal to upload and execute them, enabling you to write code in your favourite text editor.
Try any of the following examples to see what TRRTL is capable of or download the source code of any to see it for yourself.
TRRTL was written by Dan Q. It makes use of CoffeeScript and jsZIP under the MIT License. All other code is released into the public domain in accordance with The Unlicense.