Show HN: Tokamak – Server-side framework for Zig

  • As a Zig developer with one of the more popular HTTP server libraries around (http.zig), this is impressive and good use of comptime and (good) abuse of Zig's anytype. I'm looking forward to learning from the codebase.

    But, it's very slow. A quick test shows Sinatra is about 2x faster. Maybe I'm in the minority, but I feel that a primary reason to give up a GC is for performance.

  • Putting the HTTP method and path directly in the function's name using Zig @-syntax is something I've never seen before. Clever.

  • the name tokamak - funny choice! Will barely achieve fusion with an huge and complex implementation. Surely not the intended implicature.

  • I'm not a Zig programmer, but this framework seems pretty nice! Honestly, a lot nicer than I would've expected from a language that explicitly targets lower-level dev[1].

    [1]: Rust also has a focus on low-level programming, but has many higher level constructs / a more complicated type system so I'm not too surprised when I see nice web frameworks in that ecosystem

  • I love the use of `@hasDecl(root, "mime_types")`. I didn't realize that `@import("root")` was a thing.

    https://github.com/cztomsik/tokamak/blob/main/src/mime.zig

  • Interesting. What mechanism does Zig use to hook up function argument dynamically depending on what is declared in the function (or am I reading that wrong)? Not sure I've ever seen something quite like it.

  • Looks great! Also TIL about AVA https://github.com/cztomsik/ava

  • Any relation to https://github.com/TokamakUI/Tokamak?