BFOIT - Introduction to Computer Programming

Appendix B (What is TG?)

TG is an acronym for Turtle Graphics, a well-known subset of the Logo programming language.  TG was born a library of methods, written in Java, that could be used to do turtle graphics stuff in Java programs.  See the preface if you wonder why...

In addition to providing many, if not all, of the common Logo graphics procedures (e.g., forward, right, penup, etc...), TG provides simple, easy-to-use, support for mouse and keyboard events are included. See TurtleGraphicsWindow, TGKeyHandler, and TGMouseHandler for JavaDoc documentation of these classes.

After BFOIT chose Logo for its summer camp's introduction to programming lessons, TG was extended into a Java applet.  I wanted a way for students to read about a concept, at home or anywhere, on a web page and immediately play with a Logo interpreter to see it in action.  Learning is about doing, not reading or listening to a lecture.

This worked well but its time is limited now that browsers are eliminating support for Java applets.

If you use a browser that supports Java applets, here are links to a few early examples of embedded TG:

The TG applet started out with a very simple interpreter, a tiny subset of what most other Logo programming environments provided.  All that was needed was the functionality required to explore the simple concepts being presented in the web lessons.  The graphics stuff was already there; just add some operations and procedure definitions.  Looking back, providing an integated editor was half the code that needed to be written.

TG also runs as an application, a standalone program, initially because testing and debugging it was much easier than working with it as an applet.  Since my original goal for the lessons was to prepare a student for the AP CS class, I added functionality that looked like its counterpart in Java, specifically mouse and keyboard events.

BFOIT's students are supported throughout their high school years.  Most students participate starting the summer before they enter high school and remain with the program until entering college.  As one would expect, returning students want additional features so that they can put together more interesting programs.  Students say: "If only TG had [feature xyzzy], I could write this really cool program!" And so, TG grew over the years.  Version .9.38.2 of TG has more than sixty commands, and one hundred operators.

Although most of the development of TG has been concentrated on making it easy for introducing programming, it does have a few features for advanced students.  As an example, its editor runs in either a Notepad-like mode or provides a small subset of Emacs.  On the programming side, multiple turtles are fully supported.  Any turtle can TELL another to do something or ASK another turtle for some information, where it is at for example.  Pixels on the graphics canvas can be manipulated with the GETPIXELS operator and SETPIXELS command, along with a full set of bit twidling operations, e.g., BITAND, BITOR, LSHIFT, etc...  Events such as keyPressed, keyReleased, keyTyped, mouseClicked, and mouseMoved can be captured and processed.

Prefix Notation

Infix notation for '+', '-', '*', '/', '=', '<', and '>' was finally added with version .9.38 of TG.

jLogo was conceived as an introductory text-based programming language - to be followed by exposure to Java.  It is intended to be a bridge between blocks=based programming (Scratch) and Java.  I favor maintaining consistency (with prefix notation) rather than provide a few special cases of infix notation in the BFOIT lessons.  This allows the lessons to exclude precedence rules; they can wait until an introduction to Java.

But TG is now used as a standalone Logo programming environment by many.  I added infix operators for this group of people.  Currently the support is not documented in the BFOIT lessons, but I announced their implementation here.

Availability

TG is available free on the BFOIT website.  The easiest way to get a copy is via anonymous FTP (ftp.bfoit.org). See the notes on installation of TG for more details.


Go Home

Public Domain Mark
This work (BFOIT: Introduction to Computer Programming, by Guy M. Haas),
identified by Berkeley Foundation for Opportunities in IT (BFOIT),
is free of known copyright restrictions.