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/
<mq32> i've just read the https://blog.jfo.click/how-zig-do/ article and i realized: zig is actually a compiler for brainfuck
<mq32> you can comptime unroll and optimize the brainfuck code into a native program
_whitelogger has joined #zig
metaleap has quit [Ping timeout: 268 seconds]
return0e_ has joined #zig
sammich_ has joined #zig
return0e has quit [Read error: Connection reset by peer]
sammich has quit [Remote host closed the connection]
betawaffle has quit [Quit: Oh noes, my ZNC!]
betawaffle has joined #zig
Guest2255 has quit [Quit: Leaving]
metaleap has joined #zig
<andrewrk> mq32, yep and you can even run the brainfuck code at compile-time...
<andrewrk> "how does zig compare to a theoretically perfect programming language?"
metaleap has quit [Quit: Leaving]
daex has quit [Quit: /me 's znc kicks the bucket]
ForLoveOfCats has joined #zig
daex has joined #zig
Xatenev has left #zig [#zig]
ForLoveOfCats has quit [Quit: Konversation terminated!]
alexnask has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
Aruseus has joined #zig
<fengb> Is that a trick question? :P
_whitelogger has joined #zig
LER0ever has joined #zig
_whitelogger has joined #zig
<daurnimator> the stream ended rather abruptly
knebulae has quit [Read error: Connection reset by peer]
Aruseus has quit [Quit: Leaving]
_whitelogger has joined #zig
_whitelogger has joined #zig
mikdusan has quit [Quit: WeeChat 2.6]
<daurnimator> silly (?) idea: should usize on x86_64-linux actually be u63?
mikdusan has joined #zig
<Snektron> Why though
<mikdusan> what does `zig -target-cpu [cpu]` do? should it effect translate-c/@cImport ?
<andrewrk> mikdusan, it does - zig passes -Xclang args to clang to tell it about the cpu
<mikdusan> ah I think I was incorrectly linking -march= to that value
<daurnimator> Snektron: because you can't have an array or address outside of u63
<daurnimator> As long as we know we're dealing with only user-mode addresses or only kernel-mode addresses, then 63 bits is more than enough.
<Snektron> Then you could argue that it should be u48 instead
<daurnimator> 56 bit systems already exist
<daurnimator> 63 bit isn't going to break going forward
<Snektron> I doubt it
<Snektron> Rather introduce a intptr
<daurnimator> Snektron: `usize` *is* `intptr`.
<Snektron> Currently, yes
<andrewrk> usize is uintptr_t
<Snektron> Either that or have a "native word' size type
<Snektron> Either way i don't really think its useful
<daurnimator> FWIW, this came up when I was trying to automatically generate lua bindings for zig libraries. lua only supports 64 bit *signed* integers; so things like an .indexOf() were failing (cause they return a u64)
<daurnimator> s/u64/usize/
metaleap has joined #zig
<daurnimator> and I realised that the 64th bit was always going to be unused
<daurnimator> so it would be stupid to campaign for it to be suppored by lua
_whitelogger has joined #zig
_whitelogger has joined #zig
ur5us has joined #zig
dddddd has quit [Ping timeout: 268 seconds]
jjido has joined #zig
knebulae has joined #zig
ur5us has quit [Ping timeout: 248 seconds]
mikdusan has quit [Quit: WeeChat 2.6]
waleee-cl has joined #zig
<daurnimator> andrewrk: yeah.... so then it would take a u64, not a usize...
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
mahmudov has quit [Ping timeout: 260 seconds]
mikdusan has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mahmudov has joined #zig
jjido has joined #zig
marijnfs has joined #zig
<daurnimator> hmmmm.... @export isn't working for me
<marijnfs> what's the normal way to build and install zig with zig
<marijnfs> zig install just silently does nothing it seems
<daurnimator> marijnfs: hmm? stage2 isn't ready/finished yet
<marijnfs> i see, so it compiles some stuff but no binary yet
<daurnimator> marijnfs: stage2 (the zig compiler written in zig) is far from ready.
<daurnimator> marijnfs: however parts of stage2 are used by the current compiler; e.g. translate-c is written in zig; and linked into "stage0" to make stage1
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<marijnfs> ah thats pretty cool already
<daurnimator> essentially: it parts of zig (the executable) that aren't needed by the zig compiler itself are eligible to be written in *only* zig.
<daurnimator> `zig zen` may be the simplest example of that
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
daurnimator has quit [Ping timeout: 260 seconds]
jjido has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
dingenskirchen has quit [Client Quit]
dingenskirchen has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
daurnimator has joined #zig
<mq32> on the topic earlier: what size does usize have on AVR?
<mq32> AVR has a lot of different pointer sizes
<mq32> 16 bit for data pointers, or (depending on the device) 15,16 or 17 bit for code pointers
<mq32> so you have different pointer size for data- and code segments
dingenskirchen has quit [Remote host closed the connection]
mahmudov has quit [Ping timeout: 272 seconds]
dingenskirchen has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
dddddd has joined #zig
_Vi has joined #zig
LER0ever has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Xatenev has joined #zig
<Xatenev> hello, why does fmt.bufPrint takes a slice as first param and not an array?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
riba has joined #zig
jjido has joined #zig
<metaleap> Xatenev: would have to be a pointer to an array to not write into a temp copy of your passed array (the arg could be stack-allocated-then-discarded-on-return)
<metaleap> and a pointer to an array? that's called a slice =)
<Xatenev> metaleap: understood
<Xatenev> makes sense :)
<Xatenev> metaleap: is it correct that zig does not have post/prefix operators?
<Xatenev> if yes, I cant find them in the docs :P
<Xatenev> post prefix increment operators*
<metaleap> ++ and -- are not included, only += and -=
<Xatenev> I see, thanks !
<Xatenev> sorry, one more question. what is the best practice for constness? I have many structs that e.g. take a *obj type (pointer to obj), i would like it to accept const obj pointers and obj pointers, can i do that?
riba has quit [Ping timeout: 272 seconds]
<Xatenev> I'd have guessed that const pointers would cast down to non const obj pointers just fine but thats not the case :)
<shakesoda> Xatenev: prefer const wherever possible, but note things can cast up to const but not down unless you forcefully cast it away (bad!!!) or copy the object
<Xatenev> shakesoda: understood, thank you
<Xatenev> I am rewriting my raytracer from c to zig, its a pleasurable experience :)
<shakesoda> nice, i've been doing some texture generation and raytracer is on the todo list :)
<shakesoda> porting some of my gamedev libraries has been (slowly, as i learn) in progress, it has been pleasant
<Xatenev> cool
<Xatenev> yea I thought about porting to c++ or rust, but I can't take a lot of pleasure in both languages :( they are just.. to big, you have to waste a lot of time by digging through language features to find out whats the correct way to do something
<Xatenev> when you really just want to focus on your program, zig seems to be a good fit for me here :)
<shakesoda> i found rust incredibly frustrating, but not zig
<shakesoda> zig has everything i like about c, and also improves on most everything i wish were better in c... without bringing in the complicated junk in c++ and rust
<Xatenev> yeah, exactly.
<shakesoda> i've been thinking of zig being to c as rust is to c++
* mq32 just backports a C++ program to Zig and i'm really happy about it
_Vi has quit [Ping timeout: 272 seconds]
<mq32> i can remove intricacy without removing complexity
<shakesoda> mq32: on my list for when zig matures slightly more is doing the same for many of my programs
<shakesoda> hopefully not in too many releases :)
<mq32> yeah, i love zig too much now that i want to continue hacking around in C++
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
forgot-password has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
<forgot-password> Is it still possible to format floats in non-scientific notation? I recall being able to use "{.3}" to do that, but now "{:.3}" prints the scientific notation
alexnask has joined #zig
marijnfs has quit [Ping timeout: 268 seconds]
marmotini_ has joined #zig
<metaleap> {d:3.3} gives 123.456
<metaleap> with a float
<metaleap> so yeah just d prefix even for floats
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
<forgot-password> Oh cool, thanks, I couldn't make that part out in the fmt source :)
<Xatenev> what is the zig way of ignoring a param?
<Xatenev> e.g. for(arr) |_, y| { }
marmotini_ has quit [Ping timeout: 260 seconds]
<mq32> forgot-password: https://ziglang.org/documentation/master/std/#std;fmt.format
<metaleap> Xatenev: that looks right but the arr item comes first, the index second (unlike go's `for i,val := range arr`)
Snetry has quit [Ping timeout: 268 seconds]
marmotini_ has joined #zig
Xatenev has quit [Quit: Leaving.]
forgot-password has quit [Ping timeout: 265 seconds]
mahmudov has joined #zig
Snetry has joined #zig
<betawaffle> is a `?void` return type a good or bad idea?
<fengb> It’s kinda weird. Why not bool?
<andrewrk> ?void can happen in generic code and make sense. but yeah otherwise it seems you want a bool :)
<andrewrk> or maybe even an enum with 2 items
<fengb> Colloquially it’s “null or void” 🙃
<betawaffle> i'm using it for my SDL_Init wrapper
<betawaffle> does anyone have a good idea for how to make sdl errors more zig-friendly?
<andrewrk> betawaffle, maybe this sio_err function from this example can be inspiring: https://ziglang.org/#Integration-with-C-libraries-without-FFIbindings
<betawaffle> but SDL just has garbage string errors
<andrewrk> oh. R.I.P.
<betawaffle> i suppose if that's the case... they don't expect me to handle any of them without crashing. so maybe panic is a reasonable idea?
<andrewrk> I think panic on initialization is very reasonable
<shakesoda> betawaffle: i've always handled sdl errors by bailing if it's anything i can't fix by changing gl context version or so
<shakesoda> i think almost all of them are worth a panic
<shakesoda> certainly every one related to init
Akuli has joined #zig
Snetry has quit [Ping timeout: 272 seconds]
<andrewrk> heh, found this in ziglang.org referrer logs: https://compti.me/
<metaleap> a fellow voidlinuxer and zigger. the dude's got taste
<betawaffle> i don't like zigger
decentpenguin has joined #zig
<metaleap> zigster then
<betawaffle> much better
<metaleap> my zigga =)
<andrewrk> +1, let's avoid a lot of unnecessary problems by avoiding that other word
<metaleap> lol duly noted
<andrewrk> I have a branch with an abstraction to do multiple operations in parallel, with no heap allocation, a nice & clean API, and it is a "zero cost abstraction" for both evented I/O and blocking I/O
<betawaffle> what does that look like?
<andrewrk> example usage: https://clbin.com/VAh9e
<betawaffle> &async?
<fengb> There’s a lot of buzzwords in that sentence :p
<andrewrk> betawaffle, batch.add(&async self.findNativeIncludeDirPosix(allocator)); is equivalent to batch.add(&(async self.findNativeIncludeDirPosix(allocator)));
<andrewrk> it's taking the address of a temporary
<betawaffle> ah, ok
<andrewrk> this function expresses concurrency and will take advantage of it in evented I/O mode, yet also can be compiled with blocking I/O and it would be as if you didn't put the Batch thing in there
<andrewrk> this is what I dreamed of years ago
Snetry has joined #zig
<andrewrk> oops, those awaits are bogus from the example. updated: https://clbin.com/gnEEs
Aruseus has joined #zig
jjido has joined #zig
Xatenev has joined #zig
<Xatenev> metaleap: thanks :) yes I've realized then that that is the way
Aruseus has quit [Quit: Leaving]
Snetry has quit [Ping timeout: 260 seconds]
Snetry has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
benjif has joined #zig
marmotini_ has quit [Remote host closed the connection]
jjido has joined #zig
_Vi has joined #zig
<pixelherodev> "zero cost abstraction" in the C++ way, or for real?
<pixelherodev> That is, is there a comptime cost?
<companion_cube> looks like fork/join
FireFox317 has joined #zig
<FireFox317> that looks so cool andrewrk!
<FireFox317> how is the self-hosted libc detection coming along?
<metaleap> pretty hyped about this async-await story evolving in zig. in c#/ts it blows because infectious/function-colors, and go channels are a right pita to pamper+caress
forgot-password has joined #zig
forgot-password has quit [Client Quit]
decentpenguin has quit [Ping timeout: 240 seconds]
rjtobin has joined #zig
<fengb> I like go channels
mzigora has joined #zig
<jaredmm> cImport creates an assignment to an undefined variable (__builtin_va_list). Is that #515 or me doing something wrong?
moka has joined #zig
moka is now known as Guest59258
Akuli has quit [Quit: Leaving]
mokafolio has quit [Ping timeout: 272 seconds]
Guest59258 is now known as mokafolio
FireFox317 has quit [Ping timeout: 265 seconds]
mzigora has quit [Quit: mzigora]
discip has joined #zig
discip has quit [Remote host closed the connection]
_Vi has quit [Ping timeout: 272 seconds]
metaleap has quit [Quit: Leaving]
metaleap has joined #zig