I don't think it's accurate to call it "Zig's". This is an independent project started by Veikka Tuominen, a Zig core team member, but it's not owned or managed by ZSF in any way. It's Veikka's project. Don't take that away from him!
One of the features missing in bun:ffi is inferring types for symbols from header files. This would let you import C libraries in JavaScript/TypeScript directly, without having to configure bindings.<p>We embed TinyCC for FFI, but TinyCC doesn't expose a way to read the types for exported symbols.<p>Currently, it looks like this:<p><pre><code> import { dlopen, FFIType, suffix } from "bun:ffi";
// `suffix` is either "dylib", "so", or "dll" depending on the platform
// you don't have to use "suffix", it's just there for convenience
const path = `libsqlite3.${suffix}`;
const {
symbols: {
sqlite3_libversion, // the function to call
},
} = dlopen(
path, // a library name or file path
{
sqlite3_libversion: {
// no arguments, returns a string
args: [],
returns: FFIType.cstring,
},
},
);
console.log(`SQLite 3 version: ${sqlite3_libversion()}`);
</code></pre>
It would be nicer if it was something like this:<p><pre><code> import {sqlite3_libversion as version} from "sqlite3.h" with {lib: "sqlite3"};
console.log(`SQLite 3 version: ${version()}`);
</code></pre>
Would love to use Aro to do this in the future
The dlang D compiler includes a full C compiler, so you can mix and match C and D code. You can import C code from D, and D code from C.<p><pre><code> dmd hello.c
./hello
hello world
</code></pre>
This helps enormously in binding to existing C libraries.
Is this part of the long-term plan for zig to get rid of the dependency on clang/llvm?<p><a href="https://github.com/ziglang/zig/issues/16270">https://github.com/ziglang/zig/issues/16270</a>
I'm not all that familiar with the Zig tool chain.<p>Am I understanding correctly that this is a regular C compiler used as a component of the Zig compiler chain allowing compilation of C files alongside Zig? Or does Zig generate C and therefore need a C compiler under the hood?<p>Looking at the documentation suggests it is the former, not the latter.
It would be interesting to see how well it optimizes compared to the established players. The fact that it handles C23 and common GNU extensions is already impressive.
Zig is amazing. What started as a one-man project is becoming a mature software ecosystem capable of standing on its own as a peer with the major languages.
There's doesn't appear to a whole lot of comments or documentation in the code. Is this normal for Zig projects? Does it have an equivalent of Sphinx to build docs from code?
It seems like I can't include standard header files, so it can't compile a common hello world. I guess that'd be useful to mention on the README, or maybe I'm doing something wrong?<p><pre><code> main.c:1:10: fatal error: 'stdio.h' not found
#include <stdio.h>
</code></pre>
It'd be nice if header inclusion, and -l options work. This would allow benchmarking Aro against some other compilers on a wide range of C files. Usually sqlite3.c is my first go-to for stress-testing C compilers.
The ReadMe is quite lacking …<p>- why create a competing front end to Zig?<p>- what problems is it solving?<p>- what’s different than the official Zig frontend?<p>Etc