Mastodon Feed: Post

Mastodon Feed

dysfun@treehouse.systems ("gaytabase") wrote:

okay so i am not yet completely sold. there are definitely some problems for some things i want to do, but zig is so far fairly impressive.

comptime is incredibly powerful. with compile time reflection i can just inspect types and do stuff on the basis of them. it fairly quickly can turn into more code than i'd like, but suddenly i'm able to do a whole pile of things that were completely off limits in rust. even where i could do some of this in rust, it would not be nearly as simple as it is here, nor would it compile as quickly and stay compiled once for each use site. or require pulling in 3rd party libraries just to write a macro (what were they thinking?).

this provides all sorts of interesting opportunities. for example, i can iterate over the members of an enum (c-style) and determine which has the largest value. i can then use this to determine how many bits i must reserve for a tag in a pointer and produce a compile time error if i can't steal that many bits safely!

i don't even want to think about this in rust, where i wrote the tools to be able to do this sort of thing and then rust really did not want to play along for the next level up. and of course i'd have to have you decorate every enum you wanted to use with it with a derive macro even if i got through that.

i am sure i will get frustrated at the limitations of it before too long, but so far i have to say, it's looking quite good.