ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
tjpalmer has joined #zig
<tjpalmer>
Hey y'all. I have a question about zig compiler speed. Other than compile-time code execution, the grammar and language seem like it ought to be fast. And mostly it seems to be.
<tjpalmer>
But I was wondering if there are any benchmarks or large code bases for quantifying the speed.
<tjpalmer>
And I've seen the docs on debug, release-safe, and release-fast, but I'm curious about more specifics than that.
MajorLag_ has quit [Ping timeout: 260 seconds]
tjpalmer has quit [Quit: Page closed]
<andrewrk>
tjpalmer, there is not a large codebase to quantify the speed yet
<andrewrk>
what exists is not implemented yet plans to have the compiler handle object caching and compile speed optimizations
tjpalmer has joined #zig
<andrewrk>
tjpalmer, did you get my messages?
<tjpalmer>
Got them from the log. I'm only sort of online right now. Thanks for the info!
<andrewrk>
somewhere in 0.3.0 and 0.4.0 I'll do a proof of concept on compile/linking speed
<andrewrk>
fundamentally, we have the power to compile very quickly. because we carefully make no guarantee about certain things, zig is free to split a compilation up into any number of .o files it wants to, add padding, cache intermediate values, etc
<tjpalmer>
Glad to hear the plans. Compile speed is one of my top concerns in programming, so I was curious.
<tjpalmer>
Mostly unrelated, if Jai ever comes out, do you see that as competition in Zig space?
tjpalmer_ has joined #zig
tjpalmer has quit [Ping timeout: 260 seconds]
tjpalmer_ has quit [Ping timeout: 260 seconds]
Topa has joined #zig
meena has quit [Ping timeout: 276 seconds]
meena has joined #zig
Topa has quit [Ping timeout: 256 seconds]
cenomla has joined #zig
tjpalmer has joined #zig
<tjpalmer>
I searched and found old discussions on Jai, by the way. No need to worry at the moment.
tjpalmer has quit [Quit: Page closed]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
Topa has joined #zig
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
Topa has quit [Ping timeout: 240 seconds]
noonien has quit [Quit: Connection closed for inactivity]
<andrewrk>
tjpalmer, I do see Jai as (friendly) competition, but there are quite a few design decisions of Jai that are not harmonious with zig
Topa has joined #zig
<andrewrk>
compared to zig, I would characterize Jai as less concerned with (debug) safety, less concerned with the open source community, more concerned with metaprogramming
<andrewrk>
jai's compilation speed is inspiring. I plan to take a different approach to get there which 1. scales to millions of lines of code rather than jai's target of 50,000 lines, and 2. maintains integration with the LLVM toolchain
<GitHub185>
zig/master a795e4c Andrew Kelley: add some docs for reflection
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 252 seconds]
Topa has quit [Ping timeout: 265 seconds]
arBmind has quit [Quit: Leaving.]
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 265 seconds]
dd3 has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Topa has joined #zig
hio has quit [Quit: Leaving]
davr0s has joined #zig
arBmind has joined #zig
hasen_judy has joined #zig
cenomla has joined #zig
hasen_judy has quit [Ping timeout: 252 seconds]
MajorLag_ has joined #zig
<MajorLag_>
New reflection docs make me curious, does 'type' contain other fields? Could it be used to do some interesting compile-time metaprogramming like, I don't know, automatically generating a compact on-wire version of a struct?
<andrewrk>
I think it's planned to support that
<MajorLag_>
Sweet. Though that particular example wouldn't work so well without some kind of annotation system to tell it which fields to ignore or treat specially I suppose.
<MajorLag_>
Which is getting into Jai-level metaprogramming.
asdf___ has joined #zig
asdf___ has quit [Client Quit]
Hejsil has quit [Read error: Connection reset by peer]
<andrewrk>
I do think we should have some way to provide metadata for struct fields
<andrewrk>
go has that ` ` thing, but in zig it would be some arbitrary comptime value
hasen_judy has joined #zig
hasen_judy has quit [Ping timeout: 276 seconds]
arBmind has quit [Quit: Leaving.]
MajorLag_ has quit [Quit: Page closed]
MajorLag_ has joined #zig
zesterer has joined #zig
jfo has joined #zig
<jfo>
hey is there a way to jump backwards in a for conditionally?
<jfo>
like I'm looping over a "string" and if I see a particular characted I jump back to somewhere in particular
<jfo>
I know I can do this with a while loop but was wondering if it's possible just in a for
<zesterer>
Hello all. I'm new here. I discovered Zig about an hour ago. I've been in the market for a new language: I have a pretty good understanding of C++ & C and an amateur understanding of Rust. I tend to work on low-level stuff, but I've been frustrated by the lack of safety checks that C provides and the absurd complexity that C++ provides (I understand the language, but it's always difficult to forsee issues when programmi
<zesterer>
ng with it).
<zesterer>
What I've seen so far of Zig has me really impressed, but I have a few questions before I start seriously consider using it for my next project.
<zesterer>
Firstly, how do you handle the whole dynamic-memory-management-with-dangling-pointers problem? C doesn't, C++ has ridiculous runtime features like std::shared_ptr, and Rust has a prohibitively strict syntax to evade the problem. I've not yet seen any example code of this kind in Zig. What does it have?
<zesterer>
Secondly, how does Zig deal with the destruction of complex types? C (again) doesn't, C++ has destructors, and Rust has the Drop trait. What does Zig have?
<zesterer>
I'd be really thankful for answers on these :-)
Topa has quit [Ping timeout: 265 seconds]
<MajorLag_>
Zester: Zig is like C. There is no native memory management, and no constructors or destructors. There is defer.
<andrewrk>
jfo, yeah there is, you make a while loop inside the for loop
<andrewrk>
oh, you mean you want to decrement the index
<jfo>
yes
<andrewrk>
jfo, a for loop really is just sugar over var i: usize = 0; while (i < thing.len) : (i += 1) { const item = thing[i]; ... }
<andrewrk>
so if the sugar is too restricting, unsugar it and use the while
<jfo>
that's what I've been doing just wanted to see if there was another shorthand in for :)
<andrewrk>
I think we won't have that, because part of the benefit of `for` is that you know the index never goes backwards
<andrewrk>
when reading code
<andrewrk>
zesterer, greetings
<andrewrk>
we have defer and errdefer, and that's it
<andrewrk>
there are proposals to have some kind of compiler-enforced handling of cleanup, but no proposal has been accepted yet
<zesterer>
andrewrk, MajorLag_: Thanks for the response
<andrewrk>
zesterer, there is still the danger of forgetting to clean up a resource, but correct code that handles all resource cleanup avoids nesting and is simple to reason about
<andrewrk>
essentially every resource allocation will have either a defer or an errdefer after it, depending on if the resource should be unconditionally cleaned up, or cleaned up only if the function returns with an error
<andrewrk>
s/function/scope/
jfo has quit [Ping timeout: 240 seconds]
<andrewrk>
if you insert into the middle of a function code that can return an error, resource cleanup will continue to work correctly, you can't forget to update the cleanup code
<andrewrk>
and spotting resource mismanagement is trivial. it looks like an "allocate" or "open" without a "defer" on the following line
<zesterer>
andrewrk: Fair enough. I'm definitely interested by Zig, but I must use Rust instead for my next project. Thanks for clarifying!