ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
adamkowalski has joined #zig
<adamkowalski> how do I create an array literal of types
<adamkowalski> and cast it to a slice?
<adamkowalski> also can I generate a struct given a list of types?
<adamkowalski> @Type seems to be a winner!
<andrewrk> look at this fun little API: https://clbin.com/CmzMZ
<adamkowalski> So it seems we can't create struct/unions though right?
<adamkowalski> The goal is to be able to create a struct containing a vector for each type passed into the function
<adamkowalski> So Database(.{i32, bool, []const u8}) would create three vectors, one for i32, one for bool and one for []const uj8
<adamkowalski> Then there would be a notion of an id, which uniquely identifies each entry. And a map going from entity to the row in the vector it corresponds to
<adamkowalski> The reason you need the indirection is not every entity has an entry in each column
<adamkowalski> then you want to be able to iterate(.{i32, bool}, database)
<adamkowalski> which would allow you to go over all the entities which have those components
<adamkowalski> can I build something like that?
stripedpajamas has quit [Quit: sleeping...]
ur5us has quit [Ping timeout: 260 seconds]
adamkowalski has quit [Remote host closed the connection]
ur5us has joined #zig
evgeniuz has joined #zig
_whitelogger has joined #zig
Shucks has quit [Quit: Leaving]
discipulus has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
dingenskirchen has quit [Remote host closed the connection]
reductum has joined #zig
<pixelherodev> leeward: modal?
<pixelherodev> Dumb question, I know
<pixelherodev> Ahh
<pixelherodev> I think modal applications *can* be good, but *can* be bad
<pixelherodev> Just like everything else
<leeward> pixelherodev: I don't disagree in principle; I've just never come across a modal user interface I thought was in the good column.
<pixelherodev> Kakoune ;)
<leeward> Keep looking. I'm picky.
<leeward> Honestly, i3 is not likely to bother me too much on that score. Its modality is pretty limited, and I really don't like trying to click on resize handles.
hspak has joined #zig
<pixelherodev> leeward: for me, the modality of kakoune isn't a big deal; "insert mode vs normal mode" I'm okay with, I dislike more than that though :P
stripedpajamas has joined #zig
gavra has quit [Ping timeout: 240 seconds]
traviss has joined #zig
Flaminator has quit [Ping timeout: 256 seconds]
reductum has quit [Quit: WeeChat 2.8]
marnix has joined #zig
marnix has quit [Ping timeout: 240 seconds]
Mulugruntz has joined #zig
stripedpajamas has quit [Quit: sleeping...]
ur5us has quit [Ping timeout: 260 seconds]
cole-h has quit [Quit: Goodbye]
knebulae has quit [Read error: Connection reset by peer]
dermetfan has joined #zig
marnix has joined #zig
_Vi has joined #zig
copy has quit [Ping timeout: 264 seconds]
marnix has quit [Read error: Connection reset by peer]
ur5us has joined #zig
Shucks has joined #zig
<Shucks> Heya
craigo has quit [Ping timeout: 256 seconds]
craigo has joined #zig
evgeniuz has joined #zig
evgeniuz has quit [Remote host closed the connection]
waleee-cl has joined #zig
Shucks has quit [Ping timeout: 272 seconds]
Shucks has joined #zig
knebulae has joined #zig
_whitelogger has joined #zig
Shucks has quit [Quit: Leaving]
<ifreund> o7
B4s1l3 has joined #zig
B4s1l3 is now known as opDispatch
_whitelogger has joined #zig
discipulus has left #zig [#zig]
lainon has joined #zig
<ifreund> why can't you use == on two tagged unions?
<ifreund> guess std.meta.eql works though
dermetfan has quit [Ping timeout: 260 seconds]
craigo has quit [Ping timeout: 264 seconds]
<pixelherodev> ifreund: ambiguity, maybe?
<pixelherodev> Do you want to check just the *tags*, or also the *contents*? What if the contents can't be compared via `==`?
<ifreund> right, since the contents may not be comparable with == it makes sense
waleee-cl has quit [Quit: Connection closed for inactivity]
<companion_cube> if == is pure bit equality, yeah
mattmurr is now known as Guest79657
Guest79657 has quit [Killed (cherryh.freenode.net (Nickname regained by services))]
mattmurr_ has joined #zig
mattmurr_ has quit [Remote host closed the connection]
drewr has quit [Quit: brb]
marnix has joined #zig
drewr has joined #zig
dermetfan has joined #zig
marnix has quit [Ping timeout: 256 seconds]
waleee-cl has joined #zig
lainon has quit [Read error: Connection reset by peer]
xackus has joined #zig
cole-h has joined #zig
marnix has joined #zig
stripedpajamas has joined #zig
ni291187 has joined #zig
ni291187 has left #zig [#zig]
Akuli has joined #zig
SimonNa has quit [Remote host closed the connection]
xackus has quit [Ping timeout: 240 seconds]
<marnix> I think have a need for some kind of polymorphism-- how can I have a function that returns one or the other iterator over strings (runtime choice depending on function args)? Any pattern people can point me to, or an example?
<ifreund> marnix: the return type can't be comptime known?
<marnix> No, the input is a list of strings, and the return value is either a straight iterator over that list, or (depending on the first string in the list) done decoding needs to happen, which I'd like to be done in a separate iterator (without first storing the decoded list).
<ifreund> well, you could always return a tagged union
<ifreund> this seems like fairly strange code structure tbh but I don't have a lot of context
<marnix> ifreund: I could I guess. But API I'm looking for: input = strings, output = something the caller can keep calling `fn next() []const u8` on.
<marnix> ifreund: it's just like a transparent auto-detect decompressor: if gzip header then decompress+stream, if no recognized header then just stream the raw bytes.
<ifreund> marnix: one way to make this transparent would be to return a struct containing a tagged union and a next() function
<ifreund> this next() function would delegate to a next function on the active field
<ifreund> or if there are really just two things it could just be a bool and an if statement in the next()
<ifreund> marnix: I'm a little confused, shouldn't it just return a slice of bytes that may or may not have been decompressed?
skrzyp1 is now known as skrzyp
Mulugruntz has quit [Quit: ZZZzzz…]
<leeward> marnix: https://www.nmichaels.org/zig/interfaces.html <- if you actually need it
<leeward> Also, alexnask made https://github.com/alexnask/interface.zig
<leeward> Those would let you return an iterator, though I kinda like the tagged union approach for your case.
mattmurr has joined #zig
BeardPower has joined #zig
mattmurr has quit [Quit: WeeChat 2.3]
SimonNa has joined #zig
<marnix> ifreund and leeward: Thanks, I've seen those interface suggestions before-- probably indeed will go with an iterator that contains the two iterator types, and next() switches. But will consider tagged union too. Thanks for your thoughts!
signop has joined #zig
marnix has quit [Read error: Connection reset by peer]
<pixelherodev> andrewrk: I've taken your "python-as-calculator" idea a step further: if you set up an alias that auto-sets up `decimal` and precision, you can get a really nice arbitrary precision calculator
marnix has joined #zig
xackus has joined #zig
<leeward> Isn't python-as-calculator in the python tutorial?
<pixelherodev> I wouldn't know
<pixelherodev> What python tutorial is this?
<leeward> the official one
<pixelherodev> I haven't read it lol
<pixelherodev> I picked up Python by working on the KnightOS SDK a few years back :P
<leeward> I read that on a train from Worcester to Boston in...2002? Not the py3k version, of course.
<pixelherodev> Meh, that doesn't really count
<pixelherodev> It's using that to show language fundamentals, it's not seriously saying "use this as a real legit calculator!"
<pixelherodev> Whereas that is exactly what I'm doing :P
<leeward> It's probably the reason I use Python when I need a calculator.
<fengb> Back in my day, I had to from future import division
<pixelherodev> I've started doing e.g. `from decimal import *; float(round(Decimal(5.20 * pow(10, 23)) / Decimal(6.02214 * pow(10, 23)), 3))`
<leeward> Back in my day, I had to remember to put "." at the end of at least one of my integers.
<leeward> Except it's still my day.
<pixelherodev> Back in my day, we didn't say "back in my day" because it was the present!
<fengb> Kids these days
<fengb> Respect your elders
<leeward> Okay, zoomer.
<leeward> Mmm, avocados.
<leeward> Er, I mean...That looks like chem to me pixelherodev.
<pixelherodev> lol
<pixelherodev> That is very much what it is
<pixelherodev> Would be neat to have a zig interpreter for it instead ;)
<pixelherodev> Maybe I should make a Zig AST interpreter and use it to make a REPL...
<pixelherodev> No wait, terrible idea
<leeward> scipy.constants has Avogadro in it, along with a bunch of other useful physical constants.
<leeward> Is that a terrible idea, or the first step in making Zig JIT?
<leeward> You know the story of how the first lisp implementation went, right?
<pixelherodev> Nope, but I think you'll enlighten me :)
<leeward> They were trying to implement a compiler in assembler (or some 50s language), and when they got to eval, the lightbulb went off.
<leeward> There's an interesting paper somewhere, I'll see if I can find it.
heitzmann has quit [Quit: WeeChat 2.8]
heitzmann has joined #zig
<leeward> I got my chronology a bit wrong: they wanted to demonstrate that lisp was better than other languages, and so they specified eval. S.R. Russell noticed that eval could serve as an interpreter, hand-coded it, and *boom* they had a language and an interpreter.
Techcable has quit [Quit: ZNC - http://znc.in]
<pixelherodev> Whoa
<pixelherodev> I've been away for a few *days*
<pixelherodev> Amazing work, Andrew!
Techcable has joined #zig
<andrewrk> thanks
<andrewrk> next up is *const* locals
<andrewrk> which will finally make it expressive enough to test register allocation
nikita` has joined #zig
<andrewrk> I was thinking a lot about self-hosted codegen recently and I think we can actually beat llvm perf in debug builds
nikita` has quit [Read error: Connection reset by peer]
<andrewrk> I mean not only compilation speed, which is the primary goal of debug builds, but also runtime perf
<leeward> llvm's run time or compile time performance?
<leeward> I'm slow.
<andrewrk> we'll find out within a couple weeks whether this is the case
<fengb> LLVM debug builds are very much not optimized. It doesn't even convert divide by 2
<leeward> That makes sense if you don't run it through an optimizer.
<ifreund> imo compilation speed shouldn't be sacrificed for optimization, but if making things run faster is trivial and dosen't affect compile speed why not
<andrewrk> yeah there is a lot to be done that does not affect compile speed, such as lowering div-by-2 as a shift
<andrewrk> but mainly I'm thinking, using registers as variable locations
<andrewrk> llvm does not provide the ability to do this when you want to specify debug info for them. but DWARF supports this. it's a limitation of llvm's api
<leeward> llvm's architecture is to have optimizers perform transformation on IR, right? It makes sense that "check the denominator to see if it's 2" would be in an optimization pass.
<fengb> I found it semi-surprising given that GCC converted it. Maybe the default shouldn't be "zero optimizations" as much as "minimal"
<fengb> And possibly have a separate flag for zero optimizations
<leeward> Interesting. That's the #1 reason I use debug builds: variable location optimized out.
<leeward> s/debug builds/-O0
<andrewrk> even if you switch a variable to a different register, DWARF has a way to annotate this
<andrewrk> it's really quite powerful
<andrewrk> I'm guessing PDB has the same, but I have not verified this
<leeward> It's probably worth checking to make sure gdb handles those DWARF symbols correctly.
<andrewrk> wow I'm down to only 61% of zig commits authored by me
<andrewrk> ya'll are amazing
<leeward> We do double duty: PRs cost you time that you could be spending writing code.
<leeward> Is there really no option to name the output of "zig build-obj"? I don't see a -o.
<andrewrk> in self-hosted it's -femit-bin=name but I don't think that has been backported yet
<leeward> Fair enough.
<andrewrk> well you can also just use `--name foo` but that is not a file name, it affects all build artifacts
<fengb> Would you really be happy to spend your time merging PRs instead of coding though? :P
<fengb> I suppose that's why you're looking to hire >_>
<leeward> It's interesting to see what features were not demanded in stage1.
<andrewrk> any help on PRs from the hire would be welcome, but realistically I'm forseeing their time spent mostly elsewhere
<andrewrk> it's also not a top-down management structure, no mandated tasks. we pick somebody motivated and capable and then trust them to decide how to spend their own time
<andrewrk> so I may be stuck with PRs after all :)
<fengb> Feels like the Peter principle
<andrewrk> never heard of it
<fengb> You're too important to do real work now
<andrewrk> eh we'll see about that
* andrewrk mumbles something about register allocation
<leeward> Peter principle: people get promoted until they're no longer good at their jobs.
<companion_cube> I like the idea that andrewrk just wants to get zig done and move to other things
<companion_cube> best way to avoid feature creep :p
<andrewrk> can't get promoted if you don't have a boss *taps head*
<fengb> You're getting de facto promoted
<leeward> But then you went and started the ZSF, so now you have an employer.
<fengb> No title change but the workload is different
<fengb> Oh yeah, Josh and Mason are your bosses now :P
<fengb> And yourself 🤔
evgeniuz has joined #zig
evgeniuz has quit [Remote host closed the connection]
craigo has joined #zig
evgeniuz has joined #zig
evgeniuz has quit [Remote host closed the connection]
stripedpajamas has quit [Quit: stripedpajamas]
<leeward> woot, Zig code running on my nRF52840
<leeward> That was an awful lot less painful than the AVR version.
marnix has quit [Ping timeout: 258 seconds]
<pixelherodev> leeward: what ISA?
<BeardPower> The latest show-time was really great! Congratulation on the first fund-raising.
<leeward> pixelherodev: It's a Cortex-M4 with hard float.
<leeward> so...armhf
<pixelherodev> Ahh, okay
<leeward> In fact, it's not even worth writing up a howto. Just build for "-target arm-freestanding-eabihf -mcpu=cortex_m4" and it works. Pretty sweet, now that I think about it.
dingenskirchen has joined #zig
xackus has quit [Ping timeout: 260 seconds]
epmills has joined #zig
<epmills> hey, all. hope you're safe and well...
<epmills> wondering if anyone builds their apps for multiple targets, naming the binary with the version number and maybe architecture in the filename...
<epmills> something like 'foobar-1.0.0-x86_64-apple-darwin'
<epmills> anyone use build.zig for this, makefile or other?
<epmills> would love to automate this for multiple architectures and auto-generate SHAs for the binaries in a single step.
<BeardPower> Some non-programming/language question: are there any ideas of future fund-raising on the table yet?
<leeward> epmills: I think --name might be the only way to do that. Alternatively, you could put the different targets in different --output-dir s
<leeward> build.zig would work fine for it, though, if you're into that sort of thing. I think any non-build.zig build system that lets you specify commands to run would work too.
<epmills> leeward: thanks for your ideas
<leeward> no problem
<andrewrk> thanks BeardPower!
<andrewrk> BeardPower, you can ask Loris that question. His handle in this channel is kristoff-it but he's not here now. He's often in the discord server
<frmdstryr> What's the best way to convert abs(i32) to a u32? Can I just int cast it?
<BeardPower> andrewrk: Thanks! I will drop him a line and share some ideas/thoughts.
<ikskuh> frmdstryr, i would even truncate it
<ikskuh> ah wait
<ikskuh> that does not work, use intCast
<andrewrk> std.math.cast
<ikskuh> andrewrk: that is a thing? *has to look at std.math again*
<andrewrk> oops I mean absCast
<andrewrk> std.math.absCast allows any operand type and returns an unsigned integer, without the possibility of error
ur5us has joined #zig
<frmdstryr> That's perfect, thanks!
<ikskuh> andrewrk: thanks for absCast :)
<ikskuh> didn't know that and needed it atm
Akuli has quit [Quit: Leaving]
shcv has quit [Ping timeout: 260 seconds]
epmills has quit [Remote host closed the connection]
<andrewrk> I think I finally understand intuitively what "Data Oriented Programming" means
<BeardPower> andrewrk: Are you familiar with the Mike Acton's presentations?
<andrewrk> yeah
<BeardPower> :-)
<andrewrk> the one he did at handmade con seattle last year was pretty neat
dermetfan has quit [Ping timeout: 260 seconds]
<ikskuh> andrewrk, BeardPower: can you explain it in short? or link the talk=
<BeardPower> andrewrk: Last year? Wasn't that WeAreDevelopers?
<BeardPower> ikskuh: It's about that all operations are just transforming data. Data in -> transform -> data out
<BeardPower> Sorry, the first link has some timestamp...
<andrewrk> hmm I don't think the one I'm thinking of is online
<andrewrk> he live coded a simulation during the talk and refactored it
<BeardPower> Ah, interesting.
<BeardPower> The papers/stuff he released while he was working at Insomniac Games is interesting as well.
<andrewrk> it was neat, he ended up getting the core game loop down to just a few bit fiddly instructions
<BeardPower> They had some coding competition back then. Implementing some algo using the PS3 Assembler.
<BeardPower> His code reviews are quote fun.
<BeardPower> *quite
<andrewrk> lisp code reviews are quote fun
<leeward> 'fun
<BeardPower> Hehe
<ikskuh> andrewrk: i really love that there's now a zig meme "do you want that feature? well, implement it in user spcae"
<ikskuh> after reading some stuff about data-oriented design i had to thing of Jais built-in feature to turn an array of structs to a struct of arrays
<ikskuh> we can do such with a neat little comptime function
<andrewrk> ikskuh, did you see this abstraction? https://github.com/ziglang/zig/pull/5872 I felt pretty good about it
<ikskuh> const MyArrayType = StructOfArrays(struct { x: i32, y: i32 });
<ikskuh> i'll take a look
<ikskuh> github definitly needs an option to watch only certain events
<andrewrk> ahh yeah! that's the pattern I did here too, passing a struct as the input to decide a different memory layout
<ikskuh> i would love to get notifications for creation and merging of all PRs
<ikskuh> i still think @Type should support structs, especially for stuff like that
<fengb> Watch the repo?
<ikskuh> fengb: i did that…
<ikskuh> my email account is overflowing even from *some* watched topics
<fengb> Oh I disabled email
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<andrewrk> i just let the ziglang emails wash over me, like waves on the beach
<ikskuh> i ignore the github notifications completly
<fengb> I generally hate email notifications because it's so spammy
<fengb> Web notifications work pretty well though
<fengb> ... not desktop web notification spam. I mean in websites
<ikskuh> i really don't like the github interface for notifications :D
<ikskuh> i just switched over to email completly
<ikskuh> TrailerFlags is neat
<andrewrk> it took VarDecl down from always being 208 bytes to being 32 bytes for simple ones and then more bytes only when extra stuff is added
<andrewrk> e.g. `const x = 1;` is 40 bytes and `const x: i32 = 1;` is 48 bytes
<andrewrk> there's a lot more slimming of the AST memory layout that can be done, this is just scratching the surface
<fengb> Will there be bytecode soon™? :P
<andrewrk> I think the question behind the joke is whether there will be an on-disk format
<andrewrk> I don't think so for the AST. Parsing is pretty fast. Might as well just read the original source files again
<andrewrk> maybe for post-analyzed ZIR. I can imagine that there was a long-running comptime function that does a computation, and it could save a lot of time to store post-analysis ZIR
BeardPower has quit [Ping timeout: 240 seconds]
_whitelogger has joined #zig
reductum has quit [Client Quit]
iii has joined #zig