lambdaclass / concrete

Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.
Apache License 2.0
126 stars 11 forks source link
# The Concrete Programming Language [![Telegram Chat][tg-badge]][tg-url] [![license](https://img.shields.io/github/license/lambdaclass/concrete)](/LICENSE) [tg-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fconcrete_proglang%2F&logo=telegram&label=chat&color=neon [tg-url]: https://t.me/concrete_proglang

Most ideas come from previous ideas - Alan C. Kay, The Early History Of Smalltalk

In the realm of low-level programming, language safety, performance and simplicity are paramount features. We are confident that these attributes can be achieved in system programming languages without substantially sacrificing expressiveness. Concrete achieves this balance, offering a programming language that is fast, simple and safe without having a garbage collector, lifetimes and a complex borrow checker. Additionally, it features a default pluggable runtime, enabling the development of highly scalable systems that are not only reliable and efficient but also straightforward to maintain.

Writing good code should be easy. The language must be simple enough to fit in a single person’s head. Programs are about transforming data into other forms of data. Code is about expressing algorithms, not the type system. We aim to develop a simpler version of Rust that includes an optional default runtime featuring green threads and a preemptive scheduler, similar to those found in Go and Erlang.

Installing from Source

Building is as simple as cloning this repository and running the make build command, provided you have all the needed dependencies.

Dependencies

Make sure you have installed the dependencies:

If building LLVM from source, you'll need additional tools:

Setup the following env vars:

# For Debian/Ubuntu using the repository, the path will be /usr/lib/llvm-18
export MLIR_SYS_180_PREFIX=/usr/lib/llvm-18
export LLVM_SYS_180_PREFIX=/usr/lib/llvm-18
export TABLEGEN_180_PREFIX=/usr/lib/llvm-18

If you installed llvm with brew, source the env-macos.sh script to set up the needed env vars:

source scripts/env-macos.sh

Table of Contents

Design

Rust similarities and differences

Concrete take many features from Rust like:

But we want to take a different path with respect to:

Core features

Second level features

Anti-features

Syntax

mod Fibonacci {
    fn main() -> i64 {
        return fib(10);
    }

    pub fn fib(n: u64) -> u64 {
        if n < 2 {
            return n;
        }

        return fib(n - 1) + fib(n - 2);
    }
}
mod StructExample {
    struct Foo {
        bar: i32,
        baz: i64,
    }

    fn main() -> i32 {
        let mut foo: Foo = Foo {
            bar: 2,
            baz: 3,
        };

        foo.bar = foo.bar * 2;

        return get_foo_field_by_borrow(&foo) + foo.bar;
    }

    fn get_foo_field_by_borrow(x: &Foo) -> i32 {
        return x.bar;
    }
}
mod Option {
    pub enum Option<T> {
        None,
        Some(T),
    }

    pub fn map<A, B>(opt: Option<A>, f: A -> B) -> Option<B> {
        match opt {
            None -> None,
            Some(x) -> Some(f(x)),
        }
    }
}

mod UsesOption {
    import MyOption.{Option, map};

    pub fn headOfVectorPlus1(x: [u8]) -> Option<u8> {
        // head returns an option
        x.head().map((x: u8) -> x + 1)
    }

}

Inspiration

The design was very heavily influenced by all these programming languages:

Roadmap

For a full roadmap check the project.

Meaning:

Features:

Post-runtime features:

Benchmarking

There are some simple program benchmarks against Rust.

You can run them using the following make target:

make bench