26 comments

[ 3.0 ms ] story [ 55.3 ms ] thread
This is the promise that blew my mind the first time I heard about Zig years ago. So happy to see this become reality!
I wonder how much this work being pushed forward right now is a response to the Bun drama.
I am so used to thinking that Zig, Rust, and the likes are only viable in niches where C is viable, but no. not anymore at least - once this linker and incremental compilation on other targets land, Zig will become THE C replacement and that will let me iterate at the speed of JS or Python with performance of C or Rust. even Andrew's initial dream - to create a DAW with uncompromising UX - will become much easier to create. once someone creates a Zig-native immediate-mode or reactive UI framework, that is.

I am still a little salty about `@cImport` removal, though! without it, I can't confidently call it "Kotlin of C" anymore.

> Kotlin of C

That sounds good on paper. But as a guy who tried to learn Kotlin and only it. It comes with baggage to learn Java to use its libraries because... You know... they interact seamlessly and stuff. In the end, for a new learner, it might actually make things harder.

Nothing about Zig and C here, just a bit salty from my experience with Kotlin.

idk, making @cImport just "@import" is an improvement imo.
> that will let me iterate at the speed of JS or Python with performance of C or Rust.

Didn't Go already do that?

> I am so used to thinking that Zig, Rust, and the likes are only viable in niches where C is viable, but no. not anymore at least - once this linker and incremental compilation on other targets land, Zig will become THE C replacement

Yes, and it will still only be useful in the same niche that C is because the entire philosophy of Zig is to essentially be like C. You're never going to interate at JS/Python speeds with Zig because you'll always be wrangling with memory lifecycles, object lifecycles, etc...

Rust is significantly different.

> Zig, Rust, and the likes are only viable in niches where C is viable

Pretty much correct, yes.

> Zig will become THE C replacement and that will let me iterate at the speed of JS or Python with performance of C or Rust.

Fundamentally impossible. C/Zig/Rust have 100% performance as a top goal, which has to be traded off with something else and that's always realistically going to be programmer work/effort/time.

You can't have a house built 100% fast but also 100% cheap and with 100% quality. At best you could cleverly abuse the law of diminishing returns and aim for ~80% in all three areas. That's basically what Go's trying to do.

> once this linker and incremental compilation on other targets land,

In any case, why would a better linker and faster compile times of all things achieve this supposed goal?

Beyond being low level, Zig is still pretty memory unsafe and has you make choices about each allocation, making it unappealing as an applications language. Zig and Python are completely different worlds.

These improvements are quite promising and I'm looking forward to giving that a spin once it is released.

Will the Windows side for 0.17.x get some compiler improvements as well or is this Linux only?

So, this linker does fast incremental linking, which is great for development iteration speed.

But I assume that any kind of incremental linking, is mutually exclusive with link-time optimization? I.e. you'd never want to use this option for a release build?

Research "cl:define-compiler-macro".

It has been done before.

And LTO is when the C people and the C++ people started to agree.

For releases you're generally building it all at once in a merge request/deployment pipeline anyway
Are there any other languages that offer similar compilation performance. The only one I know of or remember is Turbo Pascal.
Compilation speed isn’t that much of a factor of language as far as I can understand. It is more related to how optimization is done and how machine code is generated.

Also obviously it is about how fast the actual implementation of the compiler/build-system is.

Delphi, D, Nim, Go, C# / .NET Native / Native AOT, Oberon (any on the language family), Ada (depends on the compiler, 7 vendors),...
Everyone forgets D. It’s probably the fastest to compile, even faster than Go
There has been some speculation about porting the Raku backend (Meta-Object Aware Runtime Virtual Machine - MOARVM)from C to Zig. For example the wider set of Zig Hash options could be a big optimization.

Since you ask, the front end is self hosting in NQP and with the ripening RakuAST project increasingly in Raku Grammars. The new AST (6.e.PREVIEW) will bring much better introspection and high level optimization handles. So the potential to refactor/rewrite the VM for substantial speed gains is wide open.

Anyway those with skills and interest are welcome to join the -Ofun at https://raku.org/community

I am following Raku and Zig from afar, and they both share similarities in that both languages are "optimized for fun" in a way, so no surprize that they come together.

Zig focus on compilation speed and give developers control (even more so than C). Raku, as a Perl descendant is a giant toybox and there is no one telling you not to use them. Both have in common that they give a lot of freedom to developers, which is really enjoyable. They also have in common that they are not very mature and have a limited market share and fine with it, and a community that looks genuinely nice.

The opposite of Rust. The language has the "bondage and discipline" philosophy, kind of like ADA, the idea being that it does everything it can to stop you from making mistakes. There is a lot of value in that, but it is not particularly fun. Its community was similarly defined by rules, its code of conduct was infamous, again, it serves a purpose but to me, putting the rules forward doesn't make the community look like a fun place to be. And there is the evangelism, the Rust community is aggressive "rewrite it in Rust!", "no memory unsafe languages!", etc... I have never seen such attitude from the Zig community. Sure they love their language and will tell you it is the best in the world, but they will not say that you are wrong for not using it. As for Raku, they don't seem to care that no one else use their language, they just hope it will happen eventually if they continue going forward.

If you decide to try this, feel free to share your progress and struggles on IRC, ziggit, or ZSF zulip. Plenty of people would be interested in helping out.

Good luck and happy hacking!

i'm not cool and hip like hacker news devs, but I've been seeing Zig a lot, is this the new cool thing on the street? no more Rust?
It's a hard-to-dislike language in the niche of systems programming.

The author is strongly biased and opinionated on his architectural and design choices, and those choices resonate with many.

I've been building a memory safe language that transpiles to Zig with a Go-like runtime that can run interpreted (no GC) or compiled - high-level that feels like Ruby but with incremental typing like TypeScript.

The Zig team between 0.16 and this has really made me glad I chose Zig as the target instead of Rust - which probably would've been a lot easier to target (since it's already memory safe).

I believed it had the best build system design and was the best transpilation target, and I really believe that 6 months later.

The main reason I wanted no GC is because I think aliasing is the root of all evil, and I want a language with zero global complexity (but doesn't require a PhD to use).

Working on something kinda similar. No GC, Python feel, managed memory, performance approaching C. It's here: https://blorp-lang.org if you want to compare approaches.
I really would like a 1.0, then I think it can actually be adopted by business.
I don’t think either zig or rust can replace C, no matter how much this kind of work. They will of course improve its own language. The only language that can replace C is a language is as simple as C. None of them are simple language.
Is there a design dock or explanation about how it can do incremental linking?

It's evaded other linkers in the past: gcc, llvm, mold etc....