Coding for pre-schoolers: a ‘Turtle Logo’ in Forth

*New!* (29 Aug 2020) – Turtle Logo v1.8 (portable) is available! Developer kit with source code included. Suitable from ages 3 years to adult. (970 lines of Forth code).



1. Inspiring the next generation of technology builders.

A challenge facing parents and teachers is how to help children develop ‘builder’ relationships with technology rather than being limited to the passive consumption of content created by others. The consensus on what’s important for older kids and adults is clear: coding. This enables children to participate in the creation of their own technological “micro-worlds” — environments rich in educational potential.[14]

This autumn, spurred by having our own young children (one aged 4 years, the other 16 months), we began an experiment, the result of which is a Turtle Logo program for Windows computers (freely downloadable) that is simple enough to be accessible for children from 3 years and older, while providing an extensible platform that can grow with the child.

The long-term goal is to enable children to express their creativity, artistry, and natural ‘builder’ impulses using coding, computer graphics, and robotics as readily as the previous generation could using paints, brushes, and building blocks.

2. Birth of a Project

Like many pre-schoolers born after 2010, our 4-year old girl is at ease with a tablet. The touch interface makes it easy to consume content (swipe, tap, watch, repeat), but harder to target for an application that needs enough problem-solving complexity to bring out algorithmic thinking.

This autumn, I got around to implementing an approach I’ve been mulling over for a few years. The aim was to see how far coding technology can be made engaging for pre-schoolers (3- and 4-year olds). Our two children provided a convenient justification (excuse?), Jasmine at 4 years & 8 months old and Adam at 16 months. Jasmine, already keen for new and exciting projects, was up for it — the idea of using computers to be able to build things “straight from her imagination” was a thrill. Happy convergence of interests for daddy!

The result of this experiment is a full-featured Turtle Logo drawing program for Windows computers (v1.2 released today) that is accessible even to 3-4-year old children. It is operated using a handful of easy-to-remember keys using mnemonics of their functions in the native language of the child. (One can easily re-map the keys to use mnemonics from a non-English language, or extend them to create a multi-lingual learning environment. The former is a 10-minute modification that a non-technical parent can make – drop a note in the comments if this is of interest to you.)

3. A walk through history: from the 60s to the 80s to today.

Parents who grew up in the 80s may well remember Turtle Logo in the classroom, perhaps on the Apple II, and the simplicity yet fascination it provided [1]. My first encounter with the Turtle was using Apple Logo on the IIe in fifth grade at the International School of Kenya in 1985 — the title had just been released in the US the previous summer [5].

But though new to many schools around the world, by 1982 Turtle Logo was already 15 years old, invented by Seymour Papert, Marvin Minsky, and Wally Feurzeig in 1967 , as part of a US Navy funded initiative for teaching complex concepts using computers, and subsequently funded by the US National Science Foundation.[2]

By 1983, the next iteration of Papert’s Logo vision had been developed: a mass-produced remote-controlled educational robot — Turtle Roamer — with Berol pens attached, capable of physically creating the geometric patterns using the same Turtle Logo language being taught to school-children to draw squares and circles on green monochrome screens.[2]

Fast forward to 2010 and the launch of the iPad. The reality for many pre-school children today is that consumer technology now reaches them several years before they have acquired sufficient literacy (including typing) to engage in coding. This means that by the time they encounter the “Maker culture” their relationship with technology has already been influenced by several years dominated with essentially passive content consumption. This is a significant departure from the situation 30 years ago, when technology was rougher around the edges and required active engagement to use.

The idea behind building Turtle Logo in Forth was to try to counteract this by (re-)creating the rich interactive coding environment (micro-world) that Papert’s Logo offered, without requiring command-line typing. Instead, keystrokes are mapped mnemonically to the functions they trigger (e.g. ‘R’ for ‘record’, ‘Q’ to ‘quit’, ‘C’ for ‘color).

4. How Turtle Logo Works

