-
Notifications
You must be signed in to change notification settings - Fork 0
Home
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.
| 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 → |
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.
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()
{
std::string csv = "alice,bob,charlie";
std::string delim = ",";
array names;
// PHP-style string splitting and joining
php::explode(names, delim, csv);
php::sort(names);
std::string sorted;
php::implode(sorted, delim, names);
// C++ iostreaming
std::cout << sorted << std::endl;
// Python-style string formatting
std::string title = "hello world";
python::title(title);
std::cout << title << std::endl;
// Perl-style regex grep
array matches;
std::string pat = "^a";
perl::grep(matches, pat, names);
// Ruby-style string transforms
std::string s = "aabbccdd";
ruby::squeeze(s);
std::cout << s << std::endl;
// JavaScript base64
std::string encoded;
js::btoa(encoded, s);
std::cout << encoded << std::endl;
return 0;
}No imports to install. No package manager. It's all built in.
- 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++ support —
cout/cin/cerr,string,stringstream,vector<T>,map<K,V>,set<T>, classes with methods -
Modern features — lambdas,
defer, multiple return values,:=inference, range-basedfor, function pointers - 100+ namespace functions across 6 language namespaces (php, perl, python, ruby, js, rust)
-
C23 early coverage —
_Bool,0bbinary literals,static_assert,typeof,nullptr, digit separators -
Preprocessor —
#define,#ifdef,#include,#pragma, plus#load "libfoo.so"for dynamic libraries - Embeddable — libmadc C++ API with C shims for hosting madc in your own applications
- Self-contained — no external dependencies at runtime beyond libc
- Installation — build from source, dependencies, verifying your setup
- Your First Program — from hello world to something real
-
Multi-file Projects —
#includeconventions, project structure
- Data Types — integers, floats, strings, arrays, containers
- Control Flow — if/else, for, while, switch, rust::match
- Functions — declarations, multiple returns, function pointers, lambdas
- Structs & Classes — user-defined types, methods, member access
- Strings & I/O — string operations, cout/cin, file streams
- Pointers & Arrays — C-style pointers, fixed arrays, subscripts
-
Modern Features — defer, range-for,
:=, auto, ternary
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 |
-
Preprocessor —
#define,#ifdef,#include,#load,#pragma - Embedded Headers — built-in standard and POSIX headers
- C23 Features — early C23 standard coverage
- Regex — match, search, replace
- GCC Compatibility — torture test parity, what works, what's next
- CLI Reference — command-line flags and usage
- Namespace Function Reference — consolidated function lookup
- Native Executables — ELF generation, AOT compilation
- Embedding Guide — libmadc API, hosting madc in your programs
Current release: v0.17.0 · GitHub · Changelog · Report an Issue · License: MPL 2.0