whoops! Thank you friend.
I definitely prefer Zig’s more manual, explicit and clear style, over something that looks fancy, but hides complexity from you, by adding a mountain of constructs.
cool, I def see that.
Each question has a question behind the question.
I personally look at each character in code as labor and cost - the more you have, the more expensive it is. I want the tightest code base possible
Code is Cost
without some form of sugar, string comparison will require more time when there is a change to what you are comparing – the developer (or an AI, one day) will have to mindlessly propagate updates thru if then else conditions.
When a language says “solve this yourself”, it creates tribes. And macros, infamously, create tribal sprawl.
That’s why I think switch (string)
is really a request for a better if then else chain. People just want something simpler
What do people desire?
People want clarity, and overly explicit code can be more unclear – ex, type inference is preferred const a = "abc" ++ g_str_suffix
even though there is compiler magic. Zig does great.
People want zig fmt and ZLS to help solve problems - ex ZLS will render the implicit types above. Zig does great…
to me the ask has less to do with strings, and more to do with complex conditionals. look at current state:
if cmplx-left-a == right-a {
...
}
else if cmplx-left-a == right-b or cmplx-left-a == right-c or cmplx-left-a == right-d {
...
}
else if cmplx-left-a == right-e {
...
}
else {
...
}
when there is a change to cmplx-left-a, it a PIA.
consider the below…
if cmplx-left-a == right-a { ... }
or == right-b or == right-c or == right-d { ... }
or == right-e { ... }
else {
...
}
A. zig fmt and ZLS can help structure and format the code, revealing inferences to devs
B. if you need to update cmplx-left-a, you do it once.