7 ms·
I know syntax does not REALLY matter, but Zig is just kind of subpar syntax wise. Its really verbose and picked weirdly from what already exists. Zig code is us
by phplovesong 26d ago
I know syntax does not REALLY matter, but Zig is just kind of subpar syntax wise. Its really verbose and picked weirdly from what already exists. Zig code is usually hard to read because it really noicy, and has weird things not existing in other languages without merit.
- pzittlau 26d agoI don't think that it's really subpar. It's just unusual compared to others. In and of itself it's very consistent. For instance there's `|capture|` for capturing all sort of things(errors, optionals, ...) in nearly all control flow constructs. `blk:` for naming blocks, `if`s, `switch`, and so on. Have a look at this blog post: https://matklad.github.io/2025/08/09/zigs-lovely-syntax.html https://matklad.github.io/2025/08/09/zigs-lovely-syntax.html
- phplovesong 26d agoI saw that article previously. Nearly all of the syntax seem to be in-house with little benefit. All the examples could just use some modern c-like thing. Zig has benefits, like comptime, no hidden control flow, memory mngmt, cross compilation etc. But its syntax is just a mouthfull of wats, whys and wtfs. I can forsee a compile to Zig languge popping up sometime soon.
- ulbu 26d ago|capture| hides an inconsistency that bugs me – everywhere else, assignment to a variable flows leftwards. |capture| is an unnatural rightwards assignment. in general, I like zig syntax, but i find that it had very little regard to how the eye moves on the page. it’s jarring at times.
- simjnd 26d agoBut the capture is conditional so it makes sense. if (evaluation) result = evaluation if (evaluation) |result| Although assignments as expressions in C are convenient, I don't think they make a ton of sense and find Zig's capture easier to read (easier to immediately see what's being evaluated)
- ulbu 26d agoif |result| (evaluation)
- simjnd 26d agoI think you could argue for it both ways. Then you could claim ternaries are inconsistent too, shouldn't it be: resultA : resultB ? (evaluation) if we always put result first? I think the most important piece of if statements and ternaries is the condition being evaluated and it's worth putting that first?
- ulbu 25d agobut zig has no ternaries, so it does not apply to a discussion about zig’s syntax. and ternary is a branch with no variable introduction, so it doesn’t apply again. (it’s basically a weak switch expression, and the value moves leftwards towards its invocation.)
- nromiun 26d agoOf course syntax matters in any programming language. That is like saying the alphabet and grammar does not really matter in English.
- zuzululu 26d agowith LLMs? syntax doesn't really matter anymore exactly because of what you mentioned in your last sentence.
- ModernMech 26d agoWith LLMs you pay per token, so if you can express the same code in 1 / 10th the tokens that absolutely matters. Moreover they have a finite context window, so more concise syntax can make that more economical.
- zuzululu 25d agoSure but how many devs can sustain that level of efficiency around the clock and how much thought do you think their employers will give when the LLM tokens pay 1/100~1/1000th of the wage paid
- ModernMech 25d agoWdym, the LLM is writing it either way? My point is all else being equal, you’d prefer the code that’s shorter for the reasons stated.
- zuzululu 25d agoI want code that is efficient, secure and cheap to produce. There is no way a human can compete with a network of agents doing that. Whatever edge you think exists is on a downward trend. Look at where we were in the days of GPT 4o vs now in terms of coding capability. Look at the marketplace for overseas contractors and the impact AI has had. To ship what I do now would've cost a few million dollars per year in terms of the team needed to maintain it now its 1000x cheaper
- flohofwoe 26d agoWell, compared to what? Zig is much nicer to read than Rust or C++, about the same as Typescript, but not as nice as modern C. But that's just my opinion. Such questions usually come down to "how familiar am I with this programming language", and anything that doesn't look like your pet language looks ugly. Except Rust and C++ of course, those are objectively ugly ;P
- phplovesong 26d agoOfc it boils down to familiarity. But making a custom version of, say structs is just a weird design. The mainstream struct syntax is something everyone knows, and zig made all kinds of weird decisions around it. Same goes for @SpecialThing, looks like PHP to me. Multiline strings are also a weird addition. The list goes on.
- flohofwoe 26d ago> But making a custom version of, say structs is just a weird design. This I don't understand? Zig structs are pretty much the same as in any other language, except that the declaration can be more flexible by building the struct type via comptime code (e.g. how Zig does generics) - and Zig groups structs and namespaces under the same keyword (which hardly matters in practice though). > @SpecialThing ...not any weirder than `__builtin` keywords in Clang or GCC and at least in Zig it's obvious that anything starting with a `@` is a builtin, while in Clang/GCC the `__` is not explicitly reserved for builtins. ObjC also uses a leading `@` to separate ObjC keywords from regular C keywords. Agreed that the @-noise can get a bit excessive in Zig though (mainly because implicit casting is heavily restricted, at least compared to C). > Multiline strings are also a weird addition AFAIK the 'weird' multiline syntax is for keeping the parser simple and fast. Multi-line-strings themselves are a good feature to have though. In general, if Zig code starts to look too 'noisy', that's usually a sign that the code should be simplified. I definitely don't agree with all design decisions in Zig, but the syntax is mostly fine (my main critique points are that Zig often tries to lean too much into 'design purity' than 'programmer convenience' and that parts of the stdlib are too 'object oriented'.
- 26d ago
- ModernMech 26d agoYou might be interested in this recent talk which argues concrete syntax does actually matter: https://slim.computer/concrete-syntax/ https://slim.computer/concrete-syntax/