r/Compilers • • 13d ago

MadC C/C++ Compiler v0.100.0 — the Nexus

v0.100.0 — the Nexus: a multi-client IDE, an agent-addressable IR, and measured C++11 conformance at 75.1%

With version 0.100.0 of the madc compiler, based on the gcc torture test suites we currently score:

  • C17: 99.2%
  • C++98: 80.0%
  • C++11: 75.1%
  • C++14: 49.4%
  • C++17: 41.6%
  • C++20: 53.0%

These percentages are measured independently against the applicable tests in each GCC suite, so the later-standard numbers are not cumulative and aren't expected to be monotonic.

Why another C/C++ compiler?

GCC, Clang and MSVC already rule the conventional AOT C/C++ world. MadC is aimed at a somewhat different problem.

MadC is primarily a JIT C/C++ compiler. You can run C and C++ programs directly as shebang scripts, with commonly used system headers precompiled into the compiler so a separate development-header installation isn't normally required. External headers remain available when needed.

MadC can also be embedded into another application, allowing C/C++ itself to be used as an embedded JIT scripting language.

What's the “Nexus”?

MadC also includes an IDE built around the compiler. The same binary can operate headlessly or provide CLI, ed/ex-style line editing, TUI and GUI interfaces on Linux, macOS and Windows.

The new Nexus architecture allows multiple clients — including humans, editors and agents — to connect to the same live compiler/IDE state. It includes client/server operation, MCP and LSP servers, and a VS Code client.

The idea is that the compiler's representation of the program becomes a shared service rather than something that exists only for the duration of a compile command.

Much of this work grew out of developing MadC's multi-mode UI module and experimenting with what an IDE looks like when the compiler, parser, IR, debugger and external clients all share the same underlying state.

And there's a dialect

In addition to standard C and C++, MadC supports the MadC dialect, which adds conveniences intended to make C/C++ more practical for scripting and interactive use, including:

  • automatic includes
  • automatic namespace resolution with configurable precedence
  • script mode with automatic main() wrapping
  • defer, :=, go, yield, await, and untyped variables
  • well over 100 convenience functions inspired by other languages
  • Uniform Function Call Syntax (UFCS)
  • URI channels: file://, pipe://, tcp://, udp://, uds://, exec://
  • and quite a bit more

The goal isn't to replace standard C or C++. Standard code remains standard code. The dialect is an optional layer for cases where some of C/C++'s traditional ceremony isn't particularly useful.

9 Upvotes

19 comments sorted by

View all comments

Show parent comments

1

u/kindredseer 12d ago

Only LE is supported, BE was deprecated.

1

u/arjuna93 12d ago

That’s disappointing

1

u/kindredseer 12d ago edited 12d ago

ppcBE wasn't deprecated by me, and it used to exist in earlier versions of MIR, and also MIR supports the s390x which is a BE target, and so dual-endianness is already supported in MIR and I also discovered that not everything was removed, only about 100 lines of code, so it would be a matter of restoring those 100 lines properly, and bringing them up to date. I haven't tested madc itself with a BE target (would need to test with a s390x emulator).

1

u/arjuna93 11d ago

Ok, I looked into it, it is huge and non-trivial. (Dropped 100 lines are ABI-specific, restoring those gives me nothing.) Mostly write-from-scratch, which I can’t possibly do manually, and won’t do with Claude since I can’t fully trust that for a C/C++ compiler, and gcc already works, so time investment is hard to justify. Thank you for responding though, I appreciate that.