(Replying to PARENT post)

I don't understand people recommending reading the source code to learn. Source codes can be really daunting because there are so many things going on. There can also be "tricks" using advanced language features, which defeats the purpose if you're trying to learn as a first timer. Also, "read the source" is, at least to me, an admission that there is no valid documentation 90% of the time. Reading the source of a tool or a small to medium library is fine, it's not fine for large projects or projects you know nothing about.

Incremental examples is where it's at. You should document a fonction/type/feature/whatever with a short example with basic operations and then a more involved example with good practices and potential caveats. I know this is a lot of work, I understand it can't be like that everywhere.

This is not a dig at anyone's project or language, but "read the source code" comments always strike me as unhelpful.

πŸ‘€NeutralForestπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

> "read the source code" comments always strike me as unhelpful.

I can understand why people would recommend reading the source code of projects like Redis or SQLite (and here Zig's std lib) to learn, simply because the code quality is so high.

It's also not like anyone is proposing that there will be no documentation when Zig turns 1.0 (as if high quality documentation and code quality were mutually exclusive!) simply that Zig is not YET at that stage [1].

There's much to love about Zig, and it's always a good time to be reading code, and all the more so while it's growing and shaping because you end up with a deeper knowledge and understanding of what makes a great project great.

[1] Personally, I do find the language documentation to be pretty much excellent and the IRC and Discord helpfulβ€”hey, you might even bump into Mitchell Hashimoto also asking questions there. It's the std lib that's a little less, but again, that's in flux and files like `std/mem.zig` are enough of a pleasure to read and learn from. Zig's definitely a swell worth paddling.

πŸ‘€_vvhwπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

It's important to consider that for zig at this stage, "not having valid documentation" is expected. At some point not having valid docs will become considered to be unacceptable.

Forcing people to read the code puts pressure on the code to be clean.

Not writing docs against an unstable API is a strategy to make it freer for the authors to change the API, possibly in sweeping breaking ways (for example allocgate).

πŸ‘€dnauticsπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Reading the source code is very helpful if you are an experimented programmer that already grasped the basics of the language.

It helps you to see what are the idioms, what does optimized production code look like.

Compare C++ and Go std lib and it’s easy to constate the difference in language goals that they have.

πŸ‘€iTokioπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Blog author here! I read the source quite a few times.

Almost every language has a dynamic array of some sort. They all do the same thing. They all have slightly different names. push / push_back / add / append. size / length / len / count. If you don't already know the name of a function then finding it is in a sea of text is very difficult and not fun.

Zig ArrayList: https://github.com/ziglang/zig/blob/master/lib/std/array_lis... C++ Vector: https://en.cppreference.com/w/cpp/container/vector Rust Vec: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html

Sometimes I just want to see a list of functions. I can skim a list of 40 functions in seconds. Scrolling 800 lines of code and trying to pick out every single function takes much longer and is much more error prone.

πŸ‘€forrestthewoodsπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

In general I would agree, but (as multiple people pointed out) the zig standard library source code is very accessible.
πŸ‘€ralphbπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

The Zig std source code is easy to navigate, and it won't be documented until it is stabilized.

I prefer to look up the source code either way, examples and the documentation can only get you so far.

πŸ‘€ComeviusπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

It also depends on the individual. While I value documentation, I find source so much easy to understand than several paragraphs in English describing how to use language features.

But I know others much prefer reading docs over code.

πŸ‘€hnlmorgπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

> This is not a dig at anyone's project or language, but "read the source code" comments always strike me as unhelpful.

I agree, reading the source is a good way to learn more once a person already know the language.

It can be great to help track down a bug, or learn about an obscure corner case in a function, or see more advanced idioms in use, but it's a pretty terrible and unfriendly way to learn a language in the first place.

πŸ‘€jlaroccoπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

It makes less sense when the source code uses idioms that aren't recommended for other code
πŸ‘€stylussπŸ•‘3yπŸ”Ό0πŸ—¨οΈ0