News for hackers. Stuff that matters.
Re:Zig: a system language which prioritizes optimality, safe... by pmontra on Monday August 29, 2016 @01:47AM (#12380234)
How is the goal of readability being addressed? I didn't find it particularly readable. Basically it's C with better types.

A few suggestions about the syntax, based on what many languages did in the last 25 years.

1) No mandatory () around conditionals. Make {} mandatory even for one liners instead. They remove bugs and are a common suggestion in the style guides of several languages.

2) The multine string syntax is verbose and uninviting. Use heredocs or a string delimiter reserved for that purpose.

3) Try to do without the ; line terminator

As a huge bonus, to reduce clutter, try to implement automatic import. I don't know of any language doing it, it's IDE territory right now (or editor's [1]). Still it's very useful because there is little as boring as going through a long list of imports at the beginning of each file. They should be there only when there is an ambiguity to resolve.

About readability, those {var v; while (cond) {}} blocks in the examples are puzzling. Finding a }} alone on a line was an "is this a syntax error?" moment, or just bad style.

Anyway, it seems to have generics so it's already ahead than Go, which seems to be stuck in the 60s regarding this feature (they've been pioneered by ML in 1973 according to [2]). For the rest, it's in the average of what we've seen in the past decades, so not shiny but not bad. Plenty of successful languages are like that and maybe it's a reason for their success: being average they don't scare away people. I'm thinking especially of Python, which smells oddly of C with its __underscores__ and the explicit self argument, reminding me of how we used to do OO in C passing around struct pointers (those structs were the objects, holding data and function pointers to methods).

[1] http://www.vim.org/scripts/script.php?script_id=325

[2] https://en.wikipedia.org/wiki/Generic_programming

Re:Zig: a system language which prioritizes optimality, safe... by tom_mellior on Monday August 29, 2016 @04:42AM (#12380758)
One more syntax issue:

http://andrewkelley.me/post/intro-to-zig.html shows the

    const number = parse_u64(str, 10) %% |err| return err;
pattern and then goes on to say that you can avoid repeating "%% |err| return err" all the time by writing

    const number = %return parse_u64(str, 10);
instead. I don't think that's particularly nice; it looks too much like "return the result of the call" when that's only what happens in the error case. I would have expected something more like this:

    const number = parse_u64(str, 10) %% return error;
where the compiler would turn "return error" into "|_some_var| return _some_var".
Re:Zig: a system language which prioritizes optimality, safe... by pmontra on Monday August 29, 2016 @06:17AM (#12380995)
Agreed, %return is confusing and sends the reader down a wrong path.

Your last example could work if error is the default name for the error variable, which makes sense.

Re:Zig: a system language which prioritizes optimality, safe... by codygman on Tuesday August 30, 2016 @03:15AM (#12388106)
Re:Zig: a system language which prioritizes optimality, safe... by __david__ on Monday August 29, 2016 @08:12PM (#12386447)
> 1) No mandatory () around conditionals. Make {} mandatory even for one liners instead. They remove bugs and are a common suggestion in the style guides of several languages.

No, no no! I really hate that trend in newer languages (rust and go, I'm looking at you). C got this right.

Re:Zig: a system language which prioritizes optimality, safe... by codygman on Tuesday August 30, 2016 @03:12AM (#12388094)
Make issues. I made one for the %% operator:

https://github.com/andrewrk/zig/issues/176