The pre-school child controls a little Turtle which starts off red and facing North. Colors can be changed at will (press ‘C’ or ‘X’) as can the heading of the Turtle (right and left arrows move 45 degrees clockwise and counter-clockwise). When Turtle moves forward (forward arrow), it leaves behind a painted pixel. When Turtle moves backward (backspace), it eats up any paint in its path. To move without leaving paint behind, lift the pen up (press the tick key ‘ which symbolizes a raised pen), after which one must remember to put the pen back down to resume drawing once more (press tick again to toggle).

With just these six instructions (fwd, back, left, right, color, pen-up), a child can start to create simple drawings – squares, lines, houses, flowers, sky, clouds, birds. Immediate feedback is provided through the creation forming on the graphics screen. Examples of what is possible can be seen below.

A feature that is useful when frustration inevitably hits is the immediate on-screen help (press ‘?’ to see it) which allows the child to successfully resolve a difficulty by pointing out the instructions to any nearby adult (or even an older sibling) and asking for help. It also means the child becomes confident to use the program with anyone around, i.e. technology is egalitarian not a priesthood for a few.

5. Obtaining the Program

If you’re ready to try it, the program itself is available FREE from the downloads page with an auto-installer provided so you can be up and running within minutes. (If you have any problems installing or using it, you can get help through the feedback form on the website.) The remainder of the article describes the findings from the experiment.

6. What is the benefit of exposing children early to building with technology?

Turtle Logo promotes mathematical and engineering thinking by providing children experience in breaking down complex outcomes into simple, repeatable steps. These steps need to be communicated precisely and in the correct sequence, which develops the child’s command of language both with the computer and with others. Socially and emotionally, the inevitable mishaps, oopses, and oh no!’s, lead to a positive, problem/solution orientated outlook: ‘how do I fix it’, and ‘let me try again’, until ‘aha! it works if I do it this way’.

For pre-schoolers, this typically happens with parents (or teachers) guiding, providing encouragement, and motivation. The benefits for young children are improved inter-personal skills (teamwork, collaboration), patience, and the ability and willingness to put sustained effort toward achieving an outcome to which, sometimes surprisingly, they often become remarkably invested. A further benefit is strengthening literacy: the use of phonics in the mnemonics for keystroke functions, letter recognition in finding and pressing the right keys, and an enhanced relationship with writing since keys, letters, words, are being used in practice to convey meaning to the Turtle.

Children who experience, as part of their play, that rush of exhilaration and pride (a computer-science professor of mine used to call this ”the last legal high”) — these are children for whom a fruitful foundation will have been laid for future success in science, technology, engineering, and mathematics — the STEM curriculum. From a young age they will have experienced the delightfulness of solving hard problems through their own sustained creativity, and this will stay with them throughout their schooling and beyond.[15]

This mixture of arts, computer graphics, and robotics, along with the coding, mathematics, and engineering that it requires, provides a powerful stimulus, findings echoed in the extensive “Logo Memos” from MIT’s Artificial Intelligence Lab [4]: #4 Teaching Children to be Mathematicians vs. Teaching About Mathematics, #2 Teaching Children Thinking, #20 Leading a Child to a Computer Culture.

Further examples can be found in special Maker oriented programs, such as NASA’s Robotics Summer Camps[11] or in special programs for the classroom, such as Mike Harmon’s Modular Technology teaching for 8th graders. (The latter starts with LOGO and then works through a child’s self-directed interests amongst a choice of ~30 STEM modules.[12])

7. Some observations from working on coding with my 4-year old

There have been some successes and a good deal of enjoyment in developing and using Turtle Logo with Jasmine. It is gratifying that she finds it engaging — one of her early comments was ‘Daddy, I like this more than my tablet because I can build things from my imagination!’ and indeed, there are times when she will ask to do Turtle Logo instead of watching a children’s program.

