Better HN
topnewbestaskshowjobs
Log inSign up

atmikemikeb

9 karma · joined Jun 6, 2024 (2y ago) · 9 submissions

https://mikemikeb.com
Submissions

comment 5mo ago · link · parent

I think DVUI [1] is zig's most mature UI framework, and I have been enjoying using it for a while.

Fizzy is just one project that's pushing zig's desktop app dev story. They recently integrated another open source project velopack [2] and while that part isn't in zig (everything else is), this project has almost everything I'd want from a non-toy electron application. Autoupdating, cross-platform, native macOS context and topbar menus, etc.

1: https://github.com/david-vanderson/dvui

2: https://github.com/velopack/velopack

2.

fizzy: desktop app built in zig (DVUI)(fizzyed.it ↗)

6 points · by atmikemikeb · 5mo ago · 1 comment

comment 5mo ago · link · parent

DVUI is I think the most mature zig gui project, and a very good immediate-mode approach imo. Here's a recently released open source project built on DVUI in zig: https://fizzyed.it/

comment 1y ago · link · parent

what about extern functions?

comment 1y ago · link · parent

Yeah I think mine is more about being able to provide a `host()` helper function instead of a `.get(.host)` meta function. It is somewhat boilerplate-y. I think it's really a matter of taste haha. Likely yours would be useful regardless if this is done a lot, since it abstracts some of it, if one wants that.

comment 1y ago · link · parent

I thought about dynamically sized types (DSTs) in zig recently. Was considering writing about it. I came to a different conclusion. Why not use zig's opaque?

It's pretty clean at this imo: Less metaprogramming but I think nicer to use in some cases.

  const Connection = opaque {
    pub const Header = struct {
      host_len: usize,
      // add more static fields or dynamic field lengths here
      //buff_len: usize,
    };

    pub fn init(a: std.mem.Allocator, args: struct { host: []const u8 }) *@This() {
      var this = a.allocWithOptions(u8, @sizeOf(Header) + host.len, @alignOf(Header), null);
      @memcpy(this[@sizeOf(Header)..], host);
      return this.ptr; 
    }

    pub fn host(self: *const @This()) []const u8 {
      const bytes: *u8 = @ptrCast(self);
      const header: *Header = @ptrCast(self);
      const data = bytes[@sizeOf(Header)..];
      const host = data[0..header.host_len];
      return host;
    }
  };
going off memory so I expect it to not actually compile, but I've definitely done something like this before.

7.

Ask HN: Why are there no scriptable JavaScript debuggers?

1 points · by atmikemikeb · 2y ago · 1 comment

8.

How I learned to love Zig's diagnostic pattern(mikemikeb.com ↗)

2 points · by atmikemikeb · 2y ago · discuss