News for hackers. Stuff that matters.
Re:Zig, the Ideal C Replacement Or? by com2kid on Friday May 09, 2025 @10:46PM (#43942838)
I disagree on many points the article makes, but it is well written and lays out its arguments well.

One example - I prefer the named fields of Zig over Odin's use of positional fields. Zig's syntax is the more popular one as of late, heck even C has named struct member initialization.

IMHO Positional is just asking for trouble. Yes it works fine for game programming, and not having to specify x and y thousands of times in a code base is nice, but for general purpose languages where a struct can have a dozen+ fields to init, positional assignment is how bugs are made.

Re:Zig, the Ideal C Replacement Or? by lerno on Saturday May 10, 2025 @04:11AM (#43944010)
C gives either, I think that is the true with Odin as well, it certainly is for C3. I was assuming Zig allowed both. Is this another one of Zig being strict with ”only one way”?
Re:Zig, the Ideal C Replacement Or? by Simran-B on Saturday May 10, 2025 @10:20AM (#43945857)
You can simply offer a function to create an object using positional arguments if you want that
Re:Zig, the Ideal C Replacement Or? by hansvm on Sunday May 11, 2025 @09:15AM (#43953617)
You can also create a function capable of doing that for any object, or one which curries the type parameter, if you'd like to reduce the boilerplate if you have many types of objects you'd like to instantiate positionally.
Re:Zig, the Ideal C Replacement Or? by hmac1282 on Saturday May 10, 2025 @09:14PM (#43950410)
I am only giving my impressions. Coming from other languages, this was very confusing, and the error messages were not helpful.