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/
wootehfoot has quit [Ping timeout: 258 seconds]
AndroidKK has joined #zig
AndroidKitKat has quit [Ping timeout: 265 seconds]
_Vi has quit [Ping timeout: 256 seconds]
alexnask has quit [Ping timeout: 240 seconds]
alexnask has joined #zig
Snetry has quit [Ping timeout: 240 seconds]
Snetry has joined #zig
mahmudov has quit [Remote host closed the connection]
_whitelogger has joined #zig
alexnask has quit [Ping timeout: 260 seconds]
dingenskirchen has quit [Ping timeout: 256 seconds]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 255 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
adamkowalski has joined #zig
<adamkowalski> can I use a inline for to generate the branches of a switch statement?
<adamkowalski> in the D language it looks like this https://dlang.org/spec/version.html
<adamkowalski> specifically example 4
<daurnimator> adamkowalski: you'd just do an `if`.
<adamkowalski> how do you mean?
<adamkowalski> wouldn't there be a huge performance penalty for checking each branch with an if versus a switch?
<adamkowalski> and having the switch ensures that you've covered all the cases of the union
<daurnimator> wouldn't your `inline for` already do that?
adamkowalski has quit [Ping timeout: 256 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Client Quit]
dingenskirchen has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 260 seconds]
MajorLag is now known as tgschultz
ur5us has joined #zig
betawaffle has quit [Quit: Oh noes, my ZNC!]
betawaffle has joined #zig
alichay has joined #zig
_Vi has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
return0e_ has joined #zig
knebulae has quit [Read error: Connection reset by peer]
knebulae has joined #zig
dddddd has quit [Ping timeout: 258 seconds]
sammich has quit [Ping timeout: 256 seconds]
sammich has joined #zig
<Snektron> adamkowalski, im pretty sure llvm can optimize if else chains
_Vi has quit [Ping timeout: 272 seconds]
alexnask has joined #zig
<pixelherodev> ^
<pixelherodev> IMO the programmer should *never* focus on optimization, and they should leave it to the compiler
<mq32> pixelherodev: i don't think that's true
<pixelherodev> At least until the thing *works*, at which point the *only* optimizations performed should be done using profiling tools, and the optimizations should be done on their own branch so that if the compiler learns to do them they can be reverted
<pixelherodev> That is, programmers shouldn't ever think, "well, the compiler's bad at doing X so I'm going to change the code to Y"
<pixelherodev> Optimizing is, whether you like it or not (I honestly don't know how I feel but I'm leaning towards don't), the job of the compiler these days
<pixelherodev> and programmers tend to be really bad at it (myself included) unless they have actual numbers in front of them
<mq32> pixelherodev, the compiler can only improve code generation, but is not possible to improve algorithmic complexity
<mq32> and that's where the real optimizations are
<mq32> like
<pixelherodev> Hence, once the code works, use profiling tools
<pixelherodev> But not *before*
<pixelherodev> Because all too often you'll find you actually made performance worse because of e.g. misjudging what's bottlenecking the code or overestimating the performance impact of a function etc
<mq32> for(int y = 0; y < height; y++) for(int x = 0; x < width; x++) { int offset = width * y + x; … }
<mq32> vs
<mq32> int offset = 0; for(int y = 0; y < height; y++) for(int x = 0; x < width; x++, offset++) { … }
<mq32> small change, HUGE difference in performance
<pixelherodev> Anyways, it's ... 5:30 AM but I have the day off today so I'm gonna crash now. Laters!
<mq32> haha, sleep well
* mq32 is driving to work
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
forgot-password has joined #zig
<forgot-password> Is it possible to allocate bytes with a certain alignment?
<mq32> sure
<forgot-password> `try allocator.alloc(u8 align(8), n)` produces a syntax error
<mq32> https://ziglang.org/documentation/master/std/#std;mem.Allocator.alignedAlloc
<forgot-password> But that syntax is used to specify the type of a variable in the documentation
<forgot-password> Ahh
<forgot-password> I really need to start using the new documentation, thank you :)
forgot-password has quit [Quit: leaving]
_whitelogger has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
_Vi has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
slurpie has quit [Ping timeout: 258 seconds]
<mq32> sometimes MMIO-Code is crazy
<mq32> SCB.CFSR = SCB.CFSR;
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 256 seconds]
frmdstryr has joined #zig
<shakesoda> mq32: i definitely have some loops i can refactor to move offset out like that, heh
<shakesoda> not sure if any of them are *also* in a place where it'd make a difference, but I should make a note about it
<shakesoda> pixelherodev: optimization is absolutely your business as a programmer, compilers aren't and cannot be magic.
<shakesoda> one should certainly use profilers (and otherwise benchmarking) to guide this process, though, you're blind to anything you don't actually measure.
<mq32> shakesoda: if you are on embedded, it can make a real difference
<mq32> i get like 20-50% perf boost out of my inner loops
<shakesoda> mq32: I'm not on embedded, but I certainly have loops like this that have significant load
<mq32> yeah, on PC it can also make a differnce, but not as hard as on embedded
<mq32> but the loops are a nice example why compiler optimization is something you have to keep in mind, but also not too much, because your compiler can't do magic
<shakesoda> suppose it's probably extra helpful knowledge for my projects that run on the rpi zero
<shakesoda> the weakest machine i target by a lot
<mq32> yep, true
* mq32 successfully implemented cooperative multithreading on a cortex-m3 CPU *happy*
<shakesoda> \o/
<BaroqueLarouche> Neat!
<mq32> but i wonder, it looks like it has some memory corruption :(
<mq32> even though stack pointer stays the same
marmotini_ has joined #zig
<mq32> okay, i got my memory corruption fixed :)
dddddd has joined #zig
<alexnask> :D
<mq32> now fuck everything up with switching tasks in a timer interrupt
<shakesoda> classic
<shakesoda> mq32: what are you making?
<shakesoda> multitasking on a cortex m3 is an unusual need, i am curious
<mq32> we have a kind of "operating system" in our company, but only single threaded
<mq32> and a graphics driver that is written so that no operation takes longer than 10ms or it is executed in chunks
<mq32> this makes the code a horrible mess and unmaintainable
waleee-cl has joined #zig
<mq32> and my idea was to make a semi-cooperative graphics driver
<mq32> where you can tell the system:
<mq32> "please run the graphics driver for up to 8 ms"
<shakesoda> makes sense
<shakesoda> sounds quite interesting
<mq32> yeah, it's fun
<mq32> i asked if i could improve the stuff because i needed to get my head free from the huge piece of stuff i've written in the last two years
zfoo_ has joined #zig
<fengb> You adding Zig into the toolchain? :P
<mq32> fengb: no, only C++
<mq32> i'd love to, but i'm also reasonable and will wait for that until 1.0 ;)
<fengb> Hey you gotta introduce new tech
<fengb> Then leave the company 2 months later
<fengb> 'ts the cool thing to do
<mq32> already doing this :D
<mq32> well, introducing new tech
<mq32> like "c++11"
adamkowalski has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
<BaroqueLarouche> THE FUTURE (with added echo)
<mq32> yep :D
<mq32> btw, nice find @ HSLuv!
<BaroqueLarouche> yup, found that on Hacker News
frmdstryr has quit [Remote host closed the connection]
TheLemonMan has joined #zig
wilsonk has quit [Ping timeout: 265 seconds]
wilsonk has joined #zig
adamkowalski has quit [Ping timeout: 255 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Read error: No route to host]
marmotini_ has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 255 seconds]
gonzus has joined #zig
<TheLemonMan> andrewrk, is the event/loop stuff tested on osx?
<andrewrk> TheLemonMan, no
_Vi has quit [Ping timeout: 272 seconds]
<andrewrk> I only have the behavioral tests passing with --test-evented-io on linux currently
<andrewrk> the event loop implementation supports kqueue/osx from back when I implemented it, but it needs the glue of waitUntilFdReadable/waitUntilFdWritable
<andrewrk> same situation for windows io completion ports
<andrewrk> that's what's blocking from adding CI testing for evented stuff, is to get std lib tests passing in evented mode on all OS's, and without any flakiness
<TheLemonMan> hmm, NetBSD and OpenBSD kqueue() does not support EVFILT_USER, I was looking to add an alternative pipe-based way to talk forth and back between threads
<andrewrk> sounds reasonable
<TheLemonMan> but I'll wait till OSX (and FreeBSD) event loop is working
<andrewrk> personally I would prioritize linux/windows/darwin/freebsd before netbsd and openbsd
<andrewrk> in theory the core works, just needs integration with e.g. std.os.read
<andrewrk> and probably some fuzz testing
wilsonk has quit [Ping timeout: 240 seconds]
return0e_ has quit [Remote host closed the connection]
Akuli has joined #zig
marmotini_ has quit [Remote host closed the connection]
<andrewrk> ugh, no gas in my building for 2 days now, can't make tea @_@
<fengb> Get an electric kettle
<andrewrk> I'll just suffer
<shakesoda> electric kettles are a wonderful thing to have
wilsonk has joined #zig
marijnfs__ has joined #zig
marijnfs_ has joined #zig
marijnfs_ has quit [Read error: Connection reset by peer]
marijnfs__ has quit [Ping timeout: 268 seconds]
marijnfs_ has joined #zig
zfoo_ has quit [Ping timeout: 260 seconds]
gonzus has quit [Ping timeout: 240 seconds]
zfoo_ has joined #zig
slurpie has joined #zig
_Vi has joined #zig
gunnarahlberg has joined #zig
adamkowalski has joined #zig
<gunnarahlberg> hi! I've been using IntelliJ for far to many years to even try to get as proficient in Vim
<gunnarahlberg> I've looked at https://github.com/ice1000/intellij-zig and was thinking to resurrect that
mahmudov has joined #zig
<gunnarahlberg> question - will it be feasible to re-implement the https://github.com/ziglang/zig-spec/tree/master/grammar in JFlex just because intelliJ only supports JFlex?
<gunnarahlberg> A don't want to implement a whole lot of stuff, and then realize that the upcoming compiler improvements or langserver integration was the design choice I should have chosen
<gunnarahlberg> I don't want to implement a whole lot of stuff, and then realize that the upcoming compiler improvements or langserver integration was the design choice I should have chosen
<gunnarahlberg> any thoughts on this?
<gunnarahlberg> something like https://github.com/intellij-rust would be a huge undertaking that I am willing to invest in
<gunnarahlberg> but for ziglang of course :)
<TheLemonMan> given enough time everything is feasible heh
<gunnarahlberg> yea, that is curse and blessing of programming :)
adamkowalski has quit [Ping timeout: 256 seconds]
decentpenguin has joined #zig
TheLemonMan has quit [Ping timeout: 265 seconds]
TheLemonMan has joined #zig
marijnfs1 has joined #zig
marijnfs_ has quit [Ping timeout: 258 seconds]
decentpenguin has quit [Ping timeout: 265 seconds]
decentpenguin has joined #zig
gunnarahlberg has quit [Ping timeout: 240 seconds]
txdv has joined #zig
<pmwhite> what is the current state of using C++ from zig?
<BaroqueLarouche> you need a extern "C" interface that you can import with @cImport
marijnfs1 has quit [Ping timeout: 268 seconds]
marijnfs_ has joined #zig
<andrewrk> pmwhite, it's not planned to ever support the C++ (lack of) ABI
<pmwhite> so if the library I'm calling uses vectors and stuff, then I'm in for a lot of pain I guess.
<andrewrk> only if the vectors are part of the API surface
<andrewrk> a C API can wrap an arbitrarily complicated implementation
<pmwhite> Good decision to not support C++. Would it not be true that anything I can wrap in C I can also wrap with Zig? Seems like you are saying not this.
<fengb> C++ can wrap it into a C ABI compatible layer with extern “C”. Zig only talks to C
<fengb> In a way, Zig compiler embeds Clang so it sorta compiles C++ but not in a way that the actual language understands
<andrewrk> heh, coincidentally I am listening to We Are Never Ever Getting Back Together by Taylor Swift with the lyrics "You go talk to your friends, talk to my friends, talk to me"
<pmwhite> So I would need to create a C library, compile it with a compiler that supports the C++ ABI, at which point I can link to the C library from Zig.
<BaroqueLarouche> Zig build system can build C++ files
<andrewrk> 🎵 zig is never ever ever getting C++ API support / 🎵 you go make your C++ talk to C, C code talk to Zig 🎵
<BaroqueLarouche> hahahaha
<andrewrk> pmwhite, yes that's right. zig can build all those files, but actual .zig code can only speak to .c/.h code
<pmwhite> Zig code cannot speak to any .c code that speaks to .cpp code because the .c code is converted to zig code prior to compilation, correct?
<BaroqueLarouche> only the header needs to be pure C
<andrewrk> .c code can't speak to .cpp code either
<shakesoda> friend of mine some years ago managed to get luajit ffi to talk to c++ reasonably well by manually reimplementing name mangling and doing some mangical stuff
<shakesoda> it was horrifying.
slurpie has quit [Ping timeout: 265 seconds]
<shakesoda> it is so, so much more sane to stick to writing a wrapper if needed
<andrewrk> pmwhite, you have your implementation in a .cpp file, and then instead of .hpp make a .h header. Zig can use that
<andrewrk> you can see some examples of this in the zig source repo
<andrewrk> zig_clang.cpp / zig_clang.h
<BaroqueLarouche> once Zig is closer to 1.0, someone should write a Zig backend in SWIG
<BaroqueLarouche> s/in/for
jonathon has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
adamkowalski has joined #zig
jonathon has joined #zig
adamkowalski has quit [Ping timeout: 265 seconds]
zfoo_ has quit [Read error: Connection reset by peer]
marijnfs_ has quit [Ping timeout: 258 seconds]
marijnfs_ has joined #zig
frett27_ has joined #zig
return0e_ has joined #zig
ur5us has joined #zig
return0e_ has quit [Client Quit]
<tdeo> why does SegmentedList both have an .at() and an .uncheckedAt(), only differing by an assert? wouldn't it be better to always assert, as it gets compiled out without safety on?
<andrewrk> perf in safety on builds matters too
<tdeo> ah, ok. it seems like it's the only container with that, but that might be because you can't just reach into the struct and index like you can some of the others
metaleap has joined #zig
Akuli has quit [Quit: Leaving]
frett27_ has quit [Ping timeout: 256 seconds]
mahmudov has quit [Ping timeout: 265 seconds]
decentpenguin has quit [Quit: decentpenguin]
mahmudov has joined #zig
metaleap has quit [Quit: Leaving]
daex_ has quit [Ping timeout: 268 seconds]
daex has joined #zig
return0e_ has joined #zig
slurpie has joined #zig
return0e has quit [Ping timeout: 265 seconds]
return0e has joined #zig
return0e has quit [Client Quit]
marijnfs1 has joined #zig
<Snektron> <pmwhite "so if the library I'm calling us"> Technically you could mimic c++ struct layout with packed structs
<Snektron> Well, for a specific compiler that is
<Snektron> And a specific version of that compiler
marijnfs_ has quit [Ping timeout: 255 seconds]
<Snektron> Its not very good for your mental health though, so i wouldnt recommend it
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> wow, 2 days work came out to: +2,241 −2,240
ur5us has quit [Ping timeout: 256 seconds]
slurpie has quit [Quit: Leaving]
<andrewrk> oh, beautiful, this actuall makes std lib tests with --test-evented-io compile
alexnask has quit [Ping timeout: 256 seconds]
ur5us has joined #zig
marijnfs1 has quit [Ping timeout: 265 seconds]
frmdstryr has joined #zig
mzigora has joined #zig