ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<dbandstra>
unfortunately has a few dependencies on other tings in my utils repo, but i could spin off a standalone version if anyone was interested
donlzx has quit [Remote host closed the connection]
donlzx has joined #zig
davr0s has joined #zig
xtreak has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
dbandstra has quit [Quit: Leaving]
xtreak has quit [Remote host closed the connection]
donlzx has quit [Remote host closed the connection]
noonien has joined #zig
redj has quit [Ping timeout: 240 seconds]
redj has joined #zig
davr0s has joined #zig
v1zix has quit [Quit: Page closed]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
quc has quit [Ping timeout: 240 seconds]
xtreak has joined #zig
zolk3ri has joined #zig
davr0s has joined #zig
SimonNa has quit [Remote host closed the connection]
redj_ has joined #zig
redj has quit [Ping timeout: 264 seconds]
xtreak has quit [Remote host closed the connection]
foobar2000 has joined #zig
xtreak has joined #zig
donlzx has joined #zig
sneow has joined #zig
<sneow>
hello zig
<unique_id>
hello
wilsonk has quit [Read error: Connection reset by peer]
hio has joined #zig
<hio>
Memory safety should be the nr.1 concern of any new language. I'm afraid that while ziglang does everything else right, I dont see enough attention on this.
Hejsil has joined #zig
<Hejsil>
Well, Zig provides tools for access out of bounds and using unused memory
<Hejsil>
And allocators is a powerfull tool for managing memory, though it's still manual
<Hejsil>
And this seems to be the most promising solution for ensuring that "resources" are passed around and freed correctly: https://github.com/ziglang/zig/issues/782
<Hejsil>
hio, so what specifically are you refering to when you're saying that not enough attention is put in this area?
<hio>
Hejsil: I think having every allocation trackable through a gui interface would make it comparable to Rust. I just want to have some kind of peace of mind that my program wont have any memory related issues that will cause crashes or out of memory problems at a critical time after I deploy my code. Yes it wont be 'perfect' because not every program run will cause every code path to happen but it will be as good as it gets. This would
<hio>
be acceptable for me in terms of safety. So lets say I start my zig program and then it will prompt me to open the webbrowser at localhost:9991 to show me a list of allocations live as they happen and as they get freed. Kind of like valgrind or address sanitizer but live in a nice gui. That would make memory safety a first class citizen of the language which as I said, it should be because it's a big deal
<Hejsil>
I think a lot can be done here with a leak checking allocator
<Hejsil>
It could track lines where allocations happens and report if they weren't freed
<Hejsil>
Let me see if I can find the discussions on leak checking
<Hejsil>
I personally think a leak checking allocator should be in std, but I don't know what andrewrk thinks of this
Richard10 has joined #zig
<Richard10>
Can I use range in a for statement? for example for ( 0 ... 10) | i | { ... }
<hio>
usability is the most important thing here, it should all be very easy for me to understand why, where and when allocations happen. That's why I suggested even providing a html gui for it because it's so important to make it obvious whether my code is running okay or not. Imagine a real usecase, I deploy my zig program and during production I realize that my zig process is running out of memory, constantly getting more and more. How
<hio>
do I fix it, how do I debug and find the location in my code that is causing the problem?
<Hejsil>
Richard10, No, you should use the while loop for this
<Hejsil>
hio, so your concern is more about reporting memory usage rather than leaks
<Hejsil>
Does rust even have anything in the compiler for this?
<Hejsil>
I can imagine there is external tools
<Hejsil>
I agree that it is important though
<hio>
no, it's leaks. If I decided on using Rust it's very easy: I have "100%" confidence that I'll never have a memory leak. That's the competition so zig has to provide some kind of competitor here that is equivalent or at least near equivalent (imo)
<Richard10>
OK, THANKS
<Hejsil>
Ooh, right. You just made it sound like your program was not leaking and running out of memory (which indeed could happend)
<lqd>
leaks are considered safe and are not checked by the compiler at all
xtreak has quit [Remote host closed the connection]
<hio>
I mean tracking memory in general would be nice to see, no other language has that kind of diagnostics built in. Dart has something similar, called the observatory. That's how I got the idea for an html gui after all, it's really convenient
<Hejsil>
Pretty sure we have the tools to get most of this working already
<hio>
that would be great, it would make it equal to c/c++ in terms of tool support
<unique_id>
Looking at Rust wrappings and bindings of C libraries, the community seems to have gone too far in the name of safety. The main vulkan wrapper follows the idea of not being able to trigger undefined behavior if you don't write unsafe code. The point of vulkan is to remove checking and get out of your engine's way, not add checking and extra abstractions. There are validation layers, they can use used. Respect the design of Vulkan.
redj_ is now known as redj
<unique_id>
I think productivity should be the nr.1 concern of any new language.
<Hejsil>
I think any new language
<Hejsil>
nr1 concern is to solve the problem they set out to solve
<Hejsil>
and solve it well
<Hejsil>
:)
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<unique_id>
Sure, I agree. My experience with C++ is that its so complex that it draws you into chat rooms and other places just to discuss/learn about the language itself and you forget to do your programming :) It's really unfortunate.
<unique_id>
But I'm not blaming the c++ people for that. They'll improve the language for a long, long time.
<Hejsil>
The 30+ years near full backwards compatibility of such a big language is a respectable commitment
Richard10 has quit [Quit: Page closed]
quc has joined #zig
very-mediocre has joined #zig
xtreak has joined #zig
davr0s has joined #zig
xtreak has quit [Ping timeout: 240 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk>
hi sneow
wilsonk has joined #zig
Hejsil has quit [Quit: Page closed]
<andrewrk>
hio, have you used `valgrind --leak-check=full` to debug a memory leak in native code?
<andrewrk>
it's magical
<andrewrk>
once I discovered that, I lost my fear of memory leaks. it gives you a list of leaks, and a stack trace of where each leak was allocated
<andrewrk>
you mentioned safety though, which in my mind is a separate concern from leaks
<hio>
the report is hard to read, lots of different kinds of leaks and who knows which ones are actually real leaks
<andrewrk>
that has not been my experience
<andrewrk>
I've never seen a false positive memory leak from valgrind
xtreak has joined #zig
<hio>
Me neither, I meant that valgrind usually reports a lot of "maybe" leaks. Does valgrind work with zig produced binaries?
<andrewrk>
it does, if you work around a valgrind bug with --no-rosegment
<hio>
hm ok cool
<andrewrk>
I don't think zig will ever have the sophisticated compile-time checks that rust has - you will always be able to store a dangling pointer somewhere. I do have lots of plans and ideas to increase runtime safety checks but it will never be perfect. plus we have release-fast mode where we don't have runtime checks
<andrewrk>
so if memory safety is your nr1 concern, I think you should give rust a go
<unique_id>
Sometimes I need to use the traditional for loop. Is it: "var i: u32 = 0; while(i < count) : (i += 1)" ?
<andrewrk>
unique_id, yes
<unique_id>
I need to make a large struct mostly zero initialized but set a few fields. Do I set it to undefined and use @memset/std.mem.set or is there a better way to zero initialize?
<andrewrk>
nope, your understanding is correct
<unique_id>
okay :)
<andrewrk>
and then before doing the memset, consider whether you would want a compile error at this point when you add a new field to the struct - that can be a compelling reason to explicitly initialize all the fields (even if most of them are to undefined/0)
<unique_id>
sure, but in this case it's a vulkan struct for choosing enabled device features
<andrewrk>
ah, fair enough
<andrewrk>
unique_id, I hope you will be posting screenshots :)
<unique_id>
I will!
<MajorLag2>
Since people were mentioning image loaders, I do have an entirely-too-compatable pure zig .bmp loader. png has been next on the list since it is used a lot and doesn't look too hard, but I've had a lot going on.
<andrewrk>
ha - it's really hard to resist the urge to implement all the weird bmp features
<MajorLag2>
It bothered me whenever something in the test set was incompatible, so I kept going until there weren't any.
<MajorLag2>
So if anyone has a powerful need to support OS/2 Huffman1D monochrome bitmaps, I've got you covered.
donlzx has quit [Remote host closed the connection]
donlzx has joined #zig
douglasC has joined #zig
xtreak has quit [Remote host closed the connection]
donzx has joined #zig
donlzx has quit [Ping timeout: 276 seconds]
bheads_ has joined #zig
bheads__ has quit [Ping timeout: 256 seconds]
davr0s has joined #zig
Ichorio has joined #zig
foobar2000 has quit [Ping timeout: 252 seconds]
<unique_id>
andrewrk, afaik the vulkan xml spec has enough information in it to generate complete zig bindings with correct usage of optionals and [*] :) OpenGL I don't know about, its xml does have a 'len' attribute. The xml files are definitely ugly, you need to parse C types, and it might be better to write a non-generic parser that's very hacky looking but you know it works for the current and probably all future specs. This isn't something I
<unique_id>
can work on now, but either me or someone will do it in the future :)
<andrewrk>
good to know
<andrewrk>
does the vulkan xml spec also note when ptrs are null terminated?
<unique_id>
Yes, it appears so. len="null-terminated"
<andrewrk>
beautiful. zig has a type planned for that pointer type as well
very-mediocre has quit [Ping timeout: 252 seconds]
nightmared has left #zig ["WeeChat 2.0.1"]
andi3 has joined #zig
very-mediocre has joined #zig
<andi3>
"I do have an entirely-too-compatable pure zig .bmp loader" - wouldn't it make more sense to push forward on zig libc and then solve all those issues with the respective mature c lib ?
<andrewrk>
zig can export a c ABI and .h file
<andrewrk>
why would you want to maintain it in C?
<andrewrk>
:)
karlguy has joined #zig
<andi3>
why maintain? I mean you just take some c.png lib and use it with zig and be fine across all platforms
<andrewrk>
ah I see. yeah that's something we want to get to. but there are benefits to having the code in zig: faster, allocator support, less likely for the impl to eat errors, static stack size calculation (this isn't implemented yet)
<andrewrk>
error return traces
<andi3>
I think an old c lib that has lots of though put into its functionality and was used widely will still have less bugs than zig code and will be faster due to algorithmic complexity which is much more important than what the optimizer will do so unless you basically type the same code as c, c will be better for such things for a long time
<andrewrk>
that's a fair point
<andi3>
and time is limited resource as well so why even bother retyping all that, python guys reuse fortran code all the time for the same reason, zig would be for c what python is for fortran
donzx has quit [Remote host closed the connection]
bheads__ has joined #zig
bheads_ has quit [Ping timeout: 244 seconds]
darithorn has joined #zig
douglasC has quit [Ping timeout: 252 seconds]
andi3 has quit [Ping timeout: 252 seconds]
SimonNa has joined #zig
unique_id has quit [Ping timeout: 264 seconds]
unique_id has joined #zig
unique_id has left #zig ["Konversation terminated!"]
andi3 has joined #zig
<andi3>
reading https://github.com/ziglang/zig/issues/1223 - could you use/ expand opaque type to create an int-like that does not cast to an int e.g? like const my_int = @OpaqueType(i32)
<andrewrk>
andi3, sounds like you'd like to make a proposal
<andi3>
well it was a question to begin with cause that seemed like the obvious extension of an opaque type so I thought someone might have thought the same :D
<andrewrk>
you can use a struct for that
<andrewrk>
const my_int = struct {data: i32};
<andrewrk>
I'm going to do a live coding stream in 2 hours. any suggestions for what to do?
andi3 has quit [Ping timeout: 252 seconds]
Bas_ has joined #zig
douglasC has joined #zig
<douglasC>
andrewrk: I am new to zig, so anything basic for me.
andi3 has joined #zig
<andi3>
yes but then I always have to do my_int.data or access and that is kind of ridicules
<andi3>
Memory management/ custom allocator would be really cool
<andrewrk>
andi3, but that's what you wanted I thought? inability to cast to an int
<andi3>
yes, just still not awkward syntax
<andrewrk>
what would it look like if it were not awkward?
<GitHub123>
zig/master 687bd92 Andrew Kelley: self-hosted: generate zig IR for simple function...
<andi3>
just my_int = @OpaqueType(i32) ; my_int = 3; some_other_myint = my_int; // not awkward, just like an int, var int : i32 = my_int ->compile error
<Bas_>
How is that dif... oh I see. You mean all normal operations still work?
<andrewrk>
so far that syntax will work verbatim with my struct example
<andi3>
ok Andrew give me a sec :D
<andi3>
actually no it does not? error: integer value 3 cannot be implicitly casted to type 'my_int' var i : my_int = 3;
<andi3>
this really is most useful on numeric types
<very-mediocre>
possibly a silly question, but why do you not want it to be castable to i32
<andi3>
say you have a func that takes two ints, you do not want the caller to pass the args in wrong order
zolk3ri has quit [Ping timeout: 244 seconds]
<andi3>
you can name them appropriately and then they can be passes thought out the program
<andi3>
async/ M:N multiplexing would be nice to see as well @andrew
<very-mediocre>
isn't it a bit ugly to use opaque types just to ensure param order?
<Bas_>
I think it can be nice for some things, like when you use physical units
<very-mediocre>
also you'd have to use both i32 and the fake-i32 at the callsite
<andrewrk>
andi3, yeah I think on stream I'll live code converting `zig fmt` from single-threaded blocking to multi-core event based
<andrewrk>
which will be fun because std.event.* doesn't support file I/O yet
<very-mediocre>
ok, i see what you mean regarding physical units
<andi3>
something about build system/ with c code maybe would be nice as well. there is already a good blog post though
<Bas_>
Though I never actually worked with anything like that, so it could be that it's more of a pain than a benefit.
<very-mediocre>
Bas_: I'm of that opinion, I've never felt the need to write down units
<very-mediocre>
andrewrk: where would i find your stream if i wanted to watch it later? your YT channel?
<andrewrk>
twitch.tv/superjoe30
<very-mediocre>
ty
<andi3>
like a couple days ago I wrote about ADA which takes this constraints to a new level its really not just units at all, I'd argue there is very little reason to have pure ints in your program at all aide from for loops
<very-mediocre>
sounds like it'll be kickass but unfortunately it's super late for me so I'll catch it tomorrow instead
<andi3>
will it be uploaded to yt later?
<andrewrk>
yes
<andi3>
nice
<very-mediocre>
andi3 that sounds pretty radical, why wouldn't you have ints?
<andrewrk>
sorry, I just changed my username: twitch.tv/andrewrok
<andi3>
its just hard to read and easier to make mistakes but hard to read because there are ints everywhere which eventually will have names like tmp1 tmp2 .. and having them as explicit types serves as double documentation. And they are very easy (one line) to create and have absolutely no runtime overhead
<andi3>
I think there is really no reason not to use them, how would that make your program harder to use?
<very-mediocre>
i'm having a hard time picturing how this would look
<very-mediocre>
can you give me an example of what 2 different i32 types would be?
<GitHub178>
zig/master 69e60e3 Andrew Kelley: self-hosted: better IR for empty fn...
<Bas_>
I actually like these
<Bas_>
type Day_type is range 1 .. 31;
<andi3>
yes constraints on the range are great
<Bas_>
I also like the u2 types, but an explicit range is pretty nice as well imo.
<andi3>
one other useful constraint is to only allow for + but not * because e.g. how do you multiply two days? that can just be forbidden. But that goes somewhat against operator overloading in zig so that may not be feasible
<Bas_>
Unless you have a nice syntax for that I'd delegate that to a struct then.
<very-mediocre>
pub fn DayType(comptime val: u8) type { comptime assert(val > 0 and val < 32); return struct { val: u8 } }
<Bas_>
That just checks on construction?
<very-mediocre>
yeah, i just shot from the hip
<Bas_>
ok
<andi3>
yes that does not work
<Bas_>
The good thing about being explicit about these things is that the compiler also knows.
<andi3>
but if you want to constraint range + operator + conversion, I agree one could reach for a real struct so thats not really needed
<andi3>
but simple conversion and or range should be possible as a one liner
<very-mediocre>
you could do getters and setters of course
<very-mediocre>
anyway i see what you're getting at...
<andi3>
I would define OpaqueType(x) as a type that is just like x but does not convert automatically, so the same would be possible for structs where all of x methods/ fields are available on the new type, although for structs I've not had the need yet
zolk3ri has joined #zig
<andi3>
what I find really interesting was the suggestion proposed here to have some web ui for analytics
<very-mediocre>
that code i wrote above is wrong fyi, forgot i wanted to return the struct with the value pre-assigned. I'm too sleepy to be on here right now
<Bas_>
Is it on purpose that I can't subtract two pointers from each other to get the difference/size?
<andi3>
go can produce call-graphs and I think that is the right way to go to have easy to use analytics data as profiling/ call graphs available
<very-mediocre>
this should be subtractable
<Bas_>
Yeah it is, but then I've to take into account the size of the type as well.
<Bas_>
I can do it of course, but...
<andi3>
Is it on purpose that I can't subtract two pointers - I think that is actually a good thing for the same reasoning as I want OpaqueTypes for ints
<andi3>
I've to take into account the size of the type as well. - what do you mean?
very-mediocre_ has joined #zig
<very-mediocre_>
you can do a macro that takes the size into account
very-mediocre has quit [Ping timeout: 252 seconds]
<Bas_>
@andi3 if you have two * i64, and you do the @ptrToInt, to know how many elements there are inbetween you have to divide by @sizeOf(i64)
<andi3>
... you mean the size of the type pointed to I see
<Bas_>
yes
<Bas_>
C has this neat feature where it does that for you =P
<andi3>
cpp has std::ptrdiff that would be the same I guess
<andrewrk>
andi3, you can subtract [*] pointers but not * pointers
<andrewrk>
I think
<andrewrk>
at least add
<Bas_>
Let me try
<andi3>
yes but in c that is rather a bug than a feature if you agree with the people that know c and write the compiler and turn on their warnings you will get warnings for those things
<andrewrk>
wait, why would you want to add 2 pointers together? you'd want to add a pointer and a usize
<Bas_>
subtract
<andrewrk>
error: expected type 'usize', found '[*]i32'
<Bas_>
Yeah I get that.
<andrewrk>
my mistake
<andrewrk>
supporting pointer subtraction might be something we add to [*]
<Bas_>
ok
<andrewrk>
it would assert that it didn't create a negative number (e.g. it would return a usize, not isize)
<Bas_>
I'm wondering a bit. Things I used to do with poitners in C++ I find quite messy to do in Zig.
<andrewrk>
1,555 additions and 315 deletions. it took a while to work through the compile errors but then everything worked the first try
<andi3>
what is the reasoning to not put this into a builtin? if you have builtins for conversion from ptr to int this seems more appropriate
<andrewrk>
what, a builtin for pointer subtraction?
<andi3>
those are probably things that should not have been done in cpp that way anyway
<Bas_>
lol
<andi3>
yes like std::ptrdiff
<andrewrk>
Bas_, if you show me some messy zig code examples I'll try to make some suggestions
<andi3>
std::difference is the correct one actually
<Bas_>
How can I show you?
<Bas_>
std::difference is silly imo. just do a - b ^^
winksaville has joined #zig
<andrewrk>
if it's open source you can link me to a repository, or you can paste a snippet to, e.g. https://clbin.com/
<andi3>
but it shows what you do if you read the code you know whats going on, if you. just subtract two numbers nobody knows what those do, are they in a for loop, pointers... can be anything
<andrewrk>
in english what is partition supposed to return?
<Bas_>
The partition point.
<andrewrk>
oh I see
<Bas_>
so everything before is true and everything after false.
<andrewrk>
got it
<Bas_>
ok
<andrewrk>
Bas_, I didn't work through all the logic, but my suggestion is to avoid @ptrToInt, and slice less, and introduce some index variables
<stratact>
andrewrk: quick question, why does Zig go for duck typing in generics, when the goal of the language is clarity? Wouldn't some kind of "contract-based" generics be more in-tuned with Zig for the sake of clarity? Ideally this would work with a traits system, but this again goes back to the bikeshed discussion of OOP
<andrewrk>
as a litmus test there's no reason this function shouldn't be able to run at comptime, but depending on @ptrToInt makes it runtime-only
<Bas_>
Alright, I'll try to do it with indices
<Bas_>
Yeah I didn't want to use @ptrToInt =D
<andrewrk>
it's definitely possible to implement this in a straightforward way without it
<andrewrk>
stratact, I don't have a really good answer for you
<stratact>
andrewrk: that's fine. I just wanted to share at least
<andi3>
stratact I think the same when I see var in that code here again instead of traits, bad thing is if you have a function in a function in a .... and somewhere down a var is used and it. gives you some compile error out of the darkness of some lib you are using which should have been caught right at the beginning
<andrewrk>
for me, too much contract based generics can make it difficult to read code
<stratact>
hmm, I see
<andrewrk>
it introduces a lot of complexity
<andi3>
how does contracts make code difficult to read? I find it makes it way easier than just var whee I have no idea what specifics of that var are actually used/ needed/ relied on
<andrewrk>
I didn't want to give up the ways in which C is actually quite nice and simple
<andrewrk>
andi3, it's all in the specifics
<andrewrk>
maybe we can talk about specific contracts rather than contracts in general
<Bas_>
I agree that simplicity is nice. And that's actually lacking in quite a few popular languages.
<andi3>
well complex problems require complex solutions just not as crusted as cpp but certainly about as capable and expressing contracts is pretty important IMO
<very-mediocre_>
`crusted as cpp` - hear, hear
<andrewrk>
andi3, that's certainly true. and given that most programming languages are turing complete, you can write complex enough code to solve a problem of any complexity. the question is, what does the structure of the solution look like?
<stratact>
Maybe there is a good compromise that Zig can do, which is not to be as complicated as how Rust does contract based generics but not to be too simple in duck typing generics, in order to be "practical" but at the same time not too complex
<andrewrk>
zig's answer to this question is that we have very simple building blocks, and you create your own castle with them
<andrewrk>
your castle will be complicated, but the bricks are just bricks
<Bas_>
I'm already afraid there will be too much stuff in std :P
<andi3>
well the Turing complete thing really is pointless I just need while(x) and am Turing complete but what is the point and still even if you are not Turing complete that does not make life e.g. the problems much easier either just because halting problem is solved does not mean all other language problems are
<andi3>
well the structure of the solution is just what traits are all about, giving structure into the program
<andi3>
your castle will be complicated, but the bricks are just bricks - that sounds nice hehe :D
<andrewrk>
Bas_, right now std's biggest goal is a test bed for the language. once the language is stabilized, the next task is to audit the standard library and figure out what APIs will or won't make it in. by that time we'll have nice package management solution so the non- std-lib code can go live in packages
<Bas_>
ok cool
<stratact>
Anyway just food for thought about clarity in Zig, cause I thought having contracts might make easier for the reader to understand how a generic type or function is to be used
<andi3>
....and fail fast -> better error messages
<Bas_>
I guess there's no slick way to reverse iterate through a slice?
<andi3>
I'm already afraid there will be too much stuff in std :P - why? You do not have to use it but reimplementing bubble sort every time does not cut it either so I'm happy to have something at least the size of cpp stdlib with solid algorithms which spare my time on off by one errors and bad algorithms
<andi3>
is the stream about to start? (no pressure :D )
very-mediocre_ has quit [Ping timeout: 252 seconds]
<Bas_>
I don't mind a sorting function and that stuff
<stratact>
I'd say one of the things I'm not too happy about Rust is its libstd is too minimal for my tastes, but the idea is that things to be split into separate dependencies because programming APIs evolve and old stuff shouldn't be used as much anymore
<Bas_>
I also think the std in C++ is going to grow too big
<andi3>
I mean cpp also has partial sort and find max element and rotate and stuff which is not really a given in all languages
<Bas_>
But there what also annoys me is that the language can't work without std
<andi3>
well judging from the latest talks I've heard the standard committee is mostly against a big stdlib although most users want one, the argument mainly is that standardization takes time and by time of adoption things are obsolete again
<Bas_>
as well
<Bas_>
And I'm not sure stuff like regex should be in there
<Bas_>
while at the same time really useful things like string view take a long time
<andi3>
I'd want to be able to use zig for scripting as well so I hope I can quickly do simple things like that
<andi3>
also, zig is it's own build system but if you have to go back to python or something else for scripting this defeats the point of a build system in the main language
<Bas_>
yes I actually think Zig can be used for scripting. At least it feels like it.
<Bas_>
Yeah that's really awesome
<Bas_>
(As I hate CMake =D)
<stratact>
andrewrk: will Zig have more "batteries included" in the std library than say languages like Rust?
<andi3>
but then you need basic utilities for easy access of files/ text/ system commands basically thats is
<andi3>
everyone hates cmake but at least it's something that brings cpp builds together and helps some clang tooling but the idea with build system in the same language is really great, jai has it and I'm not sure why rust does not have it, seems obvious in hindsight
<Bas_>
I also don't know why there are so many build systems that get it wrong
<douglasC>
twitch.tv... Service Unavailable - Maximum number of active clients reached. Anybody else get this
<Bas_>
xD
<andi3>
Andrew is live @stratact
<stratact>
oh, link?
<andi3>
may I say that I find it great that Andrew is so very productive but watching his desktop is quite a pain I mean beautiful desktops for linux exist these days anyway off topic and personal taste please don't take this seriously :D
<winksaville>
newbie here: compiled and install zig. Then followed the docs and wrote and ran hello.zip, worked fine. But have a question, how do you return a specific value from main? (A quick search of the docs and web didn't find an answer)
<Bas_>
return specific_value; ? =P
<stratact>
andi3: did he answer my question earlier because I didn't catch it if he did
<andi3>
I do not think that is yet decided
<andi3>
afaik
Ichorio has quit [Ping timeout: 268 seconds]
<andi3>
I think you can't return from main cause its return type is void @winksaville
<stratact>
ouch, the self hosted compiler links to libc...
<andi3>
ah so you have `expected return type of main to be 'u8', 'noreturn', 'void', or '!void'` at your disposal if you choose u8 e.g. you can return 1 without issue
<andi3>
well if you have libc in zig someday that will be no issue, that will be such a relief honestly can't wait for that
<winksaville>
@Bas_: I tried return 123; but compiler complained "error: interger value 123 cannot be implicitly casted to type 'void' ". So then an error told me that main can be 'u8', 'noreturn', 'void', or '!void'. So I changed it to 'u8' but then zig says:
<winksaville>
var stdout_file = try std.io.getStdOut();
<winksaville>
preceded by:
<winksaville>
hello.zig:4:21: error: expected type 'u8', found 'WindowsGetStdHandleErrs'
<andi3>
`const std = @import("std");` should suffice because that return does not actually count as IO
<andi3>
9I'm myself a newly in zig at best)
<winksaville>
@andi3: I have that as the first line, and all was well until changing the return type of main to u8. I'm guessing I've got to "catch" the try.
zolk3ri has quit [Remote host closed the connection]
noonien has quit [Quit: Connection closed for inactivity]
<unique_id>
I joined late on the twitch stream. Cool stream, I don't have a twitch account to comment. Not yet.
andi3 has quit [Ping timeout: 252 seconds]
<karlguy>
andrewrk: nice, another dvorak user. :P
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<stratact>
Is there ever a need to have IO blocking?
renatorabelo has joined #zig
douglasC has quit [Ping timeout: 252 seconds]
<andrewrk>
winksaville, looks like you got it figured out, yeah? make sense?
<andrewrk>
Bas_, and that implementation you can use at comptime :)
<Bas_>
Yeah that's cool.
<andrewrk>
stratact, it depends
<winksaville>
andrewrk, what I did makes sense but how can I ignore an error? For instance I want to report the error and continue to the next statement: if (stdout_file.write("Hello, world!\n")) { stderr_file.write("err to stdout"); } return 123;
<winksaville>
andrewrk, txs. Now I want to "capture" the error to a local variable is there a standard "error.None"? It seems I can initialize it to anything but that feels a little weird:
<winksaville>
var my_err: error = error.Xyz; report(my_err);