Need help?
Ask a question or report a problem on GitHub.
Open an issue
Otter language reference
An index of what Otter supports. Unsupported or experimental syntax is intentionally left out.
Values and variables
Text, numbers, booleans, lists, objects, bytes, and gone. Assignment with is; arithmetic with plus (or and), minus, times, divided by, percent of and power, or the symbols + - * /, and make; add and remove. Arithmetic runs strictly from left to right, with no precedence and no parentheses, so 2 plus 3 times 4 is 20. There are no negative number literals: write 0 minus 5. The text escapes are \n, \t, \\ and \" (see Working with text).
Read values and variables
Conditions, loops, and functions
if, otherwise, while, repeat, count, each, to, return, and stop. Comparison words: is, is not, is greater than, is at least, is less than, is at most. Comparisons work only inside if, otherwise if and while, and each side is a single value: compute a calculation into a variable first (total is price plus tax, then if total is at least 100). Each function argument is also a single value.
Read conditions Read loops Read functions
Lists, objects, files, and folders
Lists and collections, property access with of, objects with has, JSON, CSV, file discovery, and explicit file and folder operations.
Read lists Read objects and properties Read files and folders Read CSV and downloads
Networking, cryptography, and secrets
WebSockets, TCP, UDP and TLS; hashing, signing, authenticated encryption and password hashing; and the operating-system credential vault.
Read networking Read cryptography and secrets
Desktop UI, events, and layout
Create windows and controls, configure them with has, put resources into windows and row or column containers, handle events with when, and show a window:
Otter
create button into saveButton when saveButton is clicked say "Saved" .
State, derived values, and watchers
Otter supports state, derive, and when a state value changes. Derivations update from their dependencies, and watchers run only when a value actually changes.
Web applications
otter web compiles a program into a standalone HTML, CSS, and JavaScript application. Pages, rows, columns, cards, links, buttons, text, images and more are declared with is a, and drag and drop is available with draggable and accepts drops.
Errors and diagnostics
Use try and otherwise for recoverable work. Otter also provides log, warn, and error for diagnostic output. Every error is a readable Otter message that names the line - never a raw stack trace.
Read conditions and errors
Reserved words
A few words cannot be used as names, because Otter would read every use of the name as something else. otter check, otter run and otter test refuse such a name before anything runs, say why, and suggest another. Ordinary words such as name, total, status, result, value, data and done are not reserved.
Variables and parameters: cancelled, completed, failed, pending, running, listening, stopped, closed, closing, connected, connecting, secure and watching. In a condition such as if job is completed, these words check a request, job, connection, server or watcher, so a variable with one of these names could never be compared.
Functions: a function cannot be named after a statement word (such as create, find or delete) or a built-in value (such as now, today or pi), because a line that starts with that word is read as the statement, so the function could never be called.
Read the Otter 1.0 reserved words