I think this will happen naturally. As someone whoβs a C developer, I can tell you that nobody that I know really βwantsβ C; itβs just the de facto. C has many qualities, but I think itβs reasonable to say that a language designed 50 years ago is not shaped to define the next 50 years of computing. From the perspective of a C developer, I donβt really see why you wouldnβt pick Zig once itβs mature; itβs such an obvious choice, in my opinion.
I know that a ton of people like to believe that βC will never die,β and they will provide the same argument that βMany have tried, none have succeeded.β This is true, but also, to my knowledge, I donβt think there ever was any language whose entire philosophy, tooling, and capacity were made to replace C. None have succeeded because nobody really tried; they might have advertised themselves as such, but thatβs not the same.
Zig already provides a good experience for the developer than C, despite being still a very young language. The toolchain is better, the defaults are better, and basically all of the very error-prone patterns in C are safer to express in Zig already. Take the βdeferβ or βerrdefer,β for example; that one feature right thereβhow many βgotoβ statements can it shave off in the Linux kernel while also improving the correctness and readability of the code base? For fun, I downloaded from GitHub the Linux kernel to count the result:
ββ(~/workspace/temporary/linux)ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ(plgol@pollivies-MBP:s000)ββ
ββ(10:50:42 on master βΉ)ββ> sc goto | wc -l 130 β΅ ββ(Sat,Jan20)ββ
199715
That one feature alone can probably save 150k lines of code for free. This is just one silly example, but with comptime now, how many βvoid*β can we avoid?
ββ(~/workspace/temporary/linux)ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ(plgol@pollivies-MBP:s000)ββ
ββ(10:52:44 on master βΉ)ββ> rg 'void\s*\*' | wc -l ββ(Sat,Jan20)ββ
102424
The same thing now with βoptionalβ in Zigβhow much more safety can we gain from replacing all checks against null in C?
ββ(~/workspace/temporary/linux)ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ(plgol@pollivies-MBP:s000)ββ
ββ(10:57:23 on master βΉ)ββ> rg '\s*\(!\s*\w+\s*\)' | wc -l ββ(Sat,Jan20)ββ
128116
ββ(~/workspace/temporary/linux)ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ(plgol@pollivies-MBP:s000)ββ
ββ(11:04:35 on master βΉ)ββ> rg '\s*\(\s*\w+\s*!=\s*(NULL|0)\s*\)' | wc -l ββ(Sat,Jan20)ββ
9677
My point is that once Zig becomes mature and more people become aware of its existence and features, it will most certainly make its way into the Linux kernel. At the very least, as a toolchain, but more realistically, as an easy path to maintain/extend/rewrite modules of the kernel.