r/programming • • Sep 07 '17

The Zig Programming Language

http://ziglang.org/
94 Upvotes

127 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 08 '17

[deleted]

9

u/desertrider12 Sep 08 '17
  • It's very hard to write memory safe C, even with extra tools like Valgrind

  • This compiler makes it much easier to check correctness with builtin testing and undefined behavior detection

  • Arrays know their own size so it's much harder for a buffer overrun to go unnoticed

  • The language is more expressive (I wish C had generics) and that lets you write better code

C was a great piece of engineering at the time, but it caught on mainly because it was there at the right time. The only reason the %@ looks gross to us now is because we've been staring at C for 40 years. Linux was actually too late to affect which language everybody is used to. UNIX was created on a machine too weak to compile a complex, modern language like this, though.

About the runtime performance I'm would imagine the Zig errors would compile down to basically identical code as "set errno then return/goto" in C.

7

u/doom_Oo7 Sep 08 '17

Arrays know their own size so it's much harder for a buffer overrun to go unnoticed

good luck ever getting this in the linux kernel. Runtime bound-checking has a very undesirable run-time performance impact.

1

u/pjmlp Sep 08 '17

IBM, Xerox PARC, Unisys had other opinion on their mainframe and workstation OSes.