TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Zig now has built-in HTTP server and client in std

267 pointsby huydotnetabout 2 years ago

12 comments

impulser_almost 2 years ago
I wish more programming languages provided interfaces for building libraries around the std library like what Go does. It makes using libraries a lot better because you aren&#x27;t dependent on that library as long as it uses the std library interface.<p>This is huge for things like database drivers which might become outdated or not support certain features. In Go switching database drivers in as simple as importing the new library. You dont have to change your code.<p>In rust for example you have to go out and pick a database driver and no two libraries will work the same. If you pick one postgres library and it becomes outdated you have to go rewrite you code to support the next one to move too.<p>This is why I would never use Rust, or Zig for being things like http servers.
评论 #35997293 未加载
评论 #35994960 未加载
评论 #35997825 未加载
评论 #35994886 未加载
评论 #35997858 未加载
评论 #35998625 未加载
评论 #35994802 未加载
评论 #35994993 未加载
latchalmost 2 years ago
I just tried it out and it&#x27;s very slow. Using `wrk` to hit a basic endpoint that just prints &quot;hello&quot;, I got ~500 req&#x2F;sec. Using a third party zig implementation, I got ~175000 req&#x2F;sec.<p>It&#x27;s also both cumbersome to setup and use.<p>Before learning Zig, I used to think Zig needed an http server in the standard library. After using it for a few months, and watching this implementation get added, I think it&#x27;s a mistake - there just isn&#x27;t enough bandwidth to support a _quality_ kitchen-sink included stdlib.
评论 #35996486 未加载
评论 #35996566 未加载
评论 #35996676 未加载
nusarualmost 2 years ago
Relevant autodocs:<p>Server: <a href="https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#A;std:http.Server" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#A;std:http.Ser...</a><p>Client: <a href="https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#A;std:http.Client" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#A;std:http.Cli...</a>
shirroalmost 2 years ago
I wish Zig had Go-like interfaces. I understand why they don&#x27;t as they have decided control flow must be explicit but having to include a heap of boilerplate to get the same result isn&#x27;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.
评论 #35996317 未加载
评论 #35996919 未加载
评论 #35996279 未加载
评论 #36070272 未加载
jchwalmost 2 years ago
Very nice!<p>I couldn&#x27;t grok from this test suite alone, but I do have questions.<p>1. Do either the server or client support &#x27;full duplex&#x27;, i.e. streaming the response body while streaming the request body in parallel?<p>2. Are there provisions for HTTP&#x2F;2?<p>I&#x27;ll answer my own questions if I find the answers first, but I&#x27;m not very good at Zig.
评论 #35993507 未加载
评论 #35993452 未加载
评论 #35993451 未加载
WhereIsTheTruthalmost 2 years ago
Zig starting to look nice, but compile speed is painfully slow..<p>Everyone wants to go after Go, but they fail to understand how important compile speed is
评论 #35997185 未加载
评论 #35995334 未加载
评论 #35995986 未加载
tills13almost 2 years ago
why does _literally_ every line start with &quot;try&quot;?
评论 #35993463 未加载
评论 #35993461 未加载
评论 #35993469 未加载
评论 #35994823 未加载
评论 #35993813 未加载
评论 #35993443 未加载
评论 #35993625 未加载
评论 #35993447 未加载
评论 #35997817 未加载
bricssalmost 2 years ago
It can even parse JSON out-of-the-box! \m&#x2F;
评论 #35993848 未加载
stephc_int13almost 2 years ago
I tend to think that standard libraries should be minimal enough to contain mostly code that is reasonably trusted to be near optimal.<p>I don’t think that can be the case here.<p>This should be released as reference implementation, an example, provided for convenience and education, probably not production ready…
评论 #35996478 未加载
VWWHFSfQalmost 2 years ago
Is there a Rust vs Zig war going on? I just started to learn Rust because I figured that it was going to be the C++ successor and I want to be sure that my skills are (somewhat) future-proof. So what&#x27;s going on with Zig? Should I learn Zig?
评论 #35994738 未加载
评论 #35995261 未加载
评论 #35994398 未加载
评论 #35996287 未加载
评论 #35994374 未加载
评论 #35995951 未加载
评论 #35994392 未加载
评论 #35994379 未加载
评论 #35994571 未加载
评论 #35994880 未加载
评论 #35994836 未加载
评论 #35994540 未加载
badrabbitalmost 2 years ago
Nim has been unpleasant trying to get https client working with a staric build because it needs openssl. Does this support native TLS and static linking?
naikrovekalmost 2 years ago
yesss, been waiting for this, though I&#x27;ve waited long enough that I forgot why I wanted it.<p>it hasn&#x27;t been that long, I&#x27;m just an airhead.