Live data from Hacker News

Aro – Zig's new C compiler

github.com

41–50 of 130 posts

Re: Aro – Zig's new C compiler

#41

Earlier quoted context omitted.

translate-c is not required for compiling pure Zig code. However, the plan is to remove the "@cImport" built in. So if your project is importing a c header, in the future you'll add build step translating it from c to Zig, and then you import it into your Zig code as a module.

what is the reason for this change? zig less than newbie here. I've only just recently started reading the zig overview, although I have been reading hn posts about zig with interest for some time.

Primary reason is that it removes a dependency on libclang, and as such is required to remove the LLVM dependency.

Re: Aro – Zig's new C compiler

#42

Earlier quoted context omitted.

It says it's a C frontend for `zig translate-c` which translates C code to Zig code. `zig translate-c` is not required for most Zig projects or even for most Zig projects that interop with C.

Thank you. I also started reading through the Zig overview [1] and near the end of that document it says this: "Not only can Zig compile C code, but there is a very good reason to use Zig as a C compiler: Zig ships with libc." From the doc, IIUC, compilation of header files and other C code allows Zig to do direct interop with no intermediaries. Seems useful. [1] https://ziglang.org/learn/overview/

That's just wrapping clang. They're working on replacing it

Re: Aro – Zig's new C compiler

#43

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.

It appears to me it could become the low level language of choice for small embedded systems in contexts where Lua or MicroPython couldn't fit the bill performance-wise and one wants something higher level than C. Ditto for Nim and Crystal.

It’s constraints on memory management basically will never allow that to happen.

It lures people in with “use any allocator you want”! Which only appears as freedom of choice when reality it’s locking the user into the same paradigm of memory management that has given C a bad name to begin with.

Re: Aro – Zig's new C compiler

#44
post #31

Earlier quoted context omitted.

The Zig compiler has used Data Oriented Design for a long time, so any recent version has that, yes. The most substantial part of running the compiler right now is LLVM, hence the focus to provide an alternative. The other big focus right now is incremental compilation, which will make recompilations very fast.

The talk I am referring to is from 2024 and shows some metrics improving by 30% or more. And Andrew said that's not yet shipped: https://www.youtube.com/watch?v=IroPQ150F6c So, are you sure about that?? EDIT: ok, the talk was uploaded just last week, but someone in the comments clarified that: > The original talk is from 2021.. Thank you for reuploading. I feel stupid now :/

Don’t

Re: Aro – Zig's new C compiler

#45
post #43

Earlier quoted context omitted.

It appears to me it could become the low level language of choice for small embedded systems in contexts where Lua or MicroPython couldn't fit the bill performance-wise and one wants something higher level than C. Ditto for Nim and Crystal.

It’s constraints on memory management basically will never allow that to happen. It lures people in with “use any allocator you want”! Which only appears as freedom of choice when reality it’s locking the user into the same paradigm of memory management that has given C a bad name to begin with.

1/3 of the problem with c memory management is null unsafely, not a problem in zig. 1/3 more is conflating arrays with single item pointers. Also not a problem with zig. The only memory management "issue" with zig is lack of temporal memory safety.

Re: Aro – Zig's new C compiler

#46
post #29

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. dmd hello.c ./hello hello world This helps enormously in binding to existing C libraries.

How exactly does this relate to the post, Aro, other than this also being a C compiler? Could you draw a comparison for those who came here for Zig and not D? What conclusion should we draw about Aro based on what you’re saying?

It doesn't relate to Zig at all, but Walter Bright is the creator of D and tremendously proud of it.

Re: Aro – Zig's new C compiler

#47
post #46
post #29

Earlier quoted context omitted.

How exactly does this relate to the post, Aro, other than this also being a C compiler? Could you draw a comparison for those who came here for Zig and not D? What conclusion should we draw about Aro based on what you’re saying?

It doesn't relate to Zig at all, but Walter Bright is the creator of D and tremendously proud of it.

I know that he is but this is incredibly off-topic. Aro deserves the attention it is getting, without the discussion getting hijacked by another project.

D would deserve attention too, in a separate post, or here if it was explained how it relates to Aro.

Re: Aro – Zig's new C compiler

#49
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?

    main.c:1:10: fatal error: 'stdio.h' not found
    #include 

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.

Re: Aro – Zig's new C compiler

#50
post #47
post #46

Earlier quoted context omitted.

It doesn't relate to Zig at all, but Walter Bright is the creator of D and tremendously proud of it.

I know that he is but this is incredibly off-topic. Aro deserves the attention it is getting, without the discussion getting hijacked by another project. D would deserve attention too, in a separate post, or here if it was explained how it relates to Aro.

Walter's comment could be read more charitably and could show his interest in Zig and similar choices that are made.

The last sentence, or, indeed, the whole comment, can be read like "We did this for D, and it works well. [go for it]".

I don't think D is casting any shadow on Zig. Both languages play in the same field, D is older but I feel like we hear about Zig way more these days.

His comment is likely to interest people interested in Zig or PLs in general.

The comment as is might lack some finesse but I don't think it deserves this level of aggressiveness.

Post reply on HN