๐Ÿ’พ Archived View for bbs.geminispace.org โ€บ u โ€บ drh3xx โ€บ 1441 captured on 2023-11-04 at 16:26:08. Gemini links have been rewritten to link to archived content

View Raw

More Information

โฌ…๏ธ Previous capture (2023-09-28)

โžก๏ธ Next capture (2023-11-14)

๐Ÿšง View Differences

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

Comment by ๐Ÿ drh3xx

Re: "Zig and Vlang?"

In: s/OpenBSD

@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.

๐Ÿ drh3xx

2023-06-02 ยท 5 months ago

7 Later Comments โ†“

๐Ÿฆ€ jeang3nie

@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

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

@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.

2023-06-03 ยท 5 months ago

๐Ÿฆ€ jeang3nie

@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

@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

@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

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

Original Post

๐ŸŒ’ s/OpenBSD

Zig and Vlang?

๐Ÿ’ฌ drh3xx ยท 11 comments ยท 1 like ยท 2023-06-02 ยท 5 months ago