4 ms·
I've been doing Advent of Code in Zig. It's a far cry from "real world" programming, but still a decent way to get a feel for the language.
by nemo1618 7y ago
I've been doing Advent of Code in Zig. It's a far cry from "real world" programming, but still a decent way to get a feel for the language.
- wycy 7y agoDo you have a public repo of your Advent code? I started out trying to use Zig but couldn’t find documentation on how to complete even basic tasks (like passing a filename as a command line arg, then opening and reading a file line by line), so I gave up. Maybe seeing a repo of good Zig code accomplishing these tasks would get me going.
- turndown 7y agoHere[1] is a playlist of the creator of Zig coding in Zig. He also has some solutions for Advent of Code. 1. https://www.youtube.com/watch?v=hBCsWEQ_asM&list=PLviMr_WImMhHA_yCD2-VfUSB_j4qSQ8pf https://www.youtube.com/watch?v=hBCsWEQ_asM&list=PLviMr_WImM...
- wycy 7y ago> He also has some solutions for Advent of Code. I had looked at his 2018 Advent repo and was disappointed to find that he simply pasted his input directly into the code, whereas I like to compile generic binaries that can read inputs from the command line. However, it looks like his 2019 solutions for days 1 and 2 at least do read input from a file, so this year looks like it'll be a better starting point.
- crowhack 7y agoCheck out the Zig standard library and the tests for examples on doing some basic stuff with the language. Tests are generally at the end of files, you can search for "test". 0.5.0 Documentation https://ziglang.org/documentation/0.5.0/#Introduction https://ziglang.org/documentation/0.5.0/#Introduction root std library https://github.com/ziglang/zig/tree/master/lib/std https://github.com/ziglang/zig/tree/master/lib/std examples of writing and reading to a file https://github.com/ziglang/zig/blob/master/lib/std/event/fs.zig#L1307 https://github.com/ziglang/zig/blob/master/lib/std/event/fs.... There are also a ton of projects that the creator has done with Zig, you can check those out for more examples as well. https://github.com/andrewrk?utf8=%E2%9C%93&tab=repositories&q=&type=&language=zig https://github.com/andrewrk?utf8=%E2%9C%93&tab=repositories&... Looks like he has an advent of code repo too.
- nemo1618 7y agoMy solutions are here: https://github.com/lukechampine/advent https://github.com/lukechampine/advent Documentation for Zig isn't great, but it's become much easier now that the standard library is searchable: https://ziglang.org/documentation/master/std https://ziglang.org/documentation/master/std