ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
darithorn has quit [Quit: Konversation terminated!]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
renatorabelo has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
renatorabelo has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
renatorabelo has joined #zig
<renatorabelo>
c/lear
renatorabelo has quit [Ping timeout: 252 seconds]
very-mediocre has joined #zig
wilsonk has quit [Read error: No route to host]
wilsonk has joined #zig
davr0s has joined #zig
<very-mediocre>
this is awesome:https://andrewkelley.me/post/string-matching-comptime-perfect-hashing-zig.html
davr0s has quit [Read error: Connection reset by peer]
<halosghost>
this one is a demo of an 8-bit posit implementation in Julia beating a 32-bit float on quality and performance for audio-encoding (along with a lot of the technical details of posit implementations): https://youtu.be/aP0Y1uAA-2Y
<halosghost>
and here's the website that tracks the community of crazy evangelicals of posits and the work being done on them: https://posithub.org/
<halosghost>
andrewrk: they descend from unums (which have been around longer, so you may have heard of)
<andrewrk>
halosghost, thanks, I'll check this stuff out
<halosghost>
if I can manage to get a few more of my personal projects done, I'd love to start contributing to Zig; and I'm fascinated by posits; so that might be a place I go to start :)
<halosghost>
fair warning about SoftPosit: it's All Rights Reserved
<halosghost>
so, yeah
<halosghost>
oh, no wait; looks like a lot of the files are 3-clause BSD; it just doesn't have a repo-wide license
<andrewrk>
btw halosghost you don't have to wait for AUR - the static linux binaries on https://ziglang.org/download/ are 100% static
<andrewrk>
I challenge you to find a linux distro on which they don't work out of the box
<halosghost>
haha
<halosghost>
I don't doubt you (at this point, I think you've earned some benefit of the doubt)
<andrewrk>
:)
<halosghost>
honestly, I'd be tempted to do that anyway because of the cool self-hosting stuff :)
<halosghost>
but, we'll see
<halosghost>
I have other things I sadly need to do first
<halosghost>
I think I will go ahead and start idling in here more though
<halosghost>
I really annot describe how excited I am about where Zig is headed
<halosghost>
(which you may have noticed from my post on lobste.rs) :P
<MajorLag>
zig static worked on a 2.6 kernel last I tired. It's about as universal as things get in linux. Only way I can think of it being more universal is to somehow make it a fat binary with builtin QEMU user-mode emulation so it runs on arbitrary architectures.
<halosghost>
including a UEFI header so it can run on absolute bare-metal? :P
<MajorLag>
hmm... a simple benchmark I had for some of my code lost 4ns/loop in zig 0.3 release-fast compared to zig 0.2.
<halosghost>
lost meaning it's slower or faster?
<andrewrk>
MajorLag, that almost certainly has to do with the difference between LLVM 6 and 7
<MajorLag>
it's slower, and yeah since LLVM is the one doing the optimization I'm pretty sure it is to blame.
<halosghost>
well, that's too bad ):
<andrewrk>
there's still stuff zig could be doing to help llvm optimize more
<andrewrk>
I'm hoping that exploring pointer aliasing (the disallowing of it by default with safety checks, etc) will yield some good results
<andrewrk>
especially if we can ditch Type Based Alias Analysis, and just make it something like You Can Only Alias If You Tell The Compiler About It Based Analysis
<halosghost>
afaiu, certainly a more liberal use of restrict pointers helps with performance easily
<MajorLag>
Interesting, release-small is actually a bit faster
<halosghost>
MajorLag: if I had a nickel for everytime I've seen -Os binaries outperform -O2 binaries, I'd have lots of money
<andrewrk>
idea being that you choose an overall optimize for - perhaps --release-small, but then at package level, scope level, you can override what to optimize for
<halosghost>
mm, that sounds fun
<andrewrk>
maybe you want a debug build but your blake2b implementation should just go ahead and be --release-fast
unique_id has joined #zig
<MajorLag>
I'm not using any pointers in this code, at least not on purpose. It's possible that passing the struct "by-value" is actually being passed as a pointer, but @sizeOf it is only 4 so I doubt it.
<halosghost>
andrewrk: does zig do anything / have anything analogous to intN_fast_t and intN_least_t?
<andrewrk>
MajorLag, right now zig does not optimize by passing small structs by value. even a struct with 1 field is passed by reference. however llvm could decide to make it by value
<andrewrk>
zig also doesn't re-order struct fields yet. there's a lot we haven't tried to do yet
<MajorLag>
ok, but that'd be true of zig 0.2 as well. And since the 0.2 master I'm testing with is only slightly out of date of 0.3 it has to be LLVMs doing.
<andrewrk>
halosghost, I investigated intN_fast_t and intN_least_t early on and came up with the conclusion that they're at best worthless, at worst actually accomplish the opposite of intended
<halosghost>
haha
<andrewrk>
just use the number of bits that you need; zig is allowed to use a larger type if it's faster
<halosghost>
any write-up of that? I'd be interested in knowing your thoughts
<halosghost>
ahh
<halosghost>
fair enough
<andrewrk>
even in structs. because zig does not guarantee the size of structs
<halosghost>
I suppose with {i,u}N now being a thing, it's certainly less of a useful idea
<MajorLag>
and if you need exactly that size, i.e. for structs, that's what `packed` is for.
<halosghost>
right
<MajorLag>
well, anyway, nothing to do but soldier on. The code in question should be faster anyway.
<andrewrk>
the blessing and the curse of llvm is that it's a bit of a black box
unique_id has quit [Remote host closed the connection]
hooo has joined #zig
DutchGh0st has joined #zig
<DutchGh0st>
YAAS! :D
<DutchGh0st>
good job \o/
halosghost has quit [Ping timeout: 244 seconds]
halosghost has joined #zig
<halosghost>
andrewrk: you said that {i,u}Ns get gracefully compiled to bitfields in packed structs; does that include both sub-power-of-two sized ints and super-sized ones?
<halosghost>
andrewrk: e.g., does an i129 compile down to something like `struct { int64_t upper, lower, top: 1 }`, and an i7 to `struct { int8_t i: 7 }`?
<halosghost>
actually, scrap that
<halosghost>
let me ask the real question
<halosghost>
mmm
<halosghost>
nah, I just need to think about this more before I interrogate you :)
mnoronha has joined #zig
<andrewrk>
halosghost, yes
<halosghost>
awesome
<andrewrk>
yes, that includes both sub-power-of-two sized ints and super-sized ones, (not that you need to think more)
<halosghost>
right
<halosghost>
well, I'm still on the fence about whether or not it will help me, but it's cool to know :)
* halosghost
is trying to figure out a space-efficent implementation of Rationals
hooo has quit [Quit: Page closed]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<MajorLag>
andrewrk, I'm considering making a pull request that would alter std in a breaking way. What's the easiest way to run every test in std?
<andrewrk>
MajorLag, zig test std/index.zig
<andrewrk>
if you just did make install from the build folder: ./zig test ../std/index.zig
<MajorLag>
\std\io.zig:619:13: error: unable to find 'io_test.zig'
<andrewrk>
yeah - zig doesn't ship with the std lib tests
<andrewrk>
you'll have to use the std/ from source
<MajorLag>
really? there are tests in std
<andrewrk>
yeah but if there's a file that is just tests we don't ship it
<andrewrk>
mostly because of a couple compiler_rt tests that are multiple MiBs
<MajorLag>
well for the first pass I don't really need that thurogh a test.
<andrewrk>
you can also run the zig test suite with -Dskip-release which takes about 5 minutes
<andrewrk>
that will run the std lib tests on all targets, even non-native ones
<MajorLag>
ok. Also, what's the status of meta.zig? I thought there was a branch for it, but can't find it anywhere.
<MajorLag>
nevermind, I just did
davr0s has joined #zig
<andrewrk>
I think it is quite bit-rotted at this point
<DutchGh0st>
alexnask iss not around anymore ?
mnoronha has quit [Ping timeout: 260 seconds]
jjido has joined #zig
<MajorLag>
I can probably fix that as it is tangentially related. How do you feel about including it in std even without replacing the builtins for now?
<halosghost>
andrewrk: so, another question on {u,i}N: a u1 can either hold the values 0 or 1; am I correct in thinking that an i1 can only hold the values 0 or -1?
<andrewrk>
MajorLag, I would consider that progress
<andrewrk>
halosghost, correct
<halosghost>
fun
<halosghost>
I love how that implies the possibility of a negative bool
<halosghost>
e.g., the difference between “oui” and “si” in French
tbodt has joined #zig
<tbodt>
is there documentation for the stdlib somewhere?
<tbodt>
or is that in the "we'll get to it someday" list
<DutchGh0st>
is there a 'comptime if' or 'inline if' thingy?
<andrewrk>
tbodt, that's something that is high priority, but I'm insisting on solving it with auto-generated html documentation from the self-hosted compiler
<andrewrk>
so it's a big milestone to get there
<halosghost>
DutchGh0st: there are comptime expressions
<DutchGh0st>
yeah but hold on,
<andrewrk>
DutchGh0st, all if and switch expressions are implicitly comptime if the condition/target expression is comptime known
<halosghost>
andrewrk: ooh, that's fun
* halosghost
didn't know that
<andrewrk>
if you want to force an if or switch to be comptime you can do so simply by putting `comptime` before the condition/target expression, and you'll get a compile error if it couldn't be done
<tbodt>
why is the compiler being made self-hosting? I read somewhere that it solves actual problems but didn't see what those problems were
<andrewrk>
the goal is to build the compiler for all targets
<andrewrk>
there's also just the features of zig that I want to use, e.g. async/await with a thread pool. C++ doesn't have that
<halosghost>
andrewrk: if all the arguments of a function are comptime, that function is purely comptime as well, even if user-defined; yeah?
<andrewrk>
halosghost, it won't necessarily be executed at compile-time
<halosghost>
mmmm
<halosghost>
I suppose it would depend on what's in the function body for if it's even possible to be at comptime
<andrewrk>
if it has any parameters or return value types that require comptime, that will force it. e.g. if a parameter has type `type`
<halosghost>
mm
<andrewrk>
the way you can think about it is, you shouldn't have to care whether something happens at comptime or not. so don't worry about it. if you need something to be at comptime, then you can force it to be so
<halosghost>
right
<halosghost>
I'm trying to figure out how my idea for a space-efficient Rational implementation might work now that {u,i}N are a thing
<andrewrk>
DutchGh0st, int types have a `is_signed` field
<andrewrk>
u32.is_signed
<DutchGh0st>
yeahh that's what I used for is_signed() and bitcount() :)
<DutchGh0st>
Im doing it the good way then I suppose
<andrewrk>
yeah. that might get removed since @typeInfo gives you identical info
<DutchGh0st>
I like how you get to write your own helper functions for stuff like that, and get to exactly write what you want it to do
<halosghost>
@typeInfo(T).Int.is_signed and @typeInfo(T).Int.bits iirc
<halosghost>
(not entirely sure)
<DutchGh0st>
yeup
<DutchGh0st>
and btw, how would you use inline while to unroll a loop, 4 times
<DutchGh0st>
but for each of those 4 unrolls, you want to keep track of a variable, and at the end, sum up all the 4 values,
<DutchGh0st>
how'd you do that?
<DutchGh0st>
so like, loop over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], by 4 at a time, then do something like 'var r1 = val1 + 1; var r2 = val2 + 1; var r3 = val3 + 1; var r4 = val4 + 1; result += r1 + r2 + r3 + r4'
<Hejsil>
But, if I have zig in my path, i can't use it to build zig stage2
<andrewrk>
hmmm. I'm not sure if I quite understand what you're trying to do. but, stage2 is not independent from stage1. it links against zig_llvm.a and I think another .a file from stage1
<Hejsil>
Yeah, i know
<andrewrk>
but anyway the build process for stage2 assumes that you just built stage1
<Hejsil>
I can't do <make stage 1> <add stage 1 exe to path> <use the stage 1 exe from the path to build stage 2>
<andrewrk>
hm. I thought you could
<Hejsil>
Sec, i'll check again
<andrewrk>
I just did it
<Hejsil>
Or, actually, to add more details
<Hejsil>
I have a .bin in my home folder that is in my path
<andrewrk>
Hejsil, hm interesting. I think this is simply some code in the tests that is calling std.os.real without taking into account PATH
<andrewrk>
test/tests.zig:112
<andrewrk>
does libc realpath use PATH?
<andrewrk>
nope, looks like it does not
<andrewrk>
Hejsil, ok my suggestion is that std/special/build_runner.zig:43, before it initializes Builder, should resolve zig_exe with PATH and potentially call std.os.real
<andrewrk>
that will fix it
<andrewrk>
or potentially even in src/main.cpp:397, where, you are right, it is using arg0 for zig exe
<andrewrk>
ok even better, instead of using arg0 it should use os_self_exe_path
<Hejsil>
Also, `error{} == error{}` is `false`. Intended?