-
Notifications
You must be signed in to change notification settings - Fork 0
Home
C, unbound. Maybe a little unhinged. Just enough madness to be useful.
madc is real C with the workflow of a scripting language.
Write C. Run it like a script. Ship it as a native Linux ELF executable. Embed it as a runtime. Or bring madc's built-in features directly into your own C/C++ programs.
No Makefile. No toolchain ceremony. No VM. No bytecode. No fake runtime.
madc compiles C-family source directly to native x86-64 machine code, uses libc directly, caches compiled objects, and can produce real Linux binaries.
| Use madc to... | Command / API | What happens |
|---|---|---|
| Run it | madc program.mad |
JIT-compiles directly to x86-64 machine code and runs immediately. No bytecode, no interpreter. |
| Ship it | madc -o program program.mad |
Generates a native Linux ELF executable. Real binaries, real performance. |
| Embed it | libmadc |
Host madc as a compiler, JIT, and runtime inside your own C/C++ application. |
| Reuse it | madc headers, namespaces, and runtime helpers | Bring madc features directly into your own native C/C++ programs. |
Compiled objects are cached, so the first run is fast and repeat runs can skip unnecessary recompilation.
Getting Started →
Native Executables →
Embedding Guide →
madc is not a C-flavoured scripting language, bytecode VM, or toy interpreter.
It compiles to real native x86-64 machine code. It uses libc directly. It supports ordinary C-style programs, pointers, structs, functions, headers, preprocessor directives, and native linking.
madc is still growing toward fuller modern C compatibility, including broader C23 coverage, but standards completeness is not what makes something "real C."
K&R C was real C. ANSI C was real C. Embedded C compilers are real C. TinyCC is real C.
madc belongs on that spectrum:
real C at the core, extended where useful, and improving rapidly.
No Makefile. No include paths to configure. No separate compile step.
madc file.madOne file. One command. Native execution.
madc starts with familiar C syntax and real native code generation, then adds practical conveniences where they help:
-
cout,cin,cerr -
string,stringstream -
vector<T>,map<K,V>,set<T> - classes with methods
- lambdas
defer- multiple return values
-
:=type inference - range-based
for - function pointers
- embedded standard headers
Use ordinary C when you want it. Reach for modern conveniences when they make the program clearer.
madc includes useful functions inspired by PHP, Perl, Python, Ruby, JavaScript, and Rust.
Examples:
php::explode()perl::grep()python::title()ruby::squeeze()js::btoa()rust::trim()
C gives you control. Scripting languages give you convenience.
madc is designed to give you both.
madc is not only a command-line compiler. You can embed libmadc inside your own C/C++ applications — host a full C-family compiler, JIT, and runtime, or evaluate expressions on the fly:
#include <libmadc/api.h>
madc::program pgm;
pgm.exec_file("script.mad");
int64_t result;
pgm.eval("2 + 2", result);Use madc's 100+ namespace functions directly in your own C/C++ code — php::explode(), perl::grep(), python::title(), and more, without going through a scripting layer:
#include <libmadc/namespaces.h>
std::string csv = "alice,bob,charlie";
madc::array names;
php::explode(names, ",", csv);
php::sort(names);That makes madc both a compiler and a native C/C++ toolkit.
madc is aimed at real C compatibility, native execution, and practical systems-level use.
It is not pretending to be C. It is a real compiler that emits native machine code, uses libc directly, and can compile real C codebases end-to-end.
madc was created by a programmer with 40+ years of experience in C, C++, assembly, and systems development. Read the backstory →
Your C code just works:
#include <stdio.h>
int main() {
printf("hello, world\n");
return 0;
}Run it directly:
$ madc hello.mad
hello, worldOr build a native executable:
$ madc -o hello hello.mad
$ ./hello
hello, worldNow mix in the best of other languages:
#include <iostream>
int main()
{
std::string csv = "alice,bob,charlie";
std::string delim = ",";
madc::array names;
php::explode(names, delim, csv);
php::sort(names);
std::string sorted;
php::implode(sorted, delim, names);
std::cout << sorted << std::endl;
std::string title = "hello world";
python::title(title);
std::cout << title << std::endl;
madc::array matches;
std::string pat = "^a";
perl::grep(matches, pat, names);
std::string s = "aabbccdd";
ruby::squeeze(s);
std::cout << s << std::endl;
std::string encoded;
js::btoa(encoded, s);
std::cout << encoded << std::endl;
return 0;
}No imports to install. No package manager. It is all built in.
- JIT compilation to x86-64 via asmjit — runs at native speed
- Native executable generation — produce standalone Linux ELF binaries
- OBJ caching — compiled objects are cached; repeat runs skip recompilation
- Direct libc usage
- 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
- 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
libmadcAPI with C++ support and C shims - Reusable runtime helpers for native C/C++ programs
- Self-contained — no external dependencies at runtime beyond libc
madc is for developers who like C, but want a faster workflow.
Use it when you want to:
- write small native utilities without setting up a project
- prototype systems code quickly
- build C programs that run with script-like immediacy
- ship a native Linux executable
- embed a C-family compiler, JIT, and runtime inside a C/C++ application
- reuse madc's helper namespaces and runtime features directly in native C/C++ programs
- use familiar helpers from PHP, Python, Perl, Ruby, JavaScript, and Rust
- experiment with modern C extensions without leaving native code behind
madc is not trying to replace GCC, Clang, or every production C toolchain.
Use GCC or Clang when you need mature, battle-tested, fully standards-focused compilation across large production codebases and many platforms.
Use madc when you want C with immediacy:
madc program.madmadc is also not Python, Lua, JavaScript, or a scripting VM.
It borrows the convenience of scripting workflows, but the result is native code.
- Installation — build from source, dependencies, verifying your setup
- Getting Started — overview of the basic workflow
- 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
- Namespaces — how multi-language namespaces work
| Namespace | Focus |
|---|---|
| php:: | String manipulation, array operations |
| perl:: | chop/chomp, regex grep, split/join |
| python:: | Title case, alignment, format |
| ruby:: | squeeze, tr, chars, rotate |
| js:: | Base64, URL encoding, JSON |
| rust:: | 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
- Native Executables — ELF generation, AOT compilation
- Embedding Guide — libmadc API, hosting madc in your programs
- CLI Reference — command-line flags and usage
- Namespace Reference — consolidated function lookup
- Changelog — release history and notable changes
Current release: v0.17.0
madc is under active development.
The goal is simple:
real C, native code, script-like workflow, modern convenience.
C, unbound.
madc's native code generation is built on asmjit by Petr Kobalicek — an outstanding JIT assembler library without which madc would not be possible.
GitHub Repository · Report an Issue · License: MPL 2.0