General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
⃠
Fireship
comments
Comments by "⃠" (@U20E0) on "Zig in 100 Seconds" video.
notably it is also the only one not trying to “fix” C
26
fn is not that uncommon. And yes, the language’s syntax is very unconventional in every way possible. Multiline strings are achieved by prefixing a line with \\
4
1. function parameters are always immutable. 2. No. 3. a switch statement exists, but it’s quite unusual. It returns a value. Like in C it can only match against enum or integer constants, but Zig has built-in tagged unions (union with attached integer that tells you which member you should use), and switch can match the tag of the union as well. 4. not really sure what you mean by that 5. Yes. Zig distinguishes between several types of pointers, and allows pointer arithmetic (sometimes). 6. OOB checks will happen if the array has known bounds, and Zig errors if a constant array is not terminated with the requested value. Like C, strings are just an easier way to initialize a char array. Other mildly interesting things: Arbitrary bit width can be specified for integers: u5 and i7529 are both valid types Integer overflow is UB — if you want an automatic overflow check append | to the operator and % if you explicitly want to allow overflow Inline assembly is supported Vectors are supported Standard library is quite large
4
@X() is not any worse than __builtin_X().
3
You can’t compare them in a meaningful way. Zig is a drop-in replacement for C designed to cut out boilerplate and make some features (like vector types) more usable. Rust is a C++ alternative designed around memory safety
2
@yash1152 No function overloading, but a template-like concept called compile-time parameters exists. It’s significantly more usable than C++ templates (and since comptime{} exists, it’s also more versatile). You can also have type-generic parameters. i did not actually know the difference between = and := in python until now — i haven’t used it in forever. And the answer is no. The compiler treats = as a keyword, not as an operator, yielding what i would consider unpolished errors: a = b = 4; ^ expected ; after statement and return b = 4; ^^^^^^ invalid left-hand-side for assignment
2
Zig does just have pointers
1
that was said to likely be in more than 10 years
1
@Traiden_ i do still think that the syntax could be improved a lot
1
well, that’s to be expected from a language that is in version 0.10
1
it is strongly typed. Just that types are inferred.
1