6 ms·
> For a larger project like the Zig compiler itself, it takes the time down from 75 seconds to 20 seconds. We’re only just getting started. Excited to see what
by 9d 1y ago
> For a larger project like the Zig compiler itself, it takes the time down from 75 seconds to 20 seconds. We’re only just getting started.
Excited to see what he can do with this. He seems like a really smart guy.
What's the package management look like? I tried to get an app with QuickJS + SDL3 working, but the mess of C++ pushed me to Rust where it all just works. Would be glad to try it out in Zig too.
- stratts 1y agoPackage management in Zig is more manual than Rust, involving fetching the package URL using the CLI, then importing the module in your build script. This has its upsides - you can depend on arbitrary archives, so lots of Zig packages of C libraries are just a build script with a dependency on a unmodified tarball release. But obviously it's a little trickier for beginners. SDL3 has both a native Zig wrapper: https://github.com/Gota7/zig-sdl3 https://github.com/Gota7/zig-sdl3 And a more basic repackaging on the C library/API: https://github.com/castholm/SDL https://github.com/castholm/SDL For QuickJS, the only option is the C API: https://github.com/allyourcodebase/quickjs-ng https://github.com/allyourcodebase/quickjs-ng Zig makes it really easy to use C packages directly like this, though Zig's types are much more strict so you'll inevitably be doing a lot of casting when interacting with the API
- LAC-Tech 1y agoIt's also worth pointing out that the Zig std library covers a lot more than the rust one. No need for things like rustix, rand, hashbrown, and a few others I always have to add whenever I do rust stuff.
- nindalf 1y agoYou add hashbrown as an explicit dependency? The standard library HashMap is a re-export of hashbrown. Doesn’t it work for you?
- LAC-Tech 1y agohuh, does it? I always add it so I can make non-deterministic hashmaps in rust. oh and you need one more one for the hashing function I think. But I did not know hashmap re-exported hashbrown, thanks.
- nindalf 1y agoYep, they’re the same since Rust 1.36 (Jul 2019) - https://blog.rust-lang.org/2019/07/04/Rust-1.36.0/ https://blog.rust-lang.org/2019/07/04/Rust-1.36.0/
- LAC-Tech 1y agohttps://doc.rust-lang.org/std/?search=hashbrown https://doc.rust-lang.org/std/?search=hashbrown looks like there's no way to access it, outside of hashmap. Though maybe you just need the third party hasher and you can call with_hasher. IDK man there's a lot going on with rust.
- nindalf 1y agoYes that’s exactly it. If speed is a priority and the input is trusted, change the hasher to something faster like ahash. The ahash crate makes this easy.
- vlovich123 1y agoCan’t speak for the op but there’s a number of high performance interfaces that avoid redundant computations that are only available directly from hashbrown.
- eknkc 1y agoIt is pretty easy to interface stuff like QuickJS C API. I had a POC here from last year: https://github.com/eknkc/zquickjs https://github.com/eknkc/zquickjs Even this is pretty usable, handling value conversions and such thanks to comptime. (Take a look at the tests here: https://github.com/eknkc/zquickjs/blob/master/src/root.zig https://github.com/eknkc/zquickjs/blob/master/src/root.zig)
- throwawaymaths 1y agoim stunned that zig can compile itself in 75 seconds (even with llvm)
- pjmlp 1y agoWe used to have such fast compile times with Turbo Pascal, and other dialects, Modula-2, Oberon dialects, across 16 bit and early 32 bit home computers. Then everything went south, with the languages that took over mainstream computing.
- faresahmed 1y agoNot to disagree with you, but even C++ is going through great efforts to improve compile-times through C++20 modules and C++23 standard library modules (import std;). Although no compiler fully supports both, you can get an idea of how they can improve compile-times with clang and libc++ $ # No modules $ clang++ -std=c++23 -stdlib=libc++ a.cpp # 4.8s $ # With modules $ clang++ -std=c++23 -stdlib=libc++ --precompile -o std.pcm /path/to/libc++/v1/std.cppm # 4.6s but this is done once $ clang++ -std=c++23 -stdlib=libc++ -fmodule-file=std=std.pcm b.cpp # 1.5s a.cpp and b.cpp are equivalent but b.cpp does `import std;` and a.cpp imports every standard C++ header file (same thing as import std, you can find them in libc++' std.cppm). Notice that this is an extreme example since we're importing the whole standard library and is actually discouraged [^1]. Instead you can get through the day with just these flags: `-stdlib=libc++ -fimplicit-modules -fimplicit-module-maps` and of course -std=c++20 or later, no extra files/commands required! but you are only restricted to doing import <vector>; and such, no import std. [^1]: non-standard headers like `bits/stdc++.h` which does the same thing (#including the whole standard library) is what is actually discouraged because a. non-standard and b. compile-times, but I can see `import std` solving these two and being encouraged once it's widely available!
- pjmlp 1y agoAs big fan of C++ modules (see my github), we are decades away of widespread adoption, unfortunately. See regular discussions on C++ reddit, regarding state of modules support across the ecosystem.
- WalterBright 1y agoThe dmd D compiler can compile itself (debug build): real 0m18.444s user 0m17.408s sys 0m1.688s On an ancient processor (it runs so fast I just never upgraded it): cat /proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 15 model : 107 model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ stepping : 2 cpu MHz : 2299.674 cache size : 512 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes
- AndyKelley 1y ago18s eh? we're looking at 15s in https://github.com/ziglang/zig/pull/24124 https://github.com/ziglang/zig/pull/24124 oh, and by the way that includes the package manager, so the compile time accounts for: * HTTP * TLS (including aegis-128l, aegis-256, aes128-gcm, aes256-gcm, chacha20poly1305) * deflate, zstd, and xz * git protocol
- 9d 1y agoWait, is this a competition?
- WalterBright 1y agoAlways!
- 9d 1y agoDang, I'm far behind then, I haven't even downloaded QBE[1] yet! [2] https://c9x.me/compile/ https://c9x.me/compile/
- WalterBright 1y ago> Dang Better spelled as Dlang!
- candrewlee 1y ago
- txdv 1y agoI wonder if there is a guide to do that. When I tried compiling zig it would take ages because it would go through different stages (with the entirety of bootstraping from wasm)