Hello, World

The traditional introduction to any programming language is a program which repeatedly prints out the text "Hello, World!". Here it is written in steve:

@include "Control.tz"           

Controller HelloWorld.

Control : HelloWorld {
        + to iterate:
                print "Hello, world!".
}

The specifics will be discussed in more detail through the rest of this chapter. Briefly, we first declare the simulation's controller object to be a class called HelloWorld (line 3). Then we construct the HelloWorld class (lines 5-8), and as part of that class, we define a method called iterate (line 6) which will print out the text "Hello, world!". The "include" line (line 1) simply tells breve to load in a file called "Control.tz", which is included with the breve distribution. This built-in class file contains the class control, which is the parent class for our "HelloWorld" controller.

When this simulation is run, the controller object is created, and the method named iterate gets run automatically at every step of the simulation. Thus, "Hello, World!". Ad nauseum.