You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Dave Gauer 507355ec3b Added ex. 37,38 structs 4 years ago
.gitignore Initial commit with readme, script, and hello world 4 years ago
01_hello.zig Added Ex. 2, polished script, added LICENSE 4 years ago
02_std.zig Added Ex. 2, polished script, added LICENSE 4 years ago
03_assignment.zig Added first quiz 4 years ago
04_arrays.zig Added first quiz 4 years ago
05_arrays2.zig Added Ex. 5, array ops 4 years ago
06_strings.zig Added Exs. 6,7 strings 4 years ago
07_strings2.zig Added Exs. 6,7 strings 4 years ago
08_quiz.zig Added first quiz 4 years ago
09_if.zig Added Ex 9,10 for If 4 years ago
10_if2.zig Added Ex 9,10 for If 4 years ago
11_while.zig Added Ex 11-14: while loops 4 years ago
12_while2.zig Added Ex 11-14: while loops 4 years ago
13_while3.zig added quiz 2 4 years ago
14_while4.zig Added Ex 11-14: while loops 4 years ago
15_for.zig Added ex 15,16 for loops 4 years ago
16_for2.zig Ex 16 oops, forgot to unfix it. :-) 4 years ago
17_quiz2.zig added quiz 2 4 years ago
18_functions.zig Added ex 19,20 functions and pop quiz 4 years ago
19_functions2.zig Added ex 19,20 functions and pop quiz 4 years ago
20_quiz3.zig Added ex 19,20 functions and pop quiz 4 years ago
21_errors.zig Added ex 21-26 for error handling 4 years ago
22_errors2.zig Added ex 21-26 for error handling 4 years ago
23_errors3.zig Added ex 21-26 for error handling 4 years ago
24_errors4.zig Added ex 21-26 for error handling 4 years ago
25_errors5.zig Added ex 21-26 for error handling 4 years ago
26_hello2.zig Added ex 21-26 for error handling 4 years ago
27_defer.zig Adding exs 27-32 4 years ago
28_defer2.zig Adding exs 27-32 4 years ago
29_errdefer.zig Adding exs 27-32 4 years ago
30_switch.zig Adding exs 27-32 4 years ago
31_switch2.zig Adding exs 27-32 4 years ago
32_unreachable.zig Inserted ex. 32 unreachable, added quiz4. 4 years ago
33_iferror.zig Inserted ex. 32 unreachable, added quiz4. 4 years ago
34_quiz4.zig Inserted ex. 32 unreachable, added quiz4. 4 years ago
35_enums.zig Add ex 35,36 enums; updated README 4 years ago
36_enums2.zig Add ex 35,36 enums; updated README 4 years ago
37_structs.zig Added ex. 37,38 structs 4 years ago
38_structs2.zig Added ex. 37,38 structs 4 years ago
LICENSE Added Ex. 2, polished script, added LICENSE 4 years ago
README.md Added ex. 37,38 structs 4 years ago
ziglings Added ex. 37,38 structs 4 years ago

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 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.