Skip to content

radeqq007/Sunbird

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

705 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sunbird

Sunbird

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

Caution

Sunbird is currently under a big rewrite. The documentation is outdated and code examples might not work.

Sunbird is a transpiled programming language that targets TypeScript and focuses on ease of use and clarity.

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

Overview

Hello world in Sunbird

console.log("Hello, world!") // Sunbird is compatible with javascript's standard library

Defining variables and functions

let a = 1
const b: Int = 2

const add = fn(a: Int, b: Int): Int {
    return a + b
}

add(a, b)

String interpolation

const greet = fn(name: String) {
  console.log("Hello, $name")
}

greet("John")

Control flow

let a = 1
let b = 2

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

for i in 0..10 {
    console.log(i)
}

while a <= b {
    console.log(a)
    a += 1

    if a == 1 {
      continue
    }

    if a == 2 {
      break
    }
}

try {
    let c = 1 / 0
} catch e {
    console.log(e)
} finally {
    console.log("finally")
}

Type annotations

let a: Int = 1
let b: Float = 2.0
let c: String = "hello"
let d: Bool = true
let e: Void = null
let f: Array = [1, 2, 3]
let g: Fn = fn(a: Int, b: Int): Int {
  return a + b
}
let h: Hash = {1: 1, 2: 2, 3: 3}


// Nullable types
let i: Int? = null
let j: String? = "hello"
let d: Bool? = true
let e: Array? = [1, 2, 3]
let f: Fn? = fn(a: Int, b: Int): Int {
    return a + b
}
let g: Hash? = {1: 1, 2: 2, 3: 3}

About

A transpiler for the Sunbird programming language.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors