Hello, world!
Your first program
Section titled “Your first program”Create a file called hello.plu:
println("Hello, world!")Run it:
pluvial hello.pluHello, world!println(x) prints a value followed by a newline. Its sibling print(x) prints without a
trailing newline. Both accept any value type — int, float, bool, string,
array<T>, Result<T>, or a nullable T? — with a single argument.
A slightly larger example
Section titled “A slightly larger example”def greet(string name) string { return "Hello, " + name + "!"}
string who = "Pluvial"println(greet(who))Hello, Pluvial!A few things to notice:
- Functions are declared with
def. Parameters are writtentype name, and the return type goes between the)and the{(Go-style trailing return type). - Variables are declared as
<type> <name> = <initializer>. The initializer is required. string + stringconcatenates. Mixing types — for example"count: " + 3— is a compile error; convert explicitly withto_string(3).
Trying things in the REPL
Section titled “Trying things in the REPL”Running pluvial with no arguments starts an interactive Read-Eval-Print Loop. Typing an
expression prints its value; declarations and statements persist across lines:
$ pluvialPluvial REPL — type 'exit' to quit> 1 + 23> "hello".to_upper()HELLO> int x = 5> x + 16> def double(int n) int { return n * 2 }> double(7)14> exit$If a line has an error, the REPL prints the error block and keeps the session alive so you can continue typing. See the CLI reference for the full REPL behavior.
Comments
Section titled “Comments”Line comments start with # and run to the end of the line:
# this is a commentauto x = 1 # trailing comments work tooDocumentation comments start with ## at the beginning of a line and attach to the
declaration that follows them; pluvial doc renders them to Markdown.