Stream: beginners

Topic: zig 0.9


view this post on Zulip Locria Cyber (Oct 27 2021 at 00:09):

I'm using zig 0.9 and it does not compile. I'm using the trunk branch.
Should I update the code to fit zig 0.9?

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:13):

good question!

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:13):

I think we should hold off until there's an official 0.9 release

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:14):

otherwise it's harder for people to get the right version, since currently 0.9 is built from Zig's master branch

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:15):

Can I do the update in another branch?

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:17):

oh sure! I just wouldn't want to merge it into trunk until the 0.9 release is out :big_smile:

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:17):

although, depending on how long that takes, the branch might have problems with drift

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:17):

as people add more to the zig code in trunk

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:18):

so it might end up needing recurring updates over time to stay mergeable :sweat_smile:

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:19):

I think all changes we need to backwards compatible, like removing packed enum.

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:21):

good to know! :rock_on:

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:23):

Also building compiler/bitcode crashes the zig compiler

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:23):

on 0.9?

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:23):

yes

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:24):

maybe a known bug? it is a master build after all haha

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:26):

it crashes in LLVMStructGetTypeAtIndex

view this post on Zulip Richard Feldman (Oct 27 2021 at 00:27):

ok, sounds like it's too soon for us to try 0.9 :big_smile:

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:53):

ok this is jank

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:53):

const std = @import("std");

comptime {
    @export(eq, .{ .name = "eq" });
}

pub const RocDec = extern struct {
    num: i128,
};
pub fn eq(self: RocDec, other: RocDec) callconv(.C) bool {
    return self.num == other.num;
}

view this post on Zulip Locria Cyber (Oct 27 2021 at 00:54):

using i128 just crashes the compiler while i64 doesn't

view this post on Zulip Locria Cyber (Oct 27 2021 at 01:03):

blocked by https://github.com/ziglang/zig/issues/10039

view this post on Zulip Lucas Rosa (Oct 27 2021 at 01:50):

Before updating the zig version we usually need to update the version of LLVM we use and before updating our LLVM version we need to update our zig version. This tends to occur because zig quickly moves to the latest version of LLVM and their release cycles kinda alternate. So we usually do those at the same time

view this post on Zulip Lucas Rosa (Oct 27 2021 at 01:51):

there’s a few things already addressed for the 0.9 update like unused vars etc. but definitely some other stuff as well

view this post on Zulip Lucas Rosa (Oct 27 2021 at 01:53):

0.9 isn’t too far out. I’m pretty sure it’ll use LLVM 13 and we use v12 last I checked

view this post on Zulip Folkert de Vries (Oct 27 2021 at 06:05):

I updated inkwell already so upgrading llvm versions is not blocked on anything

view this post on Zulip Lucas Rosa (Oct 27 2021 at 15:02):

excellent

view this post on Zulip Matthias Beyer (Oct 30 2021 at 10:40):

Can someone give a rationale why zig is even in the codebase? I don't yet see what the benefit is over just implementing everything in Rust...

view this post on Zulip Folkert de Vries (Oct 30 2021 at 10:54):

All of the compiler is written in rust, because as you say that makes sense.

We use zig for writing code that we want to end up in the binary that a user makes. That binary is a combination of code the user wrote, and some "runtime system" that does things like implement our builtins (list and string data structures) and manage memory (the whole refcounting machinery).

view this post on Zulip Folkert de Vries (Oct 30 2021 at 10:54):

zig makes it easy to do this for all the platforms that we target: zig can be converted to LLVM IR, to webassembly and to machine code (e.g. X86_64 assembly)

view this post on Zulip Folkert de Vries (Oct 30 2021 at 10:55):

and it does that 1) way faster than rust and 2) with way less baggage: rust brings a runtime system of its own that is much larger than what C and zig bring along

view this post on Zulip Matthias Beyer (Oct 30 2021 at 10:58):

okay, I can see that .

view this post on Zulip Matthias Beyer (Oct 30 2021 at 11:01):

Still, I wonder whether no_std rust would be viable to reduce the "runtime" you speak of. I don't know zig, so I cannot judge it, but rust provides guarantees that are really neat and I was hyped when I saw that roc is implemented in Rust! :smile:

view this post on Zulip Folkert de Vries (Oct 30 2021 at 11:03):

yes, and we really want those guarantees for the compiler itself, but for that runtime system, any overhead is a shame and we actually want to do a bunch of unsafe things there

view this post on Zulip Folkert de Vries (Oct 30 2021 at 11:03):

in other words, using rust there has less of the advantages in that scenario than for writing this massive compiler application

view this post on Zulip Richard Feldman (Oct 30 2021 at 13:09):

we actually tried Rust with no_std first, and it was tons of unsafe plus linking difficulties plus not getting much help debugging memory safety issues, so we tried zig and it's gone much better!

view this post on Zulip Ivo Balbaert (Oct 30 2021 at 15:21):

Hi! I am Ivo Balbaert, a PL enthousiast and author of some books on emerging languages.
I worked in software industry (mainly 4GL, ASP.NET, C#) and taught programming languages and databases.


Last updated: Jul 26 2025 at 12:14 UTC