A programming language.
Currently, this includes:
-
Static typing
-
Generics, with monomorphization
-
Type inference on function calls
func identity<T>(t T) T { t } identity("Foo")
-
Basic types, including
Int
s,Bool
s, andString
s -
func a() { println("a") } func main() { let f = a f() }
-
Local variables
let x = 2 let y Int = 3
-
let x = if cond1 { 1 } else if cond2 { 2 } else { 3 }
-
Single-line comments
// This is a comment
-
attribute Happy [Happy] func happy() { }
-
Packages with
pub
lic and private visibility -
Native code generation using LLVM
func main() {
println("Hello World!")
}
func fibonacci(n Int) Int {
if eqInt(n, 0) {
0
} else if eqInt(n, 1) {
1
} else {
add(fibonacci(sub(n, 1)), fibonacci(sub(n, 2)))
}
}
First, install LLVM.
Run the Hello World example with
cargo r -- compile ./examples/hello.gl -o hello.o
clang-14 -no-pie hello.o -o hello
./hello