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/
<andrewrk> that was over a year ago, maybe 2
<daurnimator> Looks like there is no way for me to reply to your issue
<andrewrk> nothing is going to happen unless some wheels make some loud squeaks
<daurnimator> andrewrk: I get the feeling this is something to backchannel at conferences....
<andrewrk> I was rather thinking of holding their children hostage
<andrewrk> j/k
<pixelherodev> Aren't they engineers? What are the odds they even *have* families?
<pixelherodev> Uh
<pixelherodev> Oh wait
<pixelherodev> I see now what that was in response to
<pixelherodev> :P
<mikdusan> that webpage kinda feels like a video game
<pixelherodev> mq32, thanks for that interrupt cleanup, much more readable now :)
tridactyla has quit [*.net *.split]
tracernz has quit [*.net *.split]
tracernz has joined #zig
tridactyla has joined #zig
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 265 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
<pixelherodev> Was there an open issue for extending the standard library to import from the root source file in freestanding mode?
<pixelherodev> Or was that just a discussion we had here?
<daurnimator> andrewrk: did you ever look at my fifo paste?
<pixelherodev> andrewrk, I'm just about done with a blog post on Zig, would you like to look it over and give thoughts before I publish?
Ichorio has quit [Ping timeout: 250 seconds]
<daurnimator> pixelherodev: please do link once public :)
<pixelherodev> For sure!
<andrewrk> pixelherodev, sure
marijnfs_ has joined #zig
<pixelherodev> There an email to send it too?
<pixelherodev> Gah! s/too/to
<pixelherodev> Never mind, found it from your blog :)
marijnfs has quit [Ping timeout: 268 seconds]
<andrewrk> you could also check any one of the 4,622 commits in the zig git log :P
<andrewrk> got it
<pixelherodev> That was fast
<saskwach> Ok, I've read https://ziglang.org/documentation/master/#Arrays and I have questions.
<saskwach> Can someone explain the difference between []u8, [_]u8, [*]u8, and [2]u8, and in what contexts each is valid?
<saskwach> Or point me at something that does?
<daurnimator> saskwach: [] is a slice. which is a pointer and a length
<daurnimator> saskwach: [_] is an inferred length array. only valid when creating an array literal
<daurnimator> saskwach: [*] is a pointer to an unknown number of items
<daurnimator> saskwach: [2] is an array of length 2 (not a pointer to an array: but two elements of the type)
<daurnimator> saskwach: https://ziglang.org/documentation/master/#Pointers is probably the best docs on all these (excluding [_])
<saskwach> Ok, so if I have a function that wants to process an array of, say 10 bools, it would have `arr: [10]bool` in its parameters, but if I want it to accept an arbitrary number of bools I'd have it take `slice: []bool`?
<daurnimator> saskwach: sure
<saskwach> Oh, hmm, so there's no such thing as an array of void pointers in Zig?
<daurnimator> saskwach: whats a 'void pointer' for your definition here...
<saskwach> Oh, those aren't void pointers.
<saskwach> I was confused by "T must have a known size, which means that it cannot be c_void "
<saskwach> but c_void isn't pointer to void, it's actual `void`.
<daurnimator> yup
<saskwach> Oh, is it true that `[100]void` takes up no memory?
<daurnimator> saskwach: I think so. same with e.g `[100]u0`
<saskwach> Also, if I have a struct that contains an array of bools that I want initialized to true, my reading of the docs is that I can do...
<saskwach> fn Foo(num: usize) type { return struct { stuff: [num]bool = [_]bool{ true } ** num; }; }
<daurnimator> saskwach: sounds correct to me
<saskwach> It seems to make the array const though.
<daurnimator> saskwach: your instance is probably const. did you do `const a = Foo(100);` ?
<saskwach> If I have a method in the struct that tries to set `self.stuff[0] = false`, I get errors about assigning to const.
<saskwach> Nope, `var`
<saskwach> I'm pretty sure...
<saskwach> checking
<daurnimator> saskwach: can you paste your code? (FWIW godbolt supports running zig so good for a pastebin)
<saskwach> fancy
<saskwach> Umm, I might have rewritten it since then.
<saskwach> I will the next time I manage to reproduce it.
<saskwach> I'm also a little confused about structs. Here's the set of rules I've inferred: If it's a member that takes up memory at runtime, it ends with a comma; if it's a method, it ends with its closing curly brace, and if it's a nested struct, it ends with a semicolon. Is that right?
<saskwach> Also, those three things can be mixed in with each other inside a struct?
<daurnimator> saskwach: https://godbolt.org/z/SpTdfd
<saskwach> daurnimator, Huh, I must have done something differently. Thanks.
<daurnimator> andrewrk: why is sockaddr_un now part of IpAddress??
<andrewrk> daurnimator, where do you see this?
<andrewrk> it's the other way around. I had incorrectly done this with os.sockaddr, fixed in 0de862e8bafce9a58c1018e9b6f81b3d17279c10. see that commit msg
<daurnimator> andrewrk: "Previously I had made it a union ofsockaddr_in, sockaddr_in6, and sockaddr_un. The new abstraction forthis is now `std.net.IpAddress`."
<daurnimator> Ah looks like the code is fine
<andrewrk> yes the new abstraction for it is IpAddress, *and* it no longer incorrectly has UNIX domain sockets in there
<daurnimator> That'll teach me for just reading the commit message :p
<andrewrk> yeah I mean in your defense, it was wrong for a long time
<daurnimator> andrewrk: so the general thing when it comes to sockaddr, is that sockaddr_storage is everything except sockaddr_un. and then the customary name of sockaddr_any is everything including sockaddr_un
<andrewrk> pixelherodev, oops, I got distracted. reading now
<pixelherodev> No worries :)
<daurnimator> andrewrk: so std.net now has TcpServer .... but really there's only a couple of things that make it not also a valid unix socket server. the main thing being that it takes an IpAddress instead of a sockaddr....
<andrewrk> daurnimator, sounds like a nice improvement
<daurnimator> andrewrk: so I'd probably rename it to StreamServer or something.....
<daurnimator> or even ConnectionOrientatedServer...
<daurnimator> naming is hard.
<andrewrk> net.Server if it supports virtually every protocol
<daurnimator> andrewrk: sometimes you want to do e.g. connection-less UDP
<daurnimator> or multicast
<daurnimator> not everything fits the same paradigm/set of methods
<saskwach> I'm trying to print an array with gdb, and it's pegged my CPU.
<saskwach> This is...interesting.
<saskwach> It's 100 elements long.
<andrewrk> I can't reproduce this macos CI failure locally
muffindrake has quit [Ping timeout: 250 seconds]
muffindrake has joined #zig
<mikdusan> perhaps they bumped something on azure. yml file selects 'macOS 10.14' and I seriously doubt they began with SDK 10.15, yet failing logs show SDK 10.15 in being used?
<mikdusan> unfortunately a successful build doesn't tell me which SDK was used
<mikdusan> seems like Xcode 10.3 is being used for a build, against SDK 10.15; <-- this is not standard. Xcode 10.3 is supposed to have SDK 10.14
<mikdusan> and i'm thinking gcc-8.3.0 can't handle SDK 10.15 either
muffindrake has quit [Quit: muffindrake]
muffindrake has joined #zig
plumm has quit [Quit: Lost terminal]
_whitelogger has joined #zig
chemist69_ has quit [Ping timeout: 250 seconds]
chemist69 has joined #zig
ltriant has quit [Quit: leaving]
_whitelogger has joined #zig
<andrewrk> mikdusan, ah, nice find
<daurnimator> andrewrk: shouldn't you be in bed? :P
<andrewrk> probably
LargeEpsilon has joined #zig
LargeEpsilon has quit [Ping timeout: 265 seconds]
LargeEpsilon has joined #zig
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
marijnfs_ has quit [Quit: WeeChat 2.6]
_whitelogger has joined #zig
<pixelherodev> That's the post I mentioned regarding Zig
<pixelherodev> Note that, while the post itself works, and the /index.html works, for some inexplicable reason going to the main page (https://pixelherodev.github.io) gives a 404.
<euantor> I don't get a 404 on the index pixelherodev
<pixelherodev> ... never mind then
<pixelherodev> Huh, just started showing up for me
doublex has joined #zig
dantix has joined #zig
dantix has quit [Quit: Quit]
dantix has joined #zig
jjido has joined #zig
LargeEpsilon has quit [Ping timeout: 276 seconds]
return0e has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
return0e has joined #zig
joethephish has joined #zig
joethephish has quit [Remote host closed the connection]
joethephish has joined #zig
<joethephish> Anyone watched any of Jonathan Blow's latest Jai programming stream? He's demoing how to do some metaprogramming by making a general purpose argument parser (that can fill a struct with arguments based on the types).
<joethephish> I'd been excited about Jai but now when I watch this stream I just think about how much more elegant it would be written in Zig! In this case of this stream there’s sooo much stuff that would be way better with Zig’s comptime features, and error handling too.
<joethephish> https://www.youtube.com/watch?v=TwqXTf7VfZk <-- if you're interested
<joethephish> I find it interesting given that I think some Zig features were inspired by some Jai stuff?
dantix has quit [Ping timeout: 268 seconds]
jjido has joined #zig
ky1ko has quit [Ping timeout: 268 seconds]
dantix has joined #zig
ky1ko has joined #zig
FireFox317 has joined #zig
<FireFox317> pixelherodev: Nice post!
<pixelherodev> Thanks!
ntgg has joined #zig
<ntgg> is there a way to use -femit-docs with zig build?
dantix has quit [Ping timeout: 240 seconds]
FireFox317 has quit [Remote host closed the connection]
joethephish has quit [Remote host closed the connection]
ntgg has quit [Ping timeout: 240 seconds]
LargeEpsilon has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ichorio has joined #zig
waleee-cl has joined #zig
jjido has joined #zig
LargeEpsilon has quit [Ping timeout: 265 seconds]
<bgiannan> I built zig to investigate a compiler bug but i'm getting `Unable to dump stack trace: FileNotFound`. Am I missing something? The error being: `Assertion failed at /Users/giann/incoming/zig/src/analyze.cpp:5367 in type_has_bits.`
<bgiannan> ah found it, it doesn't like empty enum
LargeEpsilon has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
ntgg has joined #zig
mahmudov has joined #zig
riba has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ntgg has quit [Ping timeout: 246 seconds]
dimenus has joined #zig
<dimenus> is it expected to pass optimization flags and debug status in cflags when using build.zig?
<dimenus> or should that really come from the build options?
<andrewrk> typically the only flag you should be passing is -std
<andrewrk> everything that makes sense to propagate to C flags does already
<andrewrk> you can see this with --verbose-cc
<dimenus> getting up and running for embedded stuff on zig is so easy :)
<dimenus> well done
<andrewrk> :)
<andrewrk> there are a lot of open issues, but I think we're on the right track
<dimenus> is there an easy way to force a rebuild of your artifacts?
<andrewrk> not really. are you trying to use one of the --verbose flags?
<dimenus> yep
<dimenus> i can delete the cache, but that's not a good idea ( i spose i can just delete my artifact)
<andrewrk> you could make an edit that modifies the checksum
saskwach has quit [Disconnected by services]
saskwach has joined #zig
<saskwach> I figured out what was wrong with my build. I'm hitting https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=943623
<andrewrk> goodness, that's a rather show stopping bug
<saskwach> Looks like llvm-9-dev is broken on Sid right now.
<andrewrk> apt.llvm.org has sid support
<saskwach> My plan is to just roll back to the previous version.
<saskwach> I'm kinda surprised they released the package like that though. It's hard to imagine how any tests passed when nothing links.
riba has quit [Ping timeout: 240 seconds]
<saskwach> Looks like the version in experimental has it fixed. I'll try that.
<saskwach> Yep, looks like that worked.
saskwach has quit [Quit: Leaving]
LargeEpsilon_ has joined #zig
ntgg has joined #zig
LargeEpsilon has quit [Ping timeout: 240 seconds]
LargeEpsilon_ has quit [Ping timeout: 268 seconds]
return0e_ has joined #zig
<andrewrk> pixelherodev, are you going to submit your blog article to any news aggregation sites?
jjido has joined #zig
fsateler has quit [Read error: Connection reset by peer]
fsateler has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dimenus> andrewrk: did you run into an issue when using llvm-objcopy where .text* didn't end up at the beginning of the image?
<dimenus> in most linker scripts I see for rpi3, .text begins at 0x80000 but in yours it's 0x0
<andrewrk> dimenus, you're probably looking at examples intended to be used with boot loader
<andrewrk> the boot loader itself will start at 0x0
<andrewrk> in my project the app itself is its own bootloader
<dimenus> andrewrk:
<dimenus> <dimenus> well done
<dimenus> oops
<dimenus> this is just a base kernel
<pixelherodev> andrewrk, such as?
<andrewrk> https://www.reddit.com/r/Zig/ for a start
Ekho has quit [Quit: An alternate universe was just created where I didn't leave. But here, I left you. I'm sorry.]
jjido has joined #zig
Ekho has joined #zig
Ekho has quit [Max SendQ exceeded]
<pixelherodev> I'll do that soon, yeah
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
doublex has quit [Ping timeout: 245 seconds]
<dimenus> andrewrk: here's my repo https://git.sr.ht/~dimenus/zos, just trying to figure out why kernel8-csrc.img packs the code up to the beginning of the binary (which is expected)
<dimenus> while kernel8.img does not (this is the zig binary)
<dimenus> the *.elf files both show that the .text section begins at 0x80000
Ekho has joined #zig
<dimenus> both call the same linker script
kenaryn has joined #zig
Ekho has quit [Max SendQ exceeded]
return0e_ has quit [Ping timeout: 240 seconds]
<kenaryn> Hello people, I have a very simple question and yet I think it is necessary for me to ask it anyway in order to be less ignorant (that is the pessimist way to say I need to learn): please what does it mean "out of the box"? e.g. Zig supports building for WebAssembly out of the box.
ntgg has quit [Ping timeout: 252 seconds]
ntgg has joined #zig
Ekho has joined #zig
<andrewrk> kenaryn, it means that you need nothing except to unzip a tarball from ziglang.org/download, no other installation steps
<andrewrk> it also means that your system's configuration will not affect whether or not this feature is available
<kenaryn> Is is equivalent to an pre-built binary?
doublex has joined #zig
<andrewrk> the download page has pre-built binaries as well as source tarballs
<kenaryn> Allright, thank you for your explanation :)
<kenaryn> I have another question, is it a desired behaviour to NOT print the 'n/n test "my test name"... OK' input after successful tests for the last builds?
<kenaryn> Because there is now a little assymetry with the official documentation.
<kenaryn> sorry for the french, unsymmetry*
<andrewrk> good point
<andrewrk> recently I made this output more of a "progress bar" when stderr is a terminal
<kenaryn> Yes, it looks like a --quiet mode :)
<kenaryn> But it is understable, you like keeping a high signal/ratio like you said two weeks ago.
<kenaryn> understandable*
<kenaryn> high signal/noise ratio, sorry for the awkwardness
<andrewrk> mikdusan, it's also weird that it only has this error on util.cpp. that's not the first time we #include <stdlib.h> - other .cpp files do it
<mikdusan> interesting. i'll examine a local build here and see if some .cpp files have different flags
<pixelherodev> andrewrk, title suggestion for Reddit?
clktmr has joined #zig
<andrewrk> doesn't your blog post have a title?
<pixelherodev> Yes, but it's also not a very good one :P
<pixelherodev> Literally just called it "programming languages" because it was 3 AM and I figured "I'll give it a real title later" and then I forgot to do that
<andrewrk> mikdusan, I fiddled with the #include order in 790d439ce2288 and that apparently fixed it
<kenaryn> It is of low importance but into the subsection https://ziglang.org/documentation/master/#Names the TitleCaseTypeName is commonly known as PascalCase (i.e. PascalCaseTypeName). Perhaps, it would be more meaninful for a portion of programmers who read the subsection.
<mikdusan> andrewrk: include-order seems to have fixed the latest running CI build,
<andrewrk> mikdusan, I guess this is a bug in apple's libc that happens if you #include <stdlib.h> before anything else
<mikdusan> i suspect gcc830 is built against a particular SDK version and while it could be built against a different one, i think there is a kind of "binding" maybe related to gcc fixincludes, and figuring stuff out and it stays that way
<mikdusan> and yes i'm sure if we really spent the time, #include_next would be something involved here :)
saskwach has joined #zig
<saskwach> Is there more to building the docs than `zig build docs`? It seems to be running a bunch of tests that fail when I do it.
<dimenus> andrewrk: i should have just looked directly at your repo, that answer my questions I think
wootehfoot has joined #zig
<mikdusan> saskwach: not really. it's usually pretty easy to build docs. maybe post an error log
<saskwach> That's the output of "zig build docs"
<mikdusan> saskwach: i am only guessing, is your `zig` executable the same one built from your git workspace?
<saskwach> Yep, it is.
<saskwach> I just rebuilt/reinstalled it, to be sure.
<saskwach> Same error.
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
<waleee-cl> pixelherodev: great article
<waleee-cl> for those that don't frequent /r/zig,
<pixelherodev> waleee-cl, thanks!
<pixelherodev> Pretty sure I posted the link here this morning though ;)
<waleee-cl> oh, sorry. I swear I saw andrewrk asking about an article not that far ago in the irc logs
danielvu has joined #zig
<waleee-cl> ok, it was the reddit post he asked about
<pixelherodev> He was asking if I was going to post it there, yeah
danielvu has quit [Client Quit]
danielvu has joined #zig
casaca has quit [Ping timeout: 268 seconds]
casaca has joined #zig
<companion_cube> surprised that ddevault help proofread this, I thought he didn't like anything with templates
<companion_cube> /generics
<pixelherodev> From what I've seen, he doesn't so much have a problem with generics as much as he does a problem with their effect on some languages - though of course, I'm not Drew, so it might be best to just ask him directly :)
<companion_cube> that'd quickly degenerate into a flamewar ^^
<saskwach> pixelherodev, our PL stories are very similar, though I expect mine is a bit longer.
<saskwach> Also, nicely written post.
<pixelherodev> Thanks!
<pixelherodev> companion_cube, I don't think "Hey Drew, given your article on generics and Go, do you think generics are inherently bad?" would devolve into a flame war, but I also don't feel comfortable talking about someone who's not in the chat, so let's end this here please
<companion_cube> :D
<saskwach> msg pixelherodev Oh, and D and Ada.
casaca has quit [Ping timeout: 265 seconds]
<saskwach> Well, I'm bad at typing.
casaca has joined #zig
<saskwach> I feel like there's another language category that doesn't get a lot of discussion: size.
<saskwach> C++ is a BIG language, as is Rust.
<saskwach> C is relatively small, though it's got a lot more surface area than one would think from casual use.
<companion_cube> rust isn't *that* big
<saskwach> Erlang is a small language.
<s-ol> hey, how do i define a function in a function? at comptime of course.
<saskwach> Rust isn't C++ big (yet) but it's got enough large/complex features that it gives me the same feeling as writing in C++.
<saskwach> Anyway, Zig feels like a small language so far.
<s-ol> im writing a function that wraps a C function, which takes a callback argument. I would like to implement the callback and forward to the zig handler provided to me as an argument (with different arguments)
<pixelherodev> saskwach, that's part of what I was referring to when I mentioned simplicity
<s-ol> so what I would want is for the function to be emitted at the call site, much like that printf example from the zig docs
return0e_ has joined #zig
<saskwach> pixelherodev: Yeah, I figured. It's just not an aspect of languages that gets talked about a lot. I think it gets lost in the high level/low level and static/dynamic, weak/strong discussions.
<companion_cube> saskwach: depends on what you call "size", too: size of the spec, of the compiler, of the base installation package, of the executables (if any)… ?
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
<saskwach> companion_cube: I'm using the very subjective measure of how much of my own internal RAM I need to dedicate to language features in order to write effectively in it.
<companion_cube> that's primarily a function of familiarity though :)
<saskwach> Granted.
<saskwach> Except with C++, where I'd argue that there are just huge numbers of things to keep in mind all the time.
<andrewrk> I made this last night, thought people might find it interesting: https://github.com/andrewrk/zig-async-demo/tree/master/sieve
<saskwach> The first time I wrote C++ code was over 25 years ago.
<companion_cube> exactly, no one can keep all of C++ in mind
<saskwach> andrewrk: I wrote exactly the same application last night. It will be interesting to see how our implementations differ.
<companion_cube> reminds me of the classic "fringe equality" problem, which is not trivial if you don't have coroutines or something like that
<saskwach> Ok, not exactly the same. Mine isn't parallel.
kllr_sbstn has joined #zig
<saskwach> How much interest is there among people who are not me in getting Zig code running on AVRs? Also, has anyone tried generating AVR code?
<andrewrk> saskwach, yours is probably closer to the "Idiomatic Zig Implementation" which is noted at the bottom of that README
<andrewrk> AVR is still an LLVM experimental target, your best bet at this point will be teaming up with Rust community and other LLVM frontends to try to get better support in LLVM
<saskwach> andrewrk: Ah, I hadn't gotten that far down yet and was wondering what sieve2.zig was for.
<andrewrk> it is planned to have non-llvm backends in the self hosted compiler eventually, but that's a long way off
<pixelherodev> So what, going to use a separate IR? :P
<pixelherodev> Joking, joking; we've had this discussion before I think
<saskwach> Ugh, making backends for all the targets I use is such a huge task.
<andrewrk> indeed. shortest path to better AVR support is via LLVM.
<saskwach> I didn't see this discussion, and now I'm curious. What's the plan for the self-hosted compiler? Obviously generating LLVM IR gets you an awful lot. GCC hooks?
<andrewrk> first priority will be feature parity with stage1, so that we can start shipping self-hosted instead
<andrewrk> that means LLVM
FireFox317 has joined #zig
<andrewrk> but then the next thing will be an experimental x86_64-only non-llvm backend whose primary objective is Gotta Go Fast
<andrewrk> compilation speed, not runtime speed. for debug builds
<saskwach> Ah, ok.
<andrewrk> but once this is done there will probably be a build option to disable llvm support altogether, since there's utility in a fully self-hosted compiler
<companion_cube> full wasm!!
<andrewrk> a compiler with llvm disabled will have translat-c and c compilation features unavailable
<andrewrk> which is why these components of the language/compiler will be an "extension"
<andrewrk> ...in the official language reference, I meant to add
<andrewrk> s/reference/specification/
<fengb> Super late: C++ doesn’t feel big to start with, e.g. even classes can be mostly ignored. Rust has a lot of conceptual overhead you need to even begin
<companion_cube> I super disagree, but well
<pixelherodev> ... I'm going to experiment with writing a translate-c that doesn't depend on LLVM later
<companion_cube> the basics of rust are tiny: sum types, functions, impl blocks
casaca has quit [Ping timeout: 265 seconds]
<saskwach> fengb: agreed. C++'s complexity sneaks up on you, while Rust's is right up there in your face the whole time.
<pixelherodev> That's not necessarily a bad thing
<pixelherodev> With Rust, once you overcome the initial hurdle, you're pretty much set
<fengb> Not sure that's a plus or minus, since C++ is notoriously complicated for all the wrong reasons :P
<companion_cube> C++ starts directly with the whole of C, and adds a ton of things on top (including a change in the semantics of `struct`)
<saskwach> I'm not judging. I like Rust a heck of a lot better than I like C++.
<pixelherodev> C++ will just keep attacking out of nowhere like some sort of bad ninja stereotype
<fengb> Rust is more honest
<companion_cube> cargo + error messages makes beginning in rust easier than in C++, imho
<pixelherodev> Okay, companion_cube, that's blatantly false
<pixelherodev> C++ is NOT a superset of C; C is NOT a subset of C++
<pixelherodev> They are *entirely different languages*
casaca has joined #zig
<companion_cube> pixelherodev: C++ is almost a superset of C, barring a few stricter conversion rules
<pixelherodev> No, it's not.
<companion_cube> wait, what?
<pixelherodev> It's almost a superset of C99.
<companion_cube> is C99 not C?
<pixelherodev> It's a superset of a defunct C standard
<saskwach> pixelherodev: that's true, but C++ was heavily marketed as a superset of C.
<pixelherodev> And it *was*, originally.
<saskwach> It was nearly. I don't know if it ever was, except maybe when it had a different name.
<pixelherodev> C++ isn't the only language that's been changing though; C's gotten better
<andrewrk> pixelherodev, write a C compiler in Zig that can compile stage1. yo dawg
<companion_cube> even nowadays, what features of C are not in C++?
<companion_cube> (_generic maybe, but, lol)
<pixelherodev> Read the link I posted, it contains a few
<pixelherodev> Sorry, C++ is more of a superset of C *89*, not 99
<andrewrk> yeah C++ diverged, especially with C11 :(
<pixelherodev> C99 code isn't valid C++ anymore
<saskwach> It's not so much about features that are present or missing. It's got very different semantics in some cases.
<pixelherodev> To quote floooh: `C++ is also not a ‘replacement’ or a ‘successor’ to C, it’s a fork which slowly ‘devolved’ its C subset into a slightly different dialect of C without much hope that the two languages can ever be united again`
<companion_cube> and they shouldn't. still, "classic" C is mostly similar to C++ (even the new int/bool types are)
<pixelherodev> C99 struct initialization is missing in C++
<companion_cube> ohhh, right
<companion_cube> that's a good point indeed.
<saskwach> I think the biggest mistake C++ made, and one of the things that attracts me to Zig, is that you can't really call C++ libraries from C code. There's no consistent ABI. So C is still the least common denominator even if you accept the premise that C++ is a better language.
<companion_cube> interesting how rust is simpler than both C and C++ when it comes to struct initialization…
<saskwach> It's that modern language thing.
<companion_cube> yeah
<companion_cube> also, there's only `if`, not `if` and `?`
<companion_cube> see, rust is simple ;)
<pixelherodev> Well yes, but by that definition C isn't simple either
<pixelherodev> It has some legacy features like trigrams
<pixelherodev> The comma operator is another fun one
<saskwach> In over a decade of writing C professionally, I have only once even considered using trigraphs.
<pixelherodev> It's actually pretty trivial to come up with a ~3 line snippet of valid C that will confuse most C programmers
<companion_cube> I don't think C is simple indeed
<saskwach> Not to say C is simple. It's got a lot of hidden surprises.
<pixelherodev> I completely agree. C isn't *simple*; it's just *more* simple than e.g. C++, combined with literally unmatchable portability
<companion_cube> simpler than C++ is kind of a given :D
<pixelherodev> :P
<fengb> C's spec was too simple to actually map to the real world
<saskwach> C is designed to be easy to implement. That may have been the single most effective thing any language designer has ever done, when it comes to gaining wide deployment.
<fengb> I wonder how it'd have evolved if it actually had a reference compiler that was dejure standard
<andrewrk> semi related, I'm thinking that in debug mode, zig should pass -fsanitize=undefined when building C objects
<saskwach> Seems like a good idea.
<saskwach> UBSan isn't a panacea, but it's sure better than nothing.
<andrewrk> it's what zig already does for zig code
<andrewrk> to do this, zig will have to provide its own lib for diagnostics handling. clang emits calls to e.g. __ubsan_handle_pointer_overflow
<bgiannan> How do i convert a []u8 to a [*]const u8 ?
qazo has quit [Read error: Connection reset by peer]
<andrewrk> bgiannan, foo.ptr
<bgiannan> ah of course silly me
<bgiannan> thx
<s-ol> is there a way to call a function with an argument sequence that is comptime known, but generic?
<s-ol> like, I have the TypeInfo of the function and I have matching values somewhere and I want to call it
<andrewrk> zig catching undefined behavior in C code: https://clbin.com/DMBmN
FireFox317 has quit [Ping timeout: 240 seconds]
ntgg has quit [Ping timeout: 268 seconds]
<bgiannan> how do i tell zig where to look for a non-system dll ?
<daurnimator> pixelherodev: your blog post needs a better title
<wilsonk> pixelherodev: better title...but good blog post though :-D
saskwach has quit [Disconnected by services]
saskwach has joined #zig
saskwach has left #zig ["Leaving"]
saskwach has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
mahmudov has quit [Ping timeout: 268 seconds]
kenaryn has quit [Quit: WeeChat 2.3]
wootehfoot has quit [Read error: Connection reset by peer]
<dimenus> andrewrk: nice
<daurnimator> andrewrk: how does that trap work on windows?
<andrewrk> daurnimator, it's an illegal instruction
<andrewrk> I want to get this SIMD stuff merged, what do you think about this plan that I outlined?
<daurnimator> andrewrk: ah: so it runs an invalid instruction in order to have the OS itself kick off the SIGILL equivalent?
<andrewrk> yes
bjorob has joined #zig
<daurnimator> I guess we still need to set up windows exception handling?
bjorob has quit [Client Quit]
<andrewrk> we have it already for segfaults, it might already just work for illegal instruction
bjorob has joined #zig
<daurnimator> huh. TIL AddVectoredExceptionHandler
<andrewrk> another strategy which I have not yet explored is providing impls for __ubsan_handle_* functions instead of using -fsanitize-trap, which would then call the panic handler
<andrewrk> this would be better for freestanding, where an illegal instruction on the hardware isn't helpful
<andrewrk> unless maybe there's an interrupt for it? but that's hardware dependent
<daurnimator> would we want to use them for normal "safe" modes too?
<andrewrk> yes I think it makes sense to enable ubsan for safe modes when compiling C code
<dimenus> andrewrk: since I'm really in need of the SIMD PR, should I assist with peeling pieces off if I can or just leave it to scientes?
<andrewrk> dimenus, that would help a lot if you wanted to get involved
<andrewrk> idea is to break it into smaller more mergable pieces
<dimenus> makes sense
<dimenus> i'll give it a shot
<dimenus> andrewrk: when would a resolved type not have bits at runtime?
mahmudov has joined #zig
ltriant has joined #zig
<andrewrk> dimenus, void, u0, struct with no fields
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dimenus> duh
<daurnimator> andrewrk: have you looked into oss-fuzz at all?
dimenus has quit [Remote host closed the connection]
dimenus has joined #zig