Hello World
Your First Program
Create a file called hello.star:
Every StarLang program starts with a package main declaration and a fn main():void entry point.
Variables and Types
package main
fn main():void {
var x:number = 42
var name:string = "stardyn"
var active:bool = true
console.log(x)
console.log(name)
console.log(active)
}
All variables require a type annotation. Omitting the type results in a compile error.
Using Modules
math.star library:
package math
fn add(a:number, b:number):number {
return a + b
}
fn multiply(a:number, b:number):number {
return a * b
}
hello.star main program:
package main
import "math"
fn main():void {
var x:number = add(10, 32)
console.log(x)
var y:number = multiply(6, 7)
console.log(y)
}
Debugging
You can debug your program in VS Code with F5:
- Click to the left of a line number to set a breakpoint
- Press F5 to start debugging
- When paused at a breakpoint, inspect variables in the Variables panel
- Press Continue (F5) to resume execution