I find Zig syntax noicy. I dont like the @TypeOf (at symbol) and pals, and the weird .{.x} syntax feels off. Zig has some nice things going on but somehow code is really hard to read, admitting its a skill issue as im not that versed in zig.
Zig is noisy and and the syntax is really not elegant. One reason I like odin's syntax, it's minimal and so well thought out.
Zig's Lovely Syntax
241–246 of 246 posts
Re: Zig's Lovely Syntax
#242Earlier quoted context omitted.
I may be missing something but come Go has a simple: `A simple formatted string ` ?
Yours is rendered as: A\n\tsimple\n\t\tformatted\n\t\t\tstring\n\t If you wanted it without the additional indentation, you’d need to use a function to strip that out. Typescript has dedent which goes in front of the template string, for example. I guess in Zig that’s not necessary which is nice.
Re: Zig's Lovely Syntax
#243Earlier quoted context omitted.
Well, your example seems to do something completely different, which is return an ArrayList!T rather than a type.
It achieves the same result in practice. The reason Zig needs to return a type is because it lacks a way to represent `T!A` where T is a parameterized type, and A is the parameter. In this case, that would've been better because you would be able to tell exactly what the type being returned was. If you must return different types depending on the argument in D, it's also possible. Here's a silly example: struct Array…
Re: Zig's Lovely Syntax
#244Earlier quoted context omitted.
Well, your example seems to do something completely different, which is return an ArrayList!T rather than a type.
It achieves the same result in practice. The reason Zig needs to return a type is because it lacks a way to represent `T!A` where T is a parameterized type, and A is the parameter. In this case, that would've been better because you would be able to tell exactly what the type being returned was. If you must return different types depending on the argument in D, it's also possible. Here's a silly example: struct Array…
Regardless, we are now very far removed from the original code I was commenting on, which doesn't use auto to return different types.
Re: Zig's Lovely Syntax
#245> Like Rust, Zig uses 'name' (':' Type)? syntax for ascribing types, which is better than Type 'name' I'm definitely an outlier on this given the direction all syntactically C-like new languages have taken, but I have the opposite preference. I find that the most common reason I go back to check a variable declaration is to determine the type of the variable, and the harder it is to visually find that, the more annoy…
> I find that the most common reason I go back to check a variable declaration is to determine the type of the variable, Hover the mouse cursor over it. Any reasonable editor will show the type. > In Rust, in particular, this leads to some awkward syntactic verbosity, because mutable variables are declared with `let mut`, meaning that `let` is used in every declaration. Rust is very verbose for strange implementation…
> Hover the mouse cursor over it. Any reasonable editor will show the type.
That applies to most of us, obviously, but in this context we're talking about Zig. Zig's lead developer, Andrew Kelley, programs in Vim with no autocomplete or mouse support.
Even though I sometimes use editors with these features, I find it frustrating when languages seem to be designed in such a way that presumes their availability. I found Rust particularly bad about this, for example.