<daurnimator>
So I've got a FOMU that I want to try and target with zig
<daurnimator>
It came with a riscv core installed on it
<daurnimator>
Trying to figure out the details of how the toolchain works....
mahmudov has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
<andrewrk>
torque, yeah, it's the result of years of working with upstream LLD to get issues resolved, 3 different zig community members sending patches, pinging when we got no response, until finally we have no outstanding patches on top of lld
<andrewrk>
deleting the embedded LLD fork is a sign that we have been a good open source community member
<daurnimator>
:D
<daurnimator>
the cpu target PR is coming at a good time
<daurnimator>
I'm pretty sure this riscv core has almost nothing
lunamn has joined #zig
<andrewrk>
it's ready for a handoff. whenever Layne feels done I'm going to merge the shit out of it
<daurnimator>
last day of conf today :( sadly I was unable to get bitfields working and hence didn't sign up to do a lightning talk
adamkowalski has quit [Remote host closed the connection]
<andrewrk>
bummer. sounds like you had some productive interactions though
<daurnimator>
yep. lots of interesting use cases in front of us
<daurnimator>
as soon as the language stabilises we have a route in front of us to zig in the linux kernel....
<daurnimator>
Probably a 3 year journey
lunamn_ has joined #zig
<andrewrk>
you mean something other than a kernel object?
<andrewrk>
I don't think we need 3 years to make kos
lunamn has quit [Ping timeout: 268 seconds]
<andrewrk>
I'm really happy about #4206 mikdusan
<daurnimator>
andrewrk: aside from bitfields i already can make a .ko :)
AndroidKitKat has joined #zig
<daurnimator>
andrewrk: i mean in terms of writing an actual kernel module in zig and sending it for upstream inclusion. which means every distro needs a zig compiler....
<mikdusan>
yay
waleee-cl has quit [Quit: Connection closed for inactivity]
<AndroidKitKat>
hi there, i'm having some issues getting started with zig. I'm trying to do a simple Hello World, and I'm getting an error, using the examples straight from the website. Here's what I mean: https://waifupaste.moe/raw/dH5.txt
<andrewrk>
daurnimator, ahh that's a good use case
<daurnimator>
your code is zig master. did you download a zig release?
<AndroidKitKat>
Tried using both the official version from Brew on my iMac and a version from COPR on my Fedora box
<AndroidKitKat>
both show me the same issue
<daurnimator>
AndroidKitKat: those are outdated :) you should compile latest zig master yourself or just download a binary from the ziglang.org website
<AndroidKitKat>
huh, okay
<AndroidKitKat>
might want to poke the people at homebrew since it's listed as a method to instal Zig from
<AndroidKitKat>
I'm not very comfortable at all compiling my own software
<andrewrk>
AndroidKitKat, they know - this is what it feels like when a language is highly unstable
<daurnimator>
AndroidKitKat: homebrew (rightfully) only package releases. Your snippet is using new syntax that hasn't made it into a release yet
<andrewrk>
as you can see there are some downsides
<andrewrk>
we have long (6 month) release cycles for now, which favors fast-paced progress towards 1.0.0, but does not favor people trying to use zig for stable day-to-day activities
<AndroidKitKat>
I'm actually starting work a somewhat basic implementation of something like coreutils in zig as a school project. I'll make sure I use proper versions of the language then
<mikdusan>
AndroidKitKat: one neat thing about downloading from ziglang.org, is open langref.html with your browswer. it's exactly in sync and all examples are actually compiled/tested with CI before the tarball is made
ur5us has joined #zig
<andrewrk>
yeah, website doesn't update unless all tests pass for all targets
<AndroidKitKat>
thanks for the information. I'm sure I'll be having more questions, so i'll probably hang out here :>
<andrewrk>
welcome :)
<daurnimator>
AndroidKitKat: please do stick around :_)
<AndroidKitKat>
if you're at all interested in following our progress, we'll have updates here: https://pbui.codes
<AndroidKitKat>
not anything yet but we'll have stuff soon haha
<frmdstryr>
Would it be possible to retain the original stack frame when a frame is suspended and then resumed by the event loop?
<fengb>
That’s a pretty vain acronym :P
<AndroidKitKat>
it's named after our professor haha
<fengb>
No it’s clearly posix bsd
<frmdstryr>
or maybe it's just gdb
<andrewrk>
AndroidKitKat, neat! my suggestion regarding zig would be, when you start working on this, choose the latest version of zig from the download page at the time (e.g. it is currently zig-0.5.0+bac27731e), write down the version number, and stick with that for the whole project
<andrewrk>
then you can choose to upgrade at your own pace (e.g. if still working on it in april you probably would want to upgrade to 0.6.0)
<alva>
AndroidKitKat: the website ends up with light text on light background for me, best to specify a text colour if you specify a background, to ensure that it's readable
<AndroidKitKat>
yeah i was making sure to settle on a version and whatnot. need to get the rest of my team up to speed on stuff.
lunamn_ has quit [Ping timeout: 272 seconds]
<AndroidKitKat>
also alva thanks for the information i will fix that asap
<andrewrk>
I do think that this is a nice use case for zig; the builtin safety and debugging capabilities are helpful for students who don't know how to, e.g. use gdb to get a stack trace
<AndroidKitKat>
our group had originally thought about doing one in go/rust but those have been done to death and we want to make something brand new
<AndroidKitKat>
and learn a lot in the process
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
BaroqueLarouche has joined #zig
<BaroqueLarouche>
AndroidKitKat: がんばって下さい!
<BaroqueLarouche>
(only if your IRC client supports UTF-8)
<AndroidKitKat>
ありがとうございます!
<BaroqueLarouche>
speaking of languages, anybody here speak French or better Québecois tabarnak ?
<Snektron>
I wanted to use Zig for an uni project a few weeks back, but i chose python instead so i could finish the project quickly
<mikdusan>
imagine teaching first-timers with zig vs. c: no more questions about .h vs .c files. or macros. or ordering of global decls. or ... aww shucks I ran out of IRC space
dddddd has quit [Read error: Connection reset by peer]
<BaroqueLarouche>
Zig killed all my hype for C++20 and Jai
ur5us has quit [Ping timeout: 260 seconds]
<AndroidKitKat>
The first language I learned was C++, then python, and i've settled for ruby as my favorite language.
<AndroidKitKat>
hopefully i become pretty intimate with zig tho
<mq32>
<BaroqueLarouche> Zig killed all my hype for C++20 and Jai
<mq32>
+1
<mq32>
now i'm hyped for minor zig updates :D
<fengb>
I do want to see what cool features we could snipe from Jai
<BaroqueLarouche>
my guest is that Zig 1.0 will arrive before all compilers support C++20 properly (including closed platforms like consoles)
<mq32>
heh, that would be awesome
<mq32>
i really wonder how zig will look in 1.0 feature-wise
<andrewrk>
mq32, hopefully not that much different
<andrewrk>
nothing majorly breaking is planned
<mq32>
i hope so too
<andrewrk>
it's going to be a big deal once std lib async I/O is robust
<mq32>
my main problems with zig right now are actual compiler bugs regarding packed structs
<andrewrk>
yes that's high on my priority list
<mq32>
wasn't my intention to boost the priority of that btw
<mq32>
i just wanted to say that i'm really happy with how the language is right now
<mq32>
you can get some cool stuff together pretty quickly
<andrewrk>
I am a little worried about #1717
<mq32>
i already posted some screenshtos/videos of my newest stuff, but here's the actual source code: https://github.com/MasterQ32/SoftRenderLib (Software Rasterizer written in Zig)
<mq32>
andrewrk: yeah i can imagine
<daurnimator>
andrewrk: so I have some freestanding code here that uses string.h... how should that be provided?
<mq32>
daurnimator: you can probably export the used functions from zig and supply string.h yourself
<andrewrk>
daurnimator, elaborate?
<andrewrk>
oh you need some freestanding libc functions?
<mq32>
#1717 would break with a lot of conventions other languages have established (in terms of "functions are declared like vars/consts")
tdeo has quit [Remote host closed the connection]
<andrewrk>
daurnimator, all of libc that is not OS-dependent should be added to lib/std/special/c
<andrewrk>
daurnimator, select a C ABI as part of the target, and then go ahead and add -lc even though it's freestanding
<andrewrk>
might need to add another case in the compiler to enable this. it's already enabled for wasm32-freestanding-musl, which you can see in `zig targets`
<andrewrk>
but we should really be able to support basically any C ABI for any arch for any freestanding OS. especially with the new bring-your-own-OS-layer, we can even have OS-dependent libc functions, which hook into that
<andrewrk>
it would be especially nice with --bundle-libc (which would need to be added; we already have --bundle-compiler-rt), because then your object file would have your zig code, as well as exporting libc functions for external C code to use, and your OS layer would not be duplicated
<andrewrk>
a few little things need to be modified, but zig is extremely well-positioned for this use case
<andrewrk>
I suspect that `const f = fn(a: i32) bool { ... };` will look normal after a few weeks of using it. but it looks scary and different right now
<mq32>
andrewrk, i had the same thing in a language i designed and you get used to that pretty fast
<mq32>
but yeah, it's definitly weird at first
<andrewrk>
qwerty people, is `let` easier to type than `const`? both are pretty comfortable & fast on dvorak
<mq32>
i use that syntax in C++ now pretty often with lambdas as they make nice
<andrewrk>
let seems a lot nicer on qwerty
<mq32>
for me, let has a lot less movement than const which is nice
<mikdusan>
i use 3-fingers to down `let` and 4 to down `const` and they're both fast
<BaroqueLarouche>
function as expression is more consistent with the rest of the language, but yeah it's not a usual syntax
<andrewrk>
it also makes it more obvious how to make traditional generic functions
<mikdusan>
fn expr to me is about the same (and worth it) friction of `const std = @import("std");`
<BaroqueLarouche>
mikdusan: exactly
<andrewrk>
let foo = fn(comptime T: type) { return fn(x: T) T { return x + 1; } }
<andrewrk>
foo(i32)(1)
<mq32>
objective analysis of let vs. const: 10-finger-system makes let pretty easy as you use 2/3 fingers on their natural position, whereas for const you use 2/5 fingers on their natural position
<fengb>
I actually don’t know why Go opted for a different fn define since the syntax is basically there already
<mq32>
i think that's why it feels better to type
<tgschultz>
I prefer const because it makes more sense to my brain, but it's not a big deal.
<andrewrk>
coming from C it's a lot of overhead when you need all these extra tokens: `const`, `fn`, `=`
<andrewrk>
but yeah I think the consistency is worth it
<mq32>
+1 for consistency
<andrewrk>
we used to have `struct foo {}`
<tgschultz>
I'd agree. It'll seem weird at first, but objectively the traditional way is the weird one.
<daurnimator>
andrewrk: so when the C code does `#include <string.h>`, what should provide that? note that I'm compiling code with `zig build-obj --c-source`
<fengb>
Yeah people already need to get used to “backward” variables
<mq32>
and as mikdusan said, "const std = @import()" was also pretty unintuitive at first, but now it's just "there" with no friction
<fengb>
So backwards functions are at least consistent :P
<tgschultz>
also I won't have to declare structs inside of functions that do nothing but wrap a function.
<andrewrk>
daurnimator, we ship freestanding libc .h files
<tgschultz>
at least I assume that would be a consequence of this change, it's possible it isn't.
<mq32>
the nice thing with the funtion-local declarators is that we can reduce scope of a name to the bare minimum required
<andrewrk>
daurnimator, for example if you do -target wasm32-freestanding-musl, then you get lib/libc/include/generic-musl in the -I paths, and that has string.h
<mq32>
i enjoy using that for types already, but having some small local helper functions are always practical as well
<daurnimator>
andrewrk: see paste..
<BaroqueLarouche>
oh right, it will give you local functions for free
<andrewrk>
daurnimator, yep looking into this, probably just need a wee little adjustment
<BaroqueLarouche>
well almost free if you want local function to access the stack of the parent function
zfoo has quit [Remote host closed the connection]
<andrewrk>
daurnimator, try adding your target to target.cpp libcs_available
<mq32>
BaroqueLarouche, i don't that's even a concern right now
<andrewrk>
then there will probably be a next step to solve
<andrewrk>
daurnimator, we should probably have an error there: "requested to link libc, but no libc available for target xyz"
<mq32>
BaroqueLarouche, but i have a lot of "const Helper = struct { };" structs that only introduce some local functions required in the scope of the function
<daurnimator>
andrewrk: libcs available only has the one freestanding (wasm32): intentional?
<andrewrk>
yes; the use case that you're exploring right now is still experimental - go ahead and add riscv64-freestanding-musl
* andrewrk
will be back in 10 min
<mq32>
got to go... it's nice to know now why "let" feels easier to type than "const" :)
<shakesoda>
both shorter and easier key placement?
<mq32>
shakesoda, read above (and search for "objective analysis")
<shakesoda>
that's pretty much where i was going with this
<shakesoda>
:)
<daurnimator>
so adding to target.cpp got a bit further; now bits/alltypes.h is missing (which is something inside of string.h)
lunamn has joined #zig
keegans has joined #zig
<keegans>
hey, just getting a little bit confused with interfacing with c strings, I have a function that accepts name: []const u8, but i'd like to pass that to a C function, I believe that []const u8 is NUL-terminated, but I am not sure how to get it so i may pass it to the C func
<keegans>
am I supposed to cast it? apologies if i misunderstand the procedure
<hryx>
I was surprised how fired up people on GitHub get about syntax discussions (1717, let vs const, etc.) But maybe it makes sense because one will see syntax before anything else
<daurnimator>
keegans: 0.5.0 or master?
<keegans>
0.5.0, I think there is something special like [*:0] in master, but I haven't explored that yet
<daurnimator>
yes there is. you may want to swap to master :)
<keegans>
ok will do, but if possible can you explain that to me or point me in the direction, that syntax is a little bit magic to me
<daurnimator>
keegans: in master `[:0] const u8` is a null terminated slice. `[*:0]const u8` is a null terminated pointer to many
<keegans>
excellent, thanks
<keegans>
just built from source, works like a charm, thanks again
<fengb>
I’m not a big fan of let + var
<BaroqueLarouche>
#TeamConstVar
<daurnimator>
I don't mind `const`. I think `var` isn't great.
<daurnimator>
I wouldn't mind if we had `let` and `let mut`. or `const` and `mutable`
<daurnimator>
I don't think we should have `var` and `let`: its useful for vertically scanning that they are a different number of characters
<fengb>
I do like let mut
<daurnimator>
Also `let` means mutable in JS: lots of people these days have that as context
<fengb>
daurnimator: agreed
<pmwhite>
What if the var keyword is renamed to `_var` just so people abhor using.
<fengb>
There’s nothing wrong with using var. we’re not all functional here
<daurnimator>
fengb: still, we should make non-mutable 'easier'
<companion_cube>
let/let mut is cool imho
<companion_cube>
(rust's syntax is cool, generally)
<pmwhite>
Yeah, fair. I guess the goal is to encourage stating something as immutable when it already is, rather than pushing someone either way. No matter what keywords are there, people should be thinking critically about their design.
<companion_cube>
the default should be an immutable binding, then if you actually need to mutate it you can use `let mut` or `var` or whatev
<andrewrk>
I have a meeting with a lawyer tomorrow about officially starting Zig Software Foundation as a not-for-profit organization. this is a step towards being able to pay people in the zig community to work on zig stuff. I'll keep everyone posted about progress
<fengb>
Oh wow
<companion_cube>
💃
<BaroqueLarouche>
Nice!
<hryx>
Awesome!
<andrewrk>
I also have an ongoing application to Software Freedom Conservancy, so at some point here I have to pick a path to go down
<andrewrk>
thanks daurnimator for poking one of their staff members the other day :)
<andrewrk>
alright, so let's figure out the next step for your freestanding libc use case
<andrewrk>
daurnimator, look around lib/libc/include/ to get a general idea of the directory layout
<andrewrk>
`find -name "alltypes.h"` to get a sense of what that does
<andrewrk>
I suggest to make an empty directory `lib/libc/include/riscv64-freestanding-musl/` and to copy bits/alltypes.h into there from riscv64-linux-musl
<andrewrk>
I believe `lib/libc/include/riscv64-freestanding-musl` is already one of the -I paths passed for your target, so this should make alltypes.h picked up
<andrewrk>
it might even serve us well to rename all the *-linux-musl dirs to *-any-musl, and modify the corresponding code in codegen.cpp
<andrewrk>
^ if we wanted to make it so that the musl C ABI had identical headers for linux and freestanding targets. which is probably reasonable
<keegans>
just wondering if there is a better way to do this: https://gist.github.com/meme/8bb83dd617d30438e8d752bfa9e73334, since it seems that even though the value will be NUL-terminated, if i print it it will not respect the null terminator, which is strange, so I then turned it into a slice with the correct dimensions
<andrewrk>
keegans, I believe the @ptrCast is not needed
<keegans>
also, are there any plans to add datetime functionality to the zig standard library or would that make more sense as a library
<keegans>
oh, maybe I was wrong let me see if i can get away with not using it
<keegans>
yes, I do not need it my bad haha
<andrewrk>
buffer.len would be preferable to @sizeOf(@TypeOf(
<keegans>
of course, thank you
<andrewrk>
as for your actual question, I'm not sure what the problem is. the code looks fine. what behavior are you observing?
<keegans>
so if I do not specify the slice dimensions in the print, it will print the time then garbage: 2020-01-16 21:35:55�����
<keegans>
since it is reading past the buffer, but I _thought_ it null terminated the result, so I would expect it to not do that, i.e.: print would terminate at the end
<andrewrk>
right because `buffer` is 64 bytes and formatted printing has no way to know you wanted a null byte to terminate printing
<andrewrk>
but with buffer[0..size] it should work
<keegans>
yeah I was hoping I could do a better job at specifying my intention in types, but this works just fine
<andrewrk>
datetime functionality in std would be nice if there was a way to solve it and be done with it. but taking on a dependency of locales and countries/cities changing timezones, might be better to be a third party package
<keegans>
that is a good point, I did not think about shipping all that supporting data
<andrewrk>
and more importantly, the fact that it changes in response to non-technical things
<andrewrk>
it can even be a political statement, which way your time zone works
<andrewrk>
e.g. do you respect one country's claim to a city or another
<andrewrk>
I really would love to avoid having zig std lib depend on something like that
<keegans>
but they also have a zoneinfo.zip as a fallback (?)
<andrewrk>
ah, adding a system dependency. that has its own pros and cons
<keegans>
yeah i really am not sure what is best
<andrewrk>
this is a similar problem as https certificates
<keegans>
well actually, I am curious. I see people shipping statically compiled go executables in docker containers with no base image, are they just completely breaking the time library?
<andrewrk>
good question
<keegans>
anyway, thank you for your help I'll stick with the libc dependency for time for now
<keegans>
how can I convert a []const u8 to a [*:0]const u8 ? Will I have to perform an allocation and copy, or can I use the fact that the string itself should be NUL-terminated
<keegans>
in my fit to try to figure it out for myself I just crashed the compiler :(
<andrewrk>
keegans, you can use slice-and-assert-sentinel syntax: foo[x..y :0]
<andrewrk>
this gives you a `[:0]const u8` which will implicitly cast to both `[*:0]const u8` and `[]const u8`
<andrewrk>
it also asserts that `foo[y] == 0`
<keegans>
very cool, thank you
<andrewrk>
thanks for the bug report
<keegans>
ok it seems I just triggered an abort with your suggestion :(
<keegans>
i ask for your help then just drown you in bug reports, this is no reward hahaha
lukeholder has joined #zig
lukeholder has quit [Client Quit]
lukeholder has joined #zig
<keegans>
I am having some trouble reducing the test case for the new crash: https://gist.github.com/meme/cb6d455a6f00b1fe798a378ced19c651, the issue occurs with line 29 I believe, but I must go right now, any suggestions are welcomed and I will do my best to make an issue asap
<andrewrk>
another user recently figured out how to use creduce with zig
<andrewrk>
keegans, this is definitely a compiler bug, but name[0.. :0] is almost certainly incorrect, because you're accessing outside the name slice
<andrewrk>
if the byte after the name slice is 0 then it should be `name: [:0]const u8` rather than `name: []const u8`
<andrewrk>
so you don't need name[0.. :0] at all, just name. but update the parameter type. and update currentTime to return [:0]const u8 instead of []const u8, by changing buffer[0..size] to buffer[0..size :0]
<andrewrk>
give the type system all that juicy info
<daurnimator>
andrewrk: back now. was at lunch
<daurnimator>
andrewrk: I think going with sfc/spi is a much better choice than doing it yourself: they handle all sorts of tax-free statuses for us; and are essentially lawyers on free retainer
<daurnimator>
andrewrk: lib/libc/musl/include/alltypes.h.in exists.... why do I have to copy it to a relevant subdir?
<lukeholder>
andrewrk, I am interested in helping by contributing to the website/docs etc. Is the best place to put forward ideas and discuss the `www.ziglang.org` repo? Are you against using a static site generator that is not written in zig (i.e hugo or gatsby)? paying with ideas https://jmp.sh/BmkFcJE
<daurnimator>
lukeholder: oh you're a JS developer that wants to help with zig?
<daurnimator>
lukeholder: would you be interested in writing a highlight.js plugin for zig?
<lukeholder>
daurnimator, yes, web developer
<lukeholder>
Can look into that, what is ziglang.org using ?
<andrewrk>
ziglang.org uses its own self-hosted tokenizer for highlighting
<daurnimator>
lukeholder: Various things (pastebins/blog engines/web IDEs/etc) use highlight.js for highlighting: to get such things to support zig highlighting we need to get support into the upstream highlight.js
<andrewrk>
the www.ziglang.org github repo is a good place to discuss design decisions
<andrewrk>
my mind is open to changing the design/layout of the home page, as well as how it is generated. but I do consider it a matter of pride that it respects the user's light/dark preferences, has easily accessible code examples, and entire page loads from cold cache with 22 KB transferred
<andrewrk>
what you showed clearly looks more appealing to me, which is a bonus. but losing these other things would be noticed by zig's target audience of programmers
<lukeholder>
andrewrk yes I have seen those docs too.
<lukeholder>
Not looking for you to loose anything to loose focus on the audience
<lukeholder>
Not looking for you to loose anything to lose focus on the audience
<lukeholder>
There is the website / github wiki / docs / and std lib docs
<lukeholder>
If we had a design system set up, we could roll out consistency through them all, and also look to combine/unify the build system (static site generators etc)
<lukeholder>
in a secondary step
<lukeholder>
Agree on usability/accessibility/speed all really important
<lukeholder>
I will start with getting a highlight.js plugin made as a contribution to start
<pmwhite>
Which is also why I have a space in my username.
<pmwhite>
Also, I'm on my Pinebook Pro at the moment. Been trying to get my zig wayland program to work on this ARM processor, but there is some weird bug that isn't present on my usual laptopo.
<pmwhite>
I'm getting "reached unreachable code" along with an error trace that doesn't contain an unreachable keyword in it.
<daurnimator>
lukeholder: weechat
<daurnimator>
andrewrk: sorry, only getting minutes here and there to work on this
<daurnimator>
can zig act as objcopy?
epmills has quit [Remote host closed the connection]
return0e has quit [Remote host closed the connection]
<daurnimator>
adding -lc gives: Assertion failed at /home/daurnimator/src/zig/src/link.cpp:1484 in get_libc_crt_file. This is a bug in the Zig compiler.
return0e has quit [Ping timeout: 272 seconds]
adamkowalski has quit [Remote host closed the connection]
Snetry has joined #zig
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
return0e has quit [Client Quit]
_Vi has quit [Ping timeout: 260 seconds]
euantor has joined #zig
mikdusan has joined #zig
jaredmm has joined #zig
s-ol has joined #zig
Sahnvour_ has joined #zig
HesamR has quit [Remote host closed the connection]
return0e has joined #zig
ofelas has quit [Quit: shutdown -h now]
mikdusan has quit [Ping timeout: 268 seconds]
alexpana has joined #zig
dddddd has joined #zig
_Vi has joined #zig
alexpana has quit [Ping timeout: 240 seconds]
waleee-cl has joined #zig
alexpana has joined #zig
epmills has joined #zig
<keegans>
andrewrk: ah my thinking was that I wanted to make as few things use the [*:0]u8 as possible, to make it a more idiomatic Zig interface (so you feel like you're just calling zig), I will adjust to use the zero-terminated array for those functions. i'll also explore the creduce idea
<keegans>
(unless the person that did it documented the process)
zfoo_ has joined #zig
squeek_ has joined #zig
epmills has quit [Remote host closed the connection]
alexpana has quit [Ping timeout: 272 seconds]
BaroqueLarouche has joined #zig
squeek502_ has quit [Ping timeout: 272 seconds]
mikdusan has joined #zig
return0e has quit [Read error: No route to host]
return0__ has joined #zig
<betawaffle>
how do i declare an array of something *without* a zero sentinel?
<betawaffle>
(and i also want it to be volatile)
<betawaffle>
i want `@intToPtr([*]volatile vga.Entry, 0xB8000)` except with a known size
<betawaffle>
actually... i also want it to be a multi-dimensional array
<mikdusan>
andrewrk: something squirrely with linux build failures. In ci/azure/linux_script `[ IndividualCI != PullRequest ]` section somehow starts another stage1 build, and the error is thrown after that. I'm just not following how/why the 2nd stage1 build is done, and why it's using gcc 9.2.0
<mikdusan>
oh maybe `docker run ...`
waleee-cl has quit [Quit: Connection closed for inactivity]
<fengb>
How do we prevent the Zig community from devolving?
<companion_cube>
oh damn
<fengb>
I know other communities have similarly suffered. Guido stepped down for similar reasons
<BaroqueLarouche>
dealing with humans is always hard
<fengb>
Always true. However some communities work better together than others
<companion_cube>
so far rust had been pretty examplary…
<companion_cube>
I wonder what communities do better?
<fengb>
Maybe Rust core does. But there's a vocal minority of "Rust-bros"
<companion_cube>
the RiiR squad? :D
<fengb>
e.g. "why don't you just rewrite it in Rust?? It fixes all problems!!"
<fengb>
Haha yeah
<gonz_>
The discourse around safety for people getting into Rust generally speaking seems to breed this kind of outrage and histrionic behavior around unsafe languages and features.
<companion_cube>
often I don't think this is bad, it's just the accumulation that can be annoying
<gonz_>
I'm sure most of the Rust community isn't as dogmatic, but the aforementioned "bros" definitely put on a show whenever the issue of memory safety comes up.
<gonz_>
I remember a HN comment that ended with (paraphrasing): "I use Rust because it matches my ethics ..." with the implication that a language lacking memory-safety was unethical.
<fengb>
I remember that too
<companion_cube>
otoh I do understand that people dismissing segfaults and buffer overruns as inevitable is super annoying
<fengb>
My favorite HN commenter is "pron". I have no idea who he is and his handle is terrible, but he's a Zig follower and discusses tradeoffs really well
recombinant has joined #zig
<companion_cube>
like, so many vulnerabilities come from that, it'd be nice to just avoid them…
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<companion_cube>
(I mean I understand the feeling behind RiiR)
<fengb>
I think part of the problem is that people look at Rust and C as the only 2 solutions
<fengb>
Either 100% safety, or leave me alone. NO MIDDLE GROUND
<companion_cube>
on the actix thing, I think people felt comfortable with the idea of being protected against memory errors
<companion_cube>
and then whenever a bug caused by `unsafe` poped, they would get angry
<gonz_>
That last part is where I feel like people are missing the point. The software is iterative; bugs can be fixed one by one. It's unlikely that the actix-web development model is any worse than any other in the long run.
<companion_cube>
in this case, I find it a bit worrysome the guy redid his own `Cell` when it's a touchy abstraction
cow-orker has quit [Ping timeout: 240 seconds]
<fengb>
Too many programmers have ego-centric models
recombinant has quit [Read error: Connection reset by peer]
<gonz_>
I dunno, things like this just remind me why I wanted to become a code hermit and why I will.
<fengb>
We need to stop bickering about why we're right, but instead focus on getting better
<companion_cube>
thanks for linking the post from klabnik, fengb
<companion_cube>
well written as usual
<BaroqueLarouche>
fengb: +1
<fengb>
(I say this even though I have a raging ego)
recombinant has joined #zig
kristoff_it has joined #zig
Snetry has joined #zig
<tane>
fengb, to be honest, I dislike the concept of "the X community" in the first place, as it generates the in-group/out-group dichotomy in the first place
<companion_cube>
other people are egotistic, I'm just aware of my worth!
<kristoff_it>
hey all, I was stalking the discussions through the irclog, it's a tough nut to crack for Rust, the theorem-proving approach is a concept strong enough that people can understand but many don't get the nuance
<gonz_>
At some point I'll disappear from the Internet and just amass a mountain of zig code for myself for 10+ years. When that happens depends entirely on when this particular community sours (as they all do).
<kristoff_it>
and so you get fans and haters that take a fundamentalistic stance
<fengb>
gonz_: but you're more valuable providing insight amongst heathens
<companion_cube>
(I feel more like a hater of some things than a fanboy of other things :s)
<tane>
companion_cube, you still like ocaml, don't you? :)
<fengb>
I feel like haters are a natural byproduct of fanboys
<companion_cube>
tane: a lot, I'm comfortable with it and it's quite expressive
<fengb>
... Steve Klabnik does not look like what I had in mind
<gonz_>
fengb: Right. The infamously great tactic of "No, you're wrong!" :D
<tane>
it's opinionated things that drive the division, and rust is really opinionated
<companion_cube>
gonz_: no, *you're* wrong!
<fengb>
Example: I don't really think much of Odin, but I'm really disliking Jai for all the wrong reasons
marmotini_ has quit [Remote host closed the connection]
<fengb>
Even though they're very similar
marmotini_ has joined #zig
<fengb>
The Jai fanboys have really clouded my judgement
<BaroqueLarouche>
Jai has been too long in closed-door development
<companion_cube>
what about the fact it's done behind closed doors?
<companion_cube>
ah, same
<kristoff_it>
fengb: but how much of that is really dislinking the language (of which you can only see a reflection in twitch streams) vs disliking jblow and the fanboys?
<kristoff_it>
fengb: ah yeah you said it
recombinant has quit [Quit: Leaving]
<fengb>
I disagree with it... but I don't think it warrants hatred
<kristoff_it>
I wonder how Zig fanboys will look like
<gonz_>
I don't think disliking languages and their fanatics is actually a good thing. The only reasonable move is to not play, though.
<fengb>
I also feel like JBlow has the ego the size of a mountain, and being a game dev feeds into that
<gonz_>
s/good thing/bad thing/
recombinant has joined #zig
<fengb>
But... he's smart and has great ideas and I really want Jai to succeed. But I also want to spite the fanboys somehow
<tane>
fengb, just ignore them :) the problem, as in rust comes, when the fanboys keep harassing you for not using Jai in the "right way"
<companion_cube>
I'm most annoyed by Go personally, there's a lot of fanboys around Rob Pike, even though his taste in PL is… er… dubious
<fengb>
Well good thing I can't use Jai at all! :P
marmotini_ has quit [Ping timeout: 260 seconds]
<kristoff_it>
I think we all here will have a moment of illumination once the first Zig fanboyism/haterism incident happens.
<kristoff_it>
once you see from the other side of the fence, you get a better understanding of the whole picture
<BaroqueLarouche>
well there's the Zen incident
<kristoff_it>
ok, but that's different no?
<kristoff_it>
am I missing something?
<BaroqueLarouche>
yeah it's a different matter
<fengb>
I like Andrew's approach so far. He's generally pretty good at explaining tradeoffs and opinions, and not about gospel
<BaroqueLarouche>
Very good at saying no and explaining why
<fengb>
But it's also something we can try to do better in general
<fengb>
We can always do better
<fengb>
I feel like a Hallmark card
<BaroqueLarouche>
haha
<gonz_>
I feel like being reasonable about it essentially means not getting involved in dogmatically fueled language discussions at all.
<kristoff_it>
that's a good stance
<kristoff_it>
some people will challenge you anyway about it, but it's just a matter of brushing them off
<kristoff_it>
when I wrote "Why Go and not Rust?" I got a few of annoyed (even angry) priv messages about it. Even though the whole article concludes with
<kristoff_it>
"Let’s avoid tying our identity to a single language and embrace practicality first and foremost. Tribal names like Rustacean or Gopher should be avoided, as they are inherently a marketing tool for inducing stronger branding."
<gonz_>
As nice as all this seems, the truth is that communities always end up pretty garbage and the real value is in finding a few friends and confidants that share your values.
<companion_cube>
someone to rant to 💞
<gonz_>
companion_cube += 1
<companion_cube>
kristoff_it: I understand what you say, but I feel irrationally angry at Go still :(
<companion_cube>
such a lost opportunity to make things right :(
<fengb>
I generally like Go's simplicity
<companion_cube>
it coudl have been simple and yet, so much better
<fengb>
But... things like error codes and generics are a hot topic
<kristoff_it>
companion_cube: on the bright side your favorite language is not going to be controlled by Google
<companion_cube>
and nil, and lack of sum types
<companion_cube>
that makes me angry
<fengb>
I'm surprised at how hostile Go's community is against fixing errors
<fengb>
6 of the top 10 community packages are making errors less shitty
<kristoff_it>
the other angle of this story that I think is relevant is about the burnout that OSS maintainership can cause: http://antirez.com/news/129
<companion_cube>
antirez is one of the people that makes me thing "ok maybe C isn't that shitty" :D
<tane>
true
<tane>
I still need generics, hence zig seems promising :D
<kristoff_it>
I'm definitely one of the last persons that's ever going to absolve Rust fanatics, but the maintainer needed a strategy to keep a balance and avoid getting burnout completely
<companion_cube>
knowing how to delegate is crucial
metaleap has joined #zig
<andrewrk>
fengb, I really like steve klabnik
<andrewrk>
I had the pleasure of meeting him once
<companion_cube>
Ashley Williams is also nice, they live in Austin
<andrewrk>
the main benefit of the docker image is that it is alpine linux, which makes it easier to static link libc
<andrewrk>
mikdusan, since the message is "unable to find zig lib directory" I'm guessing that this is catching a problem with the cmake thing. because this is the only place where we run `zig` binary from outside a tree where it could otherwise look up the directory structure enough times and find the lib directory
<andrewrk>
in this script it's run from a separate install directory, which ensures that the lib files have been installed. so I think the new cmake thing is not working
<mikdusan>
my thoughts too. now that I can see the build script, I'm going to try to reproduce here. there is something diff about the docker run.
<mikdusan>
also what is the birds eye view / logic of why it matters to check for if [ "${BUILD_REASON}" != "PullRequest" ]
<mikdusan>
in linux_script
waleee-cl has joined #zig
<andrewrk>
that way the script does not try to do the stuff related to updating the download page for pull requests
<andrewrk>
it would fail if it tried because pull requests do not get access to the secret tokens, but then the CI would fail for PRs and we want them to succeed
<andrewrk>
the ci actually does make branches available for download. it's not exposed anywhere, but if you know the URL you can get them
<mikdusan>
oh so there is a distinction between pull and merges. and the commits we see typically with "Merge pull ..." are the ones made available for download?
<andrewrk>
the distinction is whether the commit is in a ziglang/zig branch, or if it is in a fork
<andrewrk>
`if [ "${BUILD_REASON}" != "PullRequest" ]` will trigger when the commit is in any branch of ziglang/zig
<andrewrk>
whether it's a pull request or not
<mikdusan>
I'm confused: not understanding why 9348609 failed. and af9eb7a succeeded. the latter did not run docker stuff
<mikdusan>
(commits on master branch)
<mikdusan>
ie: why does one run docker and the other not. maybe you explained it to me, I just don't get it
<andrewrk>
the "OnMasterSuccess" job runs when BuildMacOS, BuildLinux, and BuildWindows all succeed
<andrewrk>
that executs ci/azure/on_master_success
<mikdusan>
oh the tip
<mikdusan>
got it
bheads has quit [Ping timeout: 272 seconds]
<metaleap>
earlier was asked: "how do we prevent the zig community from devolving" wrt to the rust/actix thing --- if everyone never worries about it and keeps on coding or talking about the code, it's already well protected! my take on the linked blog that says: "It’s been very clear from the beginning that the Rust project saw Rust as more than just the language. The community and the people mattered. From the earliest days, leadership explicitly took th
<metaleap>
e position that it wasn’t just the code, but the people around the project were important" --- stay immune to this "not just about the code" sinkhole in an intrinsic/systemic/ingrained/habitual manner (so far zig is terrifically naturally on track here) and danger mostly averted. imho. =) good thing zig has also nothing much to be preachy about, instead it's merely the next-gen swiss-army-knife par excellence. now back to the channel's schedule
<metaleap>
d programming =)
<companion_cube>
idk, these days you can't really avoid having a community
<andrewrk>
we're immune to it *for now* because of the limited size of the user base of the project. there will be similar incidents; it's inevitable. but we can all do our parts to encourage new people to be excellent to each other
<kristoff_it>
metaleap: I suspect other people have already walked this path and they too inevitalby got caught in the usual pitfalls
<andrewrk>
rust community & steve are already doing us a favor with the news item of today, because now the tech community at large is more aware of these sorts of problems, more receptive to ideas about how to keep a more peaceful environment
<fengb>
We've had users come and go because they disagree with Zig's direction
<fengb>
And soon™ we'll start having some rivalry with Jai
<andrewrk>
hoo boy that will be interesting
<fengb>
We've already seen some with V, for better or worse >_>
<tane>
andrewrk, I asked this before, but is there some document regarding work on consistency of the stdlib, e.g. naming, whatever. I ask because I'd like to rename `compareFn` in `priority_queue.zig` to `lessThan` and propose to only use `compareFn` or functions returning `mem.Compare` and `lessThan` for functions `(T,T) bool`.
<companion_cube>
rivalry can be ok, I think?
<metaleap>
fengb: and who knows how much headaches were spared this way =) by keeping allowing low-level primitives incl unsafe and also the "embedded also matters" / "clib-less / OS-kernel-less also matters" sub-focus
<companion_cube>
V is a different problem, it's a shitshow from the start
<metaleap>
...certain classes of "community" will not touch zig with a 42-foot pole
<andrewrk>
tane, I agree with your suggestions, would accept PR
<tane>
andrewrk, alright, thanks
<andrewrk>
tbh the rival I actually respect the most right now is beef
<companion_cube>
it's windows-only though
<fengb>
Not Odin? Somewhere a ginger is sad
rageoholic has joined #zig
<andrewrk>
mikdusan, you working on a patch, or are you ok with reverting the cmake stuff until ready to try something new?
return0e_ has quit [Ping timeout: 258 seconds]
<mikdusan>
reproducing failure is taking longer than expected; so far manually on archlinux has failed. So I'm trying to use this dang-fangled docker thing of which is alien to me
<mikdusan>
so yeah maybe time to revert
<mikdusan>
would you like me to do that?
return0e has joined #zig
<andrewrk>
sure, if you're up for it, go ahead and push to master
<andrewrk>
don't feel bad btw, it's not a big deal to break master, since we have the CI only update the download page when it succeeds
<metaleap>
so we have == for prim-types, std.mem.eql for "slices", what do folks do for other eqs of two same-typed operands. say structs or unions. force-cast into "slices" by taking both operands' addr-and-@sizeOf for passing to std.mem.eql?
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
_Vi has quit [Ping timeout: 272 seconds]
<andrewrk>
usually whether structs are considered equal is problem-domain-specific
<andrewrk>
however if you want a field-wise comparison you could look at std.meta.eql
adamkowalski has joined #zig
<metaleap>
andrewrk: nice will take a look thx. with the domain stuff, yeah and here a good practice is to have a custom "equiv" (not "equal") method etc. but in a C-like one'd still appreciate "compare in-mem-bytes behind these 2 equal-sized operands", right? i mean so many structs are just packaging api stuff back & forth, whether between ffis or tooling or endpoints or whatever, not necessarily "complex business-domain level with peculiar semantic rules". go has
<metaleap>
very simple consistent equality for "whatever type you throw at it": mem bytes in the indicated range are compared. so also pointers are not followed but merely addr-equality there. it looks like std.meta.eql will do the same trick mostly, except slices would still have to be done via std.mem instead of std.meta for usual "cmp-mem" purposes
return0__ has quit [Ping timeout: 272 seconds]
<metaleap>
that is an awesome showcase for comptime btw, just being able to `fn (a: var, b: @TypeOf(a))` is so damn neat!! to consider the towers of abstractions haskellers must traverse to get the same net effect.. :D
<andrewrk>
comparing bytes of structs is not sound unless you use packed or extern, because with normal structs zig reserves the right to put metadata in them, for safety or other purposes
rageoholic has quit [Remote host closed the connection]
<metaleap>
andrewk: i'd suppose any 2 *structurally-equal* structs should be compacted down to 1 unique struct in IR? then however zig rearranges the struct the comparison would still be valid? am below-amateur wrt to the internals of course
<metaleap>
ah dang now i got it, sorry
Akuli has joined #zig
<metaleap>
if such metadata is per instance, then no bytes-cmp (trivially) feasible esp. no asm-based later on =/
return0e_ has joined #zig
<andrewrk>
but you can get such a comparison if you want; you just have to communicate that to the language by using packed
return0e has quit [Ping timeout: 268 seconds]
<tgschultz>
also padding bytes can be anything
<metaleap>
good point too, stuff isnt auto-zeroed here. ok lesson grok'd :D
SimonNa has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
<fengb>
Tangentially related: Go randomizes iterating through maps so you can't rely on that
<fengb>
Maybe Zig in debug mode can insert random data into structs?
<leeward>
I think Beef is Windows-first, but not quite Windows-only?
<leeward>
The tools first approach is solid.
<metaleap>
fengb: well yeah they have some "no can do" exceptions to `==` such as funcs and maps and channels where `==` can only be against `nil`. crikey even slices (tho not fixed-size arrs) now that i remember! so not all rosy there either.
<companion_cube>
ah indeed, binaries are windows only, but not the rest
<companion_cube>
I think the IDE is windows only tho
<leeward>
Yeah, it is.
<companion_cube>
making a custom IDE is… something I don't like, as well
<companion_cube>
give me LSP so I can keep vim
<leeward>
My problem with most of Zig's rivals is that I spend most of my time working on very embedded stuff, and most of these languages are aimed at other domains where things like performance per clock cycle matter more than they do for me.
<leeward>
Yeah, I'm not saying I would leave Emacs for it, but Go took years to get a decent profiler.
<leeward>
Of course, the fact that I can use GDB and Valgrind with Zig makes me plenty happy.
<metaleap>
companion_cube: implementing LSP is another kind of bummer tho. there still isnt a JSON-Schema (jsd) file for machine-processing-and-doing-custom-scaffold-code-gen'ing from it, last i checked (and I check regularly).
<companion_cube>
you mean, for not writing the json code yourself? yeah
<companion_cube>
but it doesn't seem worse than writing a _full_ IDE from scratch
<metaleap>
companion_cube: i mean they also keep evolving those protocols so at the very least a jsd like "vscode debug adapter protocol" project does would be a must. but LSP doesnt really care about how much friction to implement their stuff
<companion_cube>
wait, does LSP break compat in their protocol ‽
<companion_cube>
I know the debugger adapter is still in motion
<andrewrk>
fengb, in general, I like the idea of taking extra runtime penalties to gain more safety, as long as the penalties can be disabled
<fengb>
andrewrk: cool, I can write up a proposal
<fengb>
Yeah in this case I think it's more of "don't provide a hidden footgun"
<metaleap>
companion_cube: probably not so much outright breakage (soft depreciations more likely) but keep adding stuff still. gotta run & keep up or else accept inevitable slow bit rot
<fengb>
Working most of the time by accident isn't very friendly
<companion_cube>
metaleap: for implementing LSP you don't have to care, afaik
<companion_cube>
all methods are optional, so…
<leeward>
Working most of the time by accident is something a language like INTERCAL would do.
<metaleap>
speaking of LSP, who's doing the Zig one? if there's no such thing in progress, it would be my next project though more of a custom daemon prog first (stdin/stdout json over longlived pipe), with an optional LSP layer on top or left for others to add on top
<fengb>
leeward: yeah I think that's why Go randomized map iteration. It worked until it doesn't and you end up having a spirit journey to figure out why
_Vi has joined #zig
<andrewrk>
metaleap, these flags are relevant: -fdump-analysis -fno-emit-bin
mikdusan1 has joined #zig
<andrewrk>
also the unfinished merge_anal_dumps tool
<leeward>
That tool sounds wrong.
<andrewrk>
( ͡° ͜ʖ ͡°)
<metaleap>
andrewrk: what for lsp? oooh shiny compiler metadata to easily parse through you say? thx for hint
<andrewrk>
metaleap, yes it's a large json dump of the results of semantic analysis. firefox has a nice tool for viewing large json files
<andrewrk>
there are some things that don't work so well; zig's lazy analysis is a problem here
<companion_cube>
why have a custom protocol rather than targetting lsp directly, metaleap?
mikdusan has quit [Ping timeout: 272 seconds]
<metaleap>
companion_cube: speed of initial development without getting bogged down in others' brains' constructs :D
<companion_cube>
heh! :D
mikdusan1 is now known as mikdusan
<metaleap>
but given everything is optional in lsp as you, i might even take a less ignorant stance this time around.. for once!
<companion_cube>
well, you need to implement the part where you get buffer updates, otherwise there's no point
<metaleap>
for sure
<companion_cube>
and publish diagnostics based on that if you want; the rest (completion, hints, etc.) is optional
<companion_cube>
jump-to-def, show the comptime value on hover… :p
<metaleap>
...and diags can be empty initially so de-facto optional. yeah knowing me i'll first mock out the full protocol with dummy values before doing any real intel, if stamina left =/
<metaleap>
one thing i notice @andersfr has a custom zig parser in there but i gather the repo also has a longer history, am itching to see how mature the zig-builtin-ast-lib stuff is
<adamkowalski>
If anybody has used tensorflow or any other deep learning library can you all take a look at my progress on compute-graph? What do you all think about the syntax for dealing with linear algebra / building and running your graph
<adamkowalski>
That test case shows creating a graph, defining a model, running it in a session, checking the output
<companion_cube>
proper LSP (or equivalent) means you need a error-resilient parser, but that can come later anyway
<adamkowalski>
no backpropagation yet, but it's the next thing to add now that I have the forward pass working
<andrewrk>
metaleap, I believe the goal of that custom parser was to be forgiving of parse errors
faranwath has joined #zig
<adamkowalski>
andrewrk: yeah it was, but it's really out of date now. I submitted a PR to zig lsp and it was the last commit made. That was months ago
<andrewrk>
one thing I want to experiment with, to address IDEs, is to take into account whitespace for parsing. because maybe the person types { and hasn't typed } yet, but nobody starts typing into an IDE with weird indentation
<adamkowalski>
It doens't support any of the anonymous structs, literals
<metaleap>
andrewrk: i see! once in a different parsing context (non-lsp) i dealt with that by parsing not a full-file from start to finish but top-level defs as separate chunks (was intentation-based not brace-braced tho) --- so if one was temporarily broken (and usually at most 1 anyway in practice) the others could still provide intel
<companion_cube>
andrewrk: at least to recover you can skip to the next beginning-of-line statement
<metaleap>
i wont go for real-time as-you-type full feature-set anyway, more like refresh-on-save. i press ctrl+s often enough and dont need annoying red squiggles and temporarily-flashing diags while typing out lines.. annoying enough to see that "live" stuff in action while typescripting. so then no functionality for a file that wont parse isnt such a heartache either
<andrewrk>
companion_cube, yeah! I think line-independent tokenization was a good decision. I think it will be an undervalued decision until we have IDE support :)
<companion_cube>
metaleap: the thing is, LSP saves you from thinking about that
<companion_cube>
you get buffer updates, you publish diagnostics, that's it
<metaleap>
companion_cube: but in my custom go extension (written way back when vscode's/ms's own go ext was especially rubbish) i got the diags easily from `go build` which i triggered not on buffer updates but on-saves. buffer updates happen as you type, no? even if i can accumulate them for some interval, wouldnt wanna `zig build` in-mem buffers when i can trigger build-on-save and gather the diags from there.
<metaleap>
now what do see in the spec: notifications for onclose, onopen, onchange, but no onsave...... meh
<companion_cube>
because that's not your job, I think
<companion_cube>
each editor can decide when to talk to LSP
<companion_cube>
(can be on save, or as you type)
<faranwath>
I am sorry if this violates any guideline since I am about to ask a question not related to Zig, but since there might be people here with more experience than me, it's worth the shot. Has anyone tried to run Barebox (www.barebox.org) on a UEFI-based PC? I can drop into the UEFI shell but running the bootloader fails (it seems a device tree blob is
<faranwath>
missing but either their documentation is scarce or I am really overlooking something).
<metaleap>
companion_cube: oh there's some "save" stuff in the spec after all, ok. well will attack when my current other small project is done
<companion_cube>
ah, there are capabilities indeed
<andrewrk>
faranwath, generally, topics related to "system programming" are welcome here. only when it starts to get controversial or mean spirited does the off topic rule start to get enforced heavily
adamkowalski has quit [Remote host closed the connection]
<andrewrk>
you might also try #osdev
<faranwath>
andrewrk: I imagined as much, but it's always better to ask first. And yeah, it might be a better shot to try that channel, thanks for the suggestion.
kristoff_it has joined #zig
* andrewrk
will try to land #3927 today
* BaroqueLarouche
hype
TheLemonMan has joined #zig
<TheLemonMan>
yo andrewrk, I have a few questions about how #978 behaves when it's not in a function scope
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<andrewrk>
yo
mahmudov has joined #zig
<andrewrk>
happy to answer and I have some more context for this as well
<andrewrk>
@optimizeFor is one of those things where the language is more expressive than llvm is capable of handling
<andrewrk>
while zig allows setting the build mode at any scope, llvm will let us set optimization levels only at a function level
<andrewrk>
I also want "package scope" to be a thing for this, so you could have for example your blake2 dependency in --release-fast mode but your main application in debug mode
<andrewrk>
we don't currently have a "mode" setting for types such as structs. I believe we would need to introduce this, because it's not the same as build mode, which has more to do with code gen than types & memory layout
<zfoo_>
faranwath: not sure if it works on a UEFI PC, but the barebox bootloader will need a device tree
<BaroqueLarouche>
andrewrk: I'm planning to look at #2826 soon
zfoo_ has quit [Read error: Connection reset by peer]
<faranwath>
zfoo_: Right, I've used it to load Linux on ARM-based devices and it has worked like a charm. This is the first time I built with ARCH=x86 but I see no `make` target to generate a device tree. I'm muddling through the project to try and better understand it and hopefully figure out what's missing. I was told on #barebox that someone had replaced
<faranwath>
GRUB with it on his/her laptop do it does seem possible.
<faranwath>
*so it does
<TheLemonMan>
andrewrk, oh I see, we should create a hierarchy of compiler-set optimization mode -> decl-scope-set mode -> function-decl-scope optimization mode
<andrewrk>
TheLemonMan, yes that's my idea at least
<andrewrk>
each struct introduces a sub-scope (and files are structs)
<andrewrk>
I also want packages to be scopes
<andrewrk>
so: global -> package -> struct/union/enum/function
<TheLemonMan>
but what about a @optimizeFor in a block inside a function? Should that be an error?
<andrewrk>
llvm's granularity is only functions afaik
<andrewrk>
also who knows? maybe non-llvm backend will support some kinds of sub-function optimization passes
<andrewrk>
it communicates what the programmer intends, and whether the compiler can do anything with that information is a separate concern
<TheLemonMan>
roger that
<BaroqueLarouche>
I use #pragma optimize("", off) a lot with game code, so @optimizeFor will be very useful
<andrewrk>
maybe a future compiler outputs metadata in the debug info, which a third party tool reads (something like valgrind) to make a hot spot within a function faster without the checks
<metaleap>
looks like i'm doing @tagName wrong: "expected enum or union type, found '(enum literal)'" --- well sure, docs say (and compiler does too) only 1 arg is needed, and what would the "union or enum type" arg produce as a "tag name"...... headscratcher!
<metaleap>
should add i pass it a comptime-known tag but decl'd as `comptime tag: var`
marmotini_ has joined #zig
<metaleap>
ah dang looks like tagName takes the union field's value not its tag, so @memberName would be it, and now I need to obtain the enumerant's-aka-field's index
<metaleap>
...which should be enumToInt but feels shaky
<metaleap>
and results in the same err :'(
<andrewrk>
metaleap, @tagName should work on enum literals it's a missing feature
return0e has joined #zig
<metaleap>
andrewrk: thx so its just WIP-missing? use-case is: given `(comptime TUnion: type, comptime tag: var, it: TUnion)` , how to "emit" `it.<tag>` so to speak
<andrewrk>
yes
<andrewrk>
it's a pretty contributor friendly issue too
<metaleap>
#1099 isnt it, is it?
return0e has quit [Read error: Connection reset by peer]
return0__ has joined #zig
<metaleap>
(for above case, i have a `switch` version working so its not pressing, just thought i'd go with activeTag and direct dot access instead)
<andrewrk>
metaleap, no that's to do with meta data on struct fields
<andrewrk>
I think there is not an issue for the thing you just mentioned, feel free to create it
marmotini_ has quit [Ping timeout: 240 seconds]
<metaleap>
(i just searched issues for tagName) --- will do!
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
faranwath has left #zig [#zig]
<keegans>
i do not know if i am very unlucky or what, but i am getting some strange behaviour with the :0 slices suggested by andrewrk in the following program https://gist.github.com/meme/41673902002f243d9edc947440ee10ab, it does NOT work in normal mode, but if i compile with release-safe, it works properly
<daurnimator>
keegans: what error do you get?
<keegans>
well thats the thing, there is no error
<keegans>
but there is obviously something funky happening
<keegans>
that is washed away in release safe, without error
<keegans>
ah LemonBoy responded
<keegans>
I assumed that it would be _copied_
<keegans>
i clearly need to read up on how these semantics work in zig
<fengb>
Slices are fancy pointers
<andrewrk>
oh, oops I missed the buffer thing when I looked at the code last night, sorry
<fengb>
As soon as you return it, it's a pointer to stack memory that'll get wiped
<keegans>
ok, I will adjust accordingly, I am not sure why I expected what I did
<fengb>
It's a ocmmon problem because slices look like arrays
<fengb>
The usual solution to something like this is passing in the buffer
<keegans>
yep, good idea
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 265 seconds]
<andrewrk>
one trick to remember is that `var` is a memory location
<andrewrk>
all the `var`s in a function are destroyed when the function returns
<daurnimator>
andrewrk: unless the var was in a struct definition :P
<frmdstryr>
Release-safe optimizes out error messages & traces?
<andrewrk>
frmdstryr, I believe error tracing is enabled in release-safe by default. the implementation allows separately enabling/disabling error tracing however this option is not currently exposed
adamkowalski has joined #zig
<frmdstryr>
Hmm... well the panic in debug i can print the error and backtrace but in release-safe it just says optimized out
<frmdstryr>
maybe it's because it's in a nop loop toggling an led
<daurnimator>
with non-exhaustive enums merged we have lots to improve!
<daurnimator>
andrewrk: ^ are you good to accept patches to convert things? e.g. AF_ constants, windows.STATUS
<daurnimator>
hell, the errno values themselves!
<daurnimator>
getErrno will actually be able to return a `?Errno`
<andrewrk>
daurnimator, generally, yes, but let's not overcomplicate things that are working perfectly well, with regards to cross platform
<andrewrk>
errno as an enum is preferable, no arguments there - as long as it doesn't result in having to add workarounds or undue complexity to deal with differences across systems
leeward has quit [Remote host closed the connection]
<andrewrk>
I guess what I'm saying is, I'm on your side on this one, but I also want to not give up seeing the forest for the trees, if that makes sense
<andrewrk>
AF_ constants makes sense to me, since that transcends operating system
<daurnimator>
It also namespaces them
<andrewrk>
yeah, AF.INET, AF.INET6, clearly this is what was meant to be
<andrewrk>
sorry, above I meant to say "changing AF_ constants to enums ..."
<daurnimator>
let me try and pick out a possibly more controversial one.. hmmm
<andrewrk>
errno might be a good example
<andrewrk>
are the names even consistent across all platforms?
doublex_ has joined #zig
<daurnimator>
What do you mean?
<daurnimator>
Different OSes share some errnos, but also have their own
<daurnimator>
each os/bits/<os>.zig would have an enum for that OS.
leeward has joined #zig
<andrewrk>
hmm, that might work out quite nicely. does that even have to be non-exhaustive?
<andrewrk>
I suppose so
<fengb>
If we don't, then a kernel update can potentially break Zig userland
<andrewrk>
yes that's correct, since the errno listings does not cover the full range reserved by syscalls
<andrewrk>
until I checked just now my memory was fuzzy about whether or not all the errno values were reserved with names
<daurnimator>
actually, I'm not sure what range is reserved by syscalls on different OSes.... linux reserves 4096. what do others do?
<andrewrk>
wasi has actual c_int return types
<andrewrk>
apologies, it's u16
<fengb>
So we can be silly and do Errno = enum(u10)?
<andrewrk>
let's see how it ends up looking in the os.zig layer
<andrewrk>
I suggest to do errno alone
<andrewrk>
I mean separately than e.g. AF_* and others
blueberrypie has quit [Quit: leaving]
blueberrypie has joined #zig
<fengb>
How was the lawyer meeting?
<andrewrk>
it went well. she answered my questions and I feel I have a good understanding of each of the paths forward: Independent not-for-profit organization vs joining SFC or similar
<andrewrk>
I'm going to give it the weekend to mull it over, and then pick a path
<andrewrk>
estimated $5,000 USD cost to get from zero to 501(c)(3) status
<andrewrk>
but then we would have an official organization, and a united states Tax Identification Number, which is elligible for charitable donations. that's *huge* for accepting larger donations and being trusted to handle them responsibly
<andrewrk>
it would enable applying for grants for example
<andrewrk>
I've also been thinking about governance structure
<andrewrk>
I think after 1.0.0 is established, I'd like to set up a governance structure for the zig project and the organization that runs itself without me. Basically once it's stable, reduce everything to "maintenance mode". No surprises, no "let's go crazy and make zig 2.0", just steady bug fixes and dilligent project maintenance
<shakesoda>
passing the bus test would certainly be great for having confidence in it as a tool to rely on
<andrewrk>
yeah, I think we're getting closer to there
<tane>
andrewrk, what's your estimate on 1.0.0, in terms of years?
<kristoff_it>
I was about to ask the same question
<andrewrk>
I estimate 2 years
<kristoff_it>
too short of a timeframe means that you don't leave much space to revisit design decisions
<companion_cube>
andrewrk: the rust people are looking at the same thing and they're considering doing it outside the US :)
<andrewrk>
but I also think that as we get closer to 1.0.0, we can change the release structure from this 6 month thing, to a release cycle that is closer to what it will be post-1.0
<companion_cube>
(given the foreign policies of the US it makes sense)
<andrewrk>
that seems smart, but that might be too difficult for me to do with my financial resources
<companion_cube>
is there no one in germany here? :D
<wilsonk>
what are the benefits of doing it in Germany vs US?
<andrewrk>
as zig stabilizes, the releases will become more reliable and will resemble post-1.0 releases
<andrewrk>
basically the point of 1.0 is that you stop breaking stuff; but even if you are allowed to break stuff, as the language and std lib get "finished" then stuff naturally stops breaking
<andrewrk>
so you'll know that zig is starting to stabilize and become more reliable when you see the first bug fix release (e.g. 8.0.1)
<andrewrk>
oops, I meant, e.g. 0.8.1
<companion_cube>
wilsonk: not blocking people from countries the US doesn't like
<andrewrk>
I would consider myself to be a global citizen first, and a US citizen second
<companion_cube>
(see recent events where people in Iran were basically blocked from all US-based cloud services, ie... most of them)
<companion_cube>
that's very laudable andrewrk
<companion_cube>
(btw you're in NYC right?)
<andrewrk>
yes I currently live in NYC but planning to move within 1 year. my gf is pursuing a PhD
<tane>
OT: anyone going to FOSDEM in a few weeks?
<andrewrk>
I wish. I have a prior commitment
<companion_cube>
oh, moving to where?
<companion_cube>
(PhD is a big challenge, good luck to her)
<andrewrk>
it depends on where she gets accepted, but hopefully california
<companion_cube>
ah well, more sun for y'all
<companion_cube>
more advocado toasts
<andrewrk>
haha
recombinant has quit [Quit: Leaving]
<wilsonk>
companion_cube: ah, ok I see
<companion_cube>
(that said, 501c3 are nice)
<wilsonk>
andrewrk: my identical twin brother did his PhD for years at USC (back and forth to Japan also, but all the scholarships were from USC). Beautiful out there :)
<andrewrk>
oh neat! that's the one we're hoping she gets into :)
<wilsonk>
he could choose between Columbia and USC (or wait one more year for Harvard)...and ended up at USC because of the weather and we have friends there
<andrewrk>
it's close enough to SF to make it to the LLVM conferences, at least
<wilsonk>
Yeah, sweet
<companion_cube>
what'd her ideal PhD be about?
<andrewrk>
urban sustainability. e.g. making cities more resilient to climate change