Your first Scarp program

New installations: Follow the release-aware learning path and published alpha.6 download/checksum guide. This page is a historical alpha.1 file tutorial: use its own published compiler to reproduce its verified results.

Want a current project instead? Use the published alpha.6 project lab with the exact alpha.6 interpreter. The alpha.4 installation guide and alpha.4 project quickstart are separate historical references. This file tutorial deliberately uses alpha.1 semantics.

This tutorial targets v0.0.5-alpha.1. Confirm scarp --version before you begin. To evaluate upgrading to the published alpha.2, see the compiler-tested compatibility guide: it runs all 11 original alpha.1 fixtures unchanged on alpha.2, but does not claim every older source program remains compatible.

Create a file

Create hello.srp in a directory you control and save it as UTF-8:

// hello.srp
bind language = "Scarp";
print("Hello from", language);
print(1 + 2 * 3);

Run the file

scarp run hello.srp

Expected stdout:

Hello from Scarp
7

From the compiler source checkout, use cargo run -- run hello.srp instead of an installed scarp command. The filename is resolved relative to the shell's working directory.

Check without output

scarp check hello.srp

On success this command is silent. It checks syntax, names, mutability, types, and the selected execution path. It does not simply parse source: reachable arithmetic and runtime-budget errors can still be reported. tokens is different—it only lists lexical tokens.

scarp tokens hello.srp

Change a value

var visits = 1;
visits += 1;
print("Visits:", visits);

var permits reassignment; bind does not. Scarp requires semicolons for these statements and does not implicitly convert strings into numeric operands. The print statement accepts comma-separated values.

Next read variables, types, and the CLI reference.

Verified against: first-program tutorial, output guide.

Next: use a complete tested program

Next practice real functions in the verified functions tutorial, then continue with loops or source modules. The documentation project's conformance suite mirrors compiler-owned examples and checks their actual outputs when CI can build the published interpreter.

Search documentation