Zig 0.6.0 Release Notes
ziglang.org
ziglang.org
Unfortunately it is still very much the 0.x the name implies. Taking the above example defining 2 u129 or larger and trying to multiply them results in an error while compiling about it not being supported yet. Packed struct items that cross word boundaries result in a broken struct that contains a size larger than the data (which breaks pretty much all code that tries to use it due to size/type checking). Also due to comptime being as big of an idea as it is not everything works quite yet like const example: f64 = std.math.sin(4) * std.math.sin(2) being a compile time error since sin isn't defined for comptime floats yet.
Like I said it's definitely fun to play with but it's still quite a few releases away from "is this a compiler bug or did the documentation skim over something I'm just supposed to know" no longer being a problem so if that's not your cup of tea best to just watch the release notes over the next year or two.
Anyway, here's a nitpick. In this release they've removed varargs, and now this is how a printf call looks like in zig:
std.debug.warn("{}+{} is {}\n", .{1, 1, 1 + 1});
The ergonomics of typing .{} for every print seems pretty awful if you're a heavy user of debug printing. I was hoping that maybe some sort of a syntax sugar is planned so that tuples could be used without .{} -- emulating varargs, but the bug tracker doesn't turn up anything in that direction.In the previous release (0.5.0) one didn't need the .{}, but instead integer literals needed explicit casts, because the vararg implementation was limited:
std.debug.warn("{}+{} is {}\n", i32(1), i32(1), i32(1 + 1));
Both of these options seem like a regression compared to the usual printf("%d+%d is %d\n", 1, 1, 1 + 1);
... and there doesn't seem to be a way to work around it by e.g. using a function overloaded in the number of arguments (no such thing in zig) or some preprocessor tricks (again, no such thing).PS. I'm also surprised to find out that zig seems to take 2.6 seconds to compile the above example.
I think the real gotchas are that { is escaped as {{ and } as }} instead of \{ and \} (though it does follow from the old %%) and you must either include , .{} or rewrite the function call to something significantly different to do unformatted print.
Zig isn't avoiding it; it's impossible to avoid. Zig is just inferring the async-ness of the function automatically without you needing to write a keyword for it.
If you haven't heard of it: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
Highlight:
> Wanna know one [programming language] that doesn’t [have this problem]? Java. I know right? How often do you get to say, “Yeah, Java is the one that really does this right.”? But there you go. In their defense, they are actively trying to correct this oversight by moving to futures and async IO. It’s like a race to the bottom.
My experience is mostly in Go and Java and I've dabbled in C a couple of times, but I found Zig the language quite easy to understand.
Things I like the most about Zig (for now, I haven't tried everything): * error handling * optionals * tagged unions * meta programming * zig fmt
The API documentation of the std lib is still sparse though, I find it's best to search directly in the code to understand how to use it.
Looking forward to try the async functionality.
This is all coming from a guy who has only messed with Zig on a Windows box with a preference for tabs over spaces (except post indent alignment). Zig fmt works great, haven't had an issue, less difficult to get going than mingw or vs that's for sure.
Also none of what you put here is an an actual justification for stuff like this. This is like being in the twilight zone, why would anyone defend this?
Again Unix newline style is the least of the worries for whitespace, Windows and built-ins like Notepad handle it just fine for years now if that's what you code in. Try inserting tabs in place of spaces as you please in Python or Haskell though and yes you are likely to run into problems trying to run a program. It's not called "significant whitespace" in those languages because it's ignored.
It's fine to point out you think something is harder to use than it needs to be but the way you've done it says more about you than the language. You won't a whole language because it requires you run the built in formatter to compile? Might as well not use GCC either it forces you to use -- for options instead of / and other tools handle it just fine they just want to screw with Windows users that's it! What's left to talk about except these kind of nitpicks if that's where you draw the line for ignoring whole projects with years of effort put in them at?
None of what I put here was claimed as justification I said the Zig docs link to the reasons. Specifically (in case you'd rather I'd bring them up for you) the reasons were around ease of parsing as a large portion of the syntax was. The whole language specification is actualy very specific about making sure each line can be simply tokenized individually and parsed one way regardless of convetion - not actually so picked just to screw with people that like tabs or Windows. Zig fmt is allowed to "eat" any complexity in normalizing code (referencing ICU data, normalizing whitespace and other syntax, and so on) so zig build-exe doesn't have to. This philosophy of keeping as much functionality out of the core compiler and language is a big part of what allows Zig to target many places e.g. Rust doesn't even though Zig is still very fresh.
If running "zig-fmt" as part of your custom build process or using one of the editor plugins ziglang maintains that does this for you is "a slap in the face to users" I'm not sure there is any language those users would be happy with as there are other things they are going to like less than it replacing their whitespace on them. It's certainly not harder to do than post scathing reviews about how you couldn't just use tab on the release discussions though.
This is the rationalization given, but it doesn't make any sense. Carriage returns could just be ignored. It is completely trivial, especially compared to all the other changes. Can you explain how this explanation actually connects to reality?
You write about the line ending like you get paid per \r\n you push up to Git, there is no reason to care which whitespace character the formatter outputs for you. Zig init-exe is literally going to do this for you when you make a project. Build.zig can literally run zig fmt for you as part of the build process.
Why would it matter for tools? Have the tools run zigfmt. Why make users build a script to compile a hello world program? Does zig only allow a single space between tokens?
Again you are trying anything you can think of to justify a ridiculous choice because you want to defend zig as a whole. Nothing ads up here.
> there is no reason to care which whitespace character the formatter outputs for you.
I never said anything about that. I have only talked about the compiler erroring out on carriage returns as an intentional design choice.
It's not like there is an enormously "wow this would change everything about using the language" _either way_ (which is part of why it's so confusing it's the hill you're willing to die on about using Zig) it's literally "there was an option for simplifying syntax and parsing at the cost of making \r\n a syntax error". You may not agree with it but there were reasons and a path was taken. It's not the Twilight Zone, ridiculous, nonsense, user hostile, or to screw with Windows users it's a minor choice you don't agree with in a project with millions of choices to make.
This is a typical thing people do when they can't directly confront something. They throw out as much as they can and don't acknowledge when what they said was shot down, they just throw out more and hope something sticks.
https://en.m.wikipedia.org/wiki/Gish_gallop
You said so much and none of it made sense, but instead of backing up claims of "parsing being easier" or "can't support multiple line endings" or any other nonsense, you just make be on to more nonsense. Literally no other compiler intentionally breaks by default. There is no reasonable reason to do this and you haven't even come close to mentioning one and infact have had to go into bizarre concoctions because you don't want to admit how silly this is.
I then asked for clarification on why Zig shouldn't have made the decision:
"I think at this point you understand the initial aims and reasons of why Zig chose the syntax it did so here's a question about your stance both line endings should be supported by the compiler: why is it more important than the reasons Zig gave?"
and:
"Is it literally just because if you go to write your first hello world on some machines you get a syntax error telling you what needs to be changed for it to be a valid Zig source file or are there other reasons?"
And instead of responding you said more about how I've only said nonsense and unable to directly confront something.
"There is no reason to do this" is not an argument why it should be done one way or the other. "No other compiler intentionally breaks [on line endings] by default" is not a reason either but I think it relates to the only argument I identified: "if you go to write your first hello world on some machines you get a syntax error telling you what needs to be changed for it to be a valid Zig source file". I'd also love to say how silly this all is and that there is some solid reason to use tabs and Windows line endings (remember I'm a Windows user who uses the tab key) but in using Zig I have not found any reasons myself.
So on that note, again I'll ask: is there anything else this choice on line endings breaks? That is to say: not that you think it's nonsense, not that you haven't seen it before, not "well you haven't convinced me it should be this way". I'm genuinely asking about why you think it shouldn't in practice - is your only reason for caring about this because when you wrote hello world it told you the line ending needed to be \n or does it actually break some tool or workflow or limit functionality down the line or not have support somewhere or something else I haven't thought of?
If it's just the latter I think we're about as far as we can get and maybe that's why you feel there isn't any direct confrontation - you think that mildly rare error is more important than the mildly simpler syntax definition, not the end of the world for either side so be it at least we all understand the whys and why nots that led to it. I have a feeling though, considering you've been here all this time and listed it as the reason you refuse to use the language, that perhaps there are other reasons this was the wrong decision I'm still missing?
It's kind of funny to me though that there's an actual language out there where you can do use-after-free and all sorts of other C-level stuff but can't use tabs.
Zig has taken an aggressive stance on many things. For instance, it has no default allocator, no compiler warnings, variable shadowing is a compile error, no function overloading, no operator overloading, etc. And all of these decisions have pages and pages of discussion and justification.
But hey, let's keep talking about the one that is the most trivial.
Think about this. You tell your supervisors to check out zig. They ask why it doesn't work with the small program and compiler options they copied from the website. How would you explain that to them? Are you going to try to convince them that ignoring a character is a problem and that the time they spent wondering why it doesn't work is justified?