ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<martinium>
when I downloaded the tar my system auto extracts for me on double-click
<martinium>
so I moved the extracted folder to my home directory
<andrewrk>
I can have it print the directories it looked in
<martinium>
only other thing I did was link the binary to my /usr/local/bin directory to have zig command available system-wide
<andrewrk>
right, ok, let me have it check realpath too, and then that will work fine
<andrewrk>
just a minute
<martinium>
take your time
<andrewrk>
martinium, which version are you using?
<martinium>
0.2.0
<andrewrk>
ah. I highly recommend master branch
<martinium>
ah
<martinium>
I was wondering whether I should have used master or a versioned tar
<andrewrk>
we're about to release 0.3.0 in ~1 week
<martinium>
I had downloaded the zig-linux-x86_64-0.2.0
<andrewrk>
I think 0.2.0 doesn't even have the code to find the std lib
<andrewrk>
so that's why it's not working
<martinium>
now that makes total sense
<martinium>
:)
<martinium>
let me get master real quick
<andrewrk>
there's a download link for that too
<martinium>
you should maybe put a date next to master
<martinium>
so people can gauge whether it would be more worthwhile compared to the latest versioned copy
<andrewrk>
the date is always whatever day it is :)
<andrewrk>
I don't think there has been a day without a commit to master branch in a long time
<martinium>
that is good news
<martinium>
I really like the integration of the build tooling
<martinium>
one less thing to learn
<martinium>
much more efficient
<andrewrk>
one less thing your users have to have installed too
<andrewrk>
the build system is still at the proof of concept stage. I wouldn't say it's particularly ergonomic yet
<andrewrk>
it works though, and it runs zig's own test suite
<andrewrk>
and stage2 build
<martinium>
good news master build works well
<martinium>
I will use this going forward
<martinium>
may I make a suggestion to you for the lang?
<martinium>
another lang I have been using called nim had a similar install from source story for each new release
<martinium>
they created a tool called choosenim that is basically just like Rust languages tool called rustup
<martinium>
that would be a good and fast way for new users and existing users to install and use the language
<andrewrk>
yes suggestions are welcome
<martinium>
I am not a experienced programmer otherwise I'd built it myself
<martinium>
build*
<andrewrk>
I feel like choosezig/choosenim would be more complicated than "download and extract this thing"
<andrewrk>
because if you have choozezig, then the user still has to download and run choosezig
<martinium>
in usage once it is install you run the command whenever you want and you can choose to update to latest or master
<andrewrk>
and that could have just been zig itself
<martinium>
true one extra download but it manages the install
<andrewrk>
but there is no install
<martinium>
true
<andrewrk>
in my opinion, /usr/bin/* belongs to package managers, not source installations or downloads
<martinium>
I guess I am just used to using rustup
<martinium>
usually /usr/local/bin is for external downloads
<martinium>
external installations I mean
<andrewrk>
that creates a problem when you want to uninstall something
<martinium>
an alternative is that the tool downloads the latest master and sets up the symlink for the user into usr/local/bin
<martinium>
saving time
<martinium>
but its not that complicated
<andrewrk>
I keep /usr/local empty and use ~/local/foo where `foo` is a specific project or set of libraries for said specific project
<andrewrk>
there's no reason to use sudo or the root file system
<martinium>
that is probably much better from a security standpoint
scientes has joined #zig
<martinium>
I have no issue downloading the tarballs and running that way
<martinium>
most shouldn't either
<martinium>
I have to remember that it isn't separate tools like cargo and rustc
<andrewrk>
I put a lot of focus on removing dependencies of third party things
<andrewrk>
that's why we can cross compile for any target on any target
<martinium>
yeah definitely the way to go
<martinium>
are compiled zig programs built statically by default?
<martinium>
meaning they include everything needed to run the program?
<andrewrk>
certainly if you don't link any libraries
<martinium>
do you see this as a general purpose lang or mainly a systems lang?
<andrewrk>
if you use --library foo, then it's going to look for shared libs. if you put --object libfoo.a on the command line then it links statically
<andrewrk>
(I think I should rename that parameter)
<andrewrk>
general purpose
<martinium>
I've been trying to find a lang like this for a while.
<martinium>
closest has been nim
<martinium>
but that transpiles to C
<andrewrk>
the main difference between zig and nim is that zig is trying to replace C rather than build on top of it
<andrewrk>
and Zig has no runtime and especially no garbage collector
<martinium>
while still working with all that C code which is going to be around forever
<andrewrk>
well and a different approach to maintaining code simplicity, and a million little design decisions... I guess it's a lot different
<martinium>
the one thing I have not seen are benchmarks like for benchmarks game
<martinium>
the git repo I downloaded needs to refactor the code
<andrewrk>
tiehuis is especially good at that stuff
<martinium>
binary-trees.zig:54:56: error: expected type 'File', found '*File'
<martinium>
var stdout_out_stream = std.io.FileOutStream.init(&stdout_file);
<martinium>
in your own tests is this lang as fast as C so far or faster?
<andrewrk>
oh, remove the &
<andrewrk>
I changed the API recently
<andrewrk>
it's designed to be faster than C
<martinium>
I will try refactoring tiehuis benchmarks
<andrewrk>
for some stuff it's faster, for some stuff it's slower. but we're not doing everything that is planned yet. for example zig's memcpy implementation right now is trivial
<andrewrk>
but obviously we would upgrade eventually
<andrewrk>
there's no reason that any C code should be faster than equivalent zig code
<andrewrk>
we're trying to beat C at its own game
<martinium>
44 years of knowledge hopefully get a successor finally
<andrewrk>
simple example: unsigned ints in C guarantee overflow wraparound semantics. unsigned integers in Zig by default cause undefined behaivor on overflow
<martinium>
much better from a security standpoint
<andrewrk>
right because in debug mode you can have safety features
<andrewrk>
or you can just release with the undef safety checks on
<martinium>
@andrewrk, how old were you when you started programming?
<martinium>
you've created some really impressive software
<andrewrk>
12. I started with VB 6
<andrewrk>
my parents let me use the computer for 1 hour per day. then they made me go outside
<martinium>
yeah its important to step away and develop other senses
<martinium>
especially when young
<martinium>
I work in IT and nowadays all the roles are asking for programming knowledge
<martinium>
scripting is not enough anymore
<martinium>
C while a small language feels so tedious since I was first exposed to python
<martinium>
but python hides everything
<martinium>
you don't "learn" how things really work
<scientes>
I ended up in C cause I wanted to see how stuff morked
<martinium>
boom
<martinium>
thats where I am
<martinium>
I am 32 now so my time is hardfought
<martinium>
python's slowness isn't attractive
<scientes>
I think it comes down to a zen of zig thing: writing perfect software
<scientes>
the computers are so fast that slow software sometimes doesn't matter, but it *feels* wrong
<martinium>
nothing is ever perfect though
<martinium>
slow software is a waste of resources
<andrewrk>
perfect software is possible
<martinium>
especially when you have to spin up more resources to do something that you can do in another lang with 1/8th the resources
<martinium>
the learning curve is that much different
<martinium>
isn't*
<scientes>
1/8th is nothing, how about sqrt(n) resources
<scientes>
that didn't come out wrong
<scientes>
but yeah fundamentally doing things wrong
<martinium>
only new languages that have been even close to performance with C are crystal and rust until my discovery of zig
<martinium>
I blame MSFT and Apple for dumbing people down
<martinium>
abstracting everything away from users
<martinium>
when I was a kid people had to type batch scripts to get the programs on floppies to run
<martinium>
lol
<martinium>
@andrewrk, how often is the master documentation updated?
<andrewrk>
martinium, you can find out with `git log --stat -- doc/langref.html.in`
<martinium>
thx
<martinium>
plan to invest 3+ hrs per day to learning this lang from ground up
noonien has quit [Quit: Connection closed for inactivity]
clownpriest has quit [Ping timeout: 272 seconds]
clownpriest has joined #zig
<andrewrk>
cool. what will you be working on?
<martinium>
will def be small things to learn the language. CLI utilities and the like but nothing concrete in my mind yet
<martinium>
will have to write down as ideas come in my head
<martinium>
@andrewrk, another questions is does this language take advantage of parallel calcs/multiple cores?
<andrewrk>
there are std lib abstractions for spawning threads
<andrewrk>
and also in the std lib: a work in progress M:N concurrency scheme with async/await built on multiplexing coroutines onto a kernel thread pool
<martinium>
there is another language I found recently called pony lang that uses an actor model
<scientes>
can't the destroy just set the promise ptr to null atomically?
<scientes>
and have resume check for null?
<andrewrk>
scientes, I believe that is status quo
<andrewrk>
oh, you're talking about the promise ptr. no, you're introducing a new memory location that doesn't have a place to live
<scientes>
i'm talking about the promise
<MajorLag>
andrewrk, please tell me 1d8b8ad doesn't prevent comptime-known values from being used in an inner scope. that'd break a lot of my code at this point.
<scientes>
which contains a pointers (and three other bits)
<andrewrk>
scientes, let's call that the "atomic state"
<scientes>
yeah thats what its called in the sources :)
<MajorLag>
ok, cool.
<andrewrk>
scientes, one of the bits in the atomic state is the "cancel bit". that is set by cancel. resume checks for that bit
<scientes>
but the cancel bit can be set while the co-routine is running
<andrewrk>
right
<andrewrk>
the pointer that is in the atomic state, is the handle of the coroutine that calls await
<andrewrk>
when you return, if it's null, then final suspend. if it's non-null, then destroy yourself and tail resume the awaiter
<scientes>
then how does resume find the co-routine stack frame?
<scientes>
i thought that was what was in there
<andrewrk>
MajorLag, some of these bugs I'm fixing today are half a year old
<andrewrk>
you have the patience of a saint
<andrewrk>
scientes, resume is a function call
<andrewrk>
the operand to resume is the handle of the coroutine (currently called the "promise")
<MajorLag>
heh, if you knew me at work you'd know better.
<andrewrk>
the handle has a pointer to the coroutine stack frame, which has a function pointer array and index and it does a fn call into the coroutine
<andrewrk>
llvm splits coroutines into functions at each suspend point
<andrewrk>
whew. 1 more issue to hit my quota for today
<andrewrk>
I think I already found all the easy bugs
clownpriest has quit [Ping timeout: 252 seconds]
<scientes>
then why doesn't destroy null out that pointer, and have resume check for null, then we won't have that race condition described in #1363
<andrewrk>
that pointer lives in the memory of the coroutine frame
clownpriest has joined #zig
<andrewrk>
which destroy destroys
<andrewrk>
so you can't check the atomic state after it's been destroyed
<scientes>
but there has to be a pointer to that pointer that resume can check
<scientes>
the pointer that is getting SIGSEGVed
<andrewrk>
in order for that to be true there would need to be new memory location that doesn't have a place to live
<andrewrk>
a pointer to a pointer, where does the inner pointer live then?
<scientes>
we arn't following each other
<scientes>
all i'm saying is that that dereference that is leading to the SIGSEGV in the race consition can be checked for null
<andrewrk>
the race condition I'm thinking about, is trying to dereference non-null
<scientes>
oh destroy has no idea where that pointer, i c
<scientes>
*where that pointer is
<scientes>
i just don't like the memory leak when the co-routine is never resumed
<andrewrk>
I don't think my proposal has a memory leak
<andrewrk>
the rule is: when you async, it should be matched with exactly one of either: await, or cancelasync
<scientes>
how are you assuring that resume is called?
<andrewrk>
when you suspend, it should be matched with exactly one of either: resume, or cancelsuspend
<andrewrk>
the memory is destroyed when both references are gone
<andrewrk>
if you put your handle in an epoll set, and then decide to remove it from the epoll set, then you call cancelsuspend
<andrewrk>
try to come up with a scenario where there is a memory leak and we can go through it together
<andrewrk>
not so sure about llvm though. I was expecting rc3 today
kristate has joined #zig
dbandstra has joined #zig
<dbandstra>
andrewrk, i found one of my issues was a duplicate and closed it. maybe that brings you to your daily quota? :p
kristate_ has joined #zig
kristate has quit [Ping timeout: 252 seconds]
<andrewrk>
dbandstra, thanks :)
dpk has quit [Ping timeout: 260 seconds]
dpk has joined #zig
<martinium>
@andrewrk, did you study CS in Uni?
<andrewrk>
yes
<martinium>
do you have any textbook recommendations for someone like myself that really wants to learn how to properly program?\Should I read a data structures and algorithms books first or something else?
<martinium>
I am to the point where I understand the basics in any language I look at
<martinium>
understand OOP etc but haven't really practiced it much
<martinium>
zig is imperative mostly just like C correct?
<andrewrk>
martinium, I suggest choosing a challenging project to work on
<martinium>
ironically, thats how I started really learning python was when I created titter bots using libs
<martinium>
I felt more like I was just using someone elses hard work though
<martinium>
since libs provided all of those prebuilt functions
<martinium>
I want to get to a point where I can build my own libs in stuff and maybe even port good ones over to zig
<andrewrk>
you could start with game programming. game programming teaches you a lot
<martinium>
I had downloaded a book forgot the exact name but it was game programming using C++11
<martinium>
learned a bit of C++ thanks to that book
<dbandstra>
game programming is great for when you're terrible at coming up with useful/productive project ideas
<dbandstra>
don't necessarily need to worry about design etc if you just make a dude that shoots and passes levels
<martinium>
I would like to use zig for working with a raspberry pi
<martinium>
no runtime and no overhead compared to python
<scientes>
martinium, I'm working on the arm64 port
<scientes>
it mostly works
<martinium>
nice
<andrewrk>
this is outdated, but here's a kernel for rpi 3
<andrewrk>
scientes, is this ready for review? did you have a CI server working?
<martinium>
do any of you guys mind mentoring me with my programming journey? I have until this point never known anyone who codes so everything is self-study and reading on my own
<andrewrk>
martinium, you're welcome to ask questions about computer science and stuff in this channel
<andrewrk>
I'm not personally going to commit to answering everything but I think IRC can be a good way to get "crowd mentored"
<dbandstra>
it's how i learned :p
<martinium>
thanks along the way I'll get to learn the nuts and bolts of zig
<martinium>
especially as the api's change
<martinium>
hopefully I will be able to help out sooner than later
<andrewrk>
martinium, what are you waiting for? :)
<andrewrk>
write hello world
<martinium>
I work in cybersecurity so being able to debug and understand code super helpful
<andrewrk>
then decide what your next milestone will be
<andrewrk>
no, not at all. it's purely done because it was requested of me
<martinium>
using xfce I see
<martinium>
I am a fan
<martinium>
used that DE with arch for a while
<martinium>
now I mostly just use fedora and gnome 3 grew on me
<martinium>
@andrewrk, I noticed instead of using import statements to bring in the stdlib/modules you do it similar to JS by creating a const identifier
<martinium>
any specific reason for this choice?
<andrewrk>
it helps both the compiler and the human reading code more quickly understand where declarations are coming from
<martinium>
gotcha
<martinium>
what does the @ before the import keyword do?
<dbandstra>
iter() method is used in like 20 different files
<dbandstra>
i tried moving iter method into the ComponentList generic struct, but didn't like how that felt (`gbe.components.Player.iter()` instead of `gbe.iter(C.Player)`)), and i had to use comptime black magic in other places
<andrewrk>
hmm. I'd like to have another look at this later. I'm too tired right now
<dbandstra>
fair enough
<dbandstra>
don't expect something expertly designed, i'm half asleep most of the time i work on it
<dbandstra>
but i was happy today to get rid of the last bad place of code duplication in terms of component types
<martinium>
@andrewrk, you should register this channel officially so you can get a chanserv in here
<dbandstra>
i thought i would need reify but this seems to work
<dbandstra>
i'm pretty happy that i managed, in a c-esque language, to get the level of boilerplate down to almost how small it would be in something like javascript
<dbandstra>
boilerplate of things like registering new component types
<andrewrk>
that's great, I'm happy about that too
<andrewrk>
I don't think you have to give up low level speed and power to gain high level abstractions
<dbandstra>
i got pretty far doing this in C using evil macros and '.inc' files, but not this far
<andrewrk>
I'm going to bed. night
<dbandstra>
good night
<dbandstra>
(sad postscript: my c project eventually devolved into me playing with scripting languages and DSLs. i don't feel any need for that with zig)
<martinium>
well that sounds promising
clownpriest has joined #zig
<martinium>
@dbandstra, is there an API documentation yet?
<dbandstra>
API for what?
<martinium>
I am looking at the included lib folder to see the different modules in std lib
<dbandstra>
zig's std lib? there are no docs sadly
<martinium>
ex: json, crypto etc
<martinium>
yeah
<dbandstra>
if you spend time looking through those files you can see they're somewhat haphazard and inconsistent
<martinium>
for instance if I wanted to import json
<dbandstra>
i believe there's going to be a big effort in the future to clean everything up and then document it
<martinium>
const json = @import("std").json
<martinium>
would that be correct?
<martinium>
I will try and help document this stuff also
<dbandstra>
yeah
<dbandstra>
@import("std") gives you zig/std/index.zig
clownpriest has quit [Ping timeout: 252 seconds]
<dbandstra>
everything should be pretty easy to follow from there
<martinium>
yeah
<martinium>
I wanted to make sure I did not need to include the index.zig in actual import
<martinium>
in hello world example I see them access std lib then uses dot notation to access the module
<martinium>
then another dot for warn function
<martinium>
guess that specificity will keep memory size down if we only import exactly what is needed
<dbandstra>
i don't believe you should worry about that, i think if you import something but don't use it, the compiler will leave it out
<martinium>
that would be ideal
<dbandstra>
whether you do `const warn = @import("std").debug.warn; warn(...)` or `const std = @import("std"); std.debug.warn(...)` is just up to your personal preference basically
<dbandstra>
doing things the former way can lead to files with 20-30 imports at the top
<dbandstra>
which is just ugly to look at
<martinium>
yeah don't want this to be like haskell
<martinium>
with a million lang extensions
<martinium>
lol
<martinium>
yeah the API documentation for all the modules is badly needed
<dbandstra>
i'm still having trouble figuring out what convention to use for imports
<martinium>
I'll ask andrew how he plans to put this on his site
<martinium>
that should be done sooner rather than later I think
<kristate>
redj: long story short, please write more code in zig and post it on github :-)
<redj>
kristate: thanks, I guess maybe eC got into linguist before this process was established :P
kristate has quit [Remote host closed the connection]
kristate has joined #zig
clownpriest has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
commander has quit [Remote host closed the connection]
clownpriest has joined #zig
clownpriest has quit [Ping timeout: 250 seconds]
kristate has quit [Ping timeout: 272 seconds]
unique_id has quit [Remote host closed the connection]
davr0s has joined #zig
clownpriest has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
unique_id has joined #zig
c15ade4 has quit [Quit: WeeChat 2.0]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
noonien has joined #zig
clownpriest has joined #zig
bheads has joined #zig
<unique_id>
const last_day = Year_Month_Day.init(2018, Sep, Last); -- Designing a date API is fun :) It has to be full of features, readable, and performant by having both a serial based type and a field based type.
<unique_id>
I have no clue how this will end up, just trying things out for now
<unique_id>
last_day.month += 1; if (last_day.is_valid())
<unique_id>
ok yeah it's not camel case, I'll have to change that if that's what we're going for :)
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
noonien has quit [Quit: Connection closed for inactivity]
bheads has quit [Ping timeout: 272 seconds]
<unique_id>
Leap seconds are pissing me off. Not leap seconds themselves, but how people are handling them.
<unique_id>
So I must say, I'm in agreement with America, much of Europe, and China, to remove them. Good riddance xD
<unique_id>
we'll see what happens in 2023 when a decision is likely to be taken
<andrewrk>
just put `if (year >= 2023) @panic("¯\_(ツ)_/¯");`
<andrewrk>
I'm sure it will be fine
<andrewrk>
;)
<unique_id>
oh they wouldn't remove previous leap seconds though, but they would stop adding more of them. Mb for being so unclear as always.
<unique_id>
humans decide when to add a leap second at least 6 months in advance with no algorithms involved, it's entirely database driven, so at least nothing bad would happen if they would decide to stop adding more
<MajorLag>
is anyone aware of an open issue for incorrect printing of integer types > 64b?
<andrewrk>
I'm not aware of that
clownpri1 has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
<MajorLag>
I don't think it is a printing bug, but a problem with bitwise negation
<andrewrk>
oh, i'm planning on fixing that soon
<andrewrk>
probably today
<MajorLag>
ok, if it is known I'll refrain from making an issue, though I think I found a different issue while investigating.
<MajorLag>
nevermind, I am mistaken. I was running the wrong test.
<MajorLag>
the bitwise negation is legit though
<MajorLag>
*problem
<MajorLag>
Don't mind me, I'm just having trouble getting my brain fully booted today.
<wink_>
Oh, another memory question, do you plan on supporting "packed" arrays of u1's or other small bit types?
<unique_id>
I just played dbandstra's game. It's a lot of fun! I got to level ~12 with the Dreadnought (not on my first try), only to accidentally pause and I reacted by hitting escape which exited. The game has a lot of variety, I like it.
<andrewrk>
wink_, that already works
<wink_>
How, "bits: [2]u1;" looks like it was one bit per byte? Did I do something wrong?
<andrewrk>
wink_, my mistake, I thought you said packed structs
<wink_>
yea, I've seen structs do the "right" thing, but wanted to use an array.
<andrewrk>
I can't find the issue for this
<wink_>
Is the plan to support it by 1.0?
<andrewrk>
yes, or at least make the compile error helpful enough to guide you towards the right solution
<wink_>
ok
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<martinium>
@andrewrk, am a little confused with the for loop syntax in this lang
<martinium>
in C it is for ( variable initialization; condition; variable update ) {
<martinium>
}
<martinium>
Code to execute while the condition is true
davr0s has joined #zig
<tyler569>
the closest eqivalent in zig is " while (condition) : (update) { code } "
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<unique_id>
var i: usize = 0; while (i < length) : (i+=1) {}