HELLO, WORLD: YOUR FIRST SATELLITE PROGRAM
Every programming language starts the same way: a program that says hello. In satellite that program is six short lines, and three of them are the frame that every satellite program has. Learn the frame once and you can write anything inside it.
The whole program
Here it is. Type it into any plain text editor, exactly as it is shown.
(satellite)
satellite.capsule satellite.main()
{
satellite.console.display("Hello, World!")
satellite.return(satellite)
}Hello, World!What each line does
satellite.include(satellite)says “this file is a program”. It is always the first line. A file without it is a spaceship: a file that other files include, which satl will not start by itself.satellite.capsule satellite.main()is where your program begins. A capsule is satellite’s word for a function, andsatellite.mainis the one every program starts in. Everything your program does happens between its{and its}.satellite.console.display("Hello, World!")writes a line of text on the screen. The text goes between double quotes.satellite.return(satellite)is where your program ends. Its place is the last line ofsatellite.main, and when satl reaches it the program is finished.
You may already have spotted the pattern in the names. A dotted path that starts with satellite names something the language owns. satellite.console.display belongs to satellite, and so do satellite.main and satellite.return. A bare name, with no satellite in front, is something you own: a variable or a capsule you made yourself. You will see this rule everywhere, and it means you can always tell at a glance which words are yours.
Saving and running it
Save the file as hello.satl. The name is up to you, but it must end in .satl, and a plain text file is all it is. Then open a terminal in the folder where you saved it and type:
satl hello.satlsatl is the satellite interpreter: it reads your program and runs it. It first writes a short banner with the language’s name and its version, and then your program’s output, Hello, World!. If satl is not found, see the INSTALL page.
You may notice a new file beside your program called hello.sate. That is satl writing your program out in the language’s own numbered codes as it reads it. Nothing asks you to open it, and it is safe to delete.
A little more
Inside satellite.main you can write as many lines as you like, and they run from top to bottom. Two slashes, //, start a comment: a note for people, which satl skips.
(satellite)
// A comment runs from two slashes to the end of the line.
satellite.capsule satellite.main()
{
satellite.console.display("Hello, World!") // the classic
satellite.console.display(6 * 7)
satellite.variable.string name = "Ada"
satellite.console.display("Hello, " + name + "!")
satellite.return(satellite)
}Hello, World!
42
Hello, Ada!satellite.variable.string name = "Ada" makes a variable: a named box that holds a value. The type comes first (satellite.variable.string, some text), then your name for it, then its value. The + joins pieces of text together. Notice the spaces around * and +: satellite asks for a space on both sides of every math sign.
When something is missing
satl checks your whole file before it runs a single line. If one of the three frame lines is missing, it says which one, and it tells you what to type. Here is the hello program with its last line forgotten:
(satellite)
satellite.capsule satellite.main()
{
satellite.console.display("Hello, World!")
}--------------------------------------------------------------------------------
SATELLITE CRITICAL ERROR REPORT
--------------------------------------------------------------------------------
S103: FILE_HAS_NO_RETURN
satl.file(check): this file has no satellite.return -- execution ends inside
main
directory: forgot.satl
execution ends inside main, and main has to say so. Add this as main's last
line, just before its closing }:
satellite.return(satellite)
machine code 12 satl_file_missing_satellite_return_satellite -- satl exits with
this.
--------------------------------------------------------------------------------Nothing was printed, not even the hello: satl stopped before the program began. Every error report looks like this one. It gives a code (S103), what went wrong in plain words, where it happened, and what to do about it. The post READING AN ERROR REPORT walks through one line by line.
A program always has all three:
satellite.include(satellite)at the top,satellite.capsule satellite.main()where it begins, andsatellite.return(satellite)where it ends.
Where next
Everything the language has is in the FULL REFERENCE. To write capsules of your own, read CAPSULES: SATELLITE FUNCTIONS. For more about printing, read DISPLAYING TEXT, and for everything satl can do from the command line, read THE SATL COMMAND.
