6 ms·
I am always interested in zig, but these mini tutorials don't give you anything beyond what simple C does (apart from the exceptions). The full docs do not have
by andi999 6y ago
I am always interested in zig, but these mini tutorials don't give you anything beyond what simple C does (apart from the exceptions). The full docs do not have enough examples (last time I checked). I would really like something like K&R for zig.
- flohofwoe 6y agoIMHO the official documentation: https://ziglang.org/documentation/master/ https://ziglang.org/documentation/master/ And the (fairly new, and still a bit thin) std library documentation https://ziglang.org/documentation/master/std/#std https://ziglang.org/documentation/master/std/#std ...gives a good enough rundown to start writing real-world code if you're coming from another C-like programming language.
- andi999 6y agoIn my opinion it doesn't. I Shows all the features/keywords but it doesn't teach you how to use it properly. I presume you didn't study K&R?
- flohofwoe 6y agoI've read K&R Second Edition, but only after I already learned C through other means. From that PoV, K&R is an interesting look into the design rationale of C against its historic background, but since it is stuck at C89 I wouldn't recommend it today to learn the language TBH :)
- jorangreef 6y agoTo be fair, K&R (as awesome as it is) also doesn't cover things like epoll or io_uring? And then again, K&R's definitely not a half hour read. Zig's std lib documentation will keep getting better. In the meantime, the std lib code itself is so well written, it's worth a read, even coming from another language, and even if you have no intention to learn Zig. I found it easy to read and was impressed by the code structure and quality of the design. Of course, that's not to suggest that code is documentation, but I've learned alot about improving my programming in general, just by reading Zig's std lib.
- andi999 6y agoI do not want epoll and io_urig covered in the teaching material. I mean you don't learn a language by reading a dictionary is all I am trying to say.
- daurnimator 6y ago> you don't learn a language by reading a dictionary I love this quote, adding it to my quote list; is it from something?
- andi999 6y agoGlad you like it. I think I just made it up when typing the reply, since the documentation reminded me of a dictionary. But I wouldn't be surprised if this has been said before.
- banachtarski 6y agoepoll and io_uring (the latter of which did not exist when K&R was written) have nothing to do with C though
- pjmlp 6y agoK&R C also doesn't teach how to write code that is actually correct in modern C compilers, nor does it teach C best practices on how to at least try to write safe code in C.
- andi999 6y agoAgree. But it did all this at the time it was published. That's just what I would need for zig. It is OK that this doesn't exist, it just mean one person less picking up the language.
- deleted 6y ago[deleted]
- dilap 6y agoI've also found the std library code to be very clean and readable. Try taking a look at e.g. <zig>/lib/std/array_list.zig
- DixieDev 6y agoIt's hard to rationalise putting together a fully fledged guidebook when the lang is still quite unstable, with things changing very regularly. Once it hits 1.0, or possibly a short time beforehand, more people will be willing to both learn the language and/or create in-depth write-ups.
- andi999 6y agoDoes this mean zig is not ready for production?
- DixieDev 6y agoI would recommend avoiding any language in production environments until they at least hit version 1.0, unless you're able and willing to contribute by dealing with issues you encounter as you go, and fixing backward compatibility breakages as the language is updated.
- sobeston 6y agoHi, I am currently writing ziglearn.org which aims to show a lot of detailed examples.
- StreamBright 6y agoPlease include the following if you have a chance: - parsing command line arguments - logging (loglevels, files, stdout/stderr, etc.) - talking to a restful service via HTTP Thanks in advance!
- sobeston 6y agoGetting command line arguments is covered here: https://ziglearn.org/chapter-2/#iterators https://ziglearn.org/chapter-2/#iterators I don't think that going further into parsing is in scope. std.log is something that definitely needs to be covered. HTTP, I'm not sure about as it requires a lot of extra machinery outside of the standard library and these things aren't mature yet.