Skip to content

Latest commit

 

History

History
106 lines (78 loc) · 1.49 KB

README.md

File metadata and controls

106 lines (78 loc) · 1.49 KB

Glide

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 Ints, Bools, and Strings

  • Functions, usable as values

    func a() {
        println("a")
    }
    
    func main() {
        let f = a
        f()
    }
    
  • Local variables

    let x = 2
    let y Int = 3
    
  • if/else expressions

    let x = if cond1 {
        1
    } else if cond2 {
        2
    } else {
        3
    }
    
  • Single-line comments

    // This is a comment
    
  • Attributes

    attribute Happy
    
    [Happy]
    func happy() {
    }
    
  • Packages with public and private visibility

  • Native code generation using LLVM

Examples

Hello world:

func main() {
    println("Hello World!")
}

Fibonacci numbers:

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)))
    }
}

Usage

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