Zig: Already More Knowable Than C - Andrew Kelley
There is a nifty article created back in 2015 that made its way onto Hacker News today: I Do Not Know C. The author creates a delightful set of source code samples in which the reader is intended to determine the correctness, and if correct, predict the output of the provided code. If you have not done the exercises, I encourage you to take a moment to do so. What follows are some of the examples translated into Zig for comparison. The numbers correspond to the numbers from the original post linked above, but the C code is embedded here for comparison. In Zig: Output: When this example is translated to Zig, you have to explicitly decide if the pointer is nullable. For example, if you used a bare pointer in Zig: Then it wouldn't even compile: I think this error message can be improved, but even so it prevents a possible null related bug here. If the code author makes the pointer nullable, then the natural way to port the C code to Zig would be: This compiles to: This does a null check,
Zig: Already More Knowable Than C - Andrew Kelley Andrew Kelley - Zig: Already More Knowable Than C (2017 Feb 14) Zig: Already More Knowable Than C There is a nifty article created back in 2015 that made its way onto Hacker News today: I Do Not Know C . The author creates a delightful set of source code samples in which the reader is intended to determine the correctness, and if correct, predict the output of the provided code. If you have not done the exercises, I encourage you to take a moment to do so. What follows are some of the examples translated into Zig for comparison. The numbers cor
Explore this link on the map →saved by
related reading
- Devlog ⚡ Zig Programming Languageziglang.org
- Assorted thoughts on zig (and rust)scattered-thoughts.net
- Rewriting Bun in Rust | Bun Blogbun.com
- I think Zig is hard...but worth it - ratfactorratfactor.com
- What Every C Programmer Should Know About Undefined Behavior #1/3 - The LLVM Project Blogblog.llvm.org
- What Every C Programmer Should Know About Undefined Behavior #3/3 - The LLVM Project Blogblog.llvm.org
- What Every C Programmer Should Know About Undefined Behavior #2/3 - The LLVM Project Blogblog.llvm.org
- Zig explores structured concurrency [LWN.net]lwn.net
- Zig And Rustmatklad.github.io
- Perfecting WebGPU/Dawn native graphics for Zig | Hexops' devlogdevlog.hexops.com
- 0028: HYTRADBOI jam, sqllogictest in a week, how safe is zig again, rr on alder lake, google maps jank, linksscattered-thoughts.net
- Zig Creator Calls Spade a Spade, Anthropic Blows Smokeraymyers.org