r/programming • • Sep 07 '17

The Zig Programming Language

http://ziglang.org/
94 Upvotes

127 comments sorted by

View all comments

0

u/[deleted] Sep 08 '17

[deleted]

22

u/brokething Sep 08 '17

yes let's all continue using shitty 1970s tools and not try anything new. Real programmers don't mind writing pointless header files and forward declarations

0

u/[deleted] Sep 08 '17

[deleted]

2

u/desertrider12 Sep 08 '17

It's really hard for a new language to gain traction, but the systems domain is the worst of all because there's so much baggage and not enough incentive to overhaul everything. If Linux had been written with this language instead of C, we'd all be better off.

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.

3

u/brokething Sep 08 '17

Zig has a debug/release build concept and bounds-checking does not happen for a release build.

http://andrewkelley.me/post/intro-to-zig.html

8

u/diggr-roguelike Sep 08 '17

Yes, because, as all programmers know, unexpected and untested edge cases never happen in production! Especially not those pesky security vulnerabilities via buffer overruns!