Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SuperAuguste/zig-patterns
Common Zig patterns for you and your friends :)
https://github.com/SuperAuguste/zig-patterns
learning zig ziglang
Last synced: 3 months ago
JSON representation
Common Zig patterns for you and your friends :)
- Host: GitHub
- URL: https://github.com/SuperAuguste/zig-patterns
- Owner: SuperAuguste
- License: mit
- Created: 2023-12-06T21:22:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-04-15T12:25:29.000Z (7 months ago)
- Last Synced: 2024-06-11T05:31:53.881Z (5 months ago)
- Topics: learning, zig, ziglang
- Language: Zig
- Homepage:
- Size: 36.1 KB
- Stars: 135
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zig Patterns
- [Zig Patterns](#zig-patterns)
- [About](#about)
- [The Patterns](#the-patterns)
- [License](#license)## About
This repository contains examples of common patterns found in Zig's standard library and many community projects.
Note that copying (one of) these patterns verbatim into your project may not be useful; it's important to weigh the pros and cons of different patterns. If you come from another language, especially a non-systems one, you'll often find that the more unfamiliar ideas featured here may be more useful.
For example, I've seldom used interface-like patterns when designing systems in Zig, despite using such patterns dozens of times a day at my old job writing TypeScript or Go.
## The Patterns
All examples are annotated with comments including recommendations regarding when to use the patterns shown.
Example tests can be run with `zig build [name_of_pattern]`. For example, to run the tests in `typing/type_function.zig`, run `zig build type_function`.
Patterns are grouped into the following categories:
- `data` - data layout and organization techniques
- `typing` - `comptime`, runtime, or mixed `type` or type safety techniquesSome patterns may belong in multiple categories; I've selected the most fitting one in my opinion.
## License
MIT