ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
mahmudov has quit [Ping timeout: 264 seconds]
donlzx has joined #zig
kristate has joined #zig
BenJGirard has joined #zig
MajorLag1 has quit [Ping timeout: 276 seconds]
v1zix has joined #zig
kristate has quit [Remote host closed the connection]
v1zix has quit [Ping timeout: 252 seconds]
stratact has joined #zig
BenJGirard has quit [Quit: Page closed]
Richard10 has joined #zig
Richard10 has quit [Client Quit]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
xtreak has joined #zig
kristate has quit [Remote host closed the connection]
bodie_ has quit [Ping timeout: 276 seconds]
monteslu has quit [Ping timeout: 276 seconds]
odc_ has joined #zig
stratact has quit [Quit: Leaving]
odc has quit [Ping timeout: 276 seconds]
odc_ is now known as odc
monteslu has joined #zig
donlzx has quit [Ping timeout: 276 seconds]
dvn has quit [Ping timeout: 276 seconds]
bodie_ has joined #zig
bodie_ has quit [Changing host]
bodie_ has joined #zig
hryx has joined #zig
<GitHub169>
[zig] jayschwa opened pull request #1262: docs: Highlight reader's position in table of contents (master...show-place-in-toc) https://git.io/fNntr
<hryx>
The docs briefly mention a case where pointer arithmetic is not supported. Does Zig support pointer arithmetic in some ways, though?
dvn has joined #zig
quc has joined #zig
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
very-mediocre has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
quc has quit [Remote host closed the connection]
xtreak has quit [Remote host closed the connection]
v1zix has joined #zig
v1zix has quit [Client Quit]
tiehuis has joined #zig
<tiehuis>
hryx: zig has different pointers for a single item vs. an unknown number of items
<tiehuis>
these are denoted by *T and [*]T respectively
<tiehuis>
you can perform arithmetic as normal on the pointer to many, but it is disabled on the single-item pointer case
<tiehuis>
of course, you can @ptrCast between any pointers if you need to
xtreak has joined #zig
qazo has joined #zig
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
jjido has joined #zig
<hryx>
Good to know tiehuis, thanks very much
jjido has quit [Ping timeout: 256 seconds]
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
hryx has quit [Quit: Leaving]
zolk3ri has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
qazo has quit [Ping timeout: 252 seconds]
kristate has quit [Remote host closed the connection]
xtreak has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
zolk3ri has quit [Quit: leaving]
zolk3ri has joined #zig
kristate has quit [Ping timeout: 244 seconds]
stratact has joined #zig
xtreak has joined #zig
<tiehuis>
has anyone done any c va_args implementation from within zig?
<tiehuis>
that is, implementing a variadic function in zig
<tiehuis>
i'll implement one otherwise shortly, since i need it to implement printf and friends in libc
tankf33der has left #zig [#zig]
qazo has joined #zig
davr0s has joined #zig
tiehuis has quit [Quit: WeeChat 2.2]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
quc has joined #zig
quc has quit [Remote host closed the connection]
quc has joined #zig
davr0s has joined #zig
very-mediocre has quit [Ping timeout: 252 seconds]
kristate has joined #zig
edr has joined #zig
edr has joined #zig
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
xtreak has quit [Remote host closed the connection]
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
<andrewrk>
tiehuis, I think there's an issue for that
<andrewrk>
I'm not aware of any work done on it
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<GitHub122>
zig/master a9f0681 Andrew Kelley: prevent non-export symbols from clobbering builtins...
Tobba has quit [Ping timeout: 240 seconds]
unique_id has joined #zig
<unique_id>
Does the current standard library have string to ints/floats conversion functions?
qazo has quit [Ping timeout: 252 seconds]
<andrewrk>
we have float printing but not float parsing yet. we have int parsing and printing
<andrewrk>
if you're linking libc you can use those functions in the mean time
<andrewrk>
which I suspect you are for your game
<unique_id>
This is actually unrelated to my game. I'm converting some C++ currency/trading code to zig (nothing special). I was using stod which is part of the c++ stdlib, so I'll use strtod for now.
<unique_id>
Btw once I've ported this spreadsheet application over to zig, I think I'll have the honor of having made the first such app for Zig :D https://i.imgur.com/tFTiArp.png - I'll be putting that into my game just for giggles
<andrewrk>
ooh neat!
<andrewrk>
unique_id, I'm excited to get this self-hosted compiler going for you - I have some ambitious goals for how fast it will let you iterate
<unique_id>
awesome!
<andrewrk>
from the very beginning it's designed to utilize all cpu cores maximally, and stay alive watching for files to be updated and auto-rebuild
<andrewrk>
if all that goes well then I'm going to look into hot code swapping
<bheads_>
Thats going to be so good for fast development
<bheads_>
but code swapping is really tricky in some systems
<andrewrk>
I think at least swapping functions out can be portable
<andrewrk>
it's a messy feature though, to be sure
jjido has joined #zig
very-mediocre has joined #zig
davr0s has joined #zig
Tobba has quit [Ping timeout: 256 seconds]
donlzx has quit [Quit: Leaving]
<unique_id>
I'm just getting ready to ramp up my productivity. I've been in a horrible slump. I was always very productive in C#. Everything went to hell when I switched to C++, and also when switching excessively between C++ and other languages. Then I tried C and managed a month of insane productivity but switched back to C++ thinking I could carry it over. Go figure. Sigh. There's just too many things about C++ that distract me/annoy me/
<unique_id>
hinder me, it breaks my spirit.
<andrewrk>
I know what you mean
<bheads_>
I have spent the last 5 years writting enterprise java... it takes me way to long to code without and ide and a GC. It has broken me... I tried to get back into C++, but five mins after having to write header files I just give up
MajorLag1 has joined #zig
<bheads_>
I need zig or jai to fix me
Tobba has joined #zig
<andrewrk>
well, seeing as jai is closed source
<andrewrk>
that leaves zig :)
Bas_ has joined #zig
jjido has quit [Read error: Connection reset by peer]
mahmudov has joined #zig
jjido has joined #zig
very-mediocre has quit [Ping timeout: 252 seconds]
<unique_id>
Is the write method in os/file.zig supposed to be private?
<andrewrk>
unique_id, no it's not. but I think that calling it with method syntax (incorrectly?) ignores visibility modifiers
<GitHub21>
zig/master 0736e6a Andrew Kelley: std.os.File: add missing pub modifiers
<andrewrk>
unique_id, ^
andi3 has joined #zig
<andi3>
I was just testing out translate-c and it did not work, https://github.com/syoyo/aobench.git , it would be easy enough to retype by hand but that is kind of the reason I thought it may work automatically as well and now think maybe that its worth a quick notice here
<andrewrk>
andi3, translate-c is mostly complete for .h files. for translating source there is a lot of work to do
<andi3>
allright
jjido has quit [Ping timeout: 276 seconds]
<unique_id>
program arguments?
<andrewrk>
unique_id, there are a few APIs for that. the easiest cross platform one is: std.os.argsAlloc
<andrewrk>
it has to heap allocate because of windows
<unique_id>
Windows doesn't put them on the stack for you?
<unique_id>
apparently that's how it works on Linux/system v ABI
<andrewrk>
yeah
<andrewrk>
if you're targeting posix, you can use std.os.posixArgs which is a non-allocating API
<andi3>
just looking at jai again Jon aims at 30 000 lines in under one second/ half a second compile time complete rebuild, is there some estimate for what zig aims for?
<andrewrk>
no. I'm not far enough along to estimate
<andrewrk>
a clean build won't be that fast though, for several reasons
<andrewrk>
1. zig is sticking with LLVM as the backend and LLD as the linker. this gives us debug info
<andi3>
he plans to eliminate llvm for most of those super fast rebuilds to be fair
<andrewrk>
2. I'm exploring a model where zig stays alive and watches files and rebuilds using memory cached information. this means that clean builds are somewhat slower, but incremental builds are much faster
<andrewrk>
all that said, the job system is the same basic design, so I think it should be reasonably similar
<andrewrk>
jai not using llvm means that it doesn't have debug info, or work on non-x86-64 systems
<andi3>
yes
<andi3>
what I wonder is, if you use no optimization in llvm whatsoever, (why) is it still slow? like shouldn't you be able to run straight without optimizations really fast?
<winksaville>
as I understand it jai is using llvm for "release" builds and supporting other targets.
<andi3>
yes but if it was fast without optimizations he could just run it without optimizations and be done with fast builds
<andrewrk>
abstractions are inherently slow
<andi3>
he mentions that going from 30 000 lines jai to 200 000 lines c to parsing that c to compiling that c is still faster than llvm so not sure what you mean by abstraction?
<andrewrk>
LLVM is an abstraction over code generation
<andrewrk>
so if you use LLVM to do code generation, you're going to take a performance hit over implementing the whole thing yourself and tightly coupling it with your frontend code
<andi3>
yes but so is generating c parsing c and compiling c
<andi3>
and Jon wants to get debug into his own .o files actually so I think that is actually reasonable and developing on x86 as the 99,99% case that seems like a tradeoff, for some programs, non optimized builds will not work of course but than some functions will be able to ne compiled with llvm optimizations so if this works out, it sounds sound
<andrewrk>
yeah, it's impressive results so far
<andrewrk>
zig also has planned @optimizeFor() which works at the block scope level (or at least at the function level), and this would allow you to do some optimization in even debug builds, or debug code in release builds
<andi3>
and its going to be open sourced with a pretty free license as well just saying cause you mentioned - well, seeing as jai is closed source (but of course at the moment you are spot on)
<andrewrk>
this feature requires LLVM even for debug builds
<andrewrk>
I think jai will become much more relevant when it is available
<andi3>
my guess/ hope would be that it would be possible that LLVM without optimizations could be made to go much faster maybe they just not focussed on that because they are all into optimization that there is low hanging fruit
<andi3>
@winksaville actually no but I might skip through
<winksaville>
In the "backend" videos he explains a lot of things he's done.
<andi3>
today I wanted to read the build.zig code but seeing @ParentPointer and remembering what reading the Allocator code (which, now I understand actually) made me sad again and I stopped again
<winksaville>
andrewrk: I've got a zig question, I don't understand "const Self = this" I've used it blindly here (https://github.com/winksaville/ziglang-buffer/blob/master/main.zig) it seems like its a pointer and a type as I declare b of type Self and then can use "b.buffer" in the for loop. Could you explain or point me to some docs?
<andi3>
every time @ParentPointer in zig code is used I think one programmer will loose an hour of its life reading code compared to static interfaces/ traits whatever you call it
<andrewrk>
winksaville, it's not documented yet and it might change. suffice to say that if you do `const Foo = this;` at the scope of a struct or union, then Foo now refers to that type
<winksaville>
And what does "b.buffer" mean, is b a pointer?
<andi3>
@winksaville just stepped into the video and he indeed sped up llvm by a good margin (2x ?) as far as I grasp as first thanks for the link
<andrewrk>
andi3, I don't understand, are you complaining about the priority order of github issues?
<andrewrk>
there are several open issues for interfaces/traits/oop
<andi3>
can't hide that I wish there was more progression I guess but despite of my angry tone I definitely respect your rhythm to do the things just can't hold back that much, sorry
<Bas_>
You're free to contribute ^^
<andi3>
to me its actually not like there is a whole lot to discuss in the end it basically comes down to whether Andrew agrees with the c or golang types of arguments
<unique_id>
andi3: right now their 80,000 line game is compiling in 1s https://youtu.be/uZgbKrDEzAs They are targeting 1million lines/s (https://youtu.be/uZgbKrDEzAs). They'll do that by for example removing the linker. I think it's clear that Zig and Jail will benefit immensely from each other, with both of them obliterating the nonsense of older languages and innovating immensely, with Zig maybe taking a stable more mature approach and Jai
<unique_id>
possibly testing more crazy ideas.
<andi3>
one thing I really like about zig so far as well are coroutines, I have not yet really got the hang of it so its not like I can fully grasp the potential but what I have seen so far is really great and I think I will really enjoy coroutines in any language in the future like Kotlin as much around this for totally different areas as well for example
<unique_id>
I really don't see why Zig should experiment with removing llvm at this point in time. That can be done at any point in time.
<unique_id>
whoops
<Bas_>
I heard about jai before, but seeing that it's not even available I don't understand the hype.
<Bas_>
And why are there a so many plugins for stuff when you can't even compile anything? =/
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<winksaville>
Here, http://bit.ly/2LvUBgR, I've got a struct which I want to be instantiated on the stack or the heap. And I added some @compileLog's and I see that in initStack "self" is a Buffer(4096) and in initHeap it's obviously a *Buffer(4096) (i.e. a pointer). But I can use "self." to invoke fill in both cases, I find that confusing.
<unique_id>
I've personally completely bought into const, var, @ functions, try, the different pointer types and alignment, custom allocators, and honestly everything from Zig. Jai doesn't have these things from what I can see. Zig feels like a better language at the core level. I also do think methods are a nice way to namespace things, something Jai doesn't have. However, JBlow is doing some exciting innovation with his "Contex struct" and
<unique_id>
temporary storage as seen in his new talk I linked above.
<unique_id>
I look forward to seeing how it turns out :)
<andrewrk>
I'll have a look at Context structs
<unique_id>
I used to want to program in assembly just so I could tie random things to different registers that would survive across function calls. It's something I wanted to play with. That's JBlow's context struct :)
<andrewrk>
I wish there was a way to read about it without waiting while a video plays
<Bas_>
same =D
<andrewrk>
I can read a lot faster than I can wait for videos to end
<andrewrk>
unique_id, I was brainstorming an idea for this
<winksaville>
andrewrk: in the "..." menu on youtube you can "open transcript" :)
<winksaville>
If you click on a line it goes to that point in the video.
<andrewrk>
idea being that you could have a scope where, e.g. "allocator" is bound to some value, and then you omit that parameter to functions with a matching name
<andrewrk>
we're probably not going to have that. but I'll have a look at jai's feature all the same
<bheads_>
I have been wondering about jai contexts, is it really just a context in thread local global scope, with a magical ctx.allocator?
<andrewrk>
person asks: "what happens when you run out of temporary storage? For applications that don't know the maximum size in advance, is using it a bad idea?"
<andrewrk>
jblow replies: "It falls back to heap allocation which it then leaks. If you don't know the maximum size, it's not a candidate for temporary storage."
<andrewrk>
this is one of those edge cases that zig refuses to ignore
<winksaville>
andrewrk: were you able to see the transcript on youtube?
<andrewrk>
winksaville, sorry, I thought you were joking. I don't see how that would help. For one that's not the way the media was designed to be consumed, and for two it doesn't have the code snippets
very-mediocre has joined #zig
<winksaville>
when you click on the line in the transcript it goes to the video so you can see the "context" :)
<andrewrk>
I'm not going to look right now, I'm working
<winksaville>
np, just an FYI
davr0s has joined #zig
<winksaville>
andrewrk: When you've got time, my experiment, http://bit.ly/2LvUBgR, was to see how to init a struct allocated on the stack and heap. I've got it working, but ideally it would be nice to need only one initializer, is that possible now or if not is it something you think is viable in the future?
<andrewrk>
you should keep the initStack function and delete the initHeap function
<andrewrk>
if you want it on the heap, then you do allocator.create(Buffer4k.init())
<andrewrk>
"source" doesn't mean the format that it's in - it means whether it's the thing people look at and edit, or it's the thing they generate
<bheads_>
compile llvm in llvm asm then decompile that back to zig
<bheads_>
you need a path to migrate from c++ to zig
<andrewrk>
to rephrase, it doesn't matter if we have `.zig` files that provide the LLVM features. it matters what files the llvm community - people - are editing upstream
<very-mediocre>
C++ feels too crazy to transpile to anything ;|
<Bas_>
The gist of it is that you shouldn't try to be perfect, but useful ^^
<Bas_>
And then you can make it close to perfect later
<bheads_>
Having a project in to language is bad plan
<bheads_>
in two***
<bheads_>
most people will give up on using the new language
<andrewrk>
I could see there being a manual port of LLVM to zig
<andrewrk>
it would take a team of people to port each upstream commit
<bheads_>
You should checkout what the D team did
<andrewrk>
we don't have that kind of person-power right now
<bheads_>
they transpiled the c++ to D
<andrewrk>
that makes sense for D
<bheads_>
that goal was to keep parity during the conversiob
<very-mediocre>
with a stdlib that depends on the garbage collector, and the garbage collector is poor :/
<very-mediocre>
and later on, a short-lived effort to ditch the garbage collector which didn't pan out
<very-mediocre>
(responding to Bas_)
<bheads_>
andrewrk, the only thing I see bad about this is that zig is 100% depended on llvm
<bheads_>
ie, can a zig compiler be written to use the gcc back end?
<andrewrk>
bheads_, no, it's tightly coupled to llvm
<andrewrk>
I mean obviously it could, with some amount of work, but it's not designed that way
<Bas_>
Ehm... I don't get it I think. Does that mean the zig compiler has to parse C++?
<bheads_>
just want to prevent a language decision being decided around how llvm works
<bheads_>
Bas, zig_ccp.a has a c api
<Bas_>
No i mean this
<Bas_>
Use Zig's libc and Zig Self-Hosted Compiler - using zig as a C++ compiler - to build libstdc++ from source for the target.
<andrewrk>
Bas_, zig links against libclang, and clang supports compiling C++ - so we just expose that
<Bas_>
Ooh
<Bas_>
This is a stupid question. What's the value of the self hosted compiler if you have to maintain the stage1/C++ one anyway?
<bheads_>
Thats not dumb at all :)
<andrewrk>
that's a really important question
<andrewrk>
1. I'm using async/await/coroutines and a multithreaded event loop. this would be too hard (at least for me) to get right in c++
<andrewrk>
2. it gives us cross-compiled compiler-rt for all targets. so we can produce a working compiler for all targets without needing gcc-multilib or a cross build of binutils or whatever
<andrewrk>
3. superfluous features can be written in only the self-hosted compiler. for example the auto doc generator
<andrewrk>
4. it actually is a lot easier to write correct code in zig than c++
<bheads_>
I feel like Walter Bright (D lang compiler dev) soent so much time writing C++ for the compiler he didn't get a lot of experience writting complex programs in D. He never seemed to think about anything past really trivial ideas.
<bheads_>
so writting the compiler in zig means zig will get a work out (and so will andrewrk and co)
<bheads_>
then more I think about it, having the stage2 and stage3 compilers depend in zig_cpp.a is good for the stage1 compiler. its really easy for things like that to bitrot.
<andrewrk>
stage1 can't bit rot because the CI builds will build 1,2,3
<Bas_>
Hmhm I see.
<andrewrk>
that's a huge benefit of having an O(1) self-hosting process
<Bas_>
So stage1 will mostly be a 'minimal' compier to compile the stage2 compiler.
<andrewrk>
exactly - but it has to work
<Bas_>
Sure
<Bas_>
But it doesn't have to be perfect :P
<bheads_>
right but it would be easy to fix a bug in the zig compiler and ignore the stage1
<bheads_>
if the bug does not effect building the stage2
<andrewrk>
right. at some point, we start shipping stage 3, and I close all the bugs that only apply to stage1 (or at least re-label and de-prioritize them)
<bheads_>
would the stage1 and stage2/3 compilers share the same tests
very-mediocre has quit [Ping timeout: 252 seconds]
<andrewrk>
we'll have: test/stage1/*, test/stage2/*, and test/both/*
<andrewrk>
ideally all the tests will be in the "both" dir
<andrewrk>
but in reality some will be in stage1 and some will be in stage2
<bheads_>
interesting
<bheads_>
but makes sense
<winksaville>
I've built stage1 and I don't see `zig_cpp.a` I do see `zig_llvm.cpp` and `zig_llvm.cpp.o`, what am I missing?
<winksaville>
I think I see it now, `libzig_cpp.a`
<winksaville>
Can you write a compiler in zig that compiles language XYX that just uses llvm c interface plus zig_llvm.cpp?
<andrewrk>
you can write a compiler in zig that compiles language XYX (assuming that's a made up name) that just uses llvm c interfaces
<andrewrk>
zig_llvm.cpp is needed for only some extra API that llvm's C API is lacking
<winksaville>
yes, just made up XYZ, and I mentioned zig_llvm because I'd heard/saw that you'd said that.
<andi3>
@Bas_ This might be relevant https://www.jwz.org/doc/worse-is-better.html - which is pretty much the opposite of the zen of zig, avoid lokal maxima, edge cases matter etc. is all the opposite
<Bas_>
In a way, yes. But at the same time Zig is here, in it's imperfect form.
<andrewrk>
incremental improvements
<winksaville>
Will stage3 be able to compile std/special/compiler-rt/* ?
<andi3>
...but the link is great I read a couple of related articles for the bigger picture, definitely interesting thoughts
<GitHub120>
[zig] eduardosm opened pull request #1264: [WIP] begin implementing "ABI hooks" (master...fn-abi) https://git.io/fNcuK
<Bas_>
I thought it was funny he said: " Unix and C are the ultimate computer viruses. "
<Bas_>
Because he's kinda right. =D
<andi3>
I would say virus is by far not doing it justice but its still funny right :D
Bas_ has quit [Ping timeout: 252 seconds]
<andi3>
talking about jai I think its funny how jai is partly the opposite of the zen of zig but nevertheless some may argue both languages have many similarities, anyway no point in getting very much into politics here :D
<andi3>
I mean just Jons attitude like "just hack it" vs "perfekt software" but still both languages share much of the design
mahmudov has quit [Remote host closed the connection]
<winksaville>
andi3: txs for the link, good read and as for jai, I find it interesting and it does seem that zig and jai have similarties, but the big difference is zig is here now and jai isn't !!
<winksaville>
With just a few days looking a zig I do concur with andrewrk that it's easier to write correct code in zig rather than c/c++, hence my interest.
<winksaville>
So thanks Andrew for creating zig and making it available and open source!