News for hackers. Stuff that matters.
Re:Zig now has built-in HTTP server and client in std by shirro on Thursday May 18, 2023 @08:16PM (#35996167)
I wish Zig had Go-like interfaces. I understand why they don't as they have decided control flow must be explicit but having to include a heap of boilerplate to get the same result isn't a win for readability or maintenance. Given my limitations and tastes I would not want to write or maintain web backend code in Zig but there is a lot to like about Zig as a C replacement and having batteries included for things like HTTP is a win for any language.
Re:Zig now has built-in HTTP server and client in std by dvt on Thursday May 18, 2023 @08:33PM (#35996317)
> having batteries included for things like HTTP is a win for any language

I actually kind of disagree with this.

I was a super early Go contributor and helped a tiny bit on the HTTP library (back then it was the core `http` package, now it's under `net/http`). Imo, a lot of HTTP stuff tends to be very "grey area" (what are sensible timeouts? how do you handle different socket errors? should we allow self-signed certificates?) so a lot of opinionated design debate ends up happening, and there's also a lot of scope creep, including having to include things like SSL/proxying if you really want "batteries" to be included which is a lot of non-trivial work (all of a sudden, you also need a elliptic curve cryptography lib, too) that basically has nothing to do with the language itself.

I know we live in an "HTTP world" and it's a lot easier to sell a language that can also do stuff on the web, but it would be pretty far down my list.

Re:Zig now has built-in HTTP server and client in std by jonahx on Thursday May 18, 2023 @08:27PM (#35996279)
> I wish Zig had Go-like interfaces. I understand why they don't as they have decided control flow must be explicit

How do Go-like interfaces make control flow non-explicit?

Re:Zig now has built-in HTTP server and client in std by philosopher1234 on Friday May 19, 2023 @02:04AM (#35998335)
probably referring to the dynamic dispatch
Re:Zig now has built-in HTTP server and client in std by candrewlee14 on Thursday May 18, 2023 @10:04PM (#35996919)
Agreed about Go-like interfaces. I don’t think it’d fit Zig to make them dynamic at runtime the way Go does, but even just as a compile-time constraint it would make building a composable ecosystem like Go’s much easier. See writer: anytype.
Re:Zig now has built-in HTTP server and client in std by Tozen on Thursday May 25, 2023 @09:09AM (#36070272)
There have been many arguments that Zig's Try/Catch is hidden control flow. Though many would argue that trying to stick to "catch phrases", can result in painting one's self into a corner, versus what's best to accomplish a task.

Lots of people love interfaces (or similar like "traits"). Helps them get what they need done and there are lots of examples of their usage in different languages. Accomplishing the task, is what's most important.