Skip to content

A statically-typed programming language, with generics and type inference

Notifications You must be signed in to change notification settings

patrick-gu/glide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A statically-typed programming language, with generics and type inference

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages