first pckt post!
i have been writing a lot of atproto things in zig!
and so, i have started working on a zig SDK for atproto so that i don't need to reimplement DID parsing or handle resolution over and over again (which is not a bad thing to have to do at first, as it helps remind me how the protocol works and also ziglang, which is relatively new to me)
here's the (wip) SDK:
the thing most interesting about zig in my opinion is comptime
for example, this base58 decode table is computed at compile time and baked directly into the binary - no runtime initialization, no lazy statics, etc:
// base58 decode table - computed at compile time, embedded in binary
// no runtime initialization, no lazy statics, just data
const decode_table: [256]i8 = blk: {
const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
var table: [256]i8 = .{-1} ** 256; // -1 = invalid character
for (alphabet, 0..) |c, i| {
table[c] = @intCast(i);
}
break :blk table;
};
// at runtime, decoding is just a lookup: table['Z'] -> 32naively, it seems like comptime is a good fit when dealing with (parts of) a protocol like atproto where there's a lot of static structure - defined once, used everywhere
we'll see how my use progresses!