zigstr
adventofcode-2021
zigstr | adventofcode-2021 | |
---|---|---|
3 | 1 | |
108 | 5 | |
- | - | |
6.7 | 0.0 | |
7 months ago | over 2 years ago | |
Zig | Zig | |
MIT License | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
zigstr
- A Review of the Zig Programming Language (Using Advent of Code 2021)
-
Resizable string in Zig?
For Unicode text processing you can take a look at Ziglyph https://github.com/jecolon/ziglyph and for a sample UTF-8 string structure, Zigstr https://github.com/jecolon/zigstr . (bias alert: I'm the author of both. :^D )
- Maintain It with Zig
adventofcode-2021
-
A Review of the Zig Programming Language (Using Advent of Code 2021)
I also did AoC 2021 in Zig: https://github.com/avorobey/adventofcode-2021
One thing the OP didn't mention that I really liked was runtime checks on array/slice access and integer under/overflow. Because dealing with heap allocation is a bit of a hassle, I was incentivized to use static buffers a lot. I quickly figured out that I didn't have to worry about their sizes much, because if they're overrun by the unexpectedly large input or other behavior in my algorithms, I get a nice runtime error with the right line indicated, rather than corrupt memory or a crash. Same thing about choosing which integer type to use: it's not a problem if I made the wrong choice, I'll get a nice error message and fix easily. This made for a lot of peace of mind during coding. Obviously in a real production system I'd be more careful and use dynamic sizes appropriately, but for one-off programs like these it was excellent.
Overall, I really enjoyed using Zig while starting out at AoC problem 1 with zero knowledge of the language. To my mind, it's "C with as much convenience as could be wrung out of it w/o betraying the low-level core behavior". That is, no code execution hidden behind constructors or overloads, no garbage collection, straight imperative code, but with so much done right (type system, generics, errors, optionals, slices) that it feels much more pleasant and uncomparably safer than C.
(you can still get a segmentation fault, and I did a few times - by erroneously holding on to pointers inside a container while it resized. Still, uncomparably safer)
What are some alternatives?
mach - zig game engine & graphics toolkit
ziglyph - Unicode text processing for the Zig programming language.
RIIR - why not Rewrite It In Rust
utfcpp - UTF-8 with C++ in a Portable Way
arocc - A C compiler written in Zig.
wtfiles - Files that make you go WTF!
ohmygentool - LLVM/Clang based bindings generator for D language
dstep - A tool for converting C and Objective-C headers to D modules
cc-rs - Rust library for build scripts to compile C/C++ code into a Rust library
crystal - The Crystal Programming Language
Nim - Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).