Skip to content

A Rust-like language with immix GC and other cool stuffs

License

Notifications You must be signed in to change notification settings

Pivot-Studio/pivot-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,489 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pivot Lang

codecov release test

codecov

此项目目前处于早期开发阶段,不建议用于生产环境。
项目地址

安装

此处

官网

https://pivotlang.tech

CONTRIBUTING

CONTRIBUTING贡献代码

欢迎加入: QQ群 discord

dependencies

重要:如果你想参与开发,请先在项目目录make vm install,然后根据自己是linux还是mac运行make devlinux或者make devmac

特点

  • 支持静态编译与JIT
  • 高性能
  • REPL
  • 热重载
  • 极其方便的Rust/C互操作
  • 支持debug
  • 支持lsp,自带vsc插件,能提供优秀的代码支持
  • 有GC,自动管理内存
  • 强大的类型推断,支持省略大部分类型标注

一些ShowCases

使用Pivot Lang实现的简单光追

example

编辑器支持

debug

lsp

Hello World

fn main() i64 {
    println!("hello world!");
    return 0;
}

HashTable

(没错,我们的哈希表源码也是完全用Pivot Lang写的)

use std::cols::hashtable;
use core::panic::assert;
use core::eq::*;

fn main() i64 {
    let table = hashtable::new_hash_table(10 as u64, 1 as u64);
    table.insert("hello","world");
    table.insert("bye","bye");
    assert(table.get("hello") is string);
    let v = table.get("hello") as string!;
    assert("world".eq(&v));
    return 0;
}

Fibonacci

use std::io;
fn main() i64 {
    let result = fib(10);
    println!(result);
    return 0;
}

fn fib(n: i64) i64 {
    let pre = 0;
    let nxt = 0;
    let result = 1;
    for let i = 0; i < n; i = i + 1 {
        result = result + pre;
        pre = nxt;
        nxt = result;
    }
    return result;
}

Y组合子

use core::panic;
pub fn main() i64 {
    let g = |f, x| => {
        if x == 0 {
            return 1;
        }
        return x * f(x - 1);
    };
    let fact = Y(g);
    for let x = 0; x < 10; x = x + 1 {
        panic::assert(fact(x) == fact_recursion(x));
    }
    return 0;
}


struct Func<A|F> {
    f: |Func<A|F>, A| => F;
}

impl<A|F> Func<A|F> {
    fn call(f: Func<A|F>, x: A) F {
        return self.f(f, x);
    }

}

fn Y<A|R>(g: ||A| => R, A| => R) |A| => R {
    // 下方代码的类型推断是一个很好的例子
    return |x| => {
        return |f, x| => {
            return f.call(f, x);
        }(Func{
            f: |f, x| => {
                return g(|x| => {
                    return f.call(f, x);
                }, x);
            }
        }, x);
    };
}

fn fact_recursion(x: i64) i64 {
    if x == 0 {
        return 1;
    }
    return x * fact_recursion(x - 1);
}


About

A Rust-like language with immix GC and other cool stuffs

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 11

Languages