Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
> C compiler based tool that outputs DWARF or DWARF-like debug output that actually lays out everything
That sounds like C2FFI: https://github.com/rpav/c2ffi
The only language ecosystem where I've seen it used is Common Lisp. But it emits plain JSON and depends only on LLVM (albeit a specific version thereof), and I don't see any reason why you couldn't build e.g. a Python auto-binding library on top of it.
It also kinda sorta sounds like this tool the author wrote: https://github.com/Gankra/abi-cafe
> This tool helps automate testing that two languages/compilers agree on ABIs for the purposes of FFI. This is still in early development so lots of stuff is stubbed out.
...
> By running this natively on whatever platform you care about, this will tell you what FFI interfaces do and don't currently work. Ideally all you need to do is cargo run, but we're dealing with native toolchains so, expect toolchain bugs!
Trying to replace C with something like Rust, is essentially saying that we should rewrite all kernels in Rust. C is the common language because it talks to the kernel, which talks to the hardware.
Forgetting how much would need to be replaced with objectively much slower code, Rust simply cannot do some things. You cannot always make absolute guarantees about memory safety for example when it comes to low-level programming. Sometimes to be fast, you have to make assumptions and take risks.
I am currently watching the Veloron game [1] as an example of how larger Rust projects may begin to look. I see something like this [2] and it doesn't look all dissimilar from C, just with a new syntax. Has writing this game eliminated all bugs? Nope [3]. Maybe there are less segfaults and bad memory management, but this was just one class of bugs.
[1] https://gitlab.com/veloren/veloren
[2] https://gitlab.com/veloren/veloren/-/blob/master/server/src/...
[3] https://gitlab.com/veloren/veloren/-/issues/?sort=closed_des...
and if there's a stdio.h file, the D compiler will read the .h file, parse it, and present the ABI to it in a D-ish manner to your D code. Here it is:
https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cp...
It's so darned useful I expect other languages will do it, too.