Release - Mun v0.1.0

November 11, 2019, The Mun Team

We are proud to present Mun v0.1.0 - our first milestone release. As a language, Mun is still far from production-ready, but this release gives you a glimpse of what natively supported hot reloading will look like in the future. The purpose of this release is to showcase our progress and gather feedback from those brave souls willing to try out Mun at this early stage.

To get started, read the Mun Book and have a look at our Rust and C++ examples.

Mun Language

So far, the Mun language supports boolean, integer and float native types, variable assignment, logical and arithmetic operators, function definitions and if-else control flow.

fn main() {
    let result = fibonacci(nth());

    // Comments: Mun natively supports bool, float, and int
    let is_true = true;
    let var: float = 0.5;
}

// The order of function definitions doesn't matter
fn fibonacci(n:int):int {
    // If-else statements are also expressions
    let fib = if n <= 1 {
        n
    } else {
        fibonacci(n-1) + fibonacci(n-2)
    }

    // Mun allows implicit returns
    fib
}

fn nth(): int {
   // Mun allows explicit returns
   return 5;
}

Mun Runtime

The compiler’s counterpart - the Mun Runtime - is capable of hot reloading functions and provides useful diagnostics when runtime errors occur. As the Mun Runtime is written in Rust, it can be easily embedded in Rust applications by adding the mun_runtime crate as a dependency.

use mun_runtime::{invoke_fn, RetryResultExt, RuntimeBuilder};
use std::env;

fn main() {
    let lib_path = env::args().nth(1).expect("Expected path to a Mun library.");

    let mut runtime = RuntimeBuilder::new(lib_path)
        .spawn()
        .expect("Failed to spawn Runtime");

    loop {
        let n: i64 = invoke_fn!(runtime, "nth").wait();
        let result: i64 = invoke_fn!(runtime, "fibonacci", n).wait();
        println!("fibonacci({}) = {}", n, result);

        // Hot reload code when there are changes
        runtime.update();
    }
}

Mun also exposes a C API and complementary C++ bindings for the Mun Runtime.

#include <iostream>

#include "mun/runtime.h"

int main(int argc, char* argv[]) {
    if (argc < 2) {
        return 1;
    }

    auto lib_path = argv[1];
    if (auto runtime = mun::make_runtime(lib_path)) {
        while (true) {
            auto n = mun::invoke_fn<int64_t>(*runtime, "nth").wait();
            auto result = mun::invoke_fn<int64_t>(*runtime, "fibonacci", n).wait();
            std::cout << "fibonacci(" << n << ") = " << result << std::endl;

            // Hot reload code when there are changes
            runtime->update();
        }
    }

    return 2;
}

Future

For the Mun v0.1.0 release, a lot of effort has gone into building the foundations of Mun’s Compiler, Runtime, test suite, and continuous integration. This will allow the core team and other contributors to quickly add new language and runtime features in the future.

For the next version, we are planning to add language and hot reloading support for data structures, loops, and external C functions. For the full roadmap of Mun, have a look at our Trello board.