Her skill in sending keystrokes to Turtle (coding instructions) improved significantly after a few days, after which she was able to anticipate the response of the turtle and plan ahead the movements she needed to execute. Perhaps the most engaging feature (certainly the most useful algorithmically) has been the ability to record commands for subsequent play back. (Press ‘R’ to record a macro, ‘1’ to play it back.) Using this feature, we can create one tree and have an orchard, one cloud and have a sky full of clouds, one flower and have a field of flowers.

As she explored the various features, she started combining them and creating new patterns to use to fill the screen with color and form. Structure is still quite random with the favorite for a while being building chaotic mazes that we then trace through with a turtle being guided verbally (she speaks; I drive Turtle), after which we switch roles.

Especially interesting was the enthusiasm with which she worked with the the feature-limited and buggy earlier versions of the software — these in fact led to richer conversations and greater excitement (‘Daddy, I found another bug!’). It is an interesting example of how polished, complete technology which cannot be further improved or modified misses a key ingredient of what inspires children: building, making, contributing. It should also provide encouragement to parents who would like to go on a technology journey with their kids — children are more perceptive than we imagine, but a lot more forgiving of imperfection than we expect.

For Jasmine, it was a thrilling thought that we were building something that could be provided to others, and that features she came up with could impact how easy or hard it was for other children to use it. This also led to an interesting conversation about why some things are given for free (‘open source software’, or this program) while money is charged for others (such as what she sees on TV or in toy shops).

Turtle Logo in Forth has benefited from these conversations, whether through direct feature suggestions or usability elements inspired by watching her interacting with the Turtle and observing what caused her to get stuck and how to get her over the hurdle. One example is the addition of the ‘toggle color backward’ command (‘X’). Since there are 16 color choices available, if Jasmine toggled past the one she really wanted, she would have to toggle forward through all of them to get back to the one that was missed.

An important benefit has been the ability for me to make speedy changes and add new features quickly in order to preserve the momentum and enthusiasm during these times of collaborative development. Using Forth, adding the toggle color command took 15 minutes with the advantage that she saw the coding change happen in real-time while she watched and the resulting change in functionality. (A lot more feature requests came after this!) This is one of the attributes I value about Forth as a coding language.

8. Growing as your child grows: features to engage teens and adults

Turtle Logo in Forth is in this sense a “micro-world” rich in educational opportunity, a term used by Papert in his 1987 paper [17].

For older children (and adults), Turtle Logo in Forth includes a fully extensible Turtle command language which can be used to code intricate shapes and figures which can then be used in the alternative command-line environment. This extensibility is another outstanding feature of the underlying Forth language — new words defined become first-class words in the environment itself.[8,9]

The intent is to allow older children to return to the same environment they used when younger, but now as developers able to build new creative content for, e.g. their younger siblings. Engagement continues both in the process of development and the exchange of ideas, older child with younger child. Through coding, children get a say in building their own toys.

For hackers (actual or aspiring, teen or adult), the code for the program is included and fully open source. At ~750 lines of commented Forth code, it is small and easy to get one’s mind around the whole thing. It is worthwhile as an illustration of how an old-school interactive graphics program (DOS style) can be built, right down to poking the pixels using assembly language (two routines). Users interested in dabbling in some coding are free to modify and extend the functionality. (The code is made available under a GNU License, so modifications must be made available back to the community, ensuring that the commons continues to benefit.)



9. Why Forth?

The key reason I chose Forth as the language for coding Turtle Logo is its intimate connection with embedded programming, and with sensor systems, and robotics. In my view, exposing children (and their parents) early to Forth makes it easier later to transition to bigger and bolder projects.

A second reason is Forth’s universality and apparent timelessness — both of which I find increasingly important given decreasing discretionary time and the proliferation of computing languages. Using Forth, I can write to a microchip as easily as I can to a Windows, Mac, Linux, or Android machine. Forth looks more or less the same today as it did in the 1970s when it was invented by Chuck Moore, while the average life of a popular language is 5-10 years.

As Bernd puts it :

We are now in the cambric explosion of language evolution. Lots and lots of programming languages, nice and ugly, are created out of the dust. Many are short-lived, even the important ones ride on the waves of fashion. … There’s one little language with a backbone, but without much flesh, that’s Forth. If it will survive, and render flesh and shells when necessary, it will take over the world. It might be swallowed before that, but it has survived long enough to make this unlikely. – Bernd Paysan, author of GForth for Windows, Linux, and Android – Why I Use Forth.

10. Challenges

Over the past few months, I developed a set of challenges with Jasmine to help her climb the learning curve and motivate reaching for the next accomplishment. Time-permitting, I will add these in a separate posting.

But you, dear Reader, have come this far unrewarded! So here is a challenge you can try today. (Note this is probably too hard for your pre-schooler, though it does work rather well to impress them and get them wanting to have a try themselves). The solution is given as an animation (scroll down or click here).



Challenge: Can you use Turtle Logo to create a 2-color interlocking chain in 100 keystrokes or less?

A few hints

The screen is wrap-around, i.e. going off the end in any direction will bring you to the opposite side. To solve this you will need to: record a macro (press ‘R’ to stop and start recording — 50 key strokes is all you will need), use pen-up/pen-down toggle functionality (press tick (‘) to toggle), change color both forwards (‘C’) and backwards (‘X’), and move Turtle around (FWD arrow moves Turtle in the direction it is pointing, LEFT and RIGHT turn change Turtle’s heading counter-clockwise and clock-wise by 45 degrees at a time.) Once you get the macro recorded, you’ll need to replay it (‘1’), supplemented by a few thoughtful Turtle positionings in order to use the single macro to create the interlocking result.



Solution: shown as an animation — wait for it to move.



11. Feedback is a gift

If you give Turtle Logo in Forth a try especially with your little ones, please do share your feedback and views in the comments section below!

Happy Turtle-ing!

Appendix. References & Further Reading

Coding in Logo

[1] 2007 was the 40th birthday of Logo (1967) – Nostalgia.

[2] History of Logo, Papert, Turtle Robots (Valiant Technology, 1983, last shipped in 2011)

[3] Logo History from MIT’s Artificial Intelligence Labs

[4] Logo Memos from MIT Artificial Intelligence Lab work with Boston school-children on Logo and Turtle Logo

[5] Apple II History, including the Logo and Forth languages.

Coding in Forth

[6a] Why Forth? Bernd Paysan, author of GForth for Linux, Windows, an Android

[6b] Learn Forth in Y Minutes:

[7] Leo Brodie – Starting Forth

[8] Chuck Moore – History of Forth

[9] Chuck Moore – Programming a Problem Oriented Language

[10] J.V. Noble – A Beginner’s Guide to Forth

The Maker Movement

[11] NASA Robotics camps

[12] Mike Harmon – Teaching Modular Technology to 8th graders

[13] The Maker Movement

[14] The Dilemma’s of Maker Culture (Atlantic Monthly, April 2015, John Tierney)

[15] Why the Maker Movement is Important to America’s Future (Time Magazine, May 2014, Tim Bajarin)

[16] The origins of mindstorms (Wired, Mar 2007, Jim Bumgardner)

STEM curriculum and the Evolution of School

[17] MicroWorlds: Transforming Education (Seymour Papert, 1987) PDF here.

[18] Why School Reform is Impossible (Seymour Papert, inventor of Logo programming language and the Turtle Robot for education, Journal of the Learning Sciences, 1997, Volume 6, Issue 4, pp.417-427)

Note – Papert’s point here is subtle – while institutional reform is unlikely (the school has defense mechanisms to oppose changes from without), the evolution of school is inevitable, forced by the fact that technology changes children and the way they learn.

[19] STEM: Education for Global Leadership (US Dept of Education, Obama’s focus on STEM)

[20] The Advisory Committee on Mathematics Education (UK)

[21] Six Characteristics of a great STEM Lesson. (Education Week, June 2014, Anne Jolly)