The first program
The program
Section titled “The program”Write this text into hello.rgr:
class Main { sfn main:void () { def name "world" print ("hello " + name) }}The program has one class. The static function main is the entry point. The
operator def declares a variable, and the compiler finds the type of the
variable from the value.
Compile the program
Section titled “Compile the program”rgrc hello.rgr -l=es6 -d=./bin -o=hello.jsnode bin/hello.jsThe program writes hello world.
The same program for other targets
Section titled “The same program for other targets”rgrc hello.rgr -l=go -d=./bin -o=hello.gorgrc hello.rgr -l=python -d=./bin -o=hello.pyrgrc hello.rgr -l=rust -d=./bin -o=hello.rsThe operator reference shows the generated code of each operator for each target language.
The next step
Section titled “The next step”- Program structure describes classes and functions.
- Types describes the type system.
- Ownership and lifetime describes who keeps an object alive, which C++, Swift and Rust need.
- Target languages describes what each target supports.
Ranger 3.5.1 · commit f323fd4 · development build