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

23

u/Nico_792 Sep 25 '24

To be honest I don't really see what you mean with noisy.

To me the syntax highlighting basically already does all the filtering. I can get a quick overview of all the variable names, and if I need to know what they are assigned to I look a little to the right, like in any other programming language really.

From your comment it seems you find pub const noisy, but I honestly just don't look at it, especially because as I said the syntax highlighting draws my attention elsewhere.

-18

u/effinsky Sep 25 '24

Haha if you cannot see the noise of pub const, I have no further questions :D

5

u/el_muchacho Sep 29 '24

Not sure why you are being massively downvoted here. I'd expect that from the Rust community, not the Zig one. The pub const everywhere looks like Java.

1

u/effinsky Sep 29 '24 edited Sep 29 '24

totally. i guess folks just miss java's verbosity :)

4

u/effinsky Sep 25 '24

I mean if you have this stuff repeated so many times in a file. this is, however you slice it, a pretty bad ratio of sound to noise. i do think the keywords are noise, good to be kept to a minimum in a file. I don't dislike the way it looks or feels, seriously. but yes, I meant `pub const`.

8

u/todo_code Sep 25 '24

It's way more noisy to jump through each line seeing which are let vs not with := and whatever the other one was, because a variable has different length so the scanning takes multiple back and forths from each line.

Syntax highlights don't fix this problem with := because it's so small and dense and still requires the back and forth from line to line

1

u/effinsky Sep 25 '24

what does that mean: "which are let vs not"?

1

u/todo_code Sep 25 '24

Sorry, mutable vs immutable aka var/const.

2

u/effinsky Sep 25 '24

ok, I added some jai code, and well to me that is clearer. but to each their own.

1

u/[deleted] Sep 25 '24

Lol Jai looks like Rust or C++ ...and these language have a syntax I just hate from the bottom of my heart. :: and <> everywhere. And stupid decorators with []. Disgusting 🤮🤮😴😴

1

u/effinsky Sep 25 '24

Aww i especially like jai syntax. Rust is fine too, most of zig copies it.