r/Compilers • • Oct 16 '26

madc v0.105.0 — Live C/C++ REPL function redefinition, and faster compilation

Post image

I've released madc v0.105.0, with some substantial improvements to its interactive C/C++ REPL, compilation performance, and portability.

For those unfamiliar with it, madc is a self-contained C/C++ compiler with JIT execution, native executable output, and an interactive REPL, without requiring GCC, Clang, LLVM, or installed development headers or toolchain.

What's new

  • Live function redefinition — redefine a C or C++ function in the REPL and subsequent calls use the new implementation, even from previously compiled callers or existing function pointers.
  • Live variable and type redefinition — reinitialize existing variables and redefine classes or structs interactively, with versioning when a type's layout changes.
  • Interactive source editing — the REPL includes an ex-style editor. Copy, modify, search and replace code directly in the session, with changes taking effect immediately.
  • Restart and Run All — replay the entire REPL buffer in a fresh session, similar to working with a notebook.
  • Faster compilation — changes to the precompiled header representation allow madc to load only the parts a program needs, substantially reducing compilation overhead.

Performance

The updated README includes benchmarks against GCC 13.3 and Clang 18.1 on Ubuntu 24.04:

TaskmadcGCCClang
C++ Hello World (JIT vs compile/link/run)83 ms170 ms207 ms
C++ STL example (JIT vs compile/link/run)209 ms252 ms275 ms
C Hello World (JIT vs compile/link/run)9 ms21 ms37 ms

These are end-to-end timings for the specified workloads, not claims that madc universally outperforms GCC or Clang.

C/C++ compatibility

Current results against external compiler test suites include:

  • C17: 99.2% of GCC's c-torture/execute
  • C11: 220/220 on the third-party c-testsuite
  • C++98: 81.3%
  • C++11: 77.3%
  • C++17: 43.2%
  • C++20: 53.8%

The C++ figures are pass rates for selected GCC test-suite subsets, not claims of complete standards conformance.

madc is available for Linux, Windows, and macOS (Intel and Apple Silicon).
The companion IDE, madcide, has also been updated to v0.8.0 with the live REPL improvements.

GitHub: https://github.com/derekbsnider/madc

Release: https://github.com/derekbsnider/madc/releases/tag/v0.105.0

5 Upvotes

13 comments sorted by

View all comments

1

u/kostya27 Oct 16 '26

looks like it fully c compatible, can it compile sqlite and pass it tests?

2

u/kindredseer Oct 16 '26 edited Oct 16 '26

Not yet. I didn't try it until now, but getting some errors in sqlite3.c ... I'll have it working in the next release.

2

u/kindredseer Oct 16 '26

So the upcoming v0.106.0 build (still under development) now compiles sqlite and passes all tests, except for the tests that need -fsanitize (which madc does not yet support). I'm also going to make sure it is able to build redis. Do you have any other suggestions of applications/libraries it should be tested against?

1

u/kostya27 Oct 16 '26

That's big! Do you support atomics? My suggestion is to show a Pareto of compile time vs runtime, comparing with clang and gcc on sqlite benchmarks, for example, with different flags - so people can see why exactly they should use madc, and why gcc,clang worse?

1

u/kindredseer Oct 16 '26 edited Oct 16 '26

Madc is optimized for compile time because it is primarily a JIT, and optimization slows down compiling…

…that said I plan to add more codegen optimization in the future. It’s difficult to compete with gcc and clang on optimization because they have teams and teams of contributors…

The purpose of madc is more for rapid prototyping and also C/C++ scripting without requiring a full development environment to be installed.

You can mix in pieces precompiled with your standard toolset — objects and/or shared libraries and use madc to piece them together on the fly.

1

u/kostya27 Oct 16 '26

it is ok, just need to know what the tradeoff, if it is 10x faster compile and runtime slower like 30% than gcc O2 - probably this is great tradeoff.

1

u/kindredseer Oct 16 '26

Runtime averages about 80% of gcc. Compile time is generally faster, but certainly not 10X.

1

u/kostya27 Oct 16 '26

add also cproc, tcc to this test.

1

u/kindredseer Oct 24 '26

Alright, so v0.106.1 has been released and compiles sqlite and passes the same tests that gcc and clang do. This release took a bit longer than expected as I was also focused on improving compile time, and some linking issues, but will make sure cproc, tcc, and redis compile in the next release.