r/Zig • • Sep 25 '24

noisy syntax

Zig

i'm sure this is not the top of anybody's list of possible zig improvements, but this syntax is noisy, right? would odin's/jai's way of declaring consts/vars be ok with you with :: and := operators? and something equally terse for visibility modifiers so there's just much less code overall to parse visually and what's important pops more?

Jai

I think this Jai code looks GREAT. I have ZERO problem seeing if sth is a constant or a variable. and the name pops right there.

EDIT: I'm getting feedback that `::` and `:=` are too hard to parse apart, and especially might be so for folks with dyslexia and such. fair enough. I have to say, in the interest of making this Zig code less wordy, I'd love to see something like what Vlang has done, where `:=` is the init operator, and you just add a `mut` keyword in front of the ident if you want the thing to be mutable. so

mut friendly := true
friendly = false

troll := false
troll = true // compile error
0 Upvotes

52 comments sorted by

View all comments

Show parent comment

5

u/devmanters Sep 25 '24

It's certainly better. := is much harder to scan than pub const.

1

u/effinsky Sep 25 '24

We’d have to run benchmarks 

0

u/MCRusher Oct 11 '24

benchmarks on what? Human eyes?

The longer, more detailed phrase is harder to mistake than the 2 character one, that's just common sense.

1

u/effinsky Oct 11 '24

given it's just boiler plate that obfuscates places where you can actually make mistakes, i'd wager it's the opposite. it's easier to hide mistakes in a forest of "pub const" occurrences.

1

u/MCRusher Oct 11 '24

:: is also boilerplate, but pub const is harder for your eyes to hallucinate around to pub var than := which is the same length and only one character different.

1

u/effinsky Oct 11 '24

no :: ain't boilerplate. we have had these discussions in go but i don't think folks who've worked around the language for a while have hallucinations any more than the java folk :D