-- Leo's gemini proxy

-- Connecting to bbs.geminispace.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8

Comment by 🦀 jeang3nie


Re: "Zig and Vlang?"

In: s/OpenBSD


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.


🦀 jeang3nie

2023-06-02 · 1 year ago


5 Later Comments ↓


🐐 drh3xx [OP/mod] · 2023-06-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 · 2023-06-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 [OP/mod] · 2023-06-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 · 2023-06-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 [OP/mod] · 2023-06-03 at 17:04:

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


Original Post


🌒 s/OpenBSD

Zig and Vlang?

💬 drh3xx [mod] · 11 comments · 1 like · 2023-06-02 · 1 year ago

-- Response ended

-- Page fetched on Sun Jun 2 15:36:15 2024