Нет описания

Dave Gauer cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
.gitignore 3b5678815f Initial commit with readme, script, and hello world 4 лет назад
01_hello.zig adf5ddb27d Consistent instructions and examples 4 лет назад
02_std.zig adf5ddb27d Consistent instructions and examples 4 лет назад
03_assignment.zig adf5ddb27d Consistent instructions and examples 4 лет назад
04_arrays.zig adf5ddb27d Consistent instructions and examples 4 лет назад
05_arrays2.zig adf5ddb27d Consistent instructions and examples 4 лет назад
06_strings.zig adf5ddb27d Consistent instructions and examples 4 лет назад
07_strings2.zig 30ef32e238 Added Exs. 6,7 strings 4 лет назад
08_quiz.zig b9b89737fc Added first quiz 4 лет назад
09_if.zig adf5ddb27d Consistent instructions and examples 4 лет назад
10_if2.zig adf5ddb27d Consistent instructions and examples 4 лет назад
11_while.zig adf5ddb27d Consistent instructions and examples 4 лет назад
12_while2.zig adf5ddb27d Consistent instructions and examples 4 лет назад
13_while3.zig adf5ddb27d Consistent instructions and examples 4 лет назад
14_while4.zig adf5ddb27d Consistent instructions and examples 4 лет назад
15_for.zig adf5ddb27d Consistent instructions and examples 4 лет назад
16_for2.zig adf5ddb27d Consistent instructions and examples 4 лет назад
17_quiz2.zig 8795937847 added quiz 2 4 лет назад
18_functions.zig adf5ddb27d Consistent instructions and examples 4 лет назад
19_functions2.zig adf5ddb27d Consistent instructions and examples 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 лет назад
37_structs.zig 507355ec3b Added ex. 37,38 structs 4 лет назад
38_structs2.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
39_pointers.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
40_pointers2.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
41_pointers3.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
42_pointers4.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
43_pointers5.zig cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
LICENSE d618414c9c Added Ex. 2, polished script, added LICENSE 4 лет назад
README.md cf0920de31 Added Ex. 38-43 for pointers, updated README 4 лет назад
ziglings cf0920de31 Added Ex. 38-43 for pointers, 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 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
  • Pointers
  • Multi pointers
  • Slices
  • Unions
  • Numeric types (integers, floats)
  • Labelled blocks and loops
  • Loops as expressions
  • Optionals
  • Comptime
  • Inline loops (how to DEMO this?)
  • Anonymous structs
  • Sentinel termination
  • Vectors
  • Imports
  • Allocators
  • Arraylist
  • Filesystem
  • Readers and Writers
  • Formatting
  • JSON
  • Random Numbers
  • Crypto
  • Threads
  • Hash Maps
  • Stacks
  • Sorting
  • Iterators
  • Formatting specifiers
  • Advanced Formatting
  • Suspend / Resume
  • Async / Await
  • Nosuspend
  • Async Frames, Suspend Blocks

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.