<jaredmm>
Can't wait for the day I don't have to troubleshoot another gd build that has "simple" build instructions that never work on the platforms they say they do.
traviss has joined #zig
<traviss>
on windows, binary zig 0.5.0 is giving this error which i didn't see from binary 0.4.0: ...VCRUNTIME140_1.dll was not found... does anyone know what i need to do?
<traviss>
i tried updating my VS build tools from VS installer but that didn't work. i have VS community 2017 installed btw (not updated recently).
kllr_sbstn has quit [Remote host closed the connection]
<traviss>
.. along with VS build tools 2017. i updated both just now but that didn't seem to help.
<andrewrk>
traviss, github updated
<traviss>
thanks so much andrewk and everyone. amazing release!
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 240 seconds]
<traviss>
installing the visual c++ 2019 redistributable fixed my problem. i don't think i needed to do the updates i mentioned above. here is the link i used: https://aka.ms/vs/16/release/VC_redist.x64.exe
lukeholder has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 240 seconds]
hasanyasin has joined #zig
hasanyasin has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
ntgg has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
ntgg has quit [Ping timeout: 265 seconds]
<scientes>
Yeah, my libmvec function works with armv7-32bit but not qemu
<scientes>
as I was saying, qemu support for SIMD stuff is buggy
<knebulae>
@andrewrk: I have been giving a lot of though to the comment about zig perhaps one day supporting its own inline assembler. Would it be possible to pass certain blocks to nasm for assembly? Of course this can be done with C function linkage, but then you have to abide by the C ABI. I'm thinking more a naked function with a nasm {....} block. It would be highly naughty though.
<scientes>
or 4x8b operations to occur simultaneously.
<scientes>
oh thats a differn't type of SIMD
<scientes>
that's not the full thing: 16 x 8-bit, 8 x 16-bit, 4 x 32-bit, and 2 x 64
<shachaf>
knebulae: Integrating an external assembler on that level seems very complicated and not worth the trouble.
<knebulae>
That was what I figured :(
<knebulae>
it'd have to be deep in llvm to make it play nice.
<scientes>
yeah you can always link to those functions from zig
<scientes>
using assembly if you want to do weird calling conventions
<shachaf>
I feel like the benefits of inline assembly in the first place are pretty limited, when you have top-level assembly and intrinsics.
<knebulae>
@shachaf: 99.99% of the time, yes. In my case, no. But it's all good. So many cool things in the new release.
drazan4 has joined #zig
drazan has quit [Ping timeout: 268 seconds]
hasanyasin has joined #zig
doublex has quit [Ping timeout: 245 seconds]
<scientes>
should we have a signed version of truncate, and keeps the sign of the old number?
hasanyasin has quit []
doublex has joined #zig
<scientes>
developing a memory model for comptime would really improve the usefulness of comptime
<scientes>
or at least first, array indexing at comptime
<scientes>
its a huge project
chemist69 has quit [Ping timeout: 276 seconds]
reductum has joined #zig
chemist69 has joined #zig
reductum has quit [Quit: WeeChat 2.6]
andrewrk has quit [Ping timeout: 240 seconds]
LargeEpsilon has joined #zig
adsr has quit [Quit: WeeChat 2.5]
LargeEpsilon has quit [Ping timeout: 265 seconds]
LargeEpsilon has joined #zig
LargeEpsilon_ has joined #zig
LargeEpsilon has quit [Ping timeout: 276 seconds]
ltriant has quit [Quit: leaving]
stratact has quit [Quit: Konversation terminated!]
earnestly has joined #zig
stratact has joined #zig
FireFox317 has joined #zig
stratact has quit [Remote host closed the connection]
stratact has joined #zig
FireFox317 has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 240 seconds]
konv has joined #zig
marijnfs_ has quit [Quit: WeeChat 2.6]
_Vi has quit [Ping timeout: 265 seconds]
avoidr has joined #zig
rappet has quit [Quit: -]
rappet has joined #zig
gustav_o has joined #zig
<gustav_o>
hi!
<mq32>
hey
<konv>
o/
<gustav_o>
0.5.0 is looking great :) I started a project today and ran into a problem: what is the proper way to add a zig library (build.zig file) to the build process of a(nother) zig executable?
<lunamn_>
b.addPackagePath?
avoidr has quit [Quit: leaving]
<mq32>
ceymard, your code completion works pretty well!
<gustav_o>
lunamn_thanks! the import seems to work, I just can't seem to access anything public though @import("mylibrary").hello where pub const hello = "hello world!"; exists in main.zig of mylibrary
<gustav_o>
oh nm, I accidentally supplied the build.zig file to addPackagePath() instead of main.zig
Gertm has joined #zig
<Gertm>
How much C knowledge does one need to get going with Zig?
<mq32>
pretty much zero
<mq32>
you should know how a computer works (in terms of memory, pointers, stack, heap)
<mq32>
but you don't need to know syntax or semantics of C
<tencho>
I mean I get OutOfMemory error on line 11. If I set a breakpoint in heap.zig:450 then self.buffer.len is 0. How ?
tencho has quit [Quit: WeeChat 1.4]
utzig has joined #zig
kenaryn has joined #zig
<kenaryn>
Hello people, I'm reading the 0.5.0 release notes and new builtin @hasDecl in particular, but I do not know the meaning of the 'declaration' word? (i.d. in a programming sense). Is there someone who accepts to explain it to me please?
<kenaryn>
Another question: is there a lexikon associated with the Parsin Expression Grammar? same implication as the previous one but in a higher abtract reasoning. Thank you.
<kenaryn>
Parsing*
<mq32>
hey kenaryn
<mq32>
a declaration "declares" that a variable exists
<mq32>
"hereby, i declare that a is a variable of type i32!"
<mq32>
or in zig terms
<mq32>
var a : i32;
<mq32>
declarations "create" objects like variables or functions
_Vi has joined #zig
<kenaryn>
Allright but does a function isn't a declaration too? like exposed by Andrew in the official documentation
<mq32>
a function declaration is also a declaration ;)
<mq32>
fn fun() void { } // this declares a function
<kenaryn>
sorry, I missed your before-last sentence!
<kenaryn>
I understand now, you are very kind mq32.
<gustav_o>
Another question: is there a way to initialize all struct fields to 0 in zig?
Ekho has joined #zig
<mq32>
@memset
<mq32>
or std.mem.set
<mq32>
or use default-initialization with 0
<fengb>
Try not to memset arbitrarily. Zig has some built in safety, like slices, that could be overwritten
<fengb>
Except packed structs and extern structs. They can probably be memset without worries since their memory layout is well defined
<gustav_o>
how do I default-initialize with 0? this is a c struct so I cannot change the struct fields to have defaults
<fengb>
Oh C structs are extern so doing memset is fine
rifkik has quit [Read error: Connection reset by peer]
<gustav_o>
Hm, I can't quite figure out how to add my library as a dependency of my executable. exe.addPackagePath("mylib", "../../src/main.zig"); makes it possible to import zig code from main.zig but how do I inherit the library declaration? Do I break out b.addStaticLibrary() into its own function in mylib build.zig and then call that from my executable
<gustav_o>
build script?
<gustav_o>
I want to specify lib.addCSourceFile("src/deps/mycfile.c", [_][]u8{}); etc only once in the build.zig of mylib, not in all places that use the lib
Barabas has joined #zig
ikan-keli_ has joined #zig
<gustav_o>
Ok I worked around the problem by creating the executable inside of the library build script (these are "test" executables anyway), but I would be really interested to know the proper way to do this. Maybe it doesn't exist yet and it is waiting for the package manager?
ntgg has joined #zig
halosghost has joined #zig
ntgg has quit [Ping timeout: 276 seconds]
ntgg has joined #zig
<kenaryn>
Thank you digenskirchen! This is very instructing :)
waleee-cl has joined #zig
doublex has quit [Ping timeout: 245 seconds]
doublex has joined #zig
shritesh has joined #zig
<shritesh>
FYI homebrew has 0.5.0 now. `brew install zig` away.
shritesh has quit [Remote host closed the connection]
<fengb>
Driveby announcement o_O
n_1-c_k has joined #zig
<Barabas>
How would one extent functionality of an existing struct?
<Barabas>
(Without changing the existing implementation, because that could be in some library.)
<n_1-c_k>
Calling the nextPosix() function in ArgIterator got me this, https://paste.debian.net/1103497/ , am I doing it wrong? OS is debian stable.
kristoff_it has joined #zig
Akuli has joined #zig
LargeEpsilon_ has quit [Ping timeout: 265 seconds]
ntgg has quit [Ping timeout: 240 seconds]
lukeholder has joined #zig
ntgg has joined #zig
lukeholder has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
LargeEpsilon has joined #zig
<_Vi>
Is comptime-unrolled loop of ifs, comparing x to large-ish set of constant numbers going to be as efficient as switch?
<fengb>
I believe LLVM optimizes that into a jump table
<scientes>
llvm is very conservative about jump tables
<scientes>
i was working on it, but C++ is so slow
<scientes>
you can't do a jump table out of that without a bit map
<scientes>
which llvm doesn't implement
<scientes>
so the switch just does binary search
<Barabas>
in general a switch can't really be a jump table, unless you assume the default case never happens.
<fengb>
scientes: I think _Vi wants to generate switch branches using a loop
<_Vi>
Yes.
<scientes>
ooooo
<scientes>
good question
<scientes>
yeah, make up a proposal
<scientes>
but keep in mind that the llvm switch interface sucks
<scientes>
but i gues we can just ignore that
<scientes>
gcc's is better
<_Vi>
Is that `llvm switch interface` the only way to make it generate jump table or it can also do it from equivalent series of `if`s?
<scientes>
i don't believe llvm generates switch statements
<Barabas>
fengb what's it doing with lea there?
<scientes>
but i could be wrong
<scientes>
but yeah that is probably the way to do it
<Barabas>
fengb lol, if you change `x - 1` to `num - 1` it does optimize it :P
<fengb>
Oh that makes sense
<fengb>
Wait... it means you can't use the switch match in the body :(
<Barabas>
Well... x and num should be the same. The compiler should know that, but hey... it's a compiler :D
<fengb>
I was hoping LLVM would recognize this as a switch
<scientes>
fengb, you just have to write the patch to llvm
<scientes>
i think this is the way to do it
<_Vi>
Is converting the big switch to a jump table implemented in Zig code (without relying on LLVM) a good idea?
<scientes>
no
<_Vi>
Will the big chain of `if (x == 0x123456) return MyEnum.Var1;`-like things (more than 200 items) be optimized by LLVM somehow (even if it is not a jump table)?
<fengb>
Only way to be sure is inspecting the output
<mq32>
_Vi, it's not a good idea to specify what optimizations are guaranteed
<mq32>
because this would prevent optimal code generation
<_Vi>
Tried godbolting a switch with 19 variants and observing a lot of `cmp`s and conditional jumps.
<mq32>
it's probably better for the pipeline than a jump table
<mq32>
as jump tables are more common to enforce pipeline stalling
<fengb>
Well... chained conditional jumps are worse than jump tables
<Tetralux>
mq32: I hear this a lot; the point about not tying the hands of the compiler; I've yet to see any actual evidence that this is actually true. Indeed, more the opposite.
<mq32>
Tetralux: i once "optimized" my code from what the compiler did to a jump table
<Tetralux>
It was slower?
<mq32>
yes
<mq32>
by factor 3
<Tetralux>
That's because jump tables are terrible xD
<Tetralux>
if-else branches are better.
<Tetralux>
It's okay if you've got like 20,000 arms
<Tetralux>
But not for like 10.
<mq32>
yeah but even then the compiler would have emitted the same code as for the switch ^^
<mq32>
i had 256
<Tetralux>
I've never measured personally where the threshold is.
<Tetralux>
So I can only really guess, in part.
<Tetralux>
Point is, jump tables aren't worth the optimization to unless you've got a lot of them.
<fengb>
But if your if-else chain has a jump per branch, it's possibly slower already
<_Vi>
Will it be similar for 200 variants instead of 18?
<mq32>
btw, is our BDFL taking a break? he isn't here in the IRC :D
<Barabas>
wait, a jump table is computed goto
kenaryn has left #zig ["(The show must go on!)"]
<Barabas>
right?
<fengb>
For instance, my emulator core is better as a jump table because each branch is complex and the cache doesn't help too much
<fengb>
Barabas: computed goto is an optimization step beyond jump table but they're related yeah
<Barabas>
Yes I can see that. I once helped optimize some vm thingy to generate computed goto's for the instruction handling and it got 30% faster in some cases.
<Barabas>
ok
<fengb>
It really depends on cache characteristics. If you have one branch that's hit often, pushing that to the top and prevent jumps is much faster than anythiing else
<Barabas>
Yeah I can see that.
<fengb>
Or if each branch is not actually jumping, if-else chain would always be faster
<Tetralux>
I did hear that someone wrote a parser as a jump table and then rewrote it as--I think it was recursive-decent; it went from 60 to 2 ms.
<Barabas>
^^
<Tetralux>
Anecdotal of course, but.
<Tetralux>
That is somewhat representative, is my point.
<_Vi>
In a big series of `if(num == <comptime_int>) return <comptime_int>;`, is it advisable to place popular variants at the top or optimiser would shuffle them anyway?
<Barabas>
I once 'optimized' something from a virtual function call to just calling a function pointer. Thinking that would be less lookups... but eh... it was twice as slow xD
<Tetralux>
I'd suggest you always help the optimizer in any way you can.
<mq32>
Barabas: c++ can optimize most virtual function calls away if the type is inferrable
<Barabas>
It wasn't.
<Tetralux>
Isn't a virt call the same as calling a fn ptr?
<mq32>
Tetralux, double dispatch
<Tetralux>
Except with one extra vtable lookup potentially.
<mq32>
you look up the vtable, then look up the fnptr
<mq32>
but: vtable can be cached for a whole function or even call tree
<Barabas>
Yeah, that's probably why the virtual function was faster.
<Tetralux>
That sounds like their just the same - except that the compiler set it up and so can optimize it to a static call.
<Barabas>
virtual function call is
<Tetralux>
In which case, "optimizing" to a fn ptr call would end up with manual-fn-ptr-call vs optimized-to-static-call
<Barabas>
vtable->function(args)
<Tetralux>
i.e: get rid of the fn ptr altogether.
<Barabas>
kinda... plus some offset
<Tetralux>
You want everything to be static calls.
<Tetralux>
Everything.
<Barabas>
sure
<Barabas>
but a virtual function call is not static... unless it knows what actual type it is.
<Tetralux>
That's why I avoid them :)
<Barabas>
duh
<Barabas>
We use them a lot at work, because we mock out half the things for unit testing =|
<Barabas>
And then you get into arguments about making classes final and ugh
<Tetralux>
Yeah just make everything static. xD
<Tetralux>
It's so much easier.
<Tetralux>
And faster.
<Tetralux>
If you're gonna complicate things with abstractions - use ones that are actually good to begin with.
<via>
would it be possible to instead of having the concept of interfaces use function pointers to instead build them at comptime like generics? like an outstream that takes in a comptime writeFn
<Tetralux>
That's my ideal scenario.
<Tetralux>
I believe gonz_ has a way of doing that now.
<fengb>
Yes, comptime duck typing works pretty well
<via>
i mean, i haven't tried it, is there anything in the language preventing that? also specifically maybe having the fact that its async or not be comptime?
<fengb>
I allow any var that matches instream or outstream
LargeEpsilon has quit [Ping timeout: 276 seconds]
<via>
i'm not clear on how thats working, is that type checked at compile time?
_Vi has quit [Ping timeout: 265 seconds]
<gustav_o>
What do you guys think about "Default Struct Field Values" for C structs? That way one can initialize a C struct in zig just like in C (omitting fields that should be 0)
<via>
fengb: if that works, i still think a genericed stream interface would look better, so that function type signatures indicate what its actually taking
LargeEpsilon has joined #zig
avoidr has joined #zig
<fengb>
via: yeah it’s typechecked by ensuring the method exists
<fengb>
Not the best type checking. There’s a proposal for comptime checked types
LargeEpsilon has quit [Ping timeout: 240 seconds]
<via>
cool
<via>
it occured to me since i wrote what i did that comptime generic streams won't work, because everywhere that wanted to take a stream would need to know what function it writes with
gustav_o has quit [Remote host closed the connection]
_Vi has joined #zig
mahmudov has joined #zig
ntgg has joined #zig
dec0de has joined #zig
<dec0de>
Hey guys, can I help you with the website? I am a programmer and I really like the idea of zig! But the website needs some work, maybe I can help on that? (Feee ofcourse)
<dec0de>
*free
<nrdmn>
dec0de: what do you think could be improved?
<dec0de>
The design layout and everything, right now it looks like a html only site
<dec0de>
While the top bar looks good, the text as no margin, which makes it harder to read
<donpdonp>
dec0de: it might be better to simply fork the site, make some edits, then post a link here saying Hey doesnt this look better?
<nrdmn>
it is a html only site (not counting css). No Javascript, no serverside processing.
<nrdmn>
I think there could be something done about the legibility, but that's up to Andrew to decide
marijnfs has joined #zig
<nrdmn>
the paragraph headings kinda disappear when scrolling quickly over the main page
andrewrk has joined #zig
<traviss>
via: what your twitch channel?
ntgg has quit [Ping timeout: 240 seconds]
<dec0de>
Guys, I am not looking into making a heavy slow loading site
<andrewrk>
dec0de, if you're looking for "blessing" before starting on such a project, you won't get one. your options are to do such work no-strings-attached and hope it gets merged, or to be content with status quo
<mq32>
wb andrewrk!
<andrewrk>
thanks. the hard drive on my home server finally died and I had to move some stuff
<andrewrk>
lost all my music, most recent backup is years old :(
<konv>
damn
<konv>
also no js is good
<andrewrk>
I want to point out the entire home page is 22 KB transferred with a cold cache
itsMontoya has joined #zig
<mq32>
damn, my sympathies! lost a lot of projects due to a dropbox bugs years ago. sucked...
<itsMontoya>
Hey andrewrk, do you have a slack and/or discord for Zig? Or is IRC the primary?
<mq32>
is this the right way to use resume/suspend?
<mq32>
(i know it's not the intended one)
<andrewrk>
mq32, in your comment you suggest that storing frames in main() instead of the heap is problematic - actually the way you have it now is better
<andrewrk>
why heap allocate when you don't need to?
<mq32>
yeah for my example it works with storing it in main
<andrewrk>
unless in a real usage, main() would return and you want the frames to live
<mq32>
but for a more dynamic system (with different coroutines/thread functions)
<mq32>
so when i have something like "player_loop" and "enemy_loop"
<andrewrk>
that's a neat example
<mq32>
those functions would have different frames, but could be suspended with the same scheduler logic
<mq32>
but yeah, you're right. for the example, non-heap allocation is the right thing to do
kllr_sbstn has joined #zig
<mq32>
i'm still not happy with the solution in my snippet. probably improving the whole code until i am :D
<itsMontoya>
Is there any documentation on time lib?
<itsMontoya>
Like it's available funcs/structs
<Tetralux>
Nothing for anything, basically still.
<andrewrk>
I've an idea to make std lib docs happen soon
<Tetralux>
But `var t = time.Timer.start(); var time_since_start = t.read();` is useful to know :)
<Tetralux>
.. time_since_starts is in nanos
<mq32>
<andrewrk> I've an idea to make std lib docs happen soon
<mq32>
♥
<companion_cube>
sr.ht has this cool feature of hyperlinks between source files, wonder if the stdlib docs could have something similar…
<Sahnvour>
andrewrk: can we get more details ?
<andrewrk>
Sahnvour, stage1 dump json. self-hosted code parse & format into docs
<andrewrk>
the process will be to do the stage1 json dump multiple times, and the self-hosted code will merge multiple & process multiple dumps ("multibuilds")
<andrewrk>
this way at least a large portion of the code can get re-used when we self-host
<andrewrk>
this will also help with IDE integration until self-hosted is available
<itsMontoya>
Would you mind nudging me in the right direction?
<andrewrk>
itsMontoya, your addSlow function is resuming itself, it may as well be written to just do time.sleep(ns); x += 1; - you're not actually taking advantage of async functions
<andrewrk>
we also have std.time.ns_per_s
<itsMontoya>
So what I wanted to simulate was a long task and waiting for it
<itsMontoya>
Maybe I had another thread
<itsMontoya>
do long task
<itsMontoya>
and I could call await on it from the main thread
<itsMontoya>
So I figured that was how I was supposed to handle it
<andrewrk>
itsMontoya, look at @typeOf(frame), I think you may be surprised
<mq32>
<andrewrk> Sahnvour, stage1 dump json. self-hosted code parse & format into docs
<mq32>
this is a cool approach for "multibuilds"
<andrewrk>
mq32, this way inferred error sets, for example, will be correct even if the set is different across windows and linux
<itsMontoya>
Even though I'm not utilizing async per-say. How would I need to adjust this?
<mq32>
i imagine some documentation where for each function, there is a marker like "Win32: error{OutOfSpace}, Linux: error{OutOfSpace,OutOfTIme}"
<andrewrk>
itsMontoya, the idea is to do the work on another thread right?
<itsMontoya>
The next step is forking a thread, making the work occur on that thread
<itsMontoya>
YEa
<andrewrk>
did you see the code from the video at the time that I linked to?
<itsMontoya>
I'll watch it now
<andrewrk>
just that one frame, look at the code
<itsMontoya>
I have the screen open and I was referencing the code
<itsMontoya>
sleepThreadRun?
<andrewrk>
you can actually make a function `switchToAnotherThread();` with zig's async
<itsMontoya>
OH
<itsMontoya>
I see how you did it
<andrewrk>
this will be especially useful with e.g. switchToGuiThread();
<itsMontoya>
$ zig run main.zig
<itsMontoya>
1 + 2 + 3 + 4 = 10
<itsMontoya>
Yay!
<andrewrk>
scientes, I'm going to try to merge 1 commit from your SIMD branch into zig per day
<mq32>
that sounds like basic math is still working :D
<itsMontoya>
mq32, aysnc math in another thread :D
<mq32>
^^
<andrewrk>
`await` and `return` are lock-free and thread-safe; go nuts
<itsMontoya>
Whoa!
<andrewrk>
also `suspend` and `resume`, which don't even require an atomic instruction
<itsMontoya>
Does zig have interfaces or impl?
<andrewrk>
no
<andrewrk>
that part of the language is not stable
<Sahnvour>
andrewrk: just updated to master and I get `lib\std\debug.zig:227:9: error: invalid builtin function: 'atomicRmw'` when building libuserland, on windows
<kllr_sbstn>
andrewrk: is there any reason why there are consts for e and pi (in std.math) but not for M_PI_2, M_PI_4, M_SQRT2 and so on? I could create a pull request for that
<Sahnvour>
itsMontoya: this concerns zig's std lib, the error I get is from the stage1 compiler
<itsMontoya>
OH! Sorry
<Sahnvour>
leaving for tonight, will investigate tomorrow if I find some time
<Sahnvour>
no problem :)
<itsMontoya>
Have a nice evening friend!
marijnfs has quit [Quit: WeeChat 2.6]
mahmudov has quit [Ping timeout: 240 seconds]
Barabas has quit [Ping timeout: 260 seconds]
ntgg has joined #zig
<andrewrk>
Sahnvour: I think you're hitting the MSVC bad codegen bug
<andrewrk>
I had to change the CI server to MinSizeRel to work around this
mahmudov has joined #zig
<andrewrk>
I looked at the relevant code and I don't think we're invoking UB. It appears to be a legit bug that Microsoft has acknowledged and is fixing
dingenskirchen has quit [Remote host closed the connection]
ltriant has joined #zig
kllr_sbstn has quit [Remote host closed the connection]