4 ms·
I could never get into zig purely because of the syntax and I know I am not alone, can someone explain the odd choices that were taken when creating zig? the m
by kachapopopow 11mo ago
I could never get into zig purely because of the syntax and I know I am not alone, can someone explain the odd choices that were taken when creating zig?
the most odd one probably being 'const expected = [_]u32{ 123, 67, 89, 99 };'
and the 2nd most being the word 'try' instead of just ?
the 3rd one would be the imports
and `try std.fs.File.stdout().writeAll("hello world!\n");` is not really convincing either for a basic print.
- von_lohengramm 11mo ago> and the 2nd most being the word 'try' instead of just ? All control flow in Zig is done via keyword
- dwb 11mo agoThese are extremely trivial, to the point that I don’t really know what you’re complaining about. What would expect or prefer?
- kachapopopow 11mo agoit's not about triviality, but why not use what is generally accepted already, why did zig decide to be different?
- int_19h 11mo agoWhat is "generally accepted" though? If you mean C-style declarations, the fact that tools such as https://linux.die.net/man/1/cdecl https://linux.die.net/man/1/cdecl even exist to begin with shows what's wrong with it.
- kachapopopow 11mo ago<auto/type/name> <name/type> (array?) (:)= (value) <fn> <generic> <name>(<type/argument>[:] <type/argument> [(->/:) type] [import/use/using] (<package>[/|:|::|.]<type> | "file") (ok header files are a relic of the past I have to admit that) I tried writing zig and as someone who has pretty much written in every commonly used language it just felt different enough where I kept having to look up the syntax.
- dwb 11mo agoThere’s almost countless languages that don’t do anything like this, whereas Zig is very similar. It’s fine to prefer this syntax or that, but Zig is pretty ordinary, as languages go. So yes, the differences are trivial enough that it’s a bit much to complain about. You can’t have spent much time with Zig or you’d have learned the syntax easily.
- gf000 11mo agoThe same goes for go, though. And out of the two, I find Zig is still closer to any sane existing language schema. While go is like, let's write C-style types, but reverse the order, even though there is a widely accepted type notation that already reverses it with a :, that even let's you infer types in a sane way.
- usrnm 11mo agoI will never understand people bashing other languages for their syntax and readability and then saying that they prefer Rust. Async Rust is the ugliest and least readable language I've ever seen and I've done a lot of heavily templated C++
- kibwen 11mo ago> Async Rust is the ugliest and least readable language I've ever seen and I've done a lot of heavily templated C++ No, this is a wild claim that shows you've either never written async Rust or never written heavily templated C++. Feel free to give code examples if you want to suggest otherwise.
- rustystump 11mo agoEvery language i am not deeply familiar with is disgusting. But for real the ratings for me stem from how much arcane symbology i must newly memorize. I found rust to be up there but digestible. The thought of c++ makes me want to puke but not over the syntax.
- kachapopopow 11mo agotemplate<auto V> concept non_zero = (V != 0); template<typename T> concept arithmetic = std::is_arithmetic_v<T>; template<arithmetic T> requires non_zero<T{42}> struct complicated { template<auto... Values> using nested_alias = std::tuple< std::integral_constant<decltype(Values), Values>..., std::conditional_t<(Values > 0 && ...), T, std::nullptr_t> >; template<typename... Ts> static constexpr auto process() { return []<std::size_t... Is>(std::index_sequence<Is...>) { return nested_alias<(sizeof(Ts) + Is)...>{}; }(std::make_index_sequence<sizeof...(Ts)>{}); } }; I most definitely agree.
- usrnm 11mo agoThe difference is that nobody really writes application code like that, it's a tool for writing libraries and creating abstractions. If all of the ugliness of async Rust was contained inside Tokio, I would have zero problems with it, but it just infects everything it touches
- throwawaymaths 11mo ago'const expected = [_]u32{ 123, 67, 89, 99 };' constant array with u32, and let the compiler figure out how many of em there are (i reserve the right to change it in the future)
- bnolsen 11mo ago'const expected: []const u32 = &.{ 123, 67, 89, 99 };' also works.