News for hackers. Stuff that matters.
Re:Zig Quirks by 0x37 on Monday March 27, 2023 @05:48AM (#35324706)
I don't usually like participating in bikeshedding, but the @ annotation feels like PHP's $ to me in that I don't see why it needs to exist. The language design could've easily just left that out and I don't think anything would be lost.

Other than that, I'm definitely excited for Zig as a potential C++ replacement.

Re:Zig Quirks by ptato on Monday March 27, 2023 @06:07AM (#35324804)
Built-in names are essentially reserved words, and there are dozens of them. The @ prefix ensures you don't step on user's variable names, and that you can add new built-ins without making breaking changes.
Re:Zig Quirks by andrepd on Monday March 27, 2023 @06:48AM (#35325043)
Why aren't they simply namespaced, like `core.some_function`?
Re:Zig Quirks by AnIdiotOnTheNet on Monday March 27, 2023 @07:30AM (#35325314)
Because there'd need to be a magical exception for the "core" namespace that makes it not just a file of Zig code somewhere like every other module.
Re:Zig Quirks by hiccuphippo on Monday March 27, 2023 @09:24AM (#35326385)
Isn't there already a magical exception for "root" and "builtin"?
Re:Zig Quirks by kristoff_it on Monday March 27, 2023 @10:00AM (#35326759)
not really, those are two modules that are always available to you, but you still have to import them like any other Zig module `const builtin = @import("builtin");`
Re:Zig Quirks by nine_k on Monday March 27, 2023 @09:18AM (#35326329)
5 characters to type instead of 1.
Re:Zig Quirks by tleb_ on Monday March 27, 2023 @05:54AM (#35324732)
My belief is that it is about builtin functions that are provided by the compiler versus part of the standard library. They are documented in the language reference [0] versus in the standard library documentation [1].

[0]: https://ziglang.org/documentation/master/

[1]: https://ziglang.org/documentation/master/std/

Re:Zig Quirks by kristoff_it on Monday March 27, 2023 @05:53AM (#35324724)
> I don't see why it needs to exist

The symbol namespaces builtins, as those are the only identifiers that aren't declared in the file (either directly or by using `@import`).

Re:Zig Quirks by tialaramex on Monday March 27, 2023 @06:49AM (#35325055)
Although namespacing them keeps them out from under a programmer's feet, which is a significant benefit, it does seem like this would make it harder to find stuff. @cmpxchgStrong, @wasmMemorySize and @embedFile are completely unrelated, but since they're all builtins they're neighbours.
Re:Zig Quirks by Conscat on Monday March 27, 2023 @08:45AM (#35325952)
This is sort of an issue we already deal with in other languages, and imo it's not a huge deal in those. Personally I find @ more reasonable than __builtin_
Re:Zig Quirks by throwawaymaths on Monday March 27, 2023 @10:49AM (#35327407)
one side benefit is that at lot of @ code is "dangerous shit" so it draws your eye during code review. You will want to code review the "dangerous shit" that GPT-5 gives you.