Skip to content

Your first Vertex program

This page assumes you have already installed Vertex and vertex --version prints a version.

Create a file called hello.vtx:

debug "hello, vertex!"

Run it:

$ vertex run hello.vtx
hello, vertex!

That is it. No main function, no class wrapper, no sfdx-project.json, no deploy. Vertex executes top-level statements in order, top to bottom.

debug is the only way to produce observable output. It is an expression: it evaluates its argument, prints it, and returns the value so you can inspect mid-pipeline.

debug "hello"
debug 42
debug true
let sum = debug 1 + 2 // prints 3, then binds sum = 3
let name = "Alice"
let age = 30
debug "Hello, ${name}! You are ${age}."

All bindings are immutable by default. If you need to reassign:

mutable let counter = 0
counter = counter + 1
counter = counter + 1
debug counter // 2

The visible mutable keyword is deliberate. Reassignment is possible but it stands out. See Bindings.

Here is a complete program that pitches several of the ideas the tour will cover in more depth:

fn label(age: Int): String {
if age < 18 { "minor" } else { "adult" }
}
fn describe(name: String, age: Int): String {
"${name} is ${label(age)} (age ${age})"
}
debug describe("Alice", 30)
debug describe("Bob", 15)

Run it:

$ vertex run greet.vtx
Alice is adult (age 30)
Bob is minor (age 15)
  • No deploy. Vertex ran your code locally via its built-in JIT.
  • Compile-time guarantees. The types of name, age, and the return of label were all checked before anything ran.
  • Millisecond feedback. No org, no build step, no waiting.