"Zig doesn’t have lambdas" This surprises me (as a C++ guy). I use lambdas everywhere. What's the standard way of say defining a comparator when sorting an array in Zig?
Zig's Lovely Syntax
21–30 of 246 posts
Re: Zig's Lovely Syntax
#22> 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…
In my opinion the `let` is not so unnecessary. It clearly marks a statement that declares a variable, as opposed to other kind of statements, for example a function call.
This is also why C++ need the "most vexing parse" ambiguity resolution.
Re: Zig's Lovely Syntax
#23Having @ and .{ } all over the place is hardly lovely, as is having modules like JavaScript's CJS.
It's especially bad on a qwertz keyboard as well.
Curly brace syntax would never have been invented in Europe (case in point: Python and Pascal).
Re: Zig's Lovely Syntax
#24"Zig doesn’t have lambdas" This surprises me (as a C++ guy). I use lambdas everywhere. What's the standard way of say defining a comparator when sorting an array in Zig?
Same as C, define a named function, and pass a pointer to the sorting function.
Re: Zig's Lovely Syntax
#25"Zig doesn’t have lambdas" This surprises me (as a C++ guy). I use lambdas everywhere. What's the standard way of say defining a comparator when sorting an array in Zig?
Same as C, define a named function, and pass a pointer to the sorting function.
https://ziglang.org/documentation/master/std/#std.sort.binar...
Re: Zig's Lovely Syntax
#26Earlier quoted context omitted.
It's especially bad on a qwertz keyboard as well.
That's why "real programmers" use English keyboard layout regardless of the physical keyboard ;) Curly brace syntax would never have been invented in Europe (case in point: Python and Pascal).
Re: Zig's Lovely Syntax
#27Earlier quoted context omitted.
I am an exception then. Rust may be my favourite language but the syntax is pretty awful and one of its biggest weaknesses. I also love Ruby but I am pretty meh about its syntax.
I don't think many people would start to use a language unless the found the syntax at least a little simpatico - but I guess they could be drawn by the semantics it provides.
The exception is languages with syntax that require a non-standard keyboard.
Re: Zig's Lovely Syntax
#28But sure, if you only compare it with Rust, it is a big improvement.
Re: Zig's Lovely Syntax
#29Earlier quoted context omitted.
Same as C, define a named function, and pass a pointer to the sorting function.
And what if you need to close over some local variable?
And considering the memory management magic that would need to be implemented by the compiler for 'painless capture' that's probably a good thing (e.g. there would almost certainly be a hidden heap allocation required which is a big no-no in Zig).
Re: Zig's Lovely Syntax
#30In my experience, everyone finds the syntax of their favourite language lovely - I love (mostly) C++.
I don't like the syntax of Lisps, with the leading parenthesis to begin every expression.
I use it anyway because it's so useful and powerful. And I don't have any better ideas.