Live data from Hacker News

Aro – Zig's new C compiler

github.com

21–30 of 130 posts

Re: Aro – Zig's new C compiler

#21
post #15

Is this part of the long-term plan for zig to get rid of the dependency on clang/llvm? https://github.com/ziglang/zig/issues/16270

Yes.

Does Zig already compile without LLVM, even if not by default?

Also, do you know when the changes Andrew mentioned in his "Data Oriented Design" are going to be released in the zig compiler?

I would expect that when both of the above are done, compiling Zig will be really, really fast compared to anything we currently have.

Re: Aro – Zig's new C compiler

#22
post #2

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.

I agree it does seem very impressive. My first thought was that they must be using LLVM for the backend, but it looks like no, it's fully 'self-contained'.

Eliminating the dependency on LLVM is a major focus for the language team, and a big part of why Aro exists.

Note that it's the dependency which is being eliminated: it will remain possible to use LLVM as a back end, and to compile Zig and C together without using Aro to translate the C into Zig. If I'm understanding the roadmap correctly, the C headers needed to link a C library with Zig code will be translated into Zig, but doing so with the actual .c files will be optional.

Re: Aro – Zig's new C compiler

#23

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.

Re: Aro – Zig's new C compiler

#24
post #21

Earlier quoted context omitted.

Yes.

Does Zig already compile without LLVM, even if not by default? Also, do you know when the changes Andrew mentioned in his "Data Oriented Design" are going to be released in the zig compiler? I would expect that when both of the above are done, compiling Zig will be really, really fast compared to anything we currently have.

It's the major area of focus right now. You can track the issues with this tag/link if you'd like:

https://github.com/ziglang/zig/issues?q=is%3Aissue+is%3Aopen...

Re: Aro – Zig's new C compiler

#25
post #12

Earlier quoted context omitted.

Is it possible to do what Zig does and cross compile to any OS/arch, from any OS/arch? Last I tried, I found some compiler options and commands to do it, but they were badly explained, I tried for hours and it just didn't work at all, so I gave up.

The dmd D compiler can cross-compile to any of the targets that it supports. I use it all the time to develop on other platforms. I am currently adding AArch64 support to DMD's code generator. dmd doesn't run on my Raspberry Pi (yet!), so I use sshfs to access the Pi's filesystem from Ubuntu, compile programs on Ubuntu, transfer the .o file to the Pi, link it on the Pi, and run it on the Pi. I'm sorry you're having t…

The grandparent post refers to the fact that Zig ships with C, C++ library source that it lazily cross-builds (at least for linux, I don't recall how it solves this problem for macOS or windows). And possibly it uses lld too? Since Zig ships with these, it makes the whole cross-build experience much smoother and less dependent on whether your host OS distribution includes packages for your desired target OS/architecture.

Re: Aro – Zig's new C compiler

#27

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.

I'm all-in on Zig, I think it's the bee's knees.

I needed a regex library for another project, and dashed off an acceptable one in a week flat https://github.com/mnemnion/mvzr

The fun part about this is that it can compile, and match, during both comptime and runtime. Will it replace PCRE? No. But nor is it intended to.

Re: Aro – Zig's new C compiler

#28
post #21

Earlier quoted context omitted.

Yes.

Does Zig already compile without LLVM, even if not by default? Also, do you know when the changes Andrew mentioned in his "Data Oriented Design" are going to be released in the zig compiler? I would expect that when both of the above are done, compiling Zig will be really, really fast compared to anything we currently have.

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.

Re: Aro – Zig's new C compiler

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

Re: Aro – Zig's new C compiler

#30

Earlier quoted context omitted.

The dmd D compiler can cross-compile to any of the targets that it supports. I use it all the time to develop on other platforms. I am currently adding AArch64 support to DMD's code generator. dmd doesn't run on my Raspberry Pi (yet!), so I use sshfs to access the Pi's filesystem from Ubuntu, compile programs on Ubuntu, transfer the .o file to the Pi, link it on the Pi, and run it on the Pi. I'm sorry you're having t…

The grandparent post refers to the fact that Zig ships with C, C++ library source that it lazily cross-builds (at least for linux, I don't recall how it solves this problem for macOS or windows). And possibly it uses lld too? Since Zig ships with these, it makes the whole cross-build experience much smoother and less dependent on whether your host OS distribution includes packages for your desired target OS/architect…

Exactly. Zig tooling includes a linker, and that's also cross-platform. Zig can generate actual runnable executables that run anywhere from a single machine.

As far as I can tell, D's DMD can cross compile but not link. I probably missed that before (actually, I think I was trying with LDC, I found the page where they document the process while searching for it just now: https://wiki.dlang.org/Cross-compiling_with_LDC if you try those options, nothing works, at least from MacOS).

I just tried and this only works with the -c option (compile, but not link):

    dmd -os=linux -c source/app.d
Without `-c`:

``` Error: linker exited with status 1 cc app.o -o app -m64 -Xlinker -no_compact_unwind -L/Users/me/dlang/dmd-2.109.1/osx/bin/../lib -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm (dmd-2.109.1) ```

I am sure Walter knows how to compile on one machine, then go to another machine and do the linking or whatever is needed. I know nothing about those, but with Zig I need not know anything other than which flag to use to cross compile. It's a huge difference. D should do that, otherwise it's just not competitive for people like me (I am just an average joe programmer who knows how to write code but has very little interest in learning how linkers work).

Post reply on HN