Skip to content

Latest commit

 

History

History
89 lines (70 loc) · 2.11 KB

File metadata and controls

89 lines (70 loc) · 2.11 KB
Sunbird

Sunbird

GitHub go.mod Go version Build Lint Tests Coverage Go Report Card Last commit GitHub stars

Sunbird is dynamically-typed, interpreted programming language that focuses on ease of use and simplicity.

For detailed language reference, standard library docs, and guides, see the docs/ directory.

Overview

Hello world in Sunbird

import "io"

io.println("Hello world")

Defining variables and functions

// Use the := operator to declare a variable
a := 1
name := ""

// to define constants use the :: operator
x :: 20
pi :: 3.141

// Defining functions
add :: fn(a, b) {
    return a + b
}

add(a, b)

Control flow

import "io"

a := 1
b := 2

if a > b {
    io.println("a is greater than b")
} else if a < b {
    io.println("a is less than b")
} else {
    io.println("a is equal to b")
}

for i in 0..10 {
    io.println(i)
}

while a <= b {
    io.println(a)
    a += 1

    if a == 1 {
      continue
    }

    if a == 2 {
      break
    }
}

loop {
    io.println("This will run forever!")
}

try {
    c := 1 / 0
} catch e {
    io.println(e)
} finally {
    io.println("finally")
}