Raz, Set, Go
A tour of raz, in the spirit of A Tour of Go. Each lesson is one idea and a whole program, and the output shown is what the program printed when this page was made.
It is in three parts, as one counts off: Raz (one), the
first steps; Set, how data is laid out; and
Go, making programs that run, fail and finish well. To follow
along, get raz and run any program with
raz run Name.raz. When you finish, More Raz goes down to the machine.
Raz
- Hello, world A module, an import, a procedure; running, printing, exit status and arguments.
- Modules Exports, renaming, the order bodies run in, and what the compiler refuses.
- Integers The ten integer types, literals, wrapping, signed and unsigned, division, shifts and bits.
- Values and conversions Nothing converts unasked; what converts to what; booleans and reals.
- Procedures and several results Value and var parameters, several results, forward, and procedures as values.
Set
- Arrays, slices and strings Five in a row, a window onto them, bytes in UTF-8, and checks on every index.
- Records and pointers Laid out as C lays out a struct, packed records, pointers and nil.
- Enumerations, sets, variants and match Names in order, sets as bits, and cases the compiler makes you handle.
- Memory and allocators No garbage collector; you choose where memory comes from, and what happens when it runs out.
Go
- Errors A second result, compared by identity; passing errors up; and no exceptions.
- Defer Clean up beside the line that needs it, in the right order, on every way out.
- When it goes wrong Every index is checked, a failure says where and with what values, and how to read it.
- Generic modules A module that takes types and procedures; the library's List, Map and Sort.
- Talking to C Call a C library, be called back, share variables, and mind the two buffers.
- Threads Native threads without C, atomics, a mutex, and why the counter needs both.