The Actor «Ladybug»

Introduction

Today's world is unimaginable without digital electronic devices. We encounter smartphones, ATMs and computers at every turn. Modern televisions, washing machines, microwave ovens and refrigerators are also controlled by digital microprocessors.

Children, like adults, use these devices and want to know how they work. But children have little experience to understand computer science. On the other hand, many of them chat with friends over the Internet and watch cartoons in a web browser.

These basic computer skills are enough to program «Ladybug» — the actor of the free virtual learning environment. To learn the basic concepts of imperative programming, you will need nothing more than a device with a web browser and free time.

Learning environment

The prototype of «Ladybug» is the program «Kangaroo Roo», which was used in secondary schools of the USSR in early 1990s. The developers of this program Mark Sapir and Eugene Linetsky taught programming to children in grades 4-7 in Lincoln (NE) in 1992-1994. Unfortunately, «Kangaroo Roo» runs on the outdated DOS operating system and is difficult to run on modern computers. On the contrary, «Ladybug» is implemented using client-side web technologies, and runs in almost any modern web browser.

The Actor «Ladybug» understands the programming language of «Kangaroo Roo» and operates in the same environment — on a checkered board of 15 columns and 19 rows (fig. 1). The actor moves along the lines and can paint them. Of course, it can turn, but left only. To turn right, it must turn left three times.

15x19 checkered board
Fig. 1. The drawing board.

The «Ladybug» application can be used online, or it can be installed locally. A nice feature of «Ladybug» is that both the user interface and the programming language can be translated into the native language of students. The sources of this software are open under GPL-3.0 license.

You can see video lessons how to use the «Ladybug» environment on Youtube channel and use the learning environment online.

User interface

The Actor «Ladybug» can be controlled using touch screen, but preffered control devices are mouse (or touchpad) and keyboard. The user interface consists of five main parts (fig. 2):

Five main parts of the interface
Fig. 2. The Actor «Ladybug» user interface.
  1. Current mode indicator. The learning environment has three modes: Interactive (the actor executes entered commands immediately), Programming (entered commands are stored to the program) and Program execution (execute the entered program).
  2. Main menu. Menu item can be selected by clicking it or by pressing appropriate key on the keyboard. As sample, to select next environment mode you can click its title (interact on the fig. 2) or press [TAB] key.
  3. Program editor. Simple text editor is enabled in the Programming mode only. The commands can be entered manually using the keyboard or selected from the menu.
  4. Player board. The checkered board where the actor walks and draws.
  5. Notification area. Here information and error messages are displayed.

Programming language

Main commands of the drawing player programming language are:

Any image can be drawn using those commands, but writing a program using them only might take a long time. A sequence of commands can be aggregated into a subroutine to make programs shorter and more clear:

There are conditional statements to check if the actor is on the edge of the board:

The last part of the programming language commands are the statements to execute a sequence of commands repeatedly:

That's all about the programming language. Let's look at some code examples.

Code examples

Sample 1. Sequential program.

Let's the Ladybug draw a 2x2 box! Ok, the program is here:


Sample 2. Procedural program.

The above program works well but it is too long and nobody can say what it draw before it will be executed. Let's use procedures:


Sample 3. Recursive program.

Well... How about a row of boxes? No problem, let's use a recursion:


Sample 4. Condition.

Hm... The actor crashes after the fifth box due it tries to go out of board. Let's protect the actor using conditional command:


Sample 5. While loop.

The above program works correct. But there is another way to execute a part of code repeatedly — using while loop instruction:


Sample 6. Nested loops.

The program can be extended to draw as many rows of boxes as possible:


More interesting but complicated examples can be found on the site about Kangaroo Roo learning environment (in Russian).