Skip to content

octalide/mach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,725 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MACH

CI License Code Size Last Commit Issues

Mach is a statically-typed, compiled programming language designed to be simple, fast, verbose, and intuitive.

Mach is still alpha quality. Expect breaking changes as the compiler and standard library iterate.

We have an official Discord!

Overview

Core Philosophy

Mach is designed with the following principles in mind:

  • Simplicity: Mach is built to be easy to learn, read, write, and maintain.
  • Explicivity: Mach is explicit and verbose. WYSIWYG, always. Computers are not magic. Your code should not promote this illusion.
  • Maintainability: Mach's semantics and design principles prioritize long-term maintainability over short-term convenience.

Mach is NOT designed to prioritize:

  • Features: Batteries are not included. Ever.
  • Flexibility: Mach is rigid and opinionated. It should not be flexible or allow for many ways to do the same thing.
  • Code Reduction: Mach is explicit and verbose. More code is not worse code.
  • Hand-holding: Mach provides tools for safety (like read-only pointers and deferred cleanup), but it will not stop you from doing dangerous things if you explicitly ask to. Safety is a partnership between the language and the programmer.

Getting Started

Read the language documentation before installing. The docs are written more like a pamphlet than a bible and assume familiarity with basic programming concepts from other languages.

Building Mach

Prerequisites: git, make, curl. See getting started for details.

git clone https://github.com/octalide/mach
cd mach
make

This runs the 4-stage bootstrap:

  1. cmach -- bootstrap compiler (auto-downloaded from mach-boot)
  2. imach -- intermediate compiler (cmach compiles the Mach source)
  3. smach -- self-hosted compiler (imach compiles the Mach source)
  4. mach -- final compiler (smach compiles the Mach source)

The final binary is at out/linux/bin/mach. To use a custom cmach build: CMACH=/path/to/cmach make.

Examples

The following examples require the standard library as a dependency. For a standalone project, see the getting started guide or the Mach Sieve project.

Hello World

use          std.runtime;
use print:   std.print;

$main.symbol = "main";
fun main(argc: i64, argv: &&u8) i64 {
    print.println("Hello, World!");
    ret 0;
}

Fibonacci

use          std.runtime;
use print:   std.print;

fun fibr(n: u64) u64 {
    if (n < 2) {
        ret n;
    }
    ret fibr(n - 1) + fibr(n - 2);
}

$main.symbol = "main";
fun main(argc: i64, argv: &&u8) i64 {
    print.printf("fib(%d) = %d\n", 10::i64, fibr(10));
    ret 0;
}

Factorial

use          std.runtime;
use print:   std.print;

fun fact(n: u64) u64 {
    if (n == 0) {
        ret 1;
    }
    ret n * fact(n - 1);
}

$main.symbol = "main";
fun main(argc: i64, argv: &&u8) i64 {
    print.printf("fact(%d) = %d\n", 10::i64, fact(10));
    ret 0;
}

Documentation

The full language and tooling documentation is in doc/.

Credit

The inspiration for Mach comes from too many languages to count. Almost every language has problems that Mach attempts to elegantly resolve (most often by the process of reductive simplification).

Direct inspiration for the compiler comes from a few specific sources:

Mach, at its core, stands on the shoulders of countless giants that have contributed to the development of these languages either directly or by proxy. It is out of respect for their work that Mach will always be fully open source. Thank you all.

Contributing

We welcome contributions to Mach! If you would like to contribute, please read our contributing guidelines first.

License

Mach is licensed under the MIT License.

About

A programming language for people who like to know what their code is doing.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Contributors