<M948e5[m]>
hi. i have no programming experience but zig looks promising. is it possible for me to start learning zig or should i wait for 1.0, or just learn something else in the meantime?
<daurnimator>
If you have no programming experience then zig might not be the best place to start...
<scientes>
M948e5[m], start with C
<daurnimator>
no.... don't do that either. start with a scripting language so you learn condition, control flow and object abstractions. then move to something like C or Zig where you have to think about memory
<scientes>
oh ok
<scientes>
python or ruby then
<scientes>
or lua
<daurnimator>
yep; those would be fine choices. M948e5[m]^
<scientes>
I just quickly ditched those because I was interested in how computers worked
<M948e5[m]>
lua? i used to fiddle around with that back in my CS:S days
<scientes>
but i guess i still pull out ruby when perfection is not needed
<scientes>
the problem with lua is that is had bad backwards compatibility and the alternate implementation have stuck to lua 5.1, which isn't compatible with lua 5.3
<scientes>
ruby and python (especially) are the mainstream ones
<daurnimator>
scientes: which doesn't really effect learning it....
<daurnimator>
M948e5[m]: do you have a particular task you want to complete?
<M948e5[m]>
allright, should i focus on one of them or try learning both the same time?
<M948e5[m]>
at
<M948e5[m]>
no, but i want to understand computers better
<daurnimator>
how did you find/pick zig?
<M948e5[m]>
i am naturally inclined to find the best and newest approaches to doing stuff, and zig looked the part
<scientes>
zig's biggest influence comes from C
<daurnimator>
zig's biggest influence is the LLVM IR :P
<scientes>
well yeah that is true
<M948e5[m]>
how would you go about learning ruby/python if you were me? can you vouch for any good resources, free or paid?
<daurnimator>
M948e5[m]: maybe "learn python the hard way"
<scientes>
and there is no reason to pay for anything
<scientes>
except a GOOD book, but those are few
<daurnimator>
scientes: ehhhh. i disagree. for entry level stuff paid books are usually better. but medium/advanced you shouldn't be paying for anything
<scientes>
K&R C is a good book, but most good books are for more advanced stuff
<M948e5[m]>
are you taking libraries into the equation there?
<scientes>
TAoCP is a good book
<M948e5[m]>
then again, doubt my local library has anything from the recent millennia
<scientes>
libraries buy really horrible books
<scientes>
although I have seen somewhat recent stuff at libraries
<M948e5[m]>
i found a pdf of the whole thing. see you in a couple (months)?
<daurnimator>
M948e5[m]: k. just make sure you have the python3 edition not the python2 edition.
<M948e5[m]>
ah, crucial difference
<M948e5[m]>
i found it. thanks guys
fengb has joined #zig
fengb has quit [Ping timeout: 256 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
lunamn has quit [Ping timeout: 248 seconds]
Kingsqueee has quit [Ping timeout: 248 seconds]
lunamn has joined #zig
marmotini has joined #zig
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 245 seconds]
<andrewrk>
I'd like to think that zig is a reasonable choice to learn system programming
<daurnimator>
andrewrk: it is.... (well at least it will be once we have more docs). but that user sounds like they want an intro to programming as a whole. They're not going to find many books/tutorials/stack overflow answers for the programming basics in zig.
<andrewrk>
yeah that's a good point. When you're learning programming best to choose a mature language and a compiler with fewer bugs
<andrewrk>
And docs and books and stack overflow answers
<daurnimator>
andrewrk: copy ellision part 1 ready tomorrow? :)
ltriant has quit [Quit: leaving]
<andrewrk>
daurnimator, I'll try! I don't have any behavioral tests passing yet. I have a stripped down test_runner.zig producing a .o file and now i'm working through the regressions in compiler_rt and zig's libc
<andrewrk>
I need to figure out what to call that, now that it's renamed to std/special/c.zig. "zig's multi-target libc" doesn't quite explain that llvm produces library calls that depend on these functions
<daurnimator>
How is it different to compiler_rt?
<andrewrk>
it's the one that has memcpy, memset, and those other libc functions
<andrewrk>
compiler_rt is unconditionally required as a dependency of any zig object file
<andrewrk>
libc is only needed if not building against a system libc
<andrewrk>
for example in freestanding mode
<daurnimator>
that's... weird? does llvm have special code for emitting libc calls if it detects you're linking libc?
<andrewrk>
and optimizations can (and do in practice) turn loops into memcpy intrinsic calls
<daurnimator>
I thought that sort of thing (memcpy) *was* what compiler_rt contained
<andrewrk>
llvm also emits lib calls for certain other stuff which is in compiler_rt
<andrewrk>
basically the reason they're different is that libc is swappable; compiler_rt is non-negotiable
ki9a has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
kristoff_it has joined #zig
Ichorio has joined #zig
marijnfs has joined #zig
Ichorio has quit [Ping timeout: 248 seconds]
kristoff_it has quit [Ping timeout: 248 seconds]
Vexu has joined #zig
marler8997 has quit [Ping timeout: 256 seconds]
very-mediocre has joined #zig
alexander92 has joined #zig
Vexu has quit [Ping timeout: 256 seconds]
<very-mediocre>
maybe i'm missing something, is there a concise way to unwrap an optional and use it in a boolean expression? i.e. if(optional_idx != null and val < vals[optional_idx]) {...}
<very-mediocre>
unwrapping it prior to using it gets messy if the logic is a bit complex
<daurnimator>
very-mediocre: does this work? if (optional_idx) |i| if (v < vals[i]) { .... }
<very-mediocre>
yes but it gets real ugly when you have a more complex scenario with lots of "else"
heitzmann has joined #zig
Vexu has joined #zig
<BitPuffin>
andrewrk: how do you feel about having /**/ comments that are allowed to begin and end only on the same line. Sometimes that's useful for commenting out an argument or something like that
<BitPuffin>
I agree that they shouldn't span multiple lines
marmotini_ has quit [Ping timeout: 248 seconds]
knebulae has quit [Read error: Connection reset by peer]
Vexu has quit [Ping timeout: 256 seconds]
heitzmann has quit [Quit: WeeChat 2.5]
heitzmann has joined #zig
Vexu has joined #zig
Vexu has quit [Ping timeout: 256 seconds]
marmotini_ has joined #zig
alexander92 has quit [Ping timeout: 244 seconds]
alexander92 has joined #zig
Akuli has joined #zig
halosghost has joined #zig
halosghost is now known as hg
rain2 has quit [Quit: WeeChat 1.6]
Vexu has joined #zig
marijnfs has quit [Quit: WeeChat 2.4]
Vexu has quit [Quit: Page closed]
alexander92 has quit [Ping timeout: 272 seconds]
fengb has joined #zig
<fengb>
For the C devs out there, can zig fmt generate a parse error for the && operator? I always stare at it for awhile
<fengb>
andrewrk: sure, I'll try to take a stab at it later this week too
<andrewrk>
fengb, I think we can make it a parse error with a helpful error. even though `a & &b` produces valid zig AST, it will always be a semantic analysis error
<fengb>
The parser actually throws the error so it's zig fmt that's doing something different. It does "handle" || correctly though
<andrewrk>
this node.js module has to compile .c code when you npm install it. this is problematic on windows and can fail in some weird ways depending on how the c compiler is configured
<andrewrk>
but if this were written in zig and compiled to wasm, the wasm could be uploaded to npm and then it would work everywhere without depending on system c compiler
<fengb>
Hmm... there's an implicit dependency on the implementation's lifecycle. I wonder if it's possible for that allocator to "escape" the stack
<marijnfs>
stack allocator seems to work
vexu has quit [Quit: WeeChat 2.5]
<marijnfs>
if i have a var stack_alloc = &std.heap.FixedBufferAllocator.init(stack_buf).allocator;
<marijnfs>
does that stack_alloc get freed after it goes out of scope?
kristoff_it has joined #zig
<fengb>
Yes... but stack_alloc is just a pointer
<fengb>
So the deallocation shouldn't really do much. Do you want to delete the actual buffer?
kristoff_it has quit [Ping timeout: 248 seconds]
<marijnfs>
nah i defer delete that separately
<marijnfs>
i'll push what i have now in a separate github, then i have to prepare some tests etc. But I need some help with making sense of the allocator
<marijnfs>
if i don't make crazy errors
<marijnfs>
bit the timsort seems about twice as fast for now
<fengb>
Usually you allow any allocator to be passed in. Otherwise you'd be excluding runtimes like embedded or wasm (which can't use the direct allocator)
<scientes>
wasm can support direct
<scientes>
but yeah don't assume
<scientes>
and needing an allocator is.....a problem
<marijnfs>
fengb: true, it just gets a bit annoying to have to provide allocators to the sort
<scientes>
that is why the current sort was chosen
<marijnfs>
Isn't the directallocator always available?
<scientes>
that is not the zig way
<scientes>
the zig way is to always supply an allocator argument
<scientes>
it is much more flexible
ltriant has joined #zig
<fengb>
DA requires an OS backing. Bare metal embedded have no equivalent
karrick_ has joined #zig
<karrick_>
Hello. Finished reading all of the Zig document
alichay has joined #zig
<karrick_>
So much for my ability to type
<fengb>
How much slower is in-place merge sorting?
<marijnfs>
fengb: all tim implementations say it's not really worth it, but i could have a look
<marijnfs>
but you also need to allocate stuff for the run stack
<fengb>
Alternatively, merge sort should require at most N (N = number of elements) additional memory right? Could we dynamically allocate this on the stack immediately?
<marijnfs>
fengb: yes, but you still need an allocator
<fengb>
Does zig have var-arrays on the stack?
<marijnfs>
no you will kill the stack i think
<marijnfs>
i have done that before
<fengb>
Ah good point
<fengb>
You know... I've never thought about stack much before working with zig
<scientes>
fengb, no, alloca was removed from the language
porky11 has quit [Quit: Leaving]
karrick_ has quit [Remote host closed the connection]
st4ll1 has quit [Ping timeout: 268 seconds]
karrick_ has joined #zig
st4ll1 has joined #zig
marijnfs has quit [Quit: WeeChat 2.4]
karrick_ has quit [Remote host closed the connection]
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
I_Right_I has quit [Remote host closed the connection]