-
Notifications
You must be signed in to change notification settings - Fork 0
Your First Program
Derek Snider edited this page Jul 23, 2026
·
3 revisions
Create a file called hello.mad:
#include <stdio.h>
int main() {
printf("hello, world\n");
return 0;
}Run it:
madc hello.madhello, world
That's it. No Makefile, no compile step, no link flags. madc JIT-compiles your code directly to native machine code and runs it.
Looks familiar? It should — this is valid C. madc understands C syntax, C headers, and C library functions out of the box.
madc also supports C++ streams, strings, and more. Create greet.mad:
#include <iostream>
int main() {
std::string name = "World";
std::cout << "Hello, " << name << "!" << std::endl;
for (int i = 1; i <= 3; i++) {
std::cout << i << std::endl;
}
return 0;
}madc greet.madHello, World!
1
2
3
Here's where madc gets interesting. Create demo.mad:
#include <iostream>
int main() {
// PHP-style string operations
std::string csv = "charlie,alice,bob";
std::string delim = ",";
array names;
php::explode(names, delim, csv);
php::sort(names);
std::string sorted;
php::implode(sorted, delim, names);
std::cout << sorted << std::endl;
// Python-style title case
std::string title = "hello world";
python::title(title);
std::cout << title << std::endl;
// Rust-style string functions
std::string s = " padded ";
rust::trim(s);
std::cout << "[" << s << "]" << std::endl;
return 0;
}madc demo.madalice,bob,charlie
Hello World
[padded]
No imports. No package manager. These functions are built into madc across six language namespaces.
Add a shebang line and make the file executable:
#!/usr/bin/env madc
#include <stdio.h>
int main() {
printf("I'm a script!\n");
return 0;
}chmod +x script.mad
./script.madGenerate a standalone binary:
madc -o hello hello.mad
./helloThe output is a native Linux ELF executable — no runtime dependency on madc.
See Native Executables for more details.
- Data Types — integers, floats, strings, arrays, containers
- Functions — user-defined functions, multiple returns, lambdas
- Namespaces — the multi-language namespace system
- Multi-file Projects — structuring larger programs
- ← Back to Home