Every language has one. Ours is a builtin and a string concatenation.
Create a file called hello.prism:
fn main() {
let name = "developer"
println("Hello, " + name + "!")
}
Run it:
prism run hello.prism
Hello, developer!
What just happened
Let’s walk through each part.
fn main()
Every executable needs a main function. fn declares a function; the empty parentheses
say it takes no arguments.
main may omit its return type — the compiler treats a missing return type as no value.
let name = "developer"
let declares an immutable binding. The type is inferred: name is a str. To rebind a
value, use let mut:
let mut count = 0
count += 1
println("Hello, " + name + "!")
println is a builtin — no module import needed. Strings are concatenated with +; there is
no {} interpolation in v0.1.0.
Compiling ahead of time
prism run is for iteration. When you want a binary, build one:
prism build hello.prism
./hello
The output is a single static executable with no runtime dependency. On Linux you can copy it to a machine without Prism installed and it will run.
Note: by default
prism buildproduces a binary named after the source file. Useprism build -o myappto choose the output name.
Next: Syntax — or skip ahead to PrismX UI if you came for the interface part.