ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<Tetralux_> Pretty sure this is a solved problem - but how what's the recommended way to turn a `[]const u8` into `[]u8`?
<Tetralux_> alloc + copy? Or is there a cleaner way?
geemili has joined #zig
<geemili> Heyo, I just saw the email about the github sponsorship thing
<geemili> andrewk: Are you planning on putting a regular patreon post up so that newcomers on patreon can see it?
<andrewrk> geemili, yes I will do that after one month
<geemili> Ah, okay
tghume has joined #zig
<andrewrk> nope, looking now
<andrewrk> I can't wait to work on this, it looks so fun
<andrewrk> this is also up for grabs for contributors since parsing is self-hosted already
<andrewrk> such a change would be welcome to modify the types and representation, as long as zig fmt tests still pass
<daurnimator> andrewrk: what was that you were saying about github sponsoring not having the same "levels" as patreon?
<andrewrk> they don't allow arbitrary donation amounts yet
<daurnimator> ah right
<daurnimator> you might want to keep an option at $1 or $2 a month?
<andrewrk> well they also require unique rewards for each tier
<daurnimator> I think your tiers might be a bit close together... 5/15/25/50/100/400. I might recommend 2/5/25/100/500/2500
<daurnimator> --> if I actually was to start using zig in production *work* code $400 is quite low. on the other hand for a lot of people, $5 a month is above what you'd want to pay for something you use on a single weekend a month.
<strmpnk> I assume you can see what level folks have signed up for so far and which is most popular?
<andrewrk> if anyone wants to donate more than 400/month please contact me privately
rjtobin has joined #zig
<daurnimator> andrewrk: I still think you need an expensive tier to make the other ones look cheaper by comparison; it's a pretty widely used effective technique
<andrewrk> I'll consider it
recj has left #zig [#zig]
marijnfs_ has joined #zig
<fgenesis> so i found zig a couple weeks ago by recommendation and i like those ideas
<fgenesis> just had to throw that in
<andrewrk> hi fgenesis, what ideas are you referring to?
<fgenesis> didn't get around to write code and prolly won't for the forseeable future but it's made its way to the top of the list, somewhere above rust. probably a good sign
<fgenesis> oh just the general things i got from the comparison with C
<fgenesis> as a C++ coder i really like the language, but i stick to c++03 because that's still manageable
<fgenesis> gotta jump that boat before c++25 implodes under its own complexity
<fgenesis> and zig looks just about what i've always wanted to have
<fgenesis> the comptime stuff is amazing
marijnfs has quit [Ping timeout: 244 seconds]
<fgenesis> wanted to do a constexpr thing just today and turns out that was impossible to do even with c++11 so yeah, there.
<andrewrk> glad you like it
<andrewrk> it's still very beta of course, but moving fast
<fgenesis> the other end of the spectrum is obviously generating code and eval'ing it :P
<andrewrk> there's an important problem with that approach
<andrewrk> it's a cross-compilation footgun
<andrewrk> the way zig does comptime, it emulates the target
<fgenesis> yeah no i'm not asking for compile-time string-to-code things, that would be insane :P
<fgenesis> oh really
<fgenesis> that wasn't obvious from the docs
<fgenesis> like that idea
<andrewrk> yes so for example, endianness works as you would expect
<fgenesis> so it'd do big endian properly as well?
<fgenesis> ooooh yesss
<fgenesis> one thing i was wondering about tho
<fgenesis> @functions
<fgenesis> they seems so clunky. is that @ intentional to make it obvious it's a builtin?
<andrewrk> yes
<fgenesis> makes sense then
<fgenesis> and i assume zero-cost wrapping them for syntax would be possible as well?
<andrewrk> they're not all functions in the strict sense; the language can treat them specially. for example @unionInit participates in result location semantics which would not be possible to implement in userland
<andrewrk> but you have to admit, it's easy to learn. if it has @ then it's in this list: https://ziglang.org/documentation/master/#toc-Builtin-Functions
<fgenesis> fun fact: what really sold me was that zig was already on godbolt.org and someone sent me an example
<fgenesis> so gz for getting this for. godbolt seems to be *everywhere* nowaydays
<fgenesis> *far
<fgenesis> some example that generated a sine table at compile time, something i did a day before but with scripts and glue, and i love how easy that looked, right there
<andrewrk> github syntax too. popularity is picking up
<fgenesis> one last question before i shut up for today: any plans for runtime compilation?
<andrewrk> elaborate?
<fgenesis> so far i've been sold on C++ glued with Lua, but the dynamic typing is more often getting in the way than not
<fgenesis> being able to (re-)load code at runtime would fill that nice as well
<fgenesis> *niche
<fgenesis> even if it's JITed and ran through llvmjit
<andrewrk> no plans for language JIT support
<fgenesis> so far i've been missing a dynamically loadable language like lua but statically typed, and please don't mention JS/typescript/... :P
Tetralux_ is now known as Tetralux
<fgenesis> ok, fair enough
<andrewrk> closest thing to that planned is hot code swapping
<andrewrk> but that's more to make the development cycle quick
<Tetralux> > being able to (re-)load code at runtime would fill that niche as well
<Tetralux> I should note, that you could already do that.
<fgenesis> not as dll though
<Tetralux> *grins*
<fgenesis> i mean throw source at it
<daurnimator> fgenesis: I actually see a path to it in zig
<Tetralux> It's not clear to me how that would be more useful, or simpler, than a dynamic library that you hotload.
<Tetralux> Though, as someone's who's dabbled with Lua briefly in the past, I can see why you're thinking that.
<Tetralux> I can imagine why*
<fgenesis> okay maybe i DID get a bit too used to being able to generate strings at runtime and load them as a function. send help
<daurnimator> 1. make `asm` return a function. 2. make `asm` work at runtime (i.e. write a dynamic assembler). 3. work up from there
<Tetralux> *high five*
* daurnimator has far more than dabbled in lua
<Tetralux> *smirks*
<Tetralux> I'm not sure if that's good or not... xD
<daurnimator> Tetralux: for whom? :P
<fgenesis> most i've done in lua is a 5.1 bytecode mangler that makes things platform independent and self-decrunching, and i regret nothing
<Tetralux> O.O
<Tetralux> You lost me at "mangler" xD
<Tetralux> #TheSignOfOvercomplication.
<via> can you instantiate an element in a struct with another value on the struct? like... https://gist.github.com/via/3c337cc6d2d5e85713e5379d49795421
<fgenesis> well you do what you gotta do when you want to ship but keep the source code under wraps, no?
<Tetralux> Then again, I've spent hours writing Lua code for a Minecraft mod which used it to control robots that would build stuff for you - so who am I to judge.
<Tetralux> You could just make the closed-source thing load the DLL that the user writes to hook into the behavior, no?
<daurnimator> via: you'll need to set it to undefined and fix it up after.
<fgenesis> having a non-portable bytecode is an absolutely horrible idea and working around that in plain lua that doesn't even have fucking bitops is a "fun" exercise
<andrewrk> daurnimator, I mean, you *can* add +x to memory pages, write arbitrary code into it, and then jump into it with zig
<via> daurnimator: damn, that just doesn't look as clean :(
<andrewrk> that's how you would, e.g. implement a lua jit in zig
* fgenesis grumbles something about pypy
<andrewrk> via, daurnimator's workaround is correct. I vaguely recall an issue open for this
<daurnimator> andrewrk: yep. funny to call out luajit here. luajit is written using 'dynasm' -> a preprocessor that compiles inline assembly. and you know what we think about preprocessors....
<fgenesis> well, looking at the zig printf format string example... ehehe
<Tetralux> That reminds me, are there docs of some sort for understanding the zig asm syntax? - Also, why does it not seem very obvious how to read it? ;p
<daurnimator> Tetralux: no docs. it's pretty much llvm asm syntax
<daurnimator> which itself is terrible documented. espeically the clobber options
<Tetralux> Not to put a too-fine-a-point upon it, but I can read _actual_ asm much more easily xD
<fgenesis> worse than gcc inline asm?
<daurnimator> fgenesis: gcc inline asm you can at least find docs for some of the time
<fgenesis> (gnu syntax)
<daurnimator> writing e.g. the valgrind code in zig I wrote it in gcc inline asm first, then read the llvm source code to figure out what the equivalent options were...
<fgenesis> daurnimator, indeed, but that doesn't make it any less confusing
<daurnimator> fgenesis: oh it does.
<via> yeah, that worked, thanks
<Tetralux> Are there any plans to adjust the asm syntax in zig to more closely match that of zig's asm volatile?
<Tetralux> i.e: multi-line string with a return value - to name an example.
<andrewrk> the gcc inline asm docs should be correct for zig
<andrewrk> asm is something that would benefit from havingf another backend
<daurnimator> andrewrk: want me to join a <title/> bot to the channel? I miss having "about" for links
<andrewrk> sure go for it, as long as it's written in zig
<andrewrk> just kidding. go for it.
<daurnimator> andrewrk: I'll rewrite it in zig once you add coroutines ;)
<andrewrk> fair enough :)
<andrewrk> it has to be registered with freenode, we get mad spam without that setting on
<fgenesis> ooooh coros
<Tetralux> See - I'm the kind of programmer that reads "asm constraint code" and stares blankly wondering why it's not a simple sequence of asm instructions xD
<andrewrk> stackless coroutines, aka Continuation Passing Style
<andrewrk> Tetralux, it's all about telling the optimizer wtf is going on in the asm
<Tetralux> Curious. Isn't the point of writing inline asm because you want to run a very specific set of instructions?
<fgenesis> so no explicit main coro calls sub coros, like lua
<fgenesis> just curious because that's what i know and worked with so far
<daurnimator> Tetralux: yes. but then e.g. where do you want the output to be?
<fgenesis> CPS seems a bit too much like mad science, at times
<daurnimator> Tetralux: you need to tell the compiler "this asm snippet needs 2 registers free; it writes to rax, so make sure you don't keep anything you need there"
<strmpnk> Tetralux: there is no ABI that arbitrary asm must follow so it must be explicit. Registers can be trampled, inputs and outputs need to be handled, etc.
<fgenesis> Tetralux: that's so that the compiler can still optimize surrounding code, as opposed to msvc. msvc's inline asm has no such thing so all it can do is entirely disable the optimizer in functions that use inline asm
ntgg has joined #zig
<fgenesis> even being able to tell the compiler your code isn't going to modify memory helps a lot
rjtobin has quit [Quit: Leaving]
<strmpnk> That reminds me of a question, where did Zig land on aliasing rules? I know there is the noalias keyword, so I assume there aren't special case types like C?
<Tetralux> If all the constraints are doing is saying "Hey - these are the registers I care about", then could it not just be something like this? https://paste.gg/p/anonymous/f5e8e10f3cfc4c818f91930e5b1f6acb/files/58c8e835a5af48e5ad4b64a513b71130/raw
<fgenesis> please burn C's strict aliasing rules with fire
<andrewrk> strmpnk, there are a couple "research" issues open regarding aliasing
<andrewrk> currently there is a well-defined memory model, and no type-based alias analysis is planned
<fgenesis> there's a restrict keyword for a reason
<daurnimator> Tetralux: yep that's sort of what the constraint syntax is
<diltsman> No inline assembly, only Zig and a linker script. I have my processor up and running and have it finally running at 84 MHz (max frequency supoorted).
<fgenesis> diltsman: architecture?
<diltsman> Cortes M3. SAM3X8E. Arduino Due.
<daurnimator> Tetralux: the other info you need is what registers the asm uses: i.e. what is going to get "clobbered"
<Tetralux> daurnimator: Indeed. Except it's unreadable by comparison to Zig.
<Tetralux> Also re clobbered regs
<Tetralux> Just add those to the list after RAX.
<daurnimator> Tetralux: yep. that's all it is
<strmpnk> andrewrk: Ok. Reasonable defaults it sounds like.
<daurnimator> Tetralux: now to go slightly further: why do *you* pick RAX? why not let the compiler pick the best register it can?
<fgenesis> something else i've wondered about. did you consider harvard architectures?
<fgenesis> like avr's PROGMEM annotation
<Tetralux> daurnimator: I think that it's clearer if you are _able_ to hardcode the register in plain 'english'.
<Tetralux> Esp in debug mode.
<daurnimator> Tetralux: but that's tying the optimizer's hands. it might be able to go faster if it uses RDX instead
<Tetralux> There's some weeds there - like: "how much faster?"
<Tetralux> But
<Tetralux> Assuming it would be worth it to allow it to do that
<daurnimator> Tetralux: with llvm or gcc inline asm you *can* pick the registers yourself; but it's considered poor form: you should let the compiler pick for you
<Tetralux> ( .. enough to sacrifice the ability to know which one it chose)
<Tetralux> Then maybe you should have a way to state that.
<strmpnk> fgenesis: linker scripts are used for that sort of thing in other cases. Not my area of expertise but that's what I've done with playing with micro controllers in the past.
<daurnimator> Tetralux: you do
<Tetralux> In a way that doesn't require a special syntax for it.
<Tetralux> Or at least one that reads like Zig.
<Tetralux> ( .. or more like it, anyway.)
<daurnimator> now you're getting somewhere
<fgenesis> strmpnk: not really. usually you want to have different data end up in different segments, without exposing things to the linker
<fgenesis> think local, static const arrays
<daurnimator> yes I agree we should make the ASM syntax's OutputOperands, InputOperands and Clobbers more zig-like
<strmpnk> fgenesis: I guess so but that's how I got my static constants into flash. ¯\_(ツ)_/¯
<andrewrk> if we ever want to support more backends than LLVM (which I think we do someday) then we'll need our own assemblers for each architecture
<andrewrk> this would enable zig to have better inline assembly syntax (even for llvm backend)
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<andrewrk> but that's a lot of work. O(N) for each supported architecture
<fgenesis> dynasm for the rescue!
laaron has joined #zig
<strmpnk> fgenesis: I should look up PROGMEM itself but I think it's doing the same thing. It's probably a section attribute which then relates to the sections outlined in the linker script.
<fgenesis> strmpnk: yes, it's a section annotation that the default linker script uses
<daurnimator> fgenesis: indeed. time to port dynasm to zig :)
<fgenesis> strmpnk: my main problem is that i can't modify the linker script because of "arduino", so everything must be in the compiler
<strmpnk> Yeah. I see what you mean.
<fgenesis> and this piece of poopcode is probably the worst compiler and inline asm abuse i've ever done
<fgenesis> also linker are pain. i wonder who came up with the concept of a linker script. seems like an unnecessary complication on top
<fgenesis> also it's scary
<fgenesis> it's like automake just for the linker
* strmpnk considers shared libraries and dynamic linkers much scarier.
<strmpnk> I do like the idea of a simple zig assembler though. I've always hated the notation borrowed from GCC.
<Tetralux> daurimator: I'm still not really convinced that allowing the optimizer to fiddle with what registers you use is actually enough of a gain over the loss of simplicity.
<Tetralux> daurimator: I'd have to see some real world examples where that actually made a difference - and even then - not in debug builds.
<Tetralux> I want to stay sane when attempting to debug when I write the asm wrong xD
<fgenesis> Tetralux: is an extra push/pop not convincing enough?
<strmpnk> Tetralux: register selection and spills are a very expensive part of the optimizer so removing some of these constraints could make a big difference in a hot loop which predicated the asm in the first place.
<fgenesis> congrats for going to memory for nothing :P
<Tetralux> Personally, I view asm similarly to nakedcc: If you use it, it's because you are attempting to do something _very_ specific.
<Tetralux> I do _not_ want an program fiddling with that.
<Tetralux> There's enough complication as it is without having the optimizer to contend with too xD
<Tetralux> But
<Tetralux> If you really don't want to hardcode it.
<fgenesis> if you don't absolutely need a specific reg, let the optimizer select it
<Tetralux> Seems reasonable on face value.
<fgenesis> it's effectively solved an optimal map coloring problem for you and it's not nice of you to un-optimal its solution :P
<Tetralux> I just like being able to reason about the code I'm writing ;)
<Tetralux> And also being able to fix it if something breaks.
<Tetralux> I cannot fix the optimizer if it breaks
<Tetralux> Therefore I want a way to turn it off.
<fgenesis> if you want it un-optimal there's always java
<Tetralux> e.g: const res = asm volatile(r1 = RAX .noOptimize) { ... }
<daurnimator> Tetralux: that's what volatile means
<daurnimator> Tetralux: volatile = "no optimization please"
<Tetralux> Okay - that's something then. xD
<Tetralux> Though it also means "Don't optimize this away"
<Tetralux> .. which is a little different.
<fgenesis> really? the way C specifies this is that reads and writes may not be reordered and must happen even if they'd be considered unnecessary
<fgenesis> it doesn't turn off the optimizer entirely
<daurnimator> fgenesis: that's what volatile means on a variable. not on an asm block
<fgenesis> and it really shouldn't, imo
<fgenesis> oh, right
<fgenesis> wait so an asm block without volatile will be optimized?
<daurnimator> yep
<Tetralux> It _can_ be.
<fgenesis> first time anyone ever told me, good to know
<Tetralux> If LLVM or w/e decides it "doesn't actually do anything."
<daurnimator> fgenesis: volatile on a variable also doesn't mean what you said: what it really means is "one read of this variable in source code = one read of the variable in machine code"
<Tetralux> Something like that IIRC.
<daurnimator> fgenesis: you need memory barriers/fences to prevent reordering
<fgenesis> daurnimator: yes, meant that
<fgenesis> daurnimator: no, that depends on the arch
fengb has joined #zig
<fgenesis> for no *compiler* reordering, a compiler barrier is enough
<fgenesis> what the memory model makes of it is another issue
<daurnimator> fgenesis: "depends on the arch" is just a way to say that you need it; but sometimes it'll be a no-op
<Tetralux> For non-volatile, you could have: const res = asm(r1, r2, ...) { ... } // optimizer is free to pick which regs are actually used.
<fgenesis> iirc on x86 a compiler barrier is strong enough to act as a full memory barrier
<Tetralux> For volatile: const res = asm volatile(RAX, RDI, ...) { ... }
<fgenesis> (most of the time?)
* fgenesis should burn down all IT and become a farmer instead
<Tetralux> THAT
<Tetralux> RIGHT THERE
<Tetralux> .. Is why I like keeping things so simple that I could understand them coherently even if blackout drunk.
<Tetralux> Seems a reasonable goal. :)
* fgenesis looks at the shot of whiskey on the desk
<fgenesis> you're on point right there
* Tetralux empties bucket of weird asm syntax into the glass so it covers it in a mound of characters.
<Tetralux> As you can see - kinda obstructs your view does this.
<Tetralux> I like having clear vision x)
* Tetralux pours out two more glasses and hands fgenesis one
<Tetralux> Fortunately I was somewhat prepared for this.
<andrewrk> wait let's be very clear about what volatile means
<andrewrk> the docs have it correct: https://ziglang.org/documentation/master/#volatile
<andrewrk> "Loads and stores are assumed to not have side effects. If a given load or store should have side effects, such as Memory Mapped Input/Output (MMIO), use volatile. "
<fgenesis> " If you see code that is using volatile for something other than Memory Mapped Input/Output, it is probably a bug."
<fgenesis> thank you for this
<fgenesis> this is the most concise way of expressing how not to do it wrong
<daurnimator> fgenesis: yes... most of the time. where most of the time means as long as you're only in one process
<daurnimator> fgenesis: importantly if you're dealing with shared memory (including memory shared with the kernel!) then you need manual barriers on x86_64
<daurnimator> andrewrk: the confusion above was volatile on a variable vs `asm volatile`.
<andrewrk> it does mean the same thing in both cases though - it means "side effects"
<andrewrk> "this memory has side effects" and "this assembly has side effects"
<Tetralux> It's interesting to me that 'volatile' is the word that people came up with to describe that.
<daurnimator> andrewrk: `asm volatile` more means "don't change this assembly from what I've written" e.g. because you want an exact byte sequence to be in your output binary. or in the case of e.g. valgrind: you have a VM that triggers a special code path depending on exact instruction sequences
<daurnimator> or in the case of crypto code "please for the love of god don't touch this and introduce a timing attack"
<Tetralux> Maybe "sideeffected" for volatile vars, and "fixed asm {...}" for asm.
<Tetralux> I'd argue the meaning is clearer.
<daurnimator> notably for that last crypto case: the assembly *doesn't* have side effects
<andrewrk> daurnimator, no that's not what it means, it means "it has side effects"
<andrewrk> zig will never mangle the assembly code, it will either keep it or delete it (and it may not delete it if it has side effects)
<daurnimator> huh. okay I was wrong then
<emekankurumeh[m]> andrewrk: in that post the box areay is the same thing as the segmented list in the stdlib right?
<andrewrk> emekankurumeh[m], sorry what post?
<emekankurumeh[m]> the one on parsing from a while back
fengb has quit [Ping timeout: 260 seconds]
<andrewrk> emekankurumeh[m], ahhh, let me double check
<andrewrk> emekankurumeh[m], oh interesting! yes it appears we independently came up with the same data structure
<emekankurumeh[m]> on a closer inspection of that bjou language it looks like it shares a lot of qualities with zig
<andrewrk> I was actually considering a different data structure for lists however
<emekankurumeh[m]> except it's metaprogramming seems more powerful
<hryx> bJou has a cute logo °u°
[[]] has joined #zig
redj has quit [Read error: Connection reset by peer]
<hspak> is there a way to check to see if a value is undefined or am I using it wrong if I have to ask?
<andrewrk> the latter is correct: it's a bug if you have to ask
<hryx> if it's expected/legitimate to be unset, null is the right value for it
<andrewrk> +1 ^. undefined means the value could be anything, so you can't check if it's undefined. (however it's planned that safety checks could detect branching on undefined and call @panic rather than invoking undefined behavior)
<hspak> cool, thanks guys
<hryx> oh, speaking of that safety check, I was poking around ir.cpp to see how to implement it. (After one short evening of digging around, didn't figure it out yet, but might be a fun project)
ntgg has quit [Ping timeout: 246 seconds]
[[]] has quit [Remote host closed the connection]
<andrewrk> hryx, I think it's going to be different per type
<hryx> my completely uneducated guess would be that there is some way to guard all variable accesses with the safety check. but maybe that's naive -- I couldn't immediately see what "variable access" actually translates to
<hryx> oh, and I guess there's field access and array access too
<hryx> not sure if that's what you meant by "per type"
<andrewrk> I mean how are you going to tell if it's undefined?
<hryx> good point. My intuition said memcmp with 0xAA, but then I guess we still gotta know the size
<andrewrk> consider though, if it's a u8, 0xaa is a valid byte. that's the decimal number 170
<hryx> Oh shoot, of course. You mentioned quietly making it an optional (or something like it) behind the scenes
<hryx> which makes more sense
<andrewrk> this would require making @sizeOf(u8) != 1
<andrewrk> which... maybe would be ok? if it's not in a packed struct
<andrewrk> that would be breaking semantics though
<andrewrk> you can see how solving safety for types which have no guaranteed memory layout would be a good first project
<hryx> huh, I'd never understood why non-guarnateed layout was beneficial. but that application makes total sense
<andrewrk> there's also the Profile-Guided Optimization use case
<andrewrk> as another motivation for not guaranteeing layout
<daurnimator> andrewrk: I'd love a way to add manual annotations for that sort of thing
<daurnimator> also a way to check if the layout of something is what I want or not
<daurnimator> e.g. `if (@layOut(linux.iov) == @layOut([]u8))` -> can pass a slice directly in a linux.msghdr
<daurnimator> I guess you can already do that with @byteOffsetOf
<daurnimator> that's good :)
[[]] has joined #zig
<daurnimator> andrewrk: meet the bot [[]]. I just had to hack in nickserv support :P
<andrewrk> is it written in lua?
<daurnimator> yep
<daurnimator> !source
<[[]]> See my source at https://github.com/hashbang/irc-bot
<hryx> would it be silly (or even possible) to keep a hidden table of undefined variables? Something like: when x = undefined happens, add a reference to x in this hidden set, then removes x when a value is assigned to it
<andrewrk> fair enough, more motivation to get coroutines/networking going :)
<hryx> I am totally spitballing obviously
<hryx> oh hi bot
<andrewrk> hryx, I like where you're going with this. one thing to consider is you can pass a pointer to C code, and you don't control the loads/stores from that memory
<andrewrk> *from that codebase
<andrewrk> and by C code I mean any external library
<hryx> woof! good point, once you pass it to another library, who knows what will happen to it
<daurnimator> hryx: well if it's not an `extern` struct then in *most* cases they don't know the layout.
<andrewrk> but for non-C-ABI-compatible types: yes as daurnimator says they don't know the layout, and the semantics require that they don't mess with the data directly, so we can rely on being in control of loads/stores for these types
<daurnimator> andrewrk: oh? which semantics are those?
<andrewrk> if you pass a pointer to a non-extern struct to an external function, it's an "opaque type"
<daurnimator> what if I e.g. had a C function: `writeMyInt(&nonexternstruct, @byteOffsetOf(nonexternstruct, "foo"))`
<andrewrk> ok yeah good question - hang on, I might have gotten confused for a second...
<hryx> So maybe there are a few different strategies to employ for the undefined check, and it will depend on some factors: is it extern? or maybe, have you passed it to an extern function? Is it a struct, array, or scalar?
<hryx> there must be prior art on this kinda stuff
<andrewrk> that's a good point, in theory, we do know if a given type has been used in any external context
<hryx> to me this feels like a good place to spend this kind of energy - undefined access has definitely effed me even in Debug mode
<hryx> (just a meta-thought)
<daurnimator> hryx: and that's why we have valgrind :)
<andrewrk> I definitely think we can accomplish undefined-safety for non-well-defined-memory-layout types.
<hryx> daurnimator: let's make it so zig folx don't have to use valgrind! :D
<hryx> might be a stretch of course :)
<daurnimator> hryx: we don't have that power :P
<andrewrk> accomplishing undefined safety for well-defined memory layout types (such as integers and packed structs) will be a separate challenge
<daurnimator> hryx: really, I don't think we can ever catch this in all circumstances. just a few common ones (though that's good). you need a runtime VM like valgrind to get everything.
<hryx> what if Debug mode runs in a VM
<hryx> or is the perf cost too high
<andrewrk> we are talking about runtime checks though. and as hryx is hinting, there's a lot you can do with a runtime
<andrewrk> I think a runtime in debug mode is quite reasonable
<andrewrk> we've already given up the simplicity of having only 1 build mode
<andrewrk> we may as well take full advantage of Debug Mode
<hryx> are there any other langs that have such a hybrid "debug runtime, release machine" approach?
<andrewrk> rust has integer overflow checks in debug mode, guaranteed wraparound in release mode
<andrewrk> I'm not aware of a language that does what zig is considering doing with stack variable references that escape
<andrewrk> which is, essentially having stack variables that escape, allocated on the heap, but memset to 0xaa (or other sentinel value) when the function returns, so that use-after-free can be detected
<hryx> yeah, that is pretty neato. I only learned of "stack escaping" via Go, but obviously it only does part of what you said
<andrewrk> what's unique about zig code is that the semantics require the lifetimes to still be bounded by the function, so that the code still does work in freestanding mode (where the safety checks will be unavailable (unless a global allocator fitting the requirements can be provided!))
<andrewrk> the big idea here is that zig code is "lowest common denominator" so that it supports maximal code reuse in any environment
<andrewrk> however when the "denominator" is not so low after all (managed os such as linux/windows/macos/freebsd), then debug mode can have quite capable safety checks to enforce semantics and prevent undefined behavior
<hryx> I can't wait to see what people do on small chips with zig, especially if custom targets are added
<daurnimator> that reminds me... I had a quick look into writing zig for my watch
<daurnimator> I got stuck on setting up the toolchain on non-ubuntu :(
<andrewrk> setting up the toolchain? that's what zig is supposed to save you from
<daurnimator> andrewrk: gotta link with the libc etc....
<daurnimator> which means having the libc :P
<andrewrk> are you sure? what functions does it provide?
<[[]]> d​aurnimator: Title "Native Application | Tizen Developers" Shortened < https://is.gd/4hbGAd >
<andrewrk> because if it's strcmp, sin, cos, pow, strchr, etc, zig can provide those
<andrewrk> fopen.. now it starts to get tricky
<daurnimator> andrewrk: no... things like `bt_hid_host_connect` -> connect to a bluetooth device
<andrewrk> that's more than libc
<daurnimator> their OS... they can put in libc what they want :P
<andrewrk> sure, I'm just saying that's not libc, that's them requiring you to link their SDK, so fair enough that you have to install it
<hryx> andrewrk: For blue-sky safety checks ideas (e.g. run in a VM) is this the best place for discussion? https://github.com/ziglang/zig/issues/2301
<[[]]> h​ryx: Title "make Debug and ReleaseSafe modes fully safe · Issue #2301 · ziglang/zig · GitHub" Shortened < https://is.gd/wpNAVp >
<hryx> whoa
<hryx> ok that's a pretty useful bot feature daurnimator
<andrewrk> yep that's a good place for general discussion
<hryx> ok dope
<andrewrk> if an idea starts to turn into a concrete proposal that can be done, then it can be a new issue
<andrewrk> hryx, see also this related issue: https://github.com/ziglang/zig/issues/1947
<[[]]> a​ndrewrk: Title "audit analysis of undefined values; make it clear when undefined is allowed or not · Issue #1947 · ziglang/zig · GitHub" Shortened < https://is.gd/Vraffb >
<andrewrk> every time I see that bot do the title I narrow my eyes and think to myself, "that should be zig code running that bot, not lua."
<andrewrk> that's good. extra motivation for #2377
<daurnimator> andrewrk: get on coroutines then ;)
<hryx> damn daurnimator
<hryx> j/k
<daurnimator> (though the title bit the bot uses a fork of gumbo... getting that to work with zig is a whole other task)
<andrewrk> too late! you promised! :D
<daurnimator> hryx: actually that's a task you might be interested in
<daurnimator> (you seem to like parsers and things...)
<hryx> hm, which task?
<daurnimator> hryx: could you port https://gitlab.com/craigbarnes/lua-gumbo/tree/master/lib from C to zig? It's a html parser (originally created by google but then abandoned)
<[[]]> d​aurnimator: Title "lib · master · Craig Barnes / lua-gumbo · GitLab" Shortened < https://is.gd/ihkrCm >
<hryx> ooh, I see. could be fun :D
<daurnimator> hryx: so you'll do it? :D
<andrewrk> I think a title extractor could be based on a very simple html tokenizer. no parsing needed
<daurnimator> andrewrk: we used to do that.... it broke a lot. lots of websites have crazy html
<daurnimator> a good rule is: do not attempt to summon zalgo
* gonz_ > lots of websites have crazy html
<gonz_> Like all "the good old days" technologies, too permissive and they all end up being just a mishmash of choices and opinions
<gonz_> Embedded even in the zeitgeist as Postel's law
<gonz_> A lot of people seem to think protocols were better or good back in the day, but things are broken in part due to those attitudes
<daurnimator> gonz_: if you don't know it already: https://tools.ietf.org/html/draft-iab-protocol-maintenance-03
<[[]]> d​aurnimator: Title "draft-iab-protocol-maintenance-03 - The Harmful Consequences of the Robustness Principle" Shortened < https://is.gd/F9yfck >
<gonz_> Topical :D
<[[]]> d​aurnimator: Title "html - RegEx match open tags except XHTML self-contained tags - Stack Overflow" Shortened < https://is.gd/8rIJ2g >
<gonz_> andrewrk: Just switched over to github sponsors, thanks for the email laying out the bottom line (them matching it). I had completely missed the point, apparently.
<andrewrk> thanks gonz_!
jjido has joined #zig
<daurnimator> andrewrk: thanks for the shoutout in the stream :)
<andrewrk> daurnimator, np, I meant it
<andrewrk> good night
brakmic has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
avoidr has quit [Quit: leaving]
jjido has joined #zig
jjido has quit [Client Quit]
kristoff_it has quit [Ping timeout: 245 seconds]
jjido has joined #zig
brakmic_ has joined #zig
brakmic has quit [Ping timeout: 272 seconds]
brakmic_ has quit []
brakmic has joined #zig
tgschultz has quit [Read error: Connection reset by peer]
tgschultz has joined #zig
SimonNa has quit [Ping timeout: 245 seconds]
SimonNa has joined #zig
ffddr has joined #zig
hryx has quit [Ping timeout: 245 seconds]
<BitPuffin> andrewrk: when you say (in your video) that zig fmt will protect people from inconsistency that doesn't mean it's gonna get in the way of proper tabs for indent, spaces for alignment style right? :P
<BitPuffin> basically the way I usually use tabs is if I have a function call like
<BitPuffin> f(a,
<BitPuffin> b,
<BitPuffin> c)
<BitPuffin> for the b and c lines I'd tab to the same place that f is, but then use space to get b and c aligned with a
<ffddr> Hi! What options should I consider if I want to use relatively big cmake-based c library (https://github.com/warmcat/libwebsockets)? Maybe some good examples? I found two ways - link in build.zig with cmake-compiled object files + import c headers(or just write couple of extern fns). Or compile C with zig like https://github.com/tiehuis/zig-lua/blo
<ffddr> b/master/build.zig. Maybe some there are some other options?
<[[]]> f​fddr: Title "Page not found · GitHub · GitHub" Shortened < https://is.gd/sERAUs >
<[[]]> f​fddr: Title "Page not found · GitHub · GitHub" Shortened < https://is.gd/qXS6zt >
hryx has joined #zig
very-mediocre has joined #zig
ffddr has quit [Remote host closed the connection]
ffddr has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
brakmic has quit [Read error: Connection reset by peer]
brakmic has joined #zig
brakmic has quit [Client Quit]
very-mediocre has quit [Read error: Connection reset by peer]
brakmic has joined #zig
nifker has joined #zig
nifker was kicked from #zig by ChanServ [Banned: disrespect !T 1w]
very-mediocre has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
dimenus has quit [Remote host closed the connection]
ntgg has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
redj has joined #zig
ffddr has quit [Remote host closed the connection]
ffddr has joined #zig
very-mediocre has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
jjido has joined #zig
ffddr has quit [Ping timeout: 272 seconds]
ltr- has joined #zig
ntgg has quit [Ping timeout: 245 seconds]
SyrupThinker has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
very-mediocre1 has joined #zig
ffddr has joined #zig
wrl has quit [Read error: Connection reset by peer]
very-mediocre1 has quit [Read error: Connection reset by peer]
very-mediocre has joined #zig
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre has joined #zig
<ffddr> ok, I came that in libwebsockets case it will make more sense to just link against system's libwebsockets.o :)
Cadey has quit [Quit: oops]
fengb has joined #zig
dimenus has joined #zig
halosghost has joined #zig
lunamn has quit [Ping timeout: 246 seconds]
lunamn has joined #zig
ffddr has quit [Ping timeout: 246 seconds]
very-mediocre has quit [Read error: Connection reset by peer]
<ltr-> how many times ppl get in here asking for operator overloading? just courious. Im asking cos started to code more in zig and sometimes i found my self wanting a custom operator like | or a comparator, but then i realize that the code is much more clear without overloading and just name the binary function.
very-mediocre has joined #zig
<mq32> ltr-, i think that happens more often
<mq32> i have the same backstory as you, but i still think vectors require operator overloads…
<diltsman> Operator overloading is extremely powerful in C++, but it is incredibly easy to overuse. Probably 90% of the time when people use it they shouldn't. Same goes for most moderatly advanced features.
<gonz_> If there is any hope for the continued readability of zig that shit will get shut down fast
<mq32> diltsman, yeah, that's true
<mq32> i restrict myself in C++ to arithmetic overloading only
<ltr-> may be only custom operators like <=> |~!@@# any non standard combination of signs
<gonz_> Or maybe none of them
<mq32> so: overload an operator for a type only if: 1) type is an arithmetic type 2) operator is an arithmetic operator (no bitstuff or shifts)
<ltr-> i have seen scary things like overloading the ,
<diltsman> Most of the advanced C++ features are for implementers of low-level high preformance libraries. I can play all kinds of stupid games in C++ to make my library fast, and I love writing that kind of code. I also believe that anyone who writes application code that way should be fired.
<mq32> ltr-, you mean like: "vec3 = v(1),2,3" ?
* mq32 runs away
<ltr-> yes you can override the , operator
<mq32> you can even overload "operator&"
<ltr-> eeww
<mq32> which is actually kinda great :D
<mq32> but: only for library stuff
<gonz_> I don't get why people think their typing is so precious
<mq32> property<MyClass, int> prop; // public getter, private/friend setter
<gonz_> Just make it a function
<ltr-> infix function some times helps redeability IMO
<ltr-> may be one can create new operators , and in the code should be clear that is a custom infix operator
<gonz_> In that case make infix enabling tokens like putting a procedure name between `
<ltr-> like haskell yes
<gonz_> Not hijacking operators
<mq32> a `plus` b `mult` c
<mq32> gonz_: Have you ever written linear algebra heavy code in a language without operator overloading?
<gonz_> In any case the solution isn't to try to please people who could either solve their problem by splitting the parts out into separate bindings for readability or could accept a readable infix syntax enabler
<gonz_> mq32: Nope, but it's obvious that adopting something that will enable you to completely hide the meaning of an operator is bad for readability
<very-mediocre> You could always write a comptime parser for your own DSL with operators
<ltr-> ofc, i think zig syntax is very healthy right now
<mq32> yeah, that's true
<gonz_> It doesn't matter if you special case it or make rules for it, no one could look at zig's stated goals and say this is a good idea
<mq32> i'm with you. i'm just saying: "there are viable applications for operator overloading but they don't fit zen of zig"
<mq32> btw, is there any example code on how to use @Vector yet?
<ltr-> i can see ppl doing preprocesors in the build.zig file :D
Akuli has joined #zig
ffddr has joined #zig
fengb has quit [Remote host closed the connection]
<mq32> also i see that @Vector types support operators
<mq32> this is neat
fengb has joined #zig
<fengb> I have a few cases where += would have been cleaner than .set(.get() + val)
<fengb> Basically... mathy stuff
<gonz_> vec3 stuff and C++ I've used operator overloading for
<gonz_> but I'd rather take a hit syntactically than enable it wholesale
<gonz_> and making rules for it just invites people to somehow snake their usage in there
<fengb> I miss it, but not by that much
<fengb> Of course, I come from Java, Javascript, and Go so I never really had much use >_>
<fengb> And Ruby operator overloading is pretty terribad
<halosghost> if I have to have overloading, I think I'd like it the way lua does it
<fengb> s/terribad/abused heavily
<halosghost> but that doesn't really have any relevance to how Zig does operators :)
<andrewrk> I have a game written in JavaScript with some fairly sophisticated linear algebra (AI for spaceships to fight each other)
<andrewrk> I didn't have any problem with the function-based math
<fengb> Gosh I hate math in JS. That's the one thing that convinced me to use Typescript
<fengb> "Oops you used a + operator. You get NaN everywhere now!"
<daurnimator> fengb: I hate math in typescript :p
<mq32> andrewrk, nice demonstration with SDL2 yesterday!
<daurnimator> fengb: typescript seems to do nothing useful in terms of numeric types... it just has floats
<fengb> Well that's just Javascript. It protects against accidental type coercion
<andrewrk> mq32: it's a tiny taste of what the package manager is going to be able to do
<very-mediocre> Typescript secretly hates Javascript. Good luck using libraries that don't have typings. The maintainers expect you to do ludicrous workarounds for using unwashed (untyped) JS modules. So much for the incremental adoption.
<halosghost> daurnimator: you mean like js
<daurnimator> fengb: you should be able to introduce different integer types that are e.g. masked on access.
<mq32> do i understand it correctly that you compile C code to zig and then compile the zig code?
<fengb> I wrote my own type library just to prevent undefined and strings from propagating NaNs everywhere
<daurnimator> halosghost: not really.. JS you sort of get integer annotations (which asm.js really standardized)
<andrewrk> mq32: the c code gets directly compiled to machine code and the zig code gets directly compiled to machine code, then they are linked together
<gonz_> very-mediocre: Running the risk of offtopicing too much, I'll just say that I've been very happy since we switched to TS. It's 100% a good thing and yes, we've run into issues with untyped/old libraries.
<fengb> daurnimator: asmjs is dead so...
<daurnimator> halosghost: e.g. `>>> 0` is a u32. `|0` is an i32. etc.
<daurnimator> fengb: it's only dead in that wasm exists now....
<halosghost> daurnimator: the first non-float numeric type in js just happened; bigints
<gonz_> For more type stuff I've written our own standard library
<halosghost> daurnimator: and it's an extension
<daurnimator> gonz_: any chance I can get you do review a PR open against one of my projects? I don't know the TS ecosystem at all
<mq32> andrewrk, okay thanks. sounded a bit like you compiled two steps... :D
<fengb> very-mediocre: it's a wonder some libraries can even be typed. JS can be hideously complicated
<companion_cube> typescript has a very powerful type system for that reason
<fengb> Yeah it's complicated... but necessary
<halosghost> or, we could all just put a lua engine in our web browsers, cut js support, leave it behind forever, and move on with our lives :)
<daurnimator> (or anyone else that knows TS well)
<fengb> Anyway... sorry to derail this channel lol
<andrewrk> mq32: well step 1 is make SDL2.lib and step 2 is make the_game.obj
<companion_cube> halosghost: you mean wasm, surely
<andrewrk> And step 3 is link them together
<fengb> Port Lua to wasm
<halosghost> companion_cube: not really; but fine, I guess
<daurnimator> fengb: I have a talk on why that doesn't work :P
<companion_cube> why tie ourselves to one single (script) language?
<fengb> Wasm is too low level to be consumed directly
<gonz_> daurnimator: It's unlikely that I represent some kind of "default TypeScript user" since most of what I did for our standard library was port parts of Haskell into it, etc.
<halosghost> companion_cube: I'm a little skeptical of wasm
<halosghost> companion_cube: actually, I'm skeptical of any programming on the web
<companion_cube> I'm very enthusiastic, at least we can use proper langs on the web
<companion_cube> well yeah, but it's there to stay
* halosghost likes an interconnected web of hypertext documents
<daurnimator> halosghost: companion_cube: fengb: https://fengari.io
<gonz_> daurnimator: We/I do a lot of type systemy stuff to keep invalid states unable to happen, etc.
<andrewrk> Yeah I just want more browser API exposed to wasm
<halosghost> daurnimator: expired cert
<daurnimator> oh crap is my cert expired
<daurnimator> one sec... checking letsencrypt cron job
<halosghost> that reminds me, I really need to finish migrating from acme-client to uacme
<halosghost> maybe I can manage that this weekend…
<daurnimator> halosghost: I use dehyrdrated.
<halosghost> never heard of it
<halosghost> if it works for you, I'm glad :)
<halosghost> my webpage is written in C and I try to keep the thing as small as possible
<halosghost> including dependencies
<halosghost> uacme is pretty light-weight
<daurnimator> halosghost: dehydrated is a bash script.
<fengb> andrewrk: I don't think wasm proper will ever have browser APIs. But we might be able to get pretty standard "userland" wrappers
<daurnimator> that you can easily read yourself
<halosghost> daurnimator: sounds fair; I'm planning on not having bash on my next machine
<halosghost> like I said though; if it works for you, I'm glad :)
return0e has quit [Ping timeout: 258 seconds]
<daurnimator> halosghost: cert fixed try https://fengari.io/ again :)
<[[]]> d​aurnimator: Title "Fengari"
<halosghost> ah yes
<halosghost> the lua vm in js
<halosghost> I've seen this
<halosghost> daurnimator: you made it?
<daurnimator> halosghost: yep
<halosghost> nice
<halosghost> it's terrifying, but cool
<daurnimator> you'll see a link at the bottom of the page to a talk I did on why wasm isn't the answer
<companion_cube> daurnimator: I dislike untyped languages, so lua in the browser isn't exactly exciting :p
<daurnimator> though I think the audio got fucked up :(
<companion_cube> especially now that TS exists
<fengb> wat, you look nothing like what I had thought
<daurnimator> fengb: ha. what did you imagine?
<[[]]> f​engb: Shortened < https://is.gd/4un1gE >
<fengb> Again, you're a pokemon in my brain
jjido has joined #zig
jjido has quit [Client Quit]
<halosghost> daurnimator: is that your main webpage or do you have another
<very-mediocre> There's no nice way to say this. I discovered that Zig is a bad word where I live.
<daurnimator> halosghost: for fengari? there's also the github page... https://github.com/fengari-lua
ffddr has quit [Remote host closed the connection]
<[[]]> d​aurnimator: Title "Fengari · GitHub" Shortened < https://is.gd/yPBGWG >
<very-mediocre> So is Go, to some people, apparently
<halosghost> daurnimator: no, I meant for you
<daurnimator> halosghost: well this alias (daurnimator) has a blog. https://daurnimator.com
<[[]]> d​aurnimator: Title "Daurnimator's Hovel" Shortened < https://is.gd/xHpUPy >
<fengb> Ah GC problems
<halosghost> daurnimator: kewl
<companion_cube> didn't find the video about why wasm isn't the answer
<daurnimator> fengb: yep. solving GC cycles across DOM and Wasm is essentially impossible.
return0e has joined #zig
<companion_cube> isn't the answer to do everything in wasm? :p
<daurnimator> companion_cube: sure. and at that point who needs a web browser :P
<fengb> Its interop with the DOM is pretty poor
<fengb> By poor, I mean nonexistent. You have to wire in things manually and there isn't a convergence of strategies yet
<halosghost> daurnimator: I need more lua people in my life; good to meet you :)
<companion_cube> daurnimator: you'd still have a DOM
<halosghost> daurnimator: cf. https://halosgho.st if interested
<[[]]> h​alosghost: Title "/home/halosghost"
<companion_cube> well it's not like wasm is finished…
<fengb> The base spec will probably never have DOM bindings. It's designed to be platform agnostic
<halosghost> daurnimator: (not that that page will say much regarding my lua exploits)
<halosghost> that reminds me, I really need to finish my port of the punycode encoder/decoder to lua
<companion_cube> fengb: doesn't preclude spec extensions
<companion_cube> same as JS, after all
<daurnimator> halosghost: I just saw that project... I once did something similar. and then I learnt that TR46 is a thing
<halosghost> daurnimator: TR46?
<daurnimator> ha
<daurnimator> yeah
<daurnimator> that's everyones answer
<halosghost> linky?
<daurnimator> TR46 is a stupidly complex list of obscure normalisation rules you *must* apply before doing punycode
ffddr has joined #zig
<daurnimator> complex enough that they require ~8 MB of unicode tables
<fengb> o_O
<halosghost> mmm
<halosghost> that sounds fun
<daurnimator> halosghost: http://www.unicode.org/reports/tr46/
[[]] has quit [Remote host closed the connection]
[[]] has joined #zig
<fengb> Unicode is the best and worst thing that's ever happened to strings
<halosghost> ohhh yes
<daurnimator> the *only* library that implements those rules correctly is libidn2
<halosghost> I've read this
<daurnimator> guess why libidn2 suddenly became part of the core of all linux distributions about a year ago
<halosghost> heh
<companion_cube> it's like datetime, it's inherently messy
<daurnimator> halosghost: so I wrote https://daurnimator.github.io/lua-idn2/
<[[]]> d​aurnimator: Title "lua-idn2" Shortened < https://is.gd/rHDH46 >
<halosghost> daurnimator: to be fair, this is only required for idna-compat
<halosghost> daurnimator: you don't actually have to do this for general punycode usage
<daurnimator> but then I realised that I don't need to use libidn2 directly. instead libpsl includes libidn2 and also punycode routines. so I wrote https://daurnimator.github.io/lua-psl/
<[[]]> d​aurnimator: Title "lua-psl" Shortened < https://is.gd/A6RLX8 >
<daurnimator> I'm going to claim this is ontopic because we'll need to do all these same things in zig
<andrewrk> very-mediocre, what language is this? what does the word mean?
<daurnimator> ==> bindings to libidn2 and/or libpsl will be essential for zig in future for e.g. the http client
<andrewrk> daurnimator, yeah you're good, technical stuff like this is welcome
<halosghost> hehe
<fengb> Should we port libidn2 to zig?
<fengb> Is that too much work?
<very-mediocre> andrewrk: I live in Dubai. I told a friend about Zig and he told me it's local slang for pooping. That would be the local dialect only.
<andrewrk> fengb, why do you think that? it seems like the natural progression to me
<daurnimator> fengb: eventually. start with a comptime parser for the unicode data files
<very-mediocre> If it makes you feel better, I've worked with Iranian people and they informed me that Go also means poop.
<andrewrk> interesting. I predict that is a problem that is likely to happen with any single-syllable word
<daurnimator> but I'm not sure if we'll want to write libpsl in zig: most linux distros ship with libpsl with a compiled in list that gets updated
<very-mediocre> Yes most likely.
<very-mediocre> Fortunately almost nobody who uses that dialect is a programmer.
<fengb> Maybe we could switch to a single letter? :P
<halosghost> I mean, that's just the nature of language
<fengb> Zed
<tgschultz> andrewrk: happens with multi-syllable words too, there's really no avoiding it with a world of 8 billion people and constantly shifting languages
<companion_cube> I mean, in french "bit" sounds exactly like "cock", so…
<halosghost> a reasonably good-faith effort is about as much as can be expected
<companion_cube> we get over it
<halosghost> companion_cube: indeed
<fengb> Even the english world wouldn't agree on the pronunciation :D
<daurnimator> ooo, I just did a system update and linux 5.2 is downloading. I'll un-draft that PR now before I go to bed
<companion_cube> anyway, unicode is awesome 💞✨💃
<daurnimator> halosghost: if you need a unicode domain to practice on https://ȱ.com is another project of mine (bring written in zig! that's what the bloomfilter PR is for)
<halosghost> bloom filters!
* halosghost loves bloom filters
<andrewrk> daurnimator, nice
<daurnimator> andrewrk: "last checkbox item"?
<tgschultz> I don't think unicode is awesome. Unicode is a barely tollerable complex solution to a problem I'm not sure is real. It's an out there opinion, but I think language should adapt to computing more than the other way around.
<fengb> ASCII or bust :P
<Akuli> daurnimator, i used to work on a programming language called Ö
<Akuli> that's not O, that's Ö
<halosghost> tgschultz: that's a pretty western-centric view
<companion_cube> ascii is such an anglo centric hill to die on
<halosghost> but conversations like that are definitely headed towards OT
very-mediocre has quit [Read error: Connection reset by peer]
<tgschultz> halosghost: I didn't say we had to standardize on ASCII
very-mediocre has joined #zig
<daurnimator> Akuli: ȱ is a cooler letter; it's from a dead language called livonian and sounds sort of like "eugh" ;)
<halosghost> tgschultz: nor did I
<companion_cube> so what subset of utf8 would y'all rather have?
<daurnimator> Akuli: also there's only so many single letter domains I can obtain
<very-mediocre> companion_cube: better English than something like Esperanto.
<Akuli> daurnimator, but i have an ö key on my keyboard
<halosghost> companion_cube: I don't care which one as long as it contains box-drawing chars and the four separators
<halosghost> :)
<[[]]> A​kuli: Title "GitHub - Akuli/odotdot: Funny programming language" Shortened < https://is.gd/FQEwfD >
<companion_cube> very-mediocre: neither can become the one true language™
<tgschultz> I'm just saying, maybe languages should adapt to be more easily representable on computers rather than forcing computers to learn our complex, ever changing, and frankly irrational languages. Just look at how complex it is to do simple things like match text in unicode.
<daurnimator> Akuli: haha. I laughed out loud.
<companion_cube> yeah, maybe english should be written with kanjis
<very-mediocre> tgschultz is giving me some "assimilate or die" borg vibes
<fengb> tgschultz: I don't think you can just ignore Arabic or Chinese and expect it to work
<daurnimator> Akuli: you can type ȱ in most linux programs with ctrl+shift+u 2 3 1
<fengb> They'll just invent their own standards
<tgschultz> Unicode isn't quite as bad as making a writing system out of drawing the waveforms for spoken words, but it is in the same ballpark of universal but not appropriate.
<fengb> It's a miracle Unicode is even a real standard
<companion_cube> well before unicode there was one standard per language, so… 🤷
<tgschultz> Why does everyone think I'm being language centric here?
<Akuli> daurnimator, i can type ö with one key press in any program :D
<companion_cube> tgschultz: well you said languages had to adapt
<tgschultz> yes
<tgschultz> The same way languages adapted to be written when we invented writing
<companion_cube> I don't imagine you suggest removing some ascii chars, heh?
<fengb> ... they didn't adapt to writing
<fengb> Chinese has hundreds of different spoken dialects with 1 written form
[[]] has quit [Remote host closed the connection]
[[]] has joined #zig
<tgschultz> fengb: the fact that we aren't writing down waveforms says they did
<andrewrk> I tend to agree with tgschultz on this, although I recognize it's a bit easier for me with my native language than for others'
<very-mediocre> Don't underestimate English. There's a recent trend of western sociocultural guilt, but imho English is the most effective language I know out of 4.
<companion_cube> doesn't mean other people should given up theirs
<companion_cube> or all the existing text corpus in their language
<very-mediocre> well nobody's being asked to give up their language
<tgschultz> andrewk: oh yeah, no doubt english is already well suited, which does give me some cause for doubt.
<andrewrk> I like the part about unicode that it has all the characters from every language. the part I don't like is where there are multiple ways to represent the same thing
<fengb> I know English and Chinese natively. And English is much better for just about everything
<companion_cube> "sorry, this book doesn't fit unicode 2.0"
<fengb> But you can't just ignore a language and hope it'll change
<tgschultz> language adapts to medium all the time
<companion_cube> very-mediocre: s/give up/adapt/ ?
<companion_cube> what would that even mean?
<andrewrk> I don't like that some codepoints are not characters, but modifiers
<companion_cube> give up accents?
<companion_cube> andrewrk: some languages are apparently inherently modifier based :/
<companion_cube> even é I'd rather type as e+'
<tgschultz> I'm not sure what it would mean outside of latin derived languages, which are pretty much all I have experience in.
<fengb> I don't like that modifiers and characters can be "equal"
<companion_cube> that's a fair point
<tgschultz> companion_cube: here's the thing, the fact that you were easily able to recognize, through convention, that é and e+ are the same thing is the kind of adaptation I'm talking about. Hardly anyone uses interrobang because !? works fine.
<companion_cube> ‽
<companion_cube> I use interrobang a lot, sorry
<fengb> ⸘
<Akuli> ö
<fengb> Ha, I didn't expect that to be a thing
<very-mediocre> companion_cube: ...in french?...
<companion_cube> on IRC
<companion_cube> language adapts to the medium ;)
<tgschultz> fengb: didn't even render in my client, whatever it was.
<companion_cube> emojis are a prime example of that: electronic communications need another way of conveying emotions
<fengb> Inverted interrobang
<very-mediocre> OK, parce que je n'en ai jamais entendu parler.
<companion_cube> or body language
<andrewrk> it looks like a glitch to me, before I read the conversation I thought my IRC client had a bug
<companion_cube> very-mediocre: vraiment‽
<fengb> Emoji is a new language
<fengb> Humans love creating new languages
<companion_cube> it's an evolution of ascii smileys
<companion_cube> and it addresses a need
<very-mediocre> Non-English codebases are scary, tbh.
<very-mediocre> There's so much friction with the naming.
<companion_cube> for coding I agree it's a different problem
<tgschultz> I've heard that there are programmers insane enough to use emoji in code.
<companion_cube> s/insane/cheeky/ ? 🙃
<andrewrk> here is one thing I will say: some languages are fundamentally easier to represent. objectively! in terms of information theory
<andrewrk> and in software - open source software in particular - difficulty means that progress costs more time
<andrewrk> progress & time are the currency of software
<fengb> I agree from a technical perspective
<andrewrk> and so, languages which are fundamentally easier to represent, in practice, will end up getting more support. that's just a fact of life
<companion_cube> reusability means this kind of problems should be easier to solve only once, though
<andrewrk> no matter what we decide is ethically correct to do as a society
<companion_cube> (like canonizing, sorting, etc.)
<very-mediocre> There's nothing wrong with that. Everyone's too afraid of everything being perceived as racist.
<fengb> But you can't really force people to change culturally
<daurnimator> Any of those typescript lovers able to do a review for me? :) fengb?
<companion_cube> but there's not "a society", but a collection of societies
<fengb> Unicode is intentionally descriptive, for better or for worse
<tgschultz> all societies are collections of societies. It's like saying there is no animal there are only cells.
<fengb> Trying to describe all of language in one standard... it's insane that it's even possible
<companion_cube> do you consider that there's one big human society we're all part of?
<tgschultz> yes? why wouldn't that be true.
<very-mediocre> I find anyone who would try to unify everything is a scary control freak.
<companion_cube> I mean it's somewhat true, but it never takes decisions
<very-mediocre> There's nothing unethical about division, people form groups naturally.
<companion_cube> very-mediocre: would you rather go back to latin1 ?
<very-mediocre> I mean socially, and worldwide :)
<very-mediocre> e.g. Esperanto, the language of the world to be.
<companion_cube> heh, what a pipe dream
<companion_cube> it's as hopeless as having one true programming language™
<tgschultz> companion_cube: yes it does, but I think I've dragged this off topic enough.
<very-mediocre> Computers are not humans, unify as you please :)
<companion_cube> well we need an offtopic for this chan then, if there isn't one :p
<fengb> Although thanks to pop culture and technology... we're sorta unifying around English that's been unheard of before
<very-mediocre> hey it's not _entirely_ off topic
<very-mediocre> it does feed back into utf-8
<andrewrk> unicode & society can be on topic as long as everybody is nice to each other
<companion_cube> (personnally I love utf8 and you can pry it off my cold dead hands)
<companion_cube> there's no viable alternative
<fengb> As a user, I love that UTF8 exists... and as a developer I hate it for all the same reasons
<tgschultz> english is kind of the "worse is better" of languages in a lot of ways isn't it....
<companion_cube> but even among english speaking users, no one uses only ascii nowadays
<companion_cube> most people use emojis
<companion_cube> (on their phone)
<companion_cube> (or on social media)
<daurnimator> /bed
<companion_cube> and who doesn't love Σ and λ and other math symbols? :)
<tgschultz> I haven't found that to be true, but I don't engage in basically any social media and have no data for emoji usage.
<daurnimator> companion_cube: the domain name people :(
<fengb> tgschultz: I think English is the defacto because 1) ASCII is easy and 2) Hollywood has a really wide reach
<gonz_> daurnimator: Which timezone are you in?
<fengb> Even people who don't care about tech care about English because mah movies
<daurnimator> gonz_: Melbourne/Australia
<gonz_> Ah
<companion_cube> fengb: movies can be dubbed
<very-mediocre> Even if English was de facto for "wrong" reasons, there's no undo button on history without creating more problems
<gonz_> daurnimator: GN :)
<companion_cube> (although I feel like it's becoming less cool)
<daurnimator> gonz_: https://github.com/fengari-lua/fengari/pull/157 <-- if you feel like doing a review I feel unqualified for :)
<[[]]> d​aurnimator: Title "Typescript typings: First cut by roddypratt · Pull Request #157 · fengari-lua/fengari · GitHub" Shortened < https://is.gd/HWuIb4 >
<companion_cube> daurnimator: why doesn't lua have a good type system?
<fengb> companion_cube: I mean people are more willing to learn English just to consume our media
<companion_cube> and they still won't give up their mother tongue
<fengb> Corollary to Americans learning Japanese
<tgschultz> being a net exporter of culture does have its upsides
<andrewrk> I'm going to be the conductor of this off topic train for a moment and ask this question: what did V do to attract so many people worldwide? is it because the main dev is russian and not american? is there something else the project did? am I doing something wrong? I want zig to be a global community
<companion_cube> but yeah, english has an unprecedented reach
<companion_cube> andrewrk: wild promises? :D
<andrewrk> was that really it though? surely there must have been something else
<companion_cube> V attracted people by promising unrealistic features and being super assertive
<fengb> Marketing <=> Truth
<fengb> Pick one :P
<tgschultz> I'm not sure unrealistic promises alone can account
<fengb> I think it generated a lot of controversy
<companion_cube> it's like "Go but faster and with generics and simpler and with rust's goodness"
<fengb> Which yielded free notoriety
<tgschultz> fengb: that could be part of it, yes, I was thinking something similar.
<very-mediocre> If naivete follows a normal distribution, I'd expect such a representation
<ffddr> Is there any workarounds for "warning: struct lws_http_mount demoted to opaque type" (from https://github.com/warmcat/libwebsockets/blob/master/include/libwebsockets/lws-context-vhost.h#L1033)?
<[[]]> f​fddr: Title "libwebsockets/lws-context-vhost.h at master · warmcat/libwebsockets · GitHub" Shortened < https://is.gd/ijqHic >
<andrewrk> ffddr, to fix the issue, the `translate-c` feature of zig must be improved. the workaround is to manually translate the struct and put that into your codebase
<andrewrk> oh, this is a bitfield
<dimenus> can Zig do conditional compilation based on platform?
<andrewrk> yes, the workaround here will be to find out how the struct is laid out in memory and match it with a zig struct. you'll probably have to use a u32 for all the bit field fields
<dimenus> Or is it recommended that you use a compile time constant to if out code?
<dimenus> *conditional file compilation
<andrewrk> dimenus, @import("builtin"). you can see the contents of that with `zig builtin`
<andrewrk> zig has lazy analysis, so if your @import is inside an if or switch, then it can be conditionally compiled
<companion_cube> andrewrk: imho you're taking the high road of not over promising and doing things well
<companion_cube> V has consistently done the opposite, and people wanted to believe
<ffddr> andrewrk how to manual impelent the struct? I mean, I got `import of 'struct_lws_http_mount' overrides existing definition` error, probably I need to put the manual implentation to some special location?
<andrewrk> ffddr, you could name it a new name, and @ptrCast to/from the "real" one where you need to
<andrewrk> it's annoying, I know - the real fix is to improve translate-c
return0e has quit [Ping timeout: 248 seconds]
<ffddr> the header file have this: ` mounts: [*c]const struct_lws_http_mount```, and it fails to compile with struct_lws_http_mount = @OpaqueType :(
<andrewrk> why doesn't that compile?
<ffddr> The initial header have this: `const struct lws_http_mount *mounts;` in one of the structs
<ffddr> in the cimport.zig lws_http_mount is @OpaqueType
<ffddr> error: C pointers cannot point opaque types mounts: [*c]const struct_lws_http_mount,
<andrewrk> ffddr, I believe that can be fixed quickly. let me take a look.
<ffddr> I can make minimal reproducible example if it will help somehow
<andrewrk> I can reproduce it
<dimenus> sigh, oh C. andrewrk, I'm walking through vulkan-tutorial and on Windows the extension names were reading past the names
<dimenus> and all of the types are [256]u8
<dimenus> -_-
<dimenus> should a string format specifier override that and look for a null?
<andrewrk> dimenus, I think it will be more clear what should happen once we have #265
<ffddr> am I right that using packed struct and u1 will probably match memory layout of C's bitfields for this particular struct?
<mq32> ffddr, i think zig gives more guarantees than C
<mq32> but afaik you are not to assume bit order of C bit fields
<andrewrk> you can assume bit order of C bit fields to be consistent when the target C ABI matches
<andrewrk> that's the third component of "target"
<fengb> C bitfields are woefully underdefined :(
<andrewrk> however packed struct with u1 is not guaranteed to match C ABI
<mq32> C is woefully underdefined
<tgschultz> ^
<mq32> my collegues be like: "wait, i can not assume that $thing is given? But i do this since years and it works, it must be guaranteed!"
<companion_cube> "b-b-b-b-but C is so simple!"
<mq32> *a++ = *b++;
<fengb> I was actually going to try tackling bitfields... but then I encountered bits spanning alignments
<andrewrk> ffddr, I pushed 4e58855a to fix the "error: C pointers cannot point opaque types"
<andrewrk> just a small improvement to help your use case along, until translate-c-2 can catch up and become the official translate-c and then be further improved
<ffddr> wow, thanks!
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre has joined #zig
<ffddr> while its building I am trying to figure out how unsafe "packed struct" is. If I'll use u1 for this case and will check struct size and layout once - will it be enough to be sure that its safe to use (with given particular target, compiler etc)?
<fengb> Packed struct is fine in Zig. It's just undefined behavior when linking with C
<andrewrk> fengb, it's not undefined behavior - packed structs have well-defined in-memory layout, and so does the C bit fields
<fengb> Oh yeah it's consistent and well defined. So if you mirror the structure in C it'll work
<fengb> andrewrk: I meant the C spec doesn't define how the bitfields are laid out so it's ABI specific
<andrewrk> right. it's per-ABI, so you should probably put a comptime assert in there to say "hey I didn't test this C ABI yet, make sure the code works and then allow this target"
<ffddr> got it, thanks!
<fgenesis> re: default struct layout without ordering guarantees
<fgenesis> what about cache effects? like some fields that should be placed in a certain way so that they are on the same cache line
<fgenesis> (plus is there a comptime function that returns the platform cache line size?)
<andrewrk> fgenesis, zig's answer to that is: zig plans to make it easy to do profile-guided optimization, so letting the compiler choose the field layout will improve that
<andrewrk> however if you need tight control, that's what packed struct is for. there are still some improvements to packed struct planned to make it more robust and generally useful
return0e has joined #zig
<fgenesis> as in, compose a struct with smaller ones that have a forced alignment of $cacheLineSize
<fgenesis> and comptime assert that each small one actually fits in a cache line
<ffddr> can confirm, now its ` ?*const struct_lws_http_mount` and so `@cInclude(libwebsockets.h)` compiles just fine! :)
<andrewrk> such a feature is a possibility but it will probably require handling the case when the cache line size is not known. when compiling natively, cache line size can be comptime known. but when cross compiling (creating a build meant to work on multiple targets) it is runtime known
<andrewrk> there's a related issue which is function multi-versioning
ffddr has quit [Remote host closed the connection]
<Tetralux> Fn multi-versioning?
<fgenesis> oh right, nobody is stopping from AMD releasing a 256-byte-cacheline cpu
<fgenesis> *AMD from
<fgenesis> for example
fengb has quit [Remote host closed the connection]
ffddr has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
<andrewrk> ffddr, great, hope that can unblock you until the better solution is available
<ffddr> it will, thank you very much for such a fast fix!
very-mediocre has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
very-mediocre has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
ky0ko has quit [Remote host closed the connection]
[[]] has quit [Remote host closed the connection]
[[]] has joined #zig
<gonz_> Uhh, `var arena_allocator = ArenaAllocator.init(std.heap.direct_allocator)` is what you're supposed to do now, right?
<andrewrk> gonz_, yes thanks to Sauhnvor's changes DirectAllocator can be globally initialized at compile time
<andrewrk> so there is just one of them
<gonz_> Coolcool :)
<gonz_> I should update from master more often
very-mediocre has quit [Read error: Connection reset by peer]
<fgenesis> re, allocators: https://arxiv.org/pdf/1902.04738.pdf
<[[]]> f​genesis: Shortened < https://is.gd/xxQuyi >
<fgenesis> this looks like a really interesting concept
<fgenesis> keep raw pointers valid while the underlying memory is defragmented, kind of
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
very-mediocre has joined #zig
laaron has joined #zig
MH026 has joined #zig
<Tetralux> If you're problem is that you are suffering memory fragmentation, I shudder to think how much memory you are wasting due to poor architecture.
* fgenesis looks at firefox
<fgenesis> well...
<MH026> is someone able to compile zig master on aarch64?
<Tetralux> fgenesis: Yeah - that's not even worth attempting to justify xD
<andrewrk> MH026, paging scientes
<Tetralux> MH026: You getting problems with xcore-max-threads by any chance?
<fgenesis> i mean any longer-running process has that problem
<MH026> last time, this was the problem https://github.com/ziglang/zig/issues/2251
<[[]]> M​H026: Title "compile error on Arm64 · Issue #2251 · ziglang/zig · GitHub" Shortened < https://is.gd/m0OQTc >
<fgenesis> where longer-running i'd arbitrarily set at 3 minutes upwards
<Tetralux> fgensis: To a point - A significantly lesser point than what anything uses.
<MH026> wondering if there was a quick workaroudn that wouldnt have side-effects
<Tetralux> #2858?
<[[]]> T​etralux: Title "cmake: allow user to select static vs dynamic LLVM by daurnimator · Pull Request #2858 · ziglang/zig · GitHub" Shortened < https://is.gd/hmgqAu >
<Tetralux> fgensis: If Firefox saved the rendered page and wrote it to disk after a few minutes of not looking at a tab it'd help...
<Tetralux> The latent 1.5GB or w/e it is now is insane. Firefox does NOT need that much memory.
<Tetralux> I doubt it even needs half that.
<Tetralux> Like really - wtf is it doing?
<gonz_> I just blindly assume that FF (& Chrome) are both like "Oh, you have RAM left, I'll have some of that"
GrooveStomp has joined #zig
<gonz_> I had a gander at Task Manager today and saw that FF had grabbed 6GB
<Tetralux> Oh yeah - that sounds perfectly reasonable /s
<GrooveStomp> Hello
<Tetralux> I'd laugh if it had something to do with JS...
<Tetralux> Groovestomp: o/
<fgenesis> Tetralux: actually CSS evaluation can be as costly as JS nowadays
<fgenesis> if you consider that html5+CSS is already turing complete
<gonz_> It's taking 4GB right now with just my zig tabgroup open
<gonz_> I have zero idea what it could even be caching to grab that much
<emekankurumeh[m]> that's why I switched back to chrome
<gonz_> 13 tabs
<gonz_> Chrome is as bad but without good extensions
<fgenesis> i use noscript excessively and yet it racks up memory quickly, and some sites are VERY slow even though js is totally off
<gonz_> There are no good browsers
* fgenesis mumbles somethingabout elinks and arachne
<gonz_> Like I said, I want to believe that maybe it's grabbing memory because it can, through some kind of negotiation with Windows. It wasn't like this when I had less memory.
<gonz_> I have 32GB now so I can only assume it's at least a bit related.
<fgenesis> yeah right? FF 3.6 on a 1 GB machine was totally fine
<fgenesis> two browsers with a single tab open on a x32/1 GB ram machine nowdays is completely impossible
<Tetralux> I have 32GB too.
<Tetralux> I should point out
<fgenesis> (swap disabled ofc)
<Tetralux> That I have auto-tab-discarding extensions in all my browsers...
<Tetralux> Including FF.
<Tetralux> Still 3GB.
<Tetralux> I think I've seen it taking 8 before.
andersfr has joined #zig
<Tetralux> (..hence the ext.)
<fgenesis> hrm. 30 tabs open here, some extensions, FF 59 ESR, and it's at 1.6 GB ram used with a process uptime of ~2 weeks
<fgenesis> you're doing something wrong :P
<Tetralux> Also RE CSS - if that's taking more than 100MB of memory, everyone should be fired.
<Tetralux> That's beyond ridiculous.
<fgenesis> actually 40 tabs, some of them with js, most form different sites
<Tetralux> I have over 100.
<fgenesis> so i really dunno
<emekankurumeh[m]> ?
<emekankurumeh[m]> 100 tabs?
<Tetralux> Yup :)
<fgenesis> tabsplosion
<Tetralux> That's a low estimate.
<Tetralux> I swear to god, do NOT make me write a browser! x'D
<halosghost> Tetralux: please write me a browser
<halosghost> requirments: terminal-only, graphics via sixel, no scripting support required
<Tetralux> Alright - let's ditch JS, CSS, HTML... hmmm. What else can we get rid of.
<Tetralux> Obviously replace it with native x64 code.
<Tetralux> Oh - get rid of the DOM too.
<MH026> just make a browser with electron, ez
<MH026> :^)
<Tetralux> Just _reading_ that word makes steam start coming out of my ears.
<[[]]> f​genesis: Title "Codenet - IndividualComputers" Shortened < https://is.gd/dHpgFK >
fengb has joined #zig
<fengb> Someone needs to write a browser in wasm
<halosghost> gross
<Tetralux> I'd rather have the client browser tell the server what it's arch is and have the browser produce native code for it to run or something.
<fgenesis> the best implementation is that with zero overhead. but i don't think that "put network packet into buffer and jump into it" is a good, secure solution nowadays :P
<Tetralux> This is true. But there's probably a way to handle that reasonable.
<fgenesis> actually webasm is a good idea i think. or something like SPIR-V if you need compute power
<Tetralux> reasonably*
<fgenesis> something to transpile to hardware quickly
<Tetralux> My problem with webasm is that it's not what the hardware is.
<Tetralux> I don't want a VM.
<Tetralux> I want code.
<Tetralux> That runs.
<Tetralux> Fast.
<fengb> wasm isn't intended to be a VM
<fgenesis> so llvm bytecode it is, then
<fengb> But it's possible to transpile wasm into native
<fgenesis> as long as dynamic typing is out of the equation lowering to hardware should be simple enough
<Tetralux> It is. It's also possible to just have the source code on the server [...]
<Tetralux> And when a client asks for it
<Tetralux> It tells it what arch it is
<Tetralux> The server compiles it
<Tetralux> And hands it native code.
<fgenesis> DDoS made easy, i see
<fengb> Staring at wasm for awhile, it's sorta like high level LLVM (not really but it matches closer than actual hardware)
<companion_cube> why is that simpler than downloading the wasm and compiling it locally?
<companion_cube> (which also helps using native instructions, in theory)
<Tetralux> I'm not sure what you mean by "which also helps using native instrs"
<fgenesis> server will be like "what, you're big endian? haha lol" *disconnect*
<Tetralux> HAHA
<Tetralux> What safeguards does wasm have that native would not?
<Tetralux> Or put differently
<Tetralux> How does it know what to prevent you from doing?
<companion_cube> Tetralux: well same as using `-march=native` instead of generic x86_64
<fengb> wasm is specced for sandbox
<Tetralux> It's better because the server is a powerful computer that needs to compile the code for every client arch.
<Tetralux> So it could cache it.
<Tetralux> There's no point having the client recompile something that literaelly every client is gonna need.
<Tetralux> The only issue I have is how to effectively sandbox it.
<fgenesis> so it's compile+cache on the server if it wants to / is able to, and otherwise compile on client
<fgenesis> that would be good
<Tetralux> The "compile on client" part is unnecessary I think.
<Tetralux> Just download it from the server - the server can RAM cache it.
<fgenesis> say that again when your shiny new RISC-V computer arrives
<fgenesis> and no server ever supports it
<Tetralux> We already do.
<Tetralux> Zig, for instance, can already target RISC-V.
<fgenesis> ok, whatever, i mean any weird architecture
<fgenesis> something not widely supported
<fgenesis> like a browser on an AVR microcontroller or some weird shit
<Tetralux> If LLVM supports RISC-V -- which is not widely supported -- then why not add another one when the same exact thing happens? xD
<fgenesis> ok, that thing is harvard, forget about the "transpile code" thing, but you know what i mean :P
<andrewrk> btw, it looks like RISC-V is getting promoted from an experimental target to an installed-by-default target in LLVM 9
<Tetralux> Personally I want to get my hands on a RISC-V PC that's actually powerful and see how useful it is.
<andrewrk> which means it goes from tier 4 to tier 3 support in zig
<Tetralux> But that seems a way out yet.
<Tetralux> Also that seems good :)
<Tetralux> Oh right - That was one though I had. Perhaps you could have the code from the server just be -- essentially inserted as the body of a function. And then the code can only call code that's within that framework.
<Tetralux> .. which could have specially wired syscalls that don't let you just do anything.
<Tetralux> You have some skeleton code that the server's code gets inserted into. A harness, if you will.
ntgg has joined #zig
<Tetralux> I'm not entirely sure how you'd make the harness work to prevent it from doing arbitrary things, but I haven't researched into that, so.
<fengb> By creating a sandboxed vm >_>
<Tetralux> :^)
<Tetralux> For the sake of exploration, let's ignore that one for now.
<Tetralux> And because that's not solving the problem of running native code - because it's a VM. x')
<Tetralux> Though I take your point.
<Tetralux> But I'd like to actually think about it before admitting defeat lol
ffddr has quit [Remote host closed the connection]
andersfr has quit []
very-mediocre has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
avoidr has joined #zig
brakmic_ has joined #zig
brakmic has quit [Read error: Connection reset by peer]
brakmic_ has quit [Ping timeout: 245 seconds]
ofelas has joined #zig
very-mediocre has joined #zig
very-mediocre has left #zig [#zig]
<hryx> andrewrk: regarding last night's saftey checks discussion: when self-hosted is feature complete, would it make sense to remove safety checks from stage1? In particular if we add some more complex safety checks
<andrewrk> yes
<hryx> and I guess at that point, the question becomes would stage1 even need Debug
<hryx> cool
<andrewrk> I think the question would be, wolud it even need Release
<hryx> even better
<Tetralux> So long as I can build the compiler in debug and release modes... :)
<hryx> I'm toying with the "undefined values table" some more to see if it holds water
<andrewrk> once we're shipping stage2, the only point of stage1 is to build stage2
<Tetralux> Shoud be interesting :p
<andrewrk> emekankurumeh[m], after #2868 is merged we can delete libc detection for mingw
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
<emekankurumeh[m]> would that work with compiling stage 1?
<andrewrk> not sure what you're asking
fengb has quit [Remote host closed the connection]
dimenus has quit [Ping timeout: 246 seconds]
Ichorio has joined #zig
Akuli has quit [Quit: Leaving]
kristoff_it has joined #zig
halosghost has quit [Quit: WeeChat 2.5]
kristoff_it has quit [Ping timeout: 245 seconds]
<GrooveStomp> I just found out about Ziglang very recently after integrating libsoundio into a personal project. I like it, it speaks exactly to my interests.
<GrooveStomp> Just now while reading through the docs I saw that it supports tagged unions with switches. Perfect. I'm sold. :-)
ntgg has quit [Ping timeout: 246 seconds]
<emekankurumeh[m]> stage 1 requires linking to libc using stage 0
<emekankurumeh[m]> nvm
<emekankurumeh[m]> if we use a bundled libc then the executables will "static" as in they won't depend on any mingw-w64 runtime dlls
<emekankurumeh[m]> that's really nice
<andrewrk> emekankurumeh[m], can you test the windows-libc branch in your build?
<emekankurumeh[m]> sure
<andrewrk> I changed the default windows C ABI to be gnu
<andrewrk> since we have a libc for it
<andrewrk> if it works fine for you I'm going to delete the mingw native libc detection code
<andrewrk> ooh, you know what, even better. the default windows C ABI can be msvc when not linking libc, but gnu when linking libc
<emekankurumeh[m]> my only gripe is now installs are going to take even longer
<emekankurumeh[m]> is there a way to tell cmake to only install zig and the std dir?
<andrewrk> you're talking about waiting for cmake to print the entire goddamn list of installation files right?
<andrewrk> it's sad, the time spent is waiting for it to print to the terminal, not even the actual file system operations
<emekankurumeh[m]> yes
<Tetralux> Does it print the "Installing" lines to stdout, and the "updating" to stderr?
<andrewrk> I think it's starting to make more and more sense to support testing without installing. however I'm concerned this will start introducing bugs where we forget to install files and the tarballs we ship will be missing files
<emekankurumeh[m]> i usually pipe the output to /dev/null, but that makes it hard to debug build errors
<emekankurumeh[m]> it all goes to stdout
<Tetralux> Maybe you could pipe to grep for "Installing"?
<Tetralux> So it would only show those lines.
<andrewrk> I have an even better idea
<andrewrk> move installing the files to stage2
<Tetralux> Doesn't the Zig binary need those to work?
<Tetralux> I seem to remember that I accidentally tried build-exe without doing the install step once and it failed.
<emekankurumeh[m]> andrewrk: do we link to the system libc in the system libc branch or the embedded one?
<andrewrk> zig0 builds libuserland which gets linked into zig. then the files are installed
<andrewrk> so `zig build install-the-files` will work fine
<andrewrk> emekankurumeh[m], sorry i don't understand, can you elaborate?
<emekankurumeh[m]> does zig have dead code elimination for c files linked?
<andrewrk> the linker can garbage collect unused sections
<andrewrk> most code is compiled all into the .text section so if any functions are used then nothing can be garbage collected
<andrewrk> zig's libcompiler_rt.a and zig's libc.a are compiled with -ffunction-sections which puts each function into its own section
<emekankurumeh[m]> in the windows-libc branch, when building stage 1 (zig1) do we link to the system libc like before, or does zig use the bundled libc?
<andrewrk> in the windows-libc branch, for the x86_64-windows-gnu target (which now the default target on windows), when linking against libc, zig uses the bundled libc, and does not touch any system files
<andrewrk> which is why non-windows users can now build C libraries targeting windows with zig
<emekankurumeh[m]> finally switched to github sponsors
<andrewrk> thanks!
<emekankurumeh[m]> are you sure that the bundled libc is being used?
<andrewrk> emekankurumeh[m], to convince yourself, try deleting the g->libc != nullptr branch in add_mingw_link_args
ltr- has quit [Remote host closed the connection]
<andrewrk> try this command: ./zig build-exe --c-source hello.c -target x86_64-windows-gnu --library c --verbose-cc
<andrewrk> (the --verbose-cc is just to get progress)
<andrewrk> uh and you don't need the -target
<andrewrk> hello.c is https://clbin.com/0aLTI
<[[]]> a​ndrewrk: Shortened < https://is.gd/kZogei >
<andrewrk> moving the install files to stage2 is going to be way cleaner
<andrewrk> we can also implement globbing (correctly! where it will detect new files!) in zig build and then delete thousands of pointless lines
<emekankurumeh[m]> no problem building zig, stage0 and stage1
<hryx> ugh, beautiful
<andrewrk> emekankurumeh[m], no problem building and running hello-world.c?
<emekankurumeh[m]> no
<andrewrk> but you had to wait about 60 seconds for it to build libc right?
<emekankurumeh[m]> yes
<andrewrk> ok great sounds like everything "just works"
<emekankurumeh[m]> verbose-cc showed a lot of compiler invocations
<andrewrk> yep, ok great so that's working in your mingw environment
<andrewrk> this is going into master branch now
<emekankurumeh[m]> i'm kinda of going to be sad to see some of that code go
<andrewrk> I know
<andrewrk> it will rest in peace next to Jimmi's non-recursive recursive-descent parser
kristoff_it has joined #zig
<emekankurumeh[m]> regarding the `zig update` command proposed perhaps we could go a route similar to rustup and allow for installing libc source for a given target
<emekankurumeh[m]> to reduce tarball size
<andrewrk> that sounds a lot like package management
<andrewrk> emekankurumeh[m], btw your mingw linker changes were super helpful in this branch
<andrewrk> your code in link.cpp was a treasure map for how to navigate the mingw-w64 sources
kristoff_it has quit [Ping timeout: 245 seconds]
<andrewrk> also the person `wbs` in #mingw-w64 chat was incredibly helpful
<emekankurumeh[m]> np, i still have some more patches to get stage2 compiling on mingw-w64 that i'll have to open a pr for
<andrewrk> oh stage2 is broken in master btw. I let it regress until coroutine rewrite is done
<emekankurumeh[m]> before you merge that branch, i have a patch to submit
<andrewrk> oops
<andrewrk> what's the patch?
<andrewrk> make it against master now
<emekankurumeh[m]> nvm i had a typo somewhere
<emekankurumeh[m]> these lines here are to work around __stack_chk_fail and __stack_chk_guard no being found depsite the fact that they are exporteds https://github.com/ziglang/zig/blob/master/CMakeLists.txt#L8868-L8870
<[[]]> e​mekankurumeh[m]: Title "zig/CMakeLists.txt at master · ziglang/zig · GitHub" Shortened < https://is.gd/kLzR4A >
<andrewrk> oh!
<emekankurumeh[m]> i was going to try to fix that workaround
<andrewrk> zig is providing those now
<emekankurumeh[m]> without that i get mounds of linker errors
<andrewrk> daurnimator, can I request disabling the "shortened" feature of [[]] ?
<andrewrk> when do you get the linker errors?
<fgenesis> re: [[]] shortening: at least make it a normal message, i get pinged all the time
<andrewrk> oh, yeah that's actually pretty important, let's not be pinging people
<andrewrk> if that's not possible, no problem, let's not have the bot then
<tghume> just checking: is there currently any way to construct a struct type with members determined by code? Like take one struct type and create another struct type with only the fields of type i32.
<tghume> as far as I can tell this isn't currently possible, just want to make sure I'm not missing something
<andrewrk> tghume, it's not possible and the relevant issue is https://github.com/ziglang/zig/issues/383
<[[]]> a​ndrewrk: Title "builtin function @reify to create a type from a TypeInfo instance · Issue #383 · ziglang/zig · GitHub" Shortened < https://is.gd/Bqrsed >
<tghume> thanks
<andrewrk> emekankurumeh[m], also what linker errors? I think this can be solved in a clean way
<emekankurumeh[m]> undefined references to __stack_chk_fail and __stack_chk_guard
<andrewrk> this is when linking what?
<emekankurumeh[m]> stage1
<emekankurumeh[m]> libuserland specifically
<andrewrk> we pass --bundle-compiler-rt when making libuserland, which should supply both of those
<emekankurumeh[m]> thats what's confusing me
<[[]]> a​ndrewrk: Title "zig/compiler_rt.zig at master · ziglang/zig · GitHub" Shortened < https://is.gd/O5POxe >
lunamn has quit [Ping timeout: 245 seconds]
lunamn has joined #zig
Ichorio has quit [Ping timeout: 252 seconds]
<emekankurumeh[m]> nvm i think something is wrong on my end
<emekankurumeh[m]> andrewrk: nvm about those patches it seems you implemented all that stuff in the windows-libc branch
<andrewrk> cool
<andrewrk> oh were you a couple commits behind?
<emekankurumeh[m]> no compiling on mingw-w64 is broken right now, but because i never clean my build dir it was working
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
lunamn has quit [Ping timeout: 245 seconds]
GrooveStomp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]