Learn TorbScript
For people who already program - a fifteen-minute tour, then one short page per idea, all of it done in an evening.
For the shape of the language in five minutes, read TorbScript in 10 ideas. Then take the tour: fifteen minutes, and every example runs in the page. Then install TorbScript and go through the pages below in order. Each one says what you will be able to do, shows one example, and names the next page. Together they take an evening.
If you know Rust, TypeScript, Python, Go, Kotlin or Swift, Coming from another language maps what you know onto TorbScript in one table.
Who this is for#
For people who can already program in another language. If you have never programmed, the course starts from zero. If you want the exact rule behind something, the language reference has one page per construct.
Sections#
- Coming from another language - One page per language you may know - what maps directly, the habits that will trip you up, and what TorbScript leaves out.
Pages#
- TorbScript in 10 ideas - The ten ideas that make TorbScript what it is, one short example each, for somebody who programs already and wants the shape of the language in five minutes.
- A tour of TorbScript - The whole language in fifteen minutes for somebody who already programs - bindings, calls, functions, types, cases, errors, traits and pipelines, one short example each.
- Install and run - Install TorbScript with one command, run a file, and make a project with a test - the five commands you will use every day.
- Values and bindings - A binding is const or var, a second name is always a copy, and a change goes through the path where the value lives.
- Functions and closures - Declare a function with typed parameters, defaults and labels, write a closure, and pass it as the last argument of a call.
- Types and methods - Declare a type with fields, give it methods, and tell a method that changes the value from one that returns a changed copy.
- Cases and matching - Declare a type whose value is one of several cases, and take it apart with a match that has to handle every case.
- Traits - Declare what a type can do as a trait, give it to a type now or later, and use the trait as a type that holds any of them.
- Errors - A function that can fail returns a Result, a value that can be missing is an Option, and the caller handles both with match, the question mark or a fallback.
- Collections and pipelines - Build a list, a map and a set, change one in place or get a changed copy, and run values through a pipeline of steps.
- Control flow and your own constructs - Ifs and loops work as you expect, and a new control structure or a configuration block is an ordinary function you can write yourself.
- Modules and packages - Split a program into files with public and use, import from the standard library, and lay out a project so that its tests reach its code.
- Put it together - One small program - a type with cases, a type with fields, a function that can fail and a pipeline - that uses what the guide taught.
- Idiomatic TorbScript - The habits that make code read like the standard library - whole-word names, values before shared types, a checked door for every rule a value must keep, using for resources, and the formatter's layout.