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/
<daurnimator> pmwhite: just put `comptime` in front of your call
ur5us_ has joined #zig
<daurnimator> but also, you should rarely if even be making inline functions
ur5us has quit [Ping timeout: 244 seconds]
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xentec_ is now known as xentec
ur5us_ has quit [Ping timeout: 240 seconds]
<foobles> when building zig, how do you enable compiler stacktraces?
<fraktor> This is kind of a dumb question, but how does one allocate a slice of a certain size?
dnmllr has joined #zig
<fraktor> Nevermind, I just found allocator.alloc.
nephele has quit [Ping timeout: 244 seconds]
nephele_ has joined #zig
ur5us_ has joined #zig
nephele_ is now known as nephele
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 240 seconds]
slice has joined #zig
<fraktor> Is there a standard library function to parse an int, or should I roll my own?
<tdeo> std.fmt.parseInt
<tdeo> fraktor: ^
<fraktor> I'm dumb. That makes sense.
drp has joined #zig
<pmwhite> daurnimator: I didn't make the inline functions. Some of the functions in `fmt/parse_float.zig` are inline.
slice has quit [Quit: zzz]
dnmllr has quit [Ping timeout: 240 seconds]
antaoiseach has joined #zig
dddddd has quit [Ping timeout: 260 seconds]
plumm has quit [Ping timeout: 256 seconds]
<foobles> andrewrk how do you track an assertion failure? it's giving me the line number of the souce code being analyzed, but not the assertion itself
<foobles> within the compiler
<tdeo> are you running in a debugger?
<foobles> no, i cant figure out how to do that with msvc :/
<foobles> oh wait, i have a lead
<foobles> a wait, nope :/
<andrewrk> unfortunately on windows you have to build llvm,clang,and lld in debug mode in order to build zig in debug mode
<andrewrk> which is a pretty tall order
<andrewrk> on posix systems you can do release llvm,clang,lld + debug zig
<andrewrk> this is a limitation of stage1, not self-hosted
<andrewrk> really, it's a limitation of MSVC
<foobles> interesting
<foobles> somehow i got a debugger to work
<foobles> idk how
<foobles> just using CLion
<foobles> so is there no way to track a failing assert?
daex has quit [Quit: /me 's znc kicks the bucket]
daex has joined #zig
<foobles> it has an experimental third party debugger for msvc somehow
<tdeo> usually the debugger takes you right to the assert when it happens
<tdeo> also the line is printed if it's built in debug mode
foobles has quit [Ping timeout: 245 seconds]
ur5us_ has quit [Ping timeout: 244 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
slice has joined #zig
ave_ has quit [Read error: Connection reset by peer]
ave_ has joined #zig
<antaoiseach> andrewrk: the redis async talk was very nicely done ... helped clear some of my own doubts post the master doc
<antaoiseach> we should have more of those if and when possible!
<antaoiseach> from other people as well!
cole-h has quit [Quit: Goodbye]
pystub has joined #zig
antaoiseach has left #zig [#zig]
metaleap has joined #zig
mattmurr has quit [Ping timeout: 260 seconds]
mattmurr has joined #zig
pystub has quit [Ping timeout: 260 seconds]
<drp> antaoiseach: Do you have a link to the talk? All I can find are redis modules with zig.
<drp> ah I found it on the subreddit - https://www.youtube.com/watch?v=zeLToGnjIUM
<wilsonk> is the second talk available yet?
dermetfan has joined #zig
wootehfoot has joined #zig
<andrewrk> wilsonk, the 2 talks are:
<andrewrk> writing redis modules in zig: https://www.youtube.com/watch?v=Csz26Wy9Ses
<andrewrk> Modeling Data Concurrency with Asynchronous I/O in Zig: https://www.youtube.com/watch?v=zeLToGnjIUM
<wilsonk> great, thanks. Watched the second and not the first but I will watch it now. Great job on the async i/o talk :)
<andrewrk> thanks! glad you liked it :)
<daurnimator> I think it was good for a zig audience; I'm not sure if it had enough context for people not already familiar with zig (or even the concept of function colours)
demizer has quit [Ping timeout: 260 seconds]
ifreund has joined #zig
slice has quit [Remote host closed the connection]
slice has joined #zig
<alexnask> foobles I would suggest using WSL if you can to debug compiler bugs
slurpie has quit [Ping timeout: 260 seconds]
dddddd has joined #zig
demizer has joined #zig
WilhelmVonWeiner has quit [Ping timeout: 272 seconds]
bgiannan has quit [Ping timeout: 272 seconds]
wootehfoot has quit [Ping timeout: 260 seconds]
FireFox317 has joined #zig
wootehfoot has joined #zig
slice has quit [Quit: zzz]
ur5us_ has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
dddddd_ has joined #zig
dddddd has quit [Ping timeout: 246 seconds]
dddddd__ has joined #zig
dddddd_ has quit [Ping timeout: 264 seconds]
dddddd__ has quit [Ping timeout: 240 seconds]
dddddd__ has joined #zig
dddddd__ is now known as dddddd
ur5us_ has quit [Ping timeout: 252 seconds]
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
dermetfan has quit [Ping timeout: 272 seconds]
kradnoel has joined #zig
dimenus has joined #zig
dimenus has quit [Quit: WeeChat 2.8]
bgiannan has joined #zig
<drp> When I print out a float I'm getting unexpected notation. in C I would get 42.185970 with float. in zig I get 4.21859664e+01 with f32
dermetfan has joined #zig
<drp> I'm guessing std.io.getStdOut().outStream().print format floats?
<ikskuh> yep
<ikskuh> use {d} instead of {}
<mikdusan> things like `{d}` or `{d:.2}` work
<ikskuh> to get decimal notation
<drp> that did the trick, thank you
ifreund has quit [Ping timeout: 240 seconds]
ifreund has joined #zig
<fengb> Hmm... should we have a more intelligent default float output?
<ikskuh> i think the idea was that the default output of "{}" can be parsed exactly by parseFloat again
<ikskuh> so it's a sane default for serialization
decentpenguin has joined #zig
<drp> I'm just going through a C exercise book turning the exercises into zig, the docs say that f32 is equivalent to float in C but I am getting very slightly different numbers.
<drp> C outputs 42.185970 but Zig outputs 42.185966
<ikskuh> that's okay, there are floating point modes and everything
<ikskuh> what's the calculation?
<ikskuh> and how much steps does it have?
<ikskuh> hehe
<ikskuh> use f64 in zig ;)
<ikskuh> C does promotion here to double
<afontain_> that's sneaky
<ifreund> classic C
<ikskuh> yep
<ikskuh> C does a wonderful lot of casting
<ikskuh> "1" is of type int
<ifreund> it's not promotion though right? 1760.0 is a double literal
<ikskuh> so if you do "uint8_t(1) + 1" the result is "int"
<ifreund> 1760.0f is a float
<drp> interestingly enough I get nearly there now 42.185969
<ifreund> yup, that's what i thought
<drp> Any reason why zig and c would be off by 0.000001 if they're both 64 bit floats now?
<ikskuh> floating point magic
<ikskuh> because the formatting algorithm is different probably
<drp> cool, thank you for your help, I was guessing that I was getting messed about by casting, I would not have guessed that the C compiler would promote a float to a double
<ifreund> drp: it isn't, 1760.0 is a double
<ifreund> if you want a float you need the 'f' at the end
<drp> if I make the kilometers variable a double in the C code then I get the exact same value as the zig code!
<drp> I can make the zig code create the same output as the C example if I do f64 math and then cast it to an f32
foobles has joined #zig
<ikskuh> > My hobby: injecting code into other processes and changing the floating-point rounding mode on some threads
<ikskuh> hihiihi
factormystic has quit [Read error: Connection reset by peer]
<oats> I kinda almost wish identifiers for types and values didn't share the same namespace sometimes :P
waleee-cl has joined #zig
factormystic has joined #zig
antaoiseach has joined #zig
<fengb> Different namespaces for everything
<fengb> if (if) (struct if) else (struct else)
<ikskuh> the heck
<foobles> that file i linked is hilarious
<foobles> its basically exactly what you are saying
<foobles> since rust has different namespaces for variables, functions, types, macros, etc.
<foobles> afaik
<oats> heh
<ikskuh> fn union() {
<ikskuh> union union<'union> { union: &'union union<'union>, }
<ikskuh> }
<ikskuh> union!
<oats> lol the u8 function
<mikdusan> onion
<oats> I guess one namespace makes things simpler :P
<foobles> `let val = !((|(..):(_,_),__@_|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})`
<foobles> i love that site :D
<mikdusan> brainfuck is easier to read
metaleap has quit [Quit: Leaving]
<antaoiseach> Is that a butthole?
<oats> huh, that emoji is displayed *perfectly* in my terminal
<oats> I don't remember changing anything font related
<oats> interesting
<antaoiseach> hahaha... no, (_,_) I mean
<fengb> Your default font is probably emoji aware. Most are nowadays
<fengb> Thanks a lot unicode
<ikskuh> ♥
<oats> hm
<companion_cube> 💞
<companion_cube> emojis are life
<antaoiseach> Hah
<ikskuh> ⌚
kradnoel has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<ikskuh> has someone integrated openssl or another ssl library into zig yet?
xackus has joined #zig
metaleap has joined #zig
slice has joined #zig
cole-h has joined #zig
antaoiseach has left #zig [#zig]
Akuli has joined #zig
daex_ has joined #zig
daex has quit [Ping timeout: 264 seconds]
dermetfan has quit [Ping timeout: 246 seconds]
alexander92 has joined #zig
<alexander92> oi guys
<alexander92> is zig
<BaroqueLarouche> yes
<alexander92> like us-centered? we had a semiserious discussion in #nim if nim is a bit too europe-centric, because the author is german (giving zig as an example with an us author)
metaleap has quit [Quit: Leaving]
<fengb> Andrew is US based
<fengb> A lot of contributors are European though
FireFox317 has quit [Ping timeout: 256 seconds]
<ikskuh> at least some people here are europe-based :D
livcd has joined #zig
<livcd> So what was the answer?
<alexander92> hm, we have some american and asian people in nim as well, but i'd agree most are european/russians
<alexander92> yeah i wonder if there is corelation between the author and the community location
<alexander92> in languages
<fengb> Majority of the contributors are European, but BDFL is US
<ikskuh> nah, i don't think so
rzezeski has joined #zig
<alexander92> not too important anyway :)
<fengb> https://github.com/ziglang/zig/pulse lots of new people on this list >_>
<alexander92> also wanted to congrat for the incremental linker idea , sounds exciting
slurpie has joined #zig
<drp> "if nim is a bit too europe-centric" I can never parse these questions properly, too europe-centric for what? It reads like "if (x > ) {}"
<drp> I've just started to log into this channel so I might be missing historical context to the question?
<mikdusan> a quick glance at contrib list, in no real order: USA, Finland, Australia, Denmark, New Zealand, France, Poland, The Netherlands, Brazil, Japan, Canada, England, Portugal, Germany
<alexander92> drp: yeah, i am not very good in english
<alexander92> i mean, more europe-centric than us-centric
<alexander92> people sometimes assume that it's easier for us-centered communities/tech to become succesful
pystub has joined #zig
<fengb> I'm actually surprised at the diversity. A lot of US based communities are quite insular
slice has quit [Quit: zzz]
dermetfan has joined #zig
andrewrk has quit [Ping timeout: 260 seconds]
andrewrk has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> I see it as a strength. If an entire geographical region doesn't care about the project, which is not inherently tied to any geographical region, something has gone wrong
<andrewrk> s/it/diversity/
<fengb> But... 'murica 🇱🇷
<andrewrk> no
<andrewrk> also just pre-empting, absolutely no US politics discussion here
<mikdusan> need someone from Antarctica to step up :)
<andrewrk> I think people probably already knew that instinctively
<gonz_> "community" is overrated
<alexnask> fengb, You sure do love that liberian flag lol
metaleap has joined #zig
metaleap has quit [Client Quit]
metaleap has joined #zig
metaleap has quit [Client Quit]
slice has joined #zig
FireFox317 has joined #zig
metaleap has joined #zig
demizer has quit [Quit: WeeChat 2.7.1]
SimonNa has quit [Ping timeout: 246 seconds]
SimonNa has joined #zig
waleee-cl has joined #zig
<oats> Is it considered good practice to let the error set be inferred for an error union return type?
<oats> I'm kind of surprised by how common this is, I would think it would be better to make errors more explicit where possible
<andrewrk> oats, generally, in implementations, inferred error sets are fair game, but for public facing APIs, explicit error sets make sense. this will become more obvious once we have a faster compiler + package manager and everybody starts using each others' code
<oats> andrewrk: sorry, not sure what you mean by "implementations"
<andrewrk> by "implementations" I mean functions that are not part of the public API surface area
<oats> aha, gotcha
<alexander92> andrewrk sorry, i was trying to think of purely social community effects
<andrewrk> nobody did anything wrong, no need to apologise
<alexander92> thank you
<alexander92> otherwise, i wanted to ask, do you plan on supporting parallel compilation of zig code in the future?
<andrewrk> yes
<andrewrk> I've been designing the self-hosted backend with that in mind
<alexander92> i am following with interest ongoing IC work in several langs and it seems to me it would be much simpler to support both
<andrewrk> IC=?
<alexander92> incremental compilation
<andrewrk> ah
<alexander92> ok, i have to take a look: i am trying to build a small (one day reusable for different langs) pipeline based on that idea
<andrewrk> right now I'm solving the incremental compilation aspect of the problem. I plan to tackle parallel compilation as a separate task
<alexander92> and wanted to see what different languages do
<andrewrk> however I do plan to tackle parallel compilation up front, before doing most of the language implementation
<alexander92> cool: i have to take a look at that backend, are you rewriting the whole compiler?
<andrewrk> yes
<andrewrk> I'm hoping to get https://github.com/ziglang/zig/pull/5307 merged by the end of this week
<andrewrk> once it's working I will also do a live coding stream and demo it a bit
<alexander92> one thing i notice in my small work until now is that designing a language around those limitations from the beginning makes much simpler to define such a pipeline
<andrewrk> I completely agree
<alexander92> were there any big blocks in current zig's design
<andrewrk> what do you have working so far?
<alexander92> oh, it's a complete toy: i mostly have my plan
<andrewrk> yes in the stage1 compiler, the way result locations interact with inferred comptime expressions is kludgy and buggy
<alexander92> and some initial code, but i plan to PoC it this month
<andrewrk> in the rewrite I have switched from SSA to SSAT (Single Static Assignment Tree) form and it seems promising to solve the problem
<alexander92> yeah, i've heard the complaint that usually compile time code is very hard to support
<andrewrk> in zig you can mix compile time and runtime code in the same expression
<andrewrk> it's all quite intuitive from the coder's perspective, but the way stage1 compiler is designed, some expressions end up being tricky for the compiler
<alexander92> exciting
<alexander92> yeah, i have to play more with it
<alexander92> in my pipeline, i start from a subset of nim and want to eventually add exactly such a subset X of the CT stuff which is easy to express efficiently
<andrewrk> anyway sounds like you might enjoy catching that live coding stream. I'll announce it a few hours in advance here before I start
<andrewrk> twitch.tv/andrewrok
<alexander92> my idea was that one day, i'll separate the pipeline + dsl-s for some of the passes as a library and reuse it for different small languages
<alexander92> as it seems to me once one solves well such an architecture problem, it should be easy to reuse its conventions and tooling around: something like a `rails for compilers` (sounds horrible)
<alexander92> thank you, i'll subscribe
<ifreund> nice, i was worried that I had missed a stream last night cause I went to bed too early
<andrewrk> ifreund, I've moved past the chin-scratching phase and on to the "fix compile errors" phase
<alexander92> so anyway, what i wondered was if you feel that your architecture can be more generally applicable to many languages
<oats> 99% of everything I do is the chin-scratching phase
<ifreund> andrewrk: that's super exciting!
<alexander92> or if those things are inevitably too limiting to language design
<andrewrk> alexander92, it's a good question. I'm not sure yet. ZIR will be designed to the semantics of the zig language, but it's possible those semantics may be conducive to be the backend of a different language
<fengb> I skip the chin scratching and straight to banging my head against the wall
ifreund has quit [Ping timeout: 258 seconds]
<alexander92> andrewrk i dont know it :(
<alexander92> an IR can match certain interface , similarly to the module system and typechecking(e.g. only local)
ifreund has joined #zig
<alexander92> and if those components match a general API, one might be still able to reuse a lib with a general architecture around them, but maybe this wouldn't work well at all
<alexander92> too much abstraction leaks
<andrewrk> ZIR is pretty zig specific. e.g. there is an instruction which does an @import of a .zig file
<oats> huh, "instruction"
<alexander92> but thats the point: in a general lib, IR-s can have hooks for that (importing module) etc
<oats> is ZIR closer to an assembly language or a structured programming language
<andrewrk> you can also observe how early it is in its development from the lack of more passing test cases
<alexander92> i imagine it like rails: you write down your passes and data structures following the convention of the lib, they just have to fit there (e.g. my typechecking pass is connected here and runs in parallel optionally producing artifact) etc
<alexander92> and you get the other tooling for free
<alexander92> but one needs to just prototype an example, too confusing, sorry
<andrewrk> rails assumes too much IMO
<alexander92> yeah, its mostly an example
<oats> huh, that's really interesting looking
<oats> I see x86 register names in there?
<oats> is this code specific to x86?
<andrewrk> oats, zig supports inline assembly
<andrewrk> the second test case there is specific to linux x86_64 yes
<oats> ahhh
<andrewrk> that's the simplest hello world I could come up with
<alexander92> but you can make the toolkit give you more with a bit of integration: lang server, debuginfo, repl
<alexander92> so that would be worth it for small languages/research prototypes/etc
alexander92 is now known as alehander92
<Dominic[m]> I've just received a micro:bit. I'm hoping to exclusively program it in zig. I've found https://github.com/markfirmware/zig-bare-metal-microbit but I'm a bit confused about where the magic numbers came from. I was hoping someone could give me a clue which components I need to read the docs for. Maybe the wrong community.
ur5us_ has joined #zig
foobles has quit [Remote host closed the connection]
pystub has quit [Ping timeout: 265 seconds]
FireFox317 has quit [Remote host closed the connection]
<Dominic[m]> ah, figured out the magic numbers. Cool :) I assumed the CPU, but it's not that.
<xackus> andrewrk, have you set up the Zig Software Foundation? i noticed it named in your redisconf talk
<fengb> The secret is out! 🙃
ifreund has quit [Quit: WeeChat 2.8]
ifreund has joined #zig
slice has quit [Quit: zzz]
decentpenguin has quit [Quit: decentpenguin]
<mikdusan> > "not yet, still waiting on 501(c)(3) status to make an official announcement"
wootehfoot has quit [Quit: Leaving]
watzon has joined #zig
<watzon> andrewrk: stream idea. Try to pull some Crystal people over by figuring out how to cross compile a Crystal project using Zig.
<watzon> Right now Crystal's "cross compilation" creates an object file and gives you a command to run on the target machine. It would be awesome if you could just use Zig instead.
<watzon> I tried it already, but my clang knowledge is lacking and I think zig cc might be missing some things necessary to make it work.
Akuli has quit [Quit: Leaving]
SimonNa has quit [Ping timeout: 256 seconds]
SimonNa has joined #zig
<oats> I've never really checked out crystal
<oats> what's it's schtick?
<oats> s/it's/its
<oats> inglish is dum
<fengb> Syntax is Ruby like
<BaroqueLarouche> Native Ruby basically
<oats> nifty
<oats> GC'd then?
<oats> it's kinda cool how llvm has enabled so many interesting programming languages to sprout up
<companion_cube> GC'd, and with fibers
<companion_cube> so, quite fast, and yet quite high level
<oats> fibers?
<companion_cube> goroutines, if you will
<ifreund> thread abstraction like go routines
<companion_cube> green threads
<oats> ah, neat
<companion_cube> no async/await
<companion_cube> yeah it seems nice for writing websites or whatnot
lunamn0 has joined #zig
metaleap has quit [Quit: Leaving]
lunamn has quit [Ping timeout: 258 seconds]
lunamn0 is now known as lunamn
nore has quit [Ping timeout: 258 seconds]
dermetfan has quit [Ping timeout: 272 seconds]
ur5us_ has quit [Ping timeout: 260 seconds]
ifreund has quit [Ping timeout: 265 seconds]
slowtyper has quit [Ping timeout: 260 seconds]
foobles has joined #zig
nore has joined #zig
gazler_ has quit [Ping timeout: 252 seconds]
ur5us_ has joined #zig
gazler has joined #zig
slice has joined #zig
drp has quit [Quit: Leaving]