Live data from Hacker News

How I turned Zig into my favorite language to write network programs in

lalinsky.com

11–20 of 150 posts

Re: How I turned Zig into my favorite language to write network programs in

#12

Isn't this a bad time to be embracing Zig? It's currently going through an intrusive upheaval of its I/O model. My impression is that it was going to take a few years for things to shake out. Is that wrong?

IMO, it's very wrong. Zig's language is not drastically changing, it's adding a new, *very* powerful API, which similar to how most everything in zig passes an allocator as a function param, soon functions that want to do IO, will accept an object that will provide the desired abstraction, so that callers can define the ideal implementation. In other words, the only reason to not use zig if you detest upgrading or im…

This isn't quite accurate. If you look at the new IO branch[1] you'll see (for example) most of the std.fs functions are gone, and most of what's left is deprecated. The plan is for all file/network access, mutexes, etc to be accessible only through the Io interface. It'll be a big migration once 0.16 drops.

[1]: https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs.z...

> Do I have to refactor? No, the old API works flawlessly

The old API was deleted though? If you're saying it's possible to copy/paste the old stdlib into your project and maintain the old abstractions forward through the ongoing language changes, sure that's possible, but I don't think many people will want to fork std. I copy/pasted some stuff temporarily to make the 0.15 migration easier, but maintaining it forever would be swimming upstream for no reason.

Re: How I turned Zig into my favorite language to write network programs in

#13

Earlier quoted context omitted.

IMO, it's very wrong. Zig's language is not drastically changing, it's adding a new, *very* powerful API, which similar to how most everything in zig passes an allocator as a function param, soon functions that want to do IO, will accept an object that will provide the desired abstraction, so that callers can define the ideal implementation. In other words, the only reason to not use zig if you detest upgrading or im…

This isn't quite accurate. If you look at the new IO branch[1] you'll see (for example) most of the std.fs functions are gone, and most of what's left is deprecated. The plan is for all file/network access, mutexes, etc to be accessible only through the Io interface. It'll be a big migration once 0.16 drops. [1]: https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs.z... > Do I have to refactor? No, the old API…

> most of the std.fs functions are gone, and most of what's left is deprecated.

uhhh.... huh? you and I must be using very different definitions for the word most.

> The old API was deleted though?

To be completely fair, you're correct, the old deprecated writer that was available in 0.15 has been removed https://ziglang.org/documentation/0.15.2/std/#std.Io.Depreca... contrasted with the master branch which doesn't provide this anymore.

edit: lmao, your profile about text is hilarious, I appreciate the laugh!

Re: How I turned Zig into my favorite language to write network programs in

#14

Isn't this a bad time to be embracing Zig? It's currently going through an intrusive upheaval of its I/O model. My impression is that it was going to take a few years for things to shake out. Is that wrong?

What's a few years? They go by in the blink of an eye. Zig is a perfectly usable language. People who want to use it will, those who don't won't.

only for hobby project

Re: How I turned Zig into my favorite language to write network programs in

#15

Earlier quoted context omitted.

This isn't quite accurate. If you look at the new IO branch[1] you'll see (for example) most of the std.fs functions are gone, and most of what's left is deprecated. The plan is for all file/network access, mutexes, etc to be accessible only through the Io interface. It'll be a big migration once 0.16 drops. [1]: https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs.z... > Do I have to refactor? No, the old API…

> most of the std.fs functions are gone, and most of what's left is deprecated. uhhh.... huh? you and I must be using very different definitions for the word most. > The old API was deleted though? To be completely fair, you're correct, the old deprecated writer that was available in 0.15 has been removed https://ziglang.org/documentation/0.15.2/std/#std.Io.Depreca... contrasted with the master branch which doesn't p…

Even the basic stuff like `openFile` is deprecated. I don't know what else to tell you. Zig won't maintain two slightly different versions of the fs functions in parallel. Once something is deprecated, that means it's going away. https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs/D...

Re: How I turned Zig into my favorite language to write network programs in

#16

Earlier quoted context omitted.

What's a few years? They go by in the blink of an eye. Zig is a perfectly usable language. People who want to use it will, those who don't won't.

only for hobby project

You or in general? Because, you know, this is like, your opinion, man.

Re: How I turned Zig into my favorite language to write network programs in

#17

Earlier quoted context omitted.

> most of the std.fs functions are gone, and most of what's left is deprecated. uhhh.... huh? you and I must be using very different definitions for the word most. > The old API was deleted though? To be completely fair, you're correct, the old deprecated writer that was available in 0.15 has been removed https://ziglang.org/documentation/0.15.2/std/#std.Io.Depreca... contrasted with the master branch which doesn't p…

Even the basic stuff like `openFile` is deprecated. I don't know what else to tell you. Zig won't maintain two slightly different versions of the fs functions in parallel. Once something is deprecated, that means it's going away. https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs/D...

Oh, I guess that's a fair point. I didn't consider the change from `std.fs.openFile` to `std.Io.Dir.openFile` to be meaningful, but I guess that is problematic for some reason?

You're of course correct here; but I thought it was reasonable to omit changes that I would describe as namespace changes. Now considering the audience I regret doing so. (it now does require nhe Io object as well, so namespace is inarticulate here)

Re: How I turned Zig into my favorite language to write network programs in

#18

Earlier quoted context omitted.

What's a few years? They go by in the blink of an eye. Zig is a perfectly usable language. People who want to use it will, those who don't won't.

only for hobby project

TigerBeetle, Bun, and Ghostty all beg to differ...

Re: How I turned Zig into my favorite language to write network programs in

#19

Earlier quoted context omitted.

Even the basic stuff like `openFile` is deprecated. I don't know what else to tell you. Zig won't maintain two slightly different versions of the fs functions in parallel. Once something is deprecated, that means it's going away. https://github.com/ziglang/zig/blob/init-std.Io/lib/std/fs/D...

Oh, I guess that's a fair point. I didn't consider the change from `std.fs.openFile` to `std.Io.Dir.openFile` to be meaningful, but I guess that is problematic for some reason? You're of course correct here; but I thought it was reasonable to omit changes that I would describe as namespace changes. Now considering the audience I regret doing so. (it now does require nhe Io object as well, so namespace is inarticulate…

That is literally a breaking change, so your old code will by definition not work flawlessly. Maybe the migration overhead is low, but it’s not zero like your comment implies

Re: How I turned Zig into my favorite language to write network programs in

#20
I really need to play with Zig. I got really into Rust a few months ago, and I was actually extremely impressed by Tokio, so if this library also gives me Go-style concurrency without having to rely on a garbage collector, then I am likely to enjoy it.
Post reply on HN