Нет описания

Dave Gauer 2cded107cd Add ex 35,36 enums; updated README 4 лет назад
.gitignore 3b5678815f Initial commit with readme, script, and hello world 4 лет назад
01_hello.zig d618414c9c Added Ex. 2, polished script, added LICENSE 4 лет назад
02_std.zig d618414c9c Added Ex. 2, polished script, added LICENSE 4 лет назад
03_assignment.zig b9b89737fc Added first quiz 4 лет назад
04_arrays.zig b9b89737fc Added first quiz 4 лет назад
05_arrays2.zig faa49abb06 Added Ex. 5, array ops 4 лет назад
06_strings.zig 30ef32e238 Added Exs. 6,7 strings 4 лет назад
07_strings2.zig 30ef32e238 Added Exs. 6,7 strings 4 лет назад
08_quiz.zig b9b89737fc Added first quiz 4 лет назад
09_if.zig 0bb89e3e41 Added Ex 9,10 for If 4 лет назад
10_if2.zig 0bb89e3e41 Added Ex 9,10 for If 4 лет назад
11_while.zig 483fb97dfc Added Ex 11-14: while loops 4 лет назад
12_while2.zig 483fb97dfc Added Ex 11-14: while loops 4 лет назад
13_while3.zig 8795937847 added quiz 2 4 лет назад
14_while4.zig 483fb97dfc Added Ex 11-14: while loops 4 лет назад
15_for.zig 2bda44bc58 Added ex 15,16 for loops 4 лет назад
16_for2.zig 7e123933b9 Ex 16 oops, forgot to unfix it. :-) 4 лет назад
17_quiz2.zig 8795937847 added quiz 2 4 лет назад
18_functions.zig 08ec029f20 Added ex 19,20 functions and pop quiz 4 лет назад
19_functions2.zig 08ec029f20 Added ex 19,20 functions and pop quiz 4 лет назад
20_quiz3.zig 08ec029f20 Added ex 19,20 functions and pop quiz 4 лет назад
21_errors.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
22_errors2.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
23_errors3.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
24_errors4.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
25_errors5.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
26_hello2.zig 2de8a8c54d Added ex 21-26 for error handling 4 лет назад
27_defer.zig c70fa5f58f Adding exs 27-32 4 лет назад
28_defer2.zig c70fa5f58f Adding exs 27-32 4 лет назад
29_errdefer.zig c70fa5f58f Adding exs 27-32 4 лет назад
30_switch.zig c70fa5f58f Adding exs 27-32 4 лет назад
31_switch2.zig c70fa5f58f Adding exs 27-32 4 лет назад
32_unreachable.zig 738a9f6cda Inserted ex. 32 unreachable, added quiz4. 4 лет назад
33_iferror.zig 738a9f6cda Inserted ex. 32 unreachable, added quiz4. 4 лет назад
34_quiz4.zig 738a9f6cda Inserted ex. 32 unreachable, added quiz4. 4 лет назад
35_enums.zig 2cded107cd Add ex 35,36 enums; updated README 4 лет назад
36_enums2.zig 2cded107cd Add ex 35,36 enums; updated README 4 лет назад
LICENSE d618414c9c Added Ex. 2, polished script, added LICENSE 4 лет назад
README.md 2cded107cd Add ex 35,36 enums; updated README 4 лет назад
ziglings 2cded107cd Add ex 35,36 enums; updated README 4 лет назад

README.md

ziglings

Welcome to ziglings. This project contains a series of incomplete exercises. By completing the exercises, you learn how to read and write Zig code.

This project was directly inspired by the brilliant and fun rustlings project for the Rust language.

Intended Audience

This will probably be quite difficult if you've never programmed before. However, no specific programming experience is required. And in particular, you are not expected to know C or other "systems programming" language.

Each exercise is self-contained and self-explained. However, you're encouraged to also check out these Zig language resources for more detail:

Getting Started

Note: This currently uses a shell (Bash) script to automate the "game". A future update may remove this requirement. See TODO below.

Install the master release of the Zig compiler.

Verify the installation and version of zig like so:

$ zig version
0.7.1+<some hexadecimal string>

Clone this repository with Git:

git clone https://github.com/ratfactor/ziglings
cd ziglings

Then run the ziglings script and follow the instructions to begin!

./ziglings

Manual Usage

If you can't (or don't want to) use the script, you can manually verify each exercise with the Zig compiler:

zig run 01_hello.zig

TODO

Contributions are very welcome! I'm writing this to teach myself and to create the learning resource I wished for. There will be tons of room for improvement:

  • Wording of explanations
  • Idiomatic usage of Zig
  • Additional exercises
  • Re-write the ziglings script using the Zig build system (or just a Zig application)

Planned exercises:

  • Hello world (main needs to be public)
  • Importing standard library
  • Assignment
  • Arrays
  • Strings
  • If
  • While
  • For
  • Functions
  • Errors (error/try/catch/if-else-err)
  • Defer (and errdefer)
  • Switch
  • Unreachable
  • Enums
  • Structs
  • Unions
  • Pointers
  • Pointer sized integers
  • Multi pointers
  • Slices
  • Integer rules
  • Floats
  • Labelled blocks
  • Labelled loops
  • Loops as expressions
  • Optionals
  • Comptime
  • Inline loops
  • Anonymous structs
  • Sentinel termination
  • Vectors
  • Imports

The initial topics for these exercises were unabashedly cribbed from ziglearn.org. I've since moved things around in an order that I think best lets each topic build upon each other.