Skip to content
Derek Snider edited this page May 19, 2026 · 32 revisions

C, unbound.

madc — a self-contained C compiler and JIT runtime. Write C. Run it like a script. Ship it as a native executable. Embed it as a library.

No Makefile. No toolchain ceremony. One command.


How you use it

Script it Ship it Embed it
madc program.mad madc -o program program.mad #include <libmadc/api.h>
JIT-compiles directly to x86-64 machine code. No bytecode, no interpreter. Caches OBJ files — first run is fast, repeat runs are blazing. Generates native Linux ELF executables. Real binaries, real performance. libmadc brings madc scripting and 100+ multi-language functions into your own C/C++ programs.
Getting Started → Native Executables → Embedding Guide →

Why madc?

Zero ceremony — No Makefile, no include paths to configure, no separate compile step. madc file.mad and you're running.

Real C, plus more — Familiar C syntax with C++ extras: cout, string, classes, STL containers, lambdas, defer, := type inference. 40+ embedded standard headers included.

Multi-language namespaces — The best functions from PHP, Perl, Python, Ruby, JavaScript, and Rust — all available in one program via php::explode(), perl::grep(), python::title(), ruby::squeeze(), js::btoa(), rust::trim().

Not a toy — ~80% GCC torture test parity and climbing. Compiles real C codebases end-to-end.


See it in action

Your C code just works:

#include <stdio.h>

int main() {
    printf("hello, world\n");
    return 0;
}
$ madc hello.mad
hello, world

Now mix in the best of other languages:

#include <iostream>

int main()
{
    // PHP-style string splitting and joining
    string csv = "alice,bob,charlie";
    string delim = ",";
    array names;
    php::explode(names, delim, csv);
    php::sort(names);
    string sorted;
    php::implode(sorted, delim, names);
    cout << sorted << endl;

    // Python-style string formatting
    string title = "hello world";
    python::title(title);
    cout << title << endl;

    // Perl-style regex grep
    array matches;
    string pat = "^a";
    perl::grep(matches, pat, names);

    // Ruby-style string transforms
    string s = "aabbccdd";
    ruby::squeeze(s);
    cout << s << endl;

    // JavaScript base64
    string encoded;
    js::btoa(encoded, s);
    cout << encoded << endl;

    return 0;
}

No imports to install. No package manager. It's all built in.


Features

  • JIT compilation to x86-64 via asmjit — runs at native speed
  • Native EXE generation — produce standalone Linux ELF binaries
  • OBJ caching — compiled objects are cached; repeat runs skip recompilation
  • 40+ embedded headers<stdio.h>, <stdlib.h>, <math.h>, <string.h>, <unistd.h>, and more
  • C++ supportcout/cin/cerr, string, stringstream, vector<T>, map<K,V>, set<T>, classes with methods
  • Modern features — lambdas, defer, multiple return values, := inference, range-based for, function pointers
  • 100+ namespace functions across 6 language namespaces (php, perl, python, ruby, js, rust)
  • C23 early coverage_Bool, 0b binary literals, static_assert, typeof, nullptr, digit separators
  • Preprocessor#define, #ifdef, #include, #pragma, plus #load "libfoo.so" for dynamic libraries
  • Embeddablelibmadc C++ API with C shims for hosting madc in your own applications
  • Self-contained — no external dependencies at runtime beyond libc

Explore the wiki

Getting Started

Language Guide

Namespaces

Overview & prefer — how multi-language namespaces work

Namespace Functions Focus
php:: 36 String manipulation, array operations
perl:: 21 chop/chomp, regex grep, split/join
python:: 16 Title case, alignment, format
ruby:: 12 squeeze, tr, chars, rotate
js:: 6 Base64, URL encoding, JSON
rust:: 18 trim, contains, replace, split/join

Advanced Topics

Reference


Current release: v0.17.0 · GitHub · Changelog · Report an Issue · License: MPL 2.0

Clone this wiki locally