My progress learning Zig via the ziglings 😊
Go to file
Dave Gauer adf5ddb27d Consistent instructions and examples
I started off with "hints" that required the poor student to piece
together the information from incomplete bits. A complete example is
like a picture that is worth 1000 words and far clearer.
2021-02-07 11:06:51 -05:00
.gitignore Initial commit with readme, script, and hello world 2020-12-23 13:53:27 -05:00
01_hello.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
02_std.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
03_assignment.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
04_arrays.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
05_arrays2.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
06_strings.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
07_strings2.zig Added Exs. 6,7 strings 2021-01-05 19:26:02 -05:00
08_quiz.zig Added first quiz 2021-01-06 17:41:53 -05:00
09_if.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
10_if2.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
11_while.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
12_while2.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
13_while3.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
14_while4.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
15_for.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
16_for2.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
17_quiz2.zig added quiz 2 2021-01-18 20:18:49 -05:00
18_functions.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
19_functions2.zig Consistent instructions and examples 2021-02-07 11:06:51 -05:00
20_quiz3.zig Added ex 19,20 functions and pop quiz 2021-01-22 17:42:03 -05:00
21_errors.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
22_errors2.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
23_errors3.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
24_errors4.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
25_errors5.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
26_hello2.zig Added ex 21-26 for error handling 2021-01-30 20:00:32 -05:00
27_defer.zig Adding exs 27-32 2021-01-31 17:48:34 -05:00
28_defer2.zig Adding exs 27-32 2021-01-31 17:48:34 -05:00
29_errdefer.zig Adding exs 27-32 2021-01-31 17:48:34 -05:00
30_switch.zig Adding exs 27-32 2021-01-31 17:48:34 -05:00
31_switch2.zig Adding exs 27-32 2021-01-31 17:48:34 -05:00
32_unreachable.zig Inserted ex. 32 unreachable, added quiz4. 2021-02-03 19:19:31 -05:00
33_iferror.zig Inserted ex. 32 unreachable, added quiz4. 2021-02-03 19:19:31 -05:00
34_quiz4.zig Inserted ex. 32 unreachable, added quiz4. 2021-02-03 19:19:31 -05:00
35_enums.zig Add ex 35,36 enums; updated README 2021-02-06 09:29:49 -05:00
36_enums2.zig Add ex 35,36 enums; updated README 2021-02-06 09:29:49 -05:00
37_structs.zig Added ex. 37,38 structs 2021-02-06 15:54:56 -05:00
38_structs2.zig Added ex. 37,38 structs 2021-02-06 15:54:56 -05:00
LICENSE Added Ex. 2, polished script, added LICENSE 2021-01-03 12:21:11 -05:00
README.md Added ex. 37,38 structs 2021-02-06 15:54:56 -05:00
ziglings Added ex. 37,38 structs 2021-02-06 15:54:56 -05:00

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 difficult if you've never programmed before. But no specific programming experience is required. And in particular, you are not expected to have any prior experience with "systems programming" or a "systems" level language such as C.

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.