Such a good decision. There's no reason to use block comments in 2025.
Zig's Lovely Syntax
61–70 of 246 posts
Re: Zig's Lovely Syntax
#62 string json = $"""
{title}
Welcome to {sitename}.
""";
And it even allows for using embedded curly braces as real characters: string json = $$"""
{{title}}
Welcome to {{sitename}}, which uses the {sitename} syntax.
""";
The $ (meaning to interpolate curly braces) appears twice, which switches interpolation to two curly braces, leaving the single ones untouched.Re: Zig's Lovely Syntax
#63> C uses a needlessly confusing spiral rule Libellous! The "spiral rule" for C is an abomination and not part of the language. I happen to find C's type syntax a bit too clever for beginners, but it's marvellously consistent and straightforward. I can read types fine without that spiral nonsense, even if a couple of judicious typedefs are generally a good idea for any fancy function types.
It's not context free though.
Re: Zig's Lovely Syntax
#64> Raw or multiline strings are spelled like this: const still_raw = \\const raw = \\ \\Roses are red \\ \\ Violets are blue, \\ \\Sugar is sweet \\ \\ And so are you. \\ \\ \\; \\ ; This syntax seems fairly insane to me.
If it isn't obvious, the problem is that you can't indent them properly because the indentation becomes part of the string itself.
Some languages have magical "removed the indent" modes for strings (e.g. YAML) but they generally suck and just add confusion. This syntax is quite clear (at least with respect to indentation; not sure about the trailing newline - where does the string end exactly?).
Re: Zig's Lovely Syntax
#65const x: i32 = 92; D has less syntax: const int x = 92; Just for fun, read each declaration out loud.
"less syntax" isn't necessarily better. The goal isn't to have as few characters as possible.
Re: Zig's Lovely Syntax
#66I like Zig as well, but I won't call its syntax lovely. Go shows you can do pretty well without ; for line breaks, without : for variable types etc. But sure, if you only compare it with Rust, it is a big improvement.
Re: Zig's Lovely Syntax
#67const x: i32 = 92; D has less syntax: const int x = 92; Just for fun, read each declaration out loud.
"less syntax" isn't necessarily better. The goal isn't to have as few characters as possible.
I like the syntaxes of each, although Ada is too verbose to me, and with Factor and Common Lisp I have a skill issue.
Re: Zig's Lovely Syntax
#68Do I read this correctly that it replaces `\n` at the end of the line with a whitespace? CJK users probably won't be happy with the additional whitespaces.
Re: Zig's Lovely Syntax
#69> Raw or multiline strings are spelled like this: const still_raw = \\const raw = \\ \\Roses are red \\ \\ Violets are blue, \\ \\Sugar is sweet \\ \\ And so are you. \\ \\ \\; \\ ; This syntax seems fairly insane to me.
Maybe if you've never tried formatting a traditional multiline string (e.g. in Python, C++ or Rust) before. If it isn't obvious, the problem is that you can't indent them properly because the indentation becomes part of the string itself. Some languages have magical "removed the indent" modes for strings (e.g. YAML) but they generally suck and just add confusion. This syntax is quite clear (at least with respect to i…
Re: Zig's Lovely Syntax
#70> As Zig has only line-comments, this means that \n is always whitespace. Do I read this correctly that it replaces `\n` at the end of the line with a whitespace? CJK users probably won't be happy with the additional whitespaces.