-
@ Water Blower
2023-11-25 18:06:20My first zig program
Hello, nostr!
, getting relay info fromrelay.damus.io
. Took me 2 nights LOL.```rust const std = @import("std"); const Client = @import("std").http.Client;
pub fn main() !void { var client = Client{ .allocator = std.heap.page_allocator };
const url = "https://relay.damus.io"; var option = std.http.Client.FetchOptions{ .location = std.http.Client.FetchOptions.Location{ .url = url }, }; try option.headers.append("Accept", "application/nostr+json"); const res = try client.fetch(std.heap.page_allocator, option);
const status = res.status; const body = res.body;
std.debug.print("Status code: {}\n", .{status}); std.debug.print("Status code: {?s}\n", .{body}); }
Output:
bash ➜ zig run main.zig Status code: http.Status.ok Status code: {"contact":"jb55@jb55.com","description":"Damus strfry relay","name":"damus.io ","pubkey":"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245","software":"git+https://github.com/hoytech/strfry.git","supported_nips":[1,2,4,9,11,12,16,20,22,28,33,40],"version":"0.9.6-7-g7196547"} ```Why?
If nostr a fundation for free(dom) software and society? If yes, as long as we are still running on platforms that centralized entities controls, we are not truly there.
The web, is mostly just Chrome and some Safari. It's a nice way to bootstrap our ecosystem. But, to be truly free, we need to build our very own application runtime / end user platform.
Going native/ system programming language is key.
There is Gossip, the native application written in Rust. But that's pretty much it.
We need strong system level programming / system software in nostr. Maybe not me, but we need it.