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

Show parent comment

1

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

No, it is self-contained. It doesn't use any part of gcc, cling, clang, or llvm. The only significant third party component is MIR which has been heavily modified, integrated, and maintained as part of this project.

The download size of everything needed for clang-repl is ~100Mb -- ~350Mb installed. MadcC's download size is under 20Mb, and under 27Mb installed.

Also, madc's REPL is designed to work a lot more like traditional REPLs like Julia, IPython, Lisp, Smalltalk.

Feature Dimensionclang-replMadC REPL (v0.105.0)
Function RedefinitionNo true inline redefinition. Defining a function twice results in a compilation error. To work around this, users have to wrap code in changing namespaces or append completely new symbols.Yes (Live Redefinition). Overwriting an existing function routes all subsequent calls—and older, existing pointers—directly to the new code.
Type / Class Layout UpdatesImmutable. Once a struct or class is parsed into the AST, its layout cannot change without causing redefinition errors or crashing memory models.Yes (Generational Type Versioning). Variables can be re-initialized and type layouts can be mutated live while tracking the underlying alignment changes.
Session Control & PersistenceLinear / Forward-Only. The environment compiles code continuously downstream. If you make an unrecoverable type mistake, you typically have to exit and start over.State Persistence. Features a notebook-style "Restart and Run All" loop to quickly scrub a session and replay the entire text buffer inside a clean instance.
Interactive EditingBasic Console Input. Strictly reads text lines sequentially. It lacks advanced code completion upstream and requires manual printing setups.Full Emacs / Ex-Style Editor. Includes an in-session visual/line editor to query, edit, search, and replace existing buffer structures directly within the console.

2

u/archialone Oct 19 '26

So it's just a worse version of clang-repl?

1

u/kindredseer Oct 19 '26

It’s a better REPL experience.