8 ms·
Zig: Build System Reworked
- baskduf 5mo ago[flagged]
- lerp-io 5mo ago[flagged]
- abhayji 5mo ago[flagged]
- epolanski 5mo agoThis sounds like great news, Zig's compilation times are already terrific and this is going to only make them better.
- dmit 5mo ago> Zig's compilation times are already terrific In my experience, this (for now) is mostly aspirational. It's obviously a major goal, and there are clear milestones outlined on how to achieve it, but in practice the initial compile of an empty project or the excruciating pause when you `direnv allow` and ZLS needs to be (re)built are not what I'd describe as "terrific".
- epolanski 5mo agoMaybe you're right, but how many other system programming languages toolchains give you sub 50ms recompilations across millions of LoC?
- dmit 5mo agoI foresee a pjmlp comment in your near future. :)
- epolanski 5mo agoYeah, let's add a sprinkle of toxicity to my Saturday morning!
- Mawr 5mo agoWhat, you wouldn't want a condescending lecture on which exact, unpopular even at the time, languages from the 80's, which had 10% of features of Zig and ran 20x slower, also had fast compilation times? For the 1000th time? Shame on you.
- ksec 5mo agoOh that is me as well :)
- speed_spread 5mo agoI'm not pjmlp, but the cached answer is Turbo Pascal.
- schaefer 5mo ago>(re)built are not what I'd describe as "terrific". It sounds like you are a strong candidate to try out the new improvements mentioned in this devlog and see what benefits you can get for yourself.
- wffurr 5mo agoCompared to Rust or C++?
- pjmlp 5mo agoYes, compilation speeds of the 90's are slowly making a return, thankfully.
- bbkane 5mo agoI thank Go for this. Go's compilation times seemed to inspire other language devs
- magnio 5mo agoI doubt Go has any sizable effect on the community of programming language developers. Probably Pascal has more impact on this.
- DetroitThrow 5mo agoPascal has a lot of influence on this, but Go as well! My PL friends often talk about Go's benefits and flaws when thinking about advancing other their own projects or improving the mainstream languages they work on.
- Mawr 5mo agoThen you haven't been paying attention to the space. At all. Every single new post-Go language, like Rust & Zig, ships with an opinionated autoformatter and a single go-to command to manage builds, packaging, etc. And how many new languages do you see include inheritance and exceptions? Older languages have started adapting what they can too: - Python with `uv` and `black` - Java with goroutine-like fibers and modern configuration-free gcs and the go-gc-like low pause times zgc - Many languages now ship a production-ready http server, just like Go
- pjmlp 5mo agoGo has exceptions, bad ones at that. From type theory exceptions are effects, and result types are a form of effects. Auto formatting has been a thing in IDEs for a decade, and doing pre-commit hooks on CVS with indent was a thing in the 1990's. Java and .NET had http servers. Co-routines trace back to languages like Solo Pascal. Configuration free GC not really that great, given the rewrites into Rust. Anyway, Oberon, Modula-3, Eiffel, .NET,.... Pauseless GC goes back to real time Java from PTC, Aonix, Aicas, and companies like Azul with their custom hardware.
- ozgrakkurt 5mo agoJust creating a file with dummy test like if (2 * 2 != 5) { @panic("fail"); } And running `zig test file.zig -OReleaseSafe` takes a couple seconds on my computer. It also keeps taking the same amount of time every time I do it when I modify that file. Using 0.16 (or master) version so my toolchain isn't old and I'm on linux. Zig is super nice to use as a language but the compiler/stdlib isn't developed conservatively enough imo. You may not run into an issue like this when starting out with hello world but you will want to run optimized binaries for fuzz testing or benchmarking. And then it becomes super annoying considering you might be compiling a relatively small amount of code. Just for comparison, imo Zig is a much better language than these other languages, but if you did something like this in Rust/C++/C etc. this kind of issues basically doesn't ever happen. Assuming clang/gcc/ninja etc. usage for C/C++. I am able to use Ninja/Python/clang for configuring/building (-O2 or -O3)/testing ~10k loc C++ project in 200ms on the same computer for example.
- ozgrakkurt 5mo agoAlso another point. I have some zig projects from couple of months back and they all have build.zig/build.zig.zon. I tried to copy that to the new dummy project I did and of course the API changed and that is broken now (just 15 lines of build.zig code). This kind of thing just feels unacceptable considering I don't really see ANY improvement on the issues I had from back then. Also had a similar baffling experience when I last tried to come back to writing Zig. The std.time.Instant or similar API that also exists in rust and most other languages was move to the new Io interface and they also completely removed that std.time.Instant code. Overall it feels like people developing the tool don't respect the people using the tool. C++ or even Rust are much less enjoyable languages to write compared to Zig so it is really sad that it is not possible to actually use Zig for me.
- epolanski 5mo agoTo be fair the language is in beta and breaking changes are expected.
- defen 5mo ago> Just creating a file with dummy test like > if (2 * 2 != 5) { @panic("fail"); } > And running `zig test file.zig -OReleaseSafe` takes a couple seconds on my computer. What kind of computer are you on? I just ran that test (latest master build, first run): ~ % time zig test file.zig -OReleaseSafe file.zig:1:17: error: expected type expression, found '{' if (2 * 2 != 5) { @panic("fail"); } ^ zig test file.zig -OReleaseSafe 0.03s user 0.44s system 505% cpu 0.094 total Granted I'm on an M4 Mac but I wouldn't expect another system to be 20x slower.
- abhayji 5mo ago[flagged]
- portly 5mo agoAfter having used Zig for a couple of months now I am convinced it is a fantastic tool language. You just pick it up to hack some idea together freely. Every time I hit a wall, I find the creators have thought of it already and offers comfort. But nothing gets in your face how to use the programming language "correctly". For me it is now the go-to "tinker in my garage" language.
- samuell 5mo agoMy main issue with this is I expect Mojo to become the go to tinkering language for me.
- ACCount37 5mo agoIs it really that good? My go-to "tinker in my garage" language is Python - lightweight syntax that stays out of your face, batteries included, packages for everything that's not included. What's Zig's edge?
- norman784 5mo agoZig is low level, so it will certainly not replace your python usage, it is more like a modern C than anything else. There’s a video of a recent interview with Andrew Kelley, if you want to watch it to understand better what Zig is for, it’s on Jetbrains YouTube channel.
- ACCount37 5mo agoNo, I get that, but Zig being low level is kind of why I don't get why it would be a good tinkering language? When I want to tinker, I just want my logic to work, first of all. In 9 cases out of 10 that means going for high level. Even if the resulting code works with low level things like binary structures.
- deleted 5mo ago[deleted]
- 5mo ago
- KingMob 5mo ago[flagged]
- alkyon 5mo agoCarpentry would have been ideal career. Building real things, artisanal or not, and nobody insisting yet that the chest of drawers you're building include AI
- KingMob 5mo agoOf course, the flip side is, modern construction isn't done with artisanal woodworking techniques. I'm not even thinking of AI, but Rust. I guess I'm just uninterested in a "modern C".
- steveharing1 5mo agoSo i checked the license of this project, can anyone pls clarify what is (Expat) after MIT License
- papercrane 5mo agoThere are a number of licenses that are named MIT that are all similar, but not identical. The "Expat" here is the MIT license variant. It is referring to the Expat XML parsing library that first used this license. Usually when projects these days use an MIT license this is the version they use.
- maleldil 5mo agoThere are different licenses that used to be referred to as "MIT", and explicitly stating "Expat" tells you which one they're referring to (in this case, the "standard" one). This is largely unnecessary, as nearly all mentions of the MIT license refer to this one.
- brabel 5mo agoI just upgraded some code to Zig 0.16.0 and I am actually really happy with the results. It impacted A LOT of things, but the changes were actually very good and seems to have set the language for a bright future, especially with the new IO mechanism which allows supper efficient code that looks good whether it's implemented single-threaded, multi-threaded or just via an event loop! If you haven't tried Zig since 0.16.0 was released, I highly recommend having a look. The release notes for this release were huge!! https://ziglang.org/download/0.16.0/release-notes.html https://ziglang.org/download/0.16.0/release-notes.html
- ulbu 5mo agothe “(super) efficient” is not there yet. Io is still dynamic dispatch with multiple layers of indirection. afaik it’s slower than before. the upcoming releases are expected to provide a solution to this “dispatch is comptime-known, but still dynamic” problem, and drop the loses in efficiency.
- rsyring 5mo agoThe parent seems to be talking about efficient code style, not necessarily performance implementation, as they go on to discuss how it looks. That is, I think the point was DevX not io performance.
- bbkane 5mo agoHmm in the 2025 talk ( https://youtu.be/f30PceqQWko?si=qZESxMaSyt7fYMfz https://youtu.be/f30PceqQWko?si=qZESxMaSyt7fYMfz ), Andrew emphasizes that this approach is more efficient than before- even showing compiled assembly iirc. I guess that was a one-off?
- chaz72 5mo agoMy guess is that one of these (Andrew) is measuring syscalls and the other is measuring vtable indirections.
- 5mo ago
- xtreak29 5mo agoBun is moving towards rust but does this also help bun's compilation times? https://ziggit.dev/t/bun-s-zig-fork-got-4x-faster-compilation-times/15183 https://ziggit.dev/t/bun-s-zig-fork-got-4x-faster-compilatio...
- androiddrew 5mo agoI think bun is moving to rust because Anthropic owns it and the devs there like rust. So why would they invest in another implementation? Sad to see a good zig example go, but as soon as Anthropic bought it I wrote the project off.
- xorgun 5mo ago[dead]
- pylotlight 5mo agoJust plain incorrect.. please stop spouting this nonsense, this is not the reason whatsoever.
- amazingamazing 5mo agoWhat is the reason?
- galangalalgol 5mo agoI am not aure either, but bun wasn't using normal zig and there was drama about upstreaming. Combine that with anthropics desire to show they can help rewrite everything in rust and that probably accounts for some of it.
- insanitybit 5mo agoThe explicitly stated reason is that they ran into too many segfaults and it was slowing down development velocity. That said, I hope that Zig posts won't be plagued by "but the bun thing" like this in the near future.
- IshKebab 5mo agoZig has so many compelling features, and I'd even be willing to give up Rust's near-perfect memory safety in some cases. But the one thing that really put me off is string handling. It's just so super tedious. I like being able to finely manage individual string memory allocations, but I really don't want to have to do it all the time. RAII is great; I wish they'd use some light (optional) RAII for strings and containers etc.
- metaltyphoon 5mo agoFor me it’s string handling, no private, unused variable is compilation error, and having to implement interfaces myself.
- nusaru 5mo agoWhy not use an arena allocator?
- IshKebab 5mo agoTbh I don't know enough Zig to answer that. Can you give an example? E.g. some non-performance-sensitive function that returns a string? In Rust and C++ you can treat the string exactly the same as you would an integer and it's super easy. In C you have pain. Does the caller allocate a buffer? How does it know how big to make it? Do you have to have separate calls to calculate the required length? Etc. Can Zig work like Rust/C++ and not like C? My impression is that it can't.
- justinhj 5mo agoAn arena allocator lets you treat a series of allocations as a single block. In cases where you find yourself needing to micromanage a bunch of small memory allocations you can simply ignore freeing them individually and free the whole arena when you are done.
- IshKebab 5mo agoYeah sorry I know what an arena allocator is. I meant how can you write code that deals with strings (joining, formatting, passing around etc.) but isn't sensitive to performance (so `std::string`-like performance is fine) in Zig without having to deal with tedious low level allocator details. If I have to pass an allocator around everywhere that's a pain in the bum. Apparently Zig doesn't have a global allocator so it seems like you can't. (And it seems like the allocation details aren't encoded in the type anyway so it will be a disaster if you start mixing up global and non-global allocator types anyway.)
- nromiun 5mo agoIs there any proposed timeline for a stable release? Big features like the recent async IO shows the language is very unstable right now.
- bluecalm 5mo agoAndrew's take is "it's ready when it's ready but we hope it's good enough before it's fully ready that you want to use it anyway". It's different and I like it. You get one shot at it and may just as well get it right in as many areas as possible.
- nickmonad 5mo agoYep. He mentioned recently in his JetBrains interview he wants Zig to be a language for the next 50 years. Rushing 1.0 for the sake of signaling to the wider industry today would be actively harmful to that goal.
- ksec 5mo agoYes. And this kind of mentality is a near extinct in modern software development.
- mightyham 5mo agoToo bad it will not be adopted for anything serious in the next 50 years. There is no reasonable value proposition from a business standpoint for picking zig over rust. It is already the reality in much of the tech industry that Rust is filling the space previously occupied by C++. The fact that there now exists a safe low level language is legitimately a paradigm shift. It doesn't matter how many shiny cool things zig adds, being unsafe means it a technology stuck in the past.
- xydone 5mo agoThere is no ETA on 1.0, but breakage has followed the pattern of it not really being hard to upgrade to a newer version, as it is very well documented on the version release notes.
- xngbuilds 5mo agoAfter watching Andrew Kelley's interview video makes me want to pick up Zig: https://www.youtube.com/watch?v=iqddnwKF8HQ https://www.youtube.com/watch?v=iqddnwKF8HQ
- scuff3d 5mo agoI have a lot of respect for Andrew, and I really enjoy Zig, but God that interview was awful. Andrews answers were fine, but the whole thing felt very sycophantic.
- cfiggers 5mo agoI didn't get the same impression. I'm curious to know what created that feeling for you. Perhaps I'm turning a blind eye to something or other?
- scuff3d 5mo agoThere's a lot of little things that just added up, but I think the clearest example was the exchange regarding Andrew's pay from the foundation. I don't have an issue with him being paid for the work, or the amount he's taking, I would be surprised if anyone really did, but the way the interview asked the question came off as "Oh you're only making x? You should be paid so much more", and Andrew even commented in it saying "...it sounds like you're implying I deserve more...". I'm of course paraphrasing, but that's the impression I walked away with. The questions also had a tendency to be somewhat shallow. There were a lot of places where it felt like the interviewer was queuing Andrew to respond to criticism or explain controversial choices made for the language or tool chain, but the interviewer doesn't really follow up on them are point out what the issues might be. It might have been expectations I guess. I was hoping for an interesting technical interview and instead it seemed like a fluff piece.
- biffgiff 5mo agoWhy would I want to use this over, say, Node.js and TypeScript?
- throwatdem12311 5mo agoI suggest you try using Ghostty (written in Zig) for a bit and compare it to another terminal like Hyper (written in JavaScript).
- araoz 5mo agoI believe if the work you do fits well with Node & TS, you have no reason to use zig (other than for learning or curiosity). Like, if you don't need every drop of performance, memory layout & control, there's more downsides to using zig. Idk, cruds or "enterprise" stuff or websites don't benefit from zig.
- AlienRobot 5mo agoWhat? You can't run Node on embedded systems, because there isn't enough memory. A compiled zig program can be only several kilobytes with no depedenencies. Array access programmed in low-level languages can be optimized with SIMD and parallelization, which will be orders of magnitude faster than the same thing on Javascript. Text processing, image manipulation, video processing, hashing, etc. There is like infinite reasons to not use Javascript.
- yarn_ 5mo agoBecause they're for two completely different domains?
- shirol 5mo agoWish I had this mindset. If I did, I would already have many published apps :(
- sourcegrift 5mo agoWould someone tell a rust user why they should and should not try zig?
- wmedrano 5mo agoTry it if you want full control over every memory and IO operation and "drop". If you hit "goto-definition", you eventually get to see the OS switch statements and syscalls. There's not much magic. Do not try it if you are scared of memory management and memory leaks.
- pron 5mo agoI don't think Rust users are relevant here. It primarily comes down to personal preferences, and since Zig and Rust are so different, some will be drawn to Rust and others to Zig. If you really like a language and it suits your needs, be it Rust or any other, there's no need to look to switch. I think that the audience Zig is aimed at is low-level programmers who haven't taken a liking to Rust, which is the majority of them. Rust isn't very popular among experienced low-level programmers (certainly for a language that old), and I guess Zig is hoping to be more to their liking. For example, I find Rust to be far too similar to C++, and it shares most of the problems I have with C++ only with much lower adoption. I'm not saying I'm ready to make the switch, but at least Zig offers a different approach that's intriguing to me.
- dmit 5mo ago.....Did you just complain about Rust's "lower adoption" compared to C++, immediately following it by "Zig, on the other hand :eyes_emoji:"
- onlyrealcuzzo 5mo ago> We’ll be releasing 0.17.0 within a couple weeks from now. This is amazing. Didn't 0.16 take >1 year? I was not expecting such a fast 0.17 release, but am very pleased to find this out today.
- peesem 5mo agomainly because this build system change, along with upgrading to LLVM 22, are the only major changes for 0.17.0: https://ziglang.org/download/0.16.0/release-notes.html#Roadmap https://ziglang.org/download/0.16.0/release-notes.html#Roadm...
- Decabytes 5mo agoThere is an idea I've been kicking around for a long time, which I'll just call dual programming. The idea is to develop a stack that consists of just two programming languages, 1 higher level language, and one lower level language. You are supposed to do as much programming as you can in the high level language, and only drop into the low level language as needed. The problem is that unless you already know a low level programming language really well, you'll most likely have to re familiarize yourself with the language before doing the low level stuff. This makes Cpp and Rust harder to use then say C, so C becomes the default for me. But C is not without its issues of which we are aware. But Zig feels like it could fill that sweet spot really well, being simple enough that it's easier to pick up after a long break, but still coming with a lot of modern tooling that makes programming easier.
- deleted 5mo ago[deleted]
- dnautics 5mo agothis was the general motivation for my project zigler: https://github.com/E-xyza/zigler https://github.com/E-xyza/zigler
- Decabytes 5mo agoVery cool use of Elixir! I have been considering the Fig Stack (F# + Zig) myself, so I'm excited to see Zig being paired with a Functional Language
- tl 5mo agoThe OG of these is probably C and Assembly. C and (Emacs) Lisp is well known. Arguably, it's the entire reason we have Python. But if you want to pair Zig against something, I would look at Lua.
- kristoff_it 5mo ago> You are supposed to do as much programming as you can in the high level language, and only drop into the low level language as needed. I think that's a neat idea, but in the reverse: do as much as you can in the lower level language, and only go up to the high level language when the convenience is worth the cost. Roc allows this: every program has a platform written in a low-level language, and then the Roc program uses the API that the platform exposes. https://www.roc-lang.org/ https://www.roc-lang.org/ Then how you want to balance high vs low is of course up to you :^)
- forrestthewoods 5mo agoMy kingdom for Zig to have an official mechanism to emit the Linux library stubs. Zig’s ability to crosscompile and target arbitrary versions of glibc is PURE MAGIC. I leverage this magic in an unrelated C++ build system. But I have to hack around to get those library stubs from Zig. Would love it to be an official output.
- dzbarsky 5mo agoCheck out https://github.com/cerisier/glibc-stubs-generator https://github.com/cerisier/glibc-stubs-generator
- forrestthewoods 5mo agoInteresting. So here's my pretty hacky take on it. https://github.com/forrestthewoods/anubis/blob/983d8a1b9ea5e32487eaafcbbb007efa7849e760/src/rules/zig_rules.rs#L80 https://github.com/forrestthewoods/anubis/blob/983d8a1b9ea5e... It invokes zig on a dummy C or CPP file. Then it scrapes the output looking for specific files. C: crt1.o, libm.so, libpthread.so, libc.so, libdl.so, librt.so, libld.so, libutil.so, libresolv.so, libc_nonshared.a, libcompiler_rt.a C++: crt1.o, libc++abi.a, libc++.a, libunwind.a, libm.so, libpthread.so, libc.so, libdl.so, librt.so, libld.so, libutil.so, libresolv.so, libc_nonshared.a, libcompiler_rt.a Zig is also a god send in that it has all the generated glibc header bullshit for Linux. I've got a system that is able to cross-compile ffmpeg for Linux from Windows. Which is a shockingly painful and rare capability. Linux userspace design is so so so so so bad. So embarrassingly bad. Andrew Kelley is a damn saint for the mountains he moved for Zig. https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace... Now I just wish some of this capability was exposed in a slightly more formal capacity so that it could be leveraged by the broader community :)
- mangomanai 5mo agofantastic
- mangomanai 5mo agomoat
- kushagra1211 5mo agoOne thing I appreciate about Zig's development is that a surprising amount of effort goes into tooling and developer feedback loops rather than adding language features. A new language can survive missing a feature for a while. It's much harder to survive if every compile, link, and dependency update feels slow. The focus on making the development cycle measured in milliseconds instead of seconds seems like a good long-term bet.
- dgan 5mo agoI wanted to try zig, but the language still moves way, way too fast, they break API for every release, so i simply couldbt keep up, while learning the language/debugging the build system/trying to actually implement what i wanted After watching the Jetbrains interview, I still want to try again but maybe i ll wait till the 1.0 is out
- Scicomath 5mo agoYou can still use the old version if you don't have the time to update your code.