💾 Archived View for bbs.geminispace.org › u › jeang3nie › 1429 captured on 2023-11-14 at 09:12:20. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-11-04)

➡️ Next capture (2023-12-28)

🚧 View Differences

-=-=-=-=-=-=-

Comment by 🦀 jeang3nie

Re: "Zig and Vlang?"

In: s/OpenBSD

I've done a fair bit with Zig and it's wonderful. The only problem right now is that BSD support is still kind of minimal. I have had decent luck with it on FreeBSD, but last I checked in the guys trying to get it working on OpenBSD were still running into a lot of issues. Having looked a lot at the standard library there were definitely a lot of places where you would need platform-specific code which wasn't written for OpenBSD yet (or NetBSD for that matter).

Things may have changed in the months since I was using it regularly, but if you want to try I would still expect to have to get your hands dirty.

🦀 jeang3nie

Jun 02 · 5 months ago

9 Later Comments ↓

🐐 drh3xx · Jun 02 at 17:55:

@jeang3nie it might be worth me checking out. IIf nothing else the need to dig into the zig src and deep dive openbsd I could learn alot about both.

🐐 drh3xx · Jun 02 at 18:01:

@sirwilburthefirst I can read c fairly well I've just not got much experience writing anything substantial in it. I'm one of those that's language hopped and not really commited to one. I quite like go but hate Google. Love Mozilla but Rust source just looks a mess.

🦀 jeang3nie · Jun 02 at 20:29:

@drh3xx even as someone who uses Rust regularly I agree the source can look like a real mess, particularly when you get a bit more advanced and start playing around with traits, generics and lifetimes.

I had my own Zig branch for a little while where I was implementing some wrapper functions for FreeBSD system calls that don't exist on Linux. It really was a nice learning experience. The problem is I let it get too far out of sync with upstream and merging would have been a pain. But I think the language and community are awesome. The creator, Andrew K, is a really nice and welcoming guy too.

🦀 jeang3nie · Jun 02 at 20:41:

Just my 2c on V, before I forget. V makes a lot of promises but hasn't exactly delivered so far from what I've seen. I like V's syntax and stated goals, but have a hard time believing it's going to get to where it plans to go. It also requires a big runtime, which I'm not a fan of. In contrast, you can easily compile pretty tiny static executables with Zig, just like you would with C. I'd skip V unless you just have to satisfy some curiosity.

🐐 drh3xx · Jun 03 at 10:25:

@jeang3nie the main draws of vlang for me are: 1. immutabilty by default, 2. heavily inspired by go, 3. work on a standard ui module and 4. unlike zig it has a pkg system much like go, rust etc... zig definnately has more momentum though and has the advantage of multi os/arch targets out of the box with great c integration (even targeting several libc implementations) without resorting to something like ffi or cgo.

🦀 jeang3nie · Jun 03 at 12:45:

@drh3xx I can see the appeal of an included ui module, since that is something lacking in a lot of newer languages. As for immutability by default:

var x = 5; // mutable
const y = 42 // immutable

That's pretty easy to work with to me. Coming from Rust before I started working with Zig I was so used to keeping things immutable wherever possible that I got in the habit of using `const` until I ran into a spot where it wasn't possible. It's nice that Zig allows to do things like this (which is very Rust-like):

const res = if (x == y) "yak" else "buffalo";

This type of pattern can work even with blocks or loops, and includes features like breaking out of an outer loop from an inner loop using labelled blocks. All of it leads to 99% of the time being able to use const instead of var.

One thing Zig took from Go is `defer`, which makes cleanup code nice and easy.

const w = "world";
const hello = fmt.allocPrintZ(allocator, "Hello, {s}!", .{w}) catch return;
defer allocator.deinit(hello);

I think Zig borrowed from a lot of places ranging from C++ to Go to Rust. It even influenced a few recent Rust features (Rust got labelled blocks a few releases back). Anyway, I'm pretty sure that even without saying it explicitly most of these newer languages have cross pollinated with each other a lot.

In the end it's really just bytes though, so if you like the way V lets you work with them that's totally fine.

🐐 drh3xx · Jun 03 at 16:42:

@jeang3nie yeah I can use const; the (admittedly only potential) problems are when you forget to use const and then either yourself or a contributor change a var/pointer/etc... which should never have been changable. Imutability by default is just another nice safety net but not essential. The fact Zig has a nice built in test framework is a big plus for it. Defer is definately a nice addition to any language. I think I'm leaning more toward Zig even though it's going to need work on OpenBSD; I did spot the Capy UI toolkit which needs some work too but seems usable for basic GUI cross platform even now.

🦀 jeang3nie · Jun 03 at 16:53:

@drh3xx capy is using gtk3 under the hood, but doesn't provide anywhere near the functionality of using gtk directly. I had hand written bindings to gtk3 and vte that were being used in Zterm, but I always knew that was a dead end. The best gtk path in Zig right now is zig-gobject. It's doing what I really should have done and using gobject-introspection to machine generate the zig bindings.

— https://github.com/ianprime0509/zig-gobject

🐐 drh3xx · Jun 03 at 17:04:

@jeang3nie thanks for the link I'll check it out later.

Original Post

🌒 s/OpenBSD

Zig and Vlang?

💬 drh3xx · 11 comments · 1 like · Jun 02 · 5 months ago