<< 03-03-2024 >>

00:08:27FromDiscord<sOkam! 🫐> will never ever understand why people do this to themselves↵or should I say↵i'll n e u w ppl d th t thsv 🤦‍♂️ 🤷‍♂️ https://media.discordapp.net/attachments/371759389889003532/1213639084363489370/image.png?ex=65f6347a&is=65e3bf7a&hm=d88f0271cc9cd03ef45c680c4841e642a003bc7dff1e603aa60872b223845b6a&
00:09:25FromDiscord<sOkam! 🫐> single letter acronyms are so unreadable to me 😔
00:09:57FromDiscord<Elegantbeef> I 'll never understand why 'd one would write like that
00:10:25FromDiscord<Elegantbeef> Subtle shot off the portside!
00:10:29FromDiscord<sOkam! 🫐> I get it for heavy mathy code, with lots of repeated names
00:10:48FromDiscord<sOkam! 🫐> outside of that, its beyond me
00:11:26FromDiscord<morgan> yeah gotta strike a balance between v and myLongJavaProjectNameMyTypeIsVeryVeryLongMyVariable
00:11:38FromDiscord<sOkam! 🫐> In reply to @morganalyssa "yeah gotta strike a": tru 🙈
00:12:25FromDiscord<morgan> but yea i often prototype stuff in desmos and it’s painful to do anything more than single letter variables and names with number suffixes
00:12:39FromDiscord<morgan> so it’s mostly all that for the names
00:12:48FromDiscord<sOkam! 🫐> JavaRepeats.JavaRepeatsThemselves.ThemselvesWayTooMuch.ThemselvesWayTooMuchForAnyonesSanity.Sanity 🙈
00:13:00FromDiscord<morgan> exactly
00:13:19FromDiscord<Elegantbeef> I dare not say anything in attempt to not annoy sokam
00:38:29FromDiscord<Robyn [She/Her]> Say it-
01:00:03*nazgulsenpai quit (Quit: ZNC 1.8.2 - https://znc.in)
01:03:57*nazgulsenpai joined #nim
01:08:39*krux02 quit (Remote host closed the connection)
01:49:27FromDiscord<Robyn [She/Her]> I wonder if a http library using the sans-io philosophy is a good project now hmm
01:49:55FromDiscord<Robyn [She/Her]> I need a new project since I lost motivation for the MC server for now
01:50:14FromDiscord<Robyn [She/Her]> I'll probably look at doing that some time soon
01:52:21FromDiscord<hlsee> Is there any way to read assembly generated by nim?
01:53:03FromDiscord<Robyn [She/Her]> In reply to @hlsee "Is there any way": You'd do it the same way you'd do with C/C++
01:53:19FromDiscord<Robyn [She/Her]> The generated assembly will be garbage though
01:56:01FromDiscord<zumi.dxy> wish compiler explorer had a way for me to see the intermediate C output
01:56:29FromDiscord<Robyn [She/Her]> In reply to @zumi.dxy "wish compiler explorer had": Compiler explorer?
01:57:09FromDiscord<Robyn [She/Her]> With Nim though, you can use `--nimcache:<folder>` to place it into a folder of your choosing
01:57:35FromDiscord<zumi.dxy> yeah, that I can do
01:57:44FromDiscord<zumi.dxy> but I want <https://godbolt.org/> to have the same option
01:58:11FromDiscord<Robyn [She/Her]> Ah yeah fair
02:03:47FromDiscord<hlsee> I see, thanks↵(@Robyn [She/Her])
02:04:33FromDiscord<Robyn [She/Her]> No worries!
02:07:32FromDiscord<demotomohiro> Here is how to generate the assembly code: https://internet-of-tomohiro.netlify.app/nim/faq.en.html#nim-compiler-how-to-produce-assembler-codeqmark
02:08:54FromDiscord<demotomohiro> Adding `-d:danger?` option generates cleaner code as runtime checks are removed.
02:09:11FromDiscord<demotomohiro> `-d:danger`
02:24:22FromDiscord<Robyn [She/Her]> Also lto does too, iirc
02:39:35FromDiscord<leorize> termer is building something like that↵(@Robyn [She/Her])
02:47:07FromDiscord<Robyn [She/Her]> Yeah, methttp, right? Meant to be allocation free, too
04:19:41*pbsds quit (Quit: The Lounge - https://thelounge.chat)
04:40:50FromDiscord<morgan> meth ttp
04:46:31*proaxis__ quit (Quit: Leaving)
05:15:54termermorgan https://github.com/termermc/methttp
05:16:04termerand yes, your pun is correct
05:16:24termerit's not really usable right now as a full web thingy but I'm working on it
05:36:37*tc424 quit (Ping timeout: 255 seconds)
06:23:37*kenran joined #nim
06:56:03FromDiscord<cineration> How might I construct a `case` statement using nim's macros?
06:58:40FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/staticcases.nim
06:59:57FromDiscord<cineration> In reply to @Elegantbeef "https://github.com/beef331/nimtrest/blob/master/sta": Thanks!
07:07:31FromDiscord<TӨMΛ ☠> sent a long message, see https://pasty.ee/dDKKGMiXwWKY
07:08:39FromDiscord<Elegantbeef> Toma you could've done `fb.readStr(4) == "TES3"` then just `result.head = newRecordHeader(fb.read(300))` 😄
07:13:02FromDiscord<TӨMΛ ☠> Good point 😄 I feel like I somehow wanted to get rid of FileStream immediately↵Also `read()` can yield you specific amount of bytes you specify? Gosh, I hate how Nim documentation can't search for specific procedure name nowadays, I was unsure if there's proc for that and couldn't find any through Nim doc
07:16:56FromDiscord<TӨMΛ ☠> Could you direct me which package has that? ^^ will lose my hair before I find it via docs https://media.discordapp.net/attachments/371759389889003532/1213746916467277864/image.png?ex=65f698e7&is=65e423e7&hm=e27208093e0640051e996532af267fba294ace7971cb6e1ca45e4a61c322b9ee&
07:17:44FromDiscord<Elegantbeef> `std/streams` has `read` so you could read to an `array[300, byte]` but you could just do `readstr`
07:19:28*ntat joined #nim
07:38:21FromDiscord<TӨMΛ ☠> Oh, I see. I think I will stick to my fb/fr for now, it's a bit easier to grasp the topic with it for me. Will come back to streams later, it's not like I can escape from them anyway 😄
08:00:31*advesperacit joined #nim
08:01:02*azimut quit (Ping timeout: 260 seconds)
08:05:04*rockcavera quit (Remote host closed the connection)
08:54:45FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#pasty=ZZklJeEEFgmF
08:55:47FromDiscord<sOkam! 🫐> short words are always better than single letter crap, because single letter forces you to mentally parse↵you cannot skim-read with pattern matching (what our human brains are good at), and you have to stop and read letter by letter because you might misread if you skim
08:56:35FromDiscord<sOkam! 🫐> sry for the "crap" tone, it just makes no sense to me when you can use 3-4 letter shortening and remove the issue↵its frustrating 🙈
08:57:22FromDiscord<sOkam! 🫐> it has it uses, like you mentioned, but they are super rare
08:57:29FromDiscord<sOkam! 🫐> (edit) "rare" => "rare. at least for me personally"
08:58:22FromDiscord<TӨMΛ ☠> Yeah, I don't blame you, usually I do use more than 1-2 letters, it's also not a big habit of mine 😄 ↵As said, if I need to make it short, three is my usual minimum, and maybe examples I shown above wasn't the best one, I find it also a bit mentally draining today to read
08:59:27FromDiscord<sOkam! 🫐> yeah same. three letter things are generally pretty good
09:00:04FromDiscord<sOkam! 🫐> In reply to @toma400 "Yeah, I don't blame": likely because `fr` and `fb` look way too similar
09:00:36FromDiscord<TӨMΛ ☠> I love though when two letter name explains itself naturally. For example `bg` being understood as `background` is just perfect 👌
09:00:47FromDiscord<TӨMΛ ☠> In reply to @heysokam "likely because `fr` and": `f`ai`r` 😄
09:01:15FromDiscord<sOkam! 🫐> yep. bg = background, fg = foreground, ct = context. there are a few that that work great with 2
09:13:03*tc424 joined #nim
09:16:35FromDiscord<fosster> does someone know how to target wasm with llvm backend in nim?
09:17:12FromDiscord<fosster> like I know that something like this in c would be like `clang [CFLAGS] --target=wasm32 [..]`
09:19:39FromDiscord<fosster> if i can't do it this way, maybe I should be using emscripten or idk
09:25:13FromDiscord<odexine> In reply to @heysokam "yep. bg = background,": I disagree with context, to me it must be “ctx”
09:41:58FromDiscord<sOkam! 🫐> In reply to @fosster "does someone know how": idk about the llvm backend, but compiling with zigcc might give you the option 🤔↵never compiled for wasm, but I figure the option must be there if you say clang has it
09:55:39FromDiscord<fosster> someone pointed out that I could use emscripten to target wasm with nim, but tbh I don't want to use emscripten cause I want to build simple and bloat-free software
09:59:47*junaid_ joined #nim
10:00:55FromDiscord<Elegantbeef> fosster `--cpu:wasm32 --os:standalone` should be it
10:03:41FromDiscord<Elegantbeef> You also should be able to use clang with the normal nim compiler
10:03:42FromDiscord<Elegantbeef> Just requires flag twiddling
10:04:31FromDiscord<demotomohiro> In reply to @heysokam "single letter acronyms are": If you know a language that uses many characters like japanese or chinese, guessing what single character means is a lot easier than guessing single alphabet letter.↵幅 = width↵絵 = picture
10:04:54FromDiscord<fosster> what you mean with twiddling
10:05:20FromDiscord<Elegantbeef> I mean you likely need to select the proper linker and clang settings for wasm
10:06:29FromDiscord<fosster> actually runing with these flags gives me an error `Error: cannot open file: ./src/panicoverride`
10:07:00FromDiscord<Elegantbeef> `--os:any` might work
10:07:41FromDiscord<fosster> `~/.choosenim/toolchains/nim-2.0.2/lib/system/osalloc.nim(218, 10) Error: Port memory manager to your platform`
10:08:06FromDiscord<fosster> should I change memory managment tecnique?
10:08:40FromDiscord<Elegantbeef> https://github.com/arnetheduck/nlvm?tab=readme-ov-file#wasm32-support
10:08:48FromDiscord<Elegantbeef> You should use `-d:useMalloc`
10:17:01FromDiscord<Elegantbeef> Probably easier to use wasi-sdk or clang to compile the code
10:17:46FromDiscord<fosster> it's a mess to be honest
10:18:18FromDiscord<Elegantbeef> Right
10:20:24FromDiscord<fosster> furthermore I also see nlvm does not have support to any memory managment
10:20:29FromDiscord<fosster> except manual
10:20:43FromDiscord<fosster> which isn't ideal for the application I wanna build
10:21:30FromDiscord<fosster> I first though I could maybe create a script to compile to c and then use clang to compile further to wasm, but I don't know how
10:21:40FromDiscord<fosster> I first thought I could maybe create a script to compile to c and then use clang to compile further to wasm, but I don't know how
10:25:15FromDiscord<Elegantbeef> I mean you can just make a config
10:25:18FromDiscord<Elegantbeef> You don't need a script
10:37:53FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#pasty=BhLbvzEuCHZA
10:38:17FromDiscord<Elegantbeef> Add a check before
10:38:24FromDiscord<Elegantbeef> Or throw an assertion in there
10:38:48FromDiscord<ieltan> hm right. I was just unsure if there was a better way to handle this
10:38:50FromDiscord<ieltan> thanks 🙂
10:39:47FromDiscord<Elegantbeef> fosster https://play.nim-lang.org/#pasty=EuLeDPHViCaV for the config
10:40:01FromDiscord<Elegantbeef> you can throw that in a `when defined(wasm)` or w/e
10:40:09FromDiscord<Elegantbeef> That uses clang to wasm
10:40:19FromDiscord<Elegantbeef> You then can just do \`nim -d\:wasm project.nim
10:41:57*junaid_ quit (Remote host closed the connection)
10:44:04FromDiscord<ieltan> writting hooks for my type right now and im kinda confused.. `=dup` and `=copy` do the same thing right ? from the docs it says `=dup` is an optimization of `=copy` so if i implement it i dont need to implement `=copy` right ?
10:44:24FromDiscord<Elegantbeef> Right
10:44:34FromDiscord<ieltan> great, thanks again 🙂
10:44:49FromDiscord<Elegantbeef> Atleast I think so... who knows with the state of the docs
10:47:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=VTSwdgNpdjWd
10:48:00FromDiscord<Elegantbeef> I take it back
10:48:11FromDiscord<Elegantbeef> `toOpenArray(0, -1)` is an empty collection
10:48:24FromDiscord<Elegantbeef> So in that case you do not need to do anything
10:48:39FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=AfxlLMmYzECt
10:54:21FromDiscord<fosster> thanks for the hint, however I get `command line(1, 2) Error: invalid command line option: '--sysroot'`
10:57:47FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#pasty=SIbQZhYRDrVT
10:58:20FromDiscord<ieltan> I just did the test for uncheckedArray and it works too
10:58:32FromDiscord<ieltan> thanks a million
11:58:01FromDiscord<tauruuuuuus> is there a way to generate a compile-time error?
12:02:09FromDiscord<Robyn [She/Her]> In reply to @tauruuuuuus "is there a way": `{.error: "Your error message here".}`
12:02:38FromDiscord<Robyn [She/Her]> When the code path is triggered it'll display the error
12:03:02FromDiscord<Robyn [She/Her]> In a macro there's also `error("error message here")` which accepts a line info object
12:04:03FromDiscord<tauruuuuuus> Nice, thank you!
12:04:23FromDiscord<tauruuuuuus> I'll try it out immediately
12:16:56FromDiscord<Robyn [She/Her]> Good luck!
13:27:07FromDiscord<whisperecean> What would be the best way to pass data from python script to Nim program?
13:27:55FromDiscord<Robyn [She/Her]> In reply to @whisperecean "What would be the": There's a few options, you could use `nimpy` and import the Python script in Nim using that
13:28:36FromDiscord<Robyn [She/Her]> Or you could use `std/os` and run the Python script, redirecting the stdin and stdout
13:28:50FromDiscord<whisperecean> That sounds kinda complicated. The script I am relying to needs imap lib.
13:28:52FromDiscord<Robyn [She/Her]> There's more I can't think of at the moment
13:29:09FromDiscord<whisperecean> Yeah redirecting the std[in/out] is the easies but not sure i like it
13:29:12FromDiscord<Robyn [She/Her]> In reply to @whisperecean "That sounds kinda complicated.": Nimpy is actually really simple, look at the GitHub for it
13:29:49FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=fPtCgGyhVGmR
13:29:55FromDiscord<Robyn [She/Her]> That's an example from the README
13:30:46FromDiscord<whisperecean> How would I import a whole script tho?
13:31:07FromDiscord<Robyn [She/Her]> What do you mean?
13:31:27FromDiscord<whisperecean> Or wait a second..this is so I can use Python and the libs in my Nim code?
13:31:34FromDiscord<Robyn [She/Her]> If you make a few functions in the script you can call from Nim, you'd be able to interop like that
13:31:37FromDiscord<Robyn [She/Her]> In reply to @whisperecean "Or wait a second..this": Yep!
13:31:59FromDiscord<Robyn [She/Her]> Ideally you'd use a Nim library when possible, but using Python modules when you need to, is an option
14:05:31*xet7 quit (Remote host closed the connection)
14:10:25*azimut joined #nim
14:35:11FromDiscord<tauruuuuuus> Robyn I don't recognize you anymore without the purple profile pic
14:35:39FromDiscord<tauruuuuuus> 🤣
14:36:38FromDiscord<griffith1deadly> In reply to @tauruuuuuus "Robyn I don't recognize": same
14:55:11*junaid_ joined #nim
15:44:00FromDiscord<whackerz> <@&371760044473319454> there's a spammer in the element room
16:29:36FromDiscord<Robyn [She/Her]> In reply to @tauruuuuuus "Robyn I don't recognize": Aha oh well
16:30:00FromDiscord<Robyn [She/Her]> At least I didn't change my name at the same time too (@Phil)
16:35:25*om3ga joined #nim
16:37:35*xet7 joined #nim
16:40:06*advesperacit quit ()
16:41:41*advesperacit joined #nim
16:42:16*xet7 quit (Remote host closed the connection)
17:06:56FromDiscord<nikita4437> how can I write to preopened fd (previous process open fd 3 and exec to my nim application)? I try open(myFile, 3, mode), but it return false when fd 3 is opened and return true if fd is not opened (I run application directly without wrapper process with exec). maybe there is some other way?
17:11:03*rockcavera joined #nim
17:16:26FromDiscord<nikita4437> sent a code paste, see https://play.nim-lang.org/#pasty=YvNbEqrfrXFj
17:21:00*kenran quit (Remote host closed the connection)
17:25:38*rockcavera quit (Remote host closed the connection)
17:26:35FromDiscord<alex.boisvert> I'm using the jsony library to serialize simple objects/structs from nim server to nim js client.... However, when I do so, my strings get weirdly mis-encoded. A string on the server such as `Hello` gets reencoded and shown on the client as `0%H0%e0%l0%l0%o`. Wondering if I'm running into some sort of byte -> UTF encoding issue? Tho, with UTF-8 being default, it seems I wouldn't get into double-byte encoding with these 0's.
17:27:02FromDiscord<alex.boisvert> Any thoughts anyone?
17:28:48FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=McunmtHxDDdy
17:29:00*rockcavera joined #nim
17:30:05FromDiscord<alex.boisvert> More info: The string values in my json payload -- as seen through Chrome's devtools network tab -- look fine. It's just after jsony deserialization that they get mangled.
17:30:13FromDiscord<nikita4437> In reply to @demotomohiro "It is alredy wrapped": yep, I missed it, thanks
17:40:13arkanoidhow does nim finds nimsugges/nimsuggest.nim during compilation? "nim dump" doesn't include the the root folder
17:52:21*krux02 joined #nim
17:58:08*junaid_ quit (Remote host closed the connection)
17:58:41FromDiscord<Robyn [She/Her]> For a `receive_bytes` callback, wouldn't it only accepting a blocking function be an issue or?
17:59:02FromDiscord<Robyn [She/Her]> For async sockets specifically
18:00:50FromDiscord<marioboi3112> sent a code paste, see https://play.nim-lang.org/#pasty=EnogNebRowua
18:01:46FromDiscord<marioboi3112> i am so confused
18:04:04FromDiscord<leorize> it shouldn't but `10` probably got promoted to float somehow
18:05:10FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=wAAOdjXnwrbL
18:07:13FromDiscord<marioboi3112> In reply to @leorize "it shouldn't but `10`": it does work, i ran the code without the 4th line, and it printed 14.5
18:08:10FromDiscord<marioboi3112> In reply to @chronos.vitaqua "Does `x.float` work?": yep it does work, but im confused why it didnt work for the 3rd line and it worked for the 4th line,
18:08:14FromDiscord<warcrime> hello my brothers and sisters
18:08:48FromDiscord<marioboi3112> In reply to @warcrime "hello my brothers and": Hey! 👋🏼
18:09:11FromDiscord<warcrime> is there a channel for code reviews?
18:09:55FromDiscord<leorize> that's why I said it shouldn't, Nim does not allow mixed integer/float math↵(@marioboi3112)
18:09:55FromDiscord<warcrime> i built something very basic and i'm looking to make it more readable
18:10:04FromDiscord<warcrime> (edit) "i built something ... verycontrol" added "with" | "withvery basic ... and" added "control structures"
18:10:09FromDiscord<leorize> `10` should be int but I suppose they recently make it so that it could be promoted to float
18:10:14FromDiscord<demotomohiro> In reply to @marioboi3112 "yep it does work,": You cannot do adding between different types without convertion.↵10 in `10 + 4.5` can be converted to float losslessy at compile time.
18:10:33FromDiscord<warcrime> sent a code paste, see https://play.nim-lang.org/#pasty=aBYdXlUOqOgm
18:10:35FromDiscord<leorize> this is the channel↵(@warcrime)
18:10:39FromDiscord<marioboi3112> In reply to @leorize "`10` should be int": if that was the case, then it should've worked for line 3
18:11:07FromDiscord<warcrime> who is leorize?
18:11:19FromDiscord<marioboi3112> In reply to @demotomohiro "You cannot do adding": so nim would convert it even if i didnt explicitly told it to, couldnt it do the same thing for line 3?
18:12:12FromDiscord<leorize> use `case` instead of `if`-`else` here and it should make the code a tad cleaner↵(@warcrime)
18:12:42FromDiscord<warcrime> In reply to @leorize "use `case` instead of": could i use an enum too?
18:12:57FromDiscord<warcrime> or a method to abstract the while loop?
18:14:25FromDiscord<demotomohiro> In reply to @marioboi3112 "so nim would convert": When you do `var x = 10`, type of x become int.↵And in general, you cannot convert between int and float without losing precision.
18:18:14FromDiscord<leorize> you can, but it's unlikely to make this any better, unless you want to build a state machine↵(@warcrime)
18:18:24FromDiscord<marioboi3112> In reply to @demotomohiro "When you do `var": oh ok i see noww, thanks a lot, so to conclude things, values that are not stored in a variable, can automatically be parsed...
18:19:27*junaid_ joined #nim
18:21:35FromDiscord<demotomohiro> In reply to @warcrime "how can i make": You don't need to use Deque for stack, you can use seq as stack.↵There are `pop` proc and `s[^1]` to peek stack top for seq.
18:22:30FromDiscord<leorize> they're using it as a queue
18:22:47FromDiscord<leorize> see `addFirst` and `popFirst` being used
18:23:10FromDiscord<leorize> oh wait they're not touching the last stuff
18:23:35FromDiscord<warcrime> i'm building a mini-lisp compiler
18:23:59FromDiscord<leorize> you'll want to build a state machine then
18:24:09FromDiscord<leorize> and something to represent your syntax tree
18:24:24FromDiscord<warcrime> yea
18:25:01FromDiscord<leorize> https://github.com/kanaka/mal/tree/master/impls/nim \<- this is a bit old but could be useful
19:05:42*azimut quit (Remote host closed the connection)
19:06:12*azimut joined #nim
19:39:42FromDiscord<guttural666> is there an easy way to loop over an object typedesc of an object and get the field names just like with the fieldPairs iterator for instantiated objects?
19:49:40FromDiscord<Robyn [She/Her]> In reply to @guttural666 "is there an easy": `default(T).fieldPairs` should work
19:49:49FromDiscord<Robyn [She/Her]> Why doesn't `T.fieldPairs` work though?
19:50:44FromDiscord<guttural666> In reply to @chronos.vitaqua "`default(T).fieldPairs` should work": that does work, but I'd prefer to loop over the compile time type, not a runtime variable
19:50:54FromDiscord<guttural666> fieldPairs just takes a value, not a typesec
19:51:16FromDiscord<leorize> because no one wrote an iterator for it \:p
19:51:17FromDiscord<Robyn [She/Her]> In reply to @guttural666 "fieldPairs just takes a": Ah
19:51:58FromDiscord<guttural666> In reply to @leorize "because no one wrote": i guess I'd have to write a macro for this
19:52:53FromDiscord<odexine> wait huh? you need a value for fieldpairs to work
19:52:58FromDiscord<odexine> fields will give just the field names
19:53:43*junaid_ quit (Remote host closed the connection)
19:54:00FromDiscord<odexine> oh fields doesnt have a typedesc iterator either
19:54:18FromDiscord<odexine> oh wait no fields gives the fields itself
19:54:26FromDiscord<odexine> that's interesting, i forgot that already
19:54:44FromDiscord<odexine> that's a good point that there should probably be a fieldNames iterator
19:55:10FromDiscord<guttural666> In reply to @odexine "fields will give just": context: I'm trying to build a SOA from a given object type
19:55:51FromDiscord<Robyn [She/Her]> SOA?
19:56:02FromDiscord<guttural666> (edit) "SOA" => "structure of arrays"
19:56:11FromDiscord<odexine> struct of arrays
19:56:17FromDiscord<guttural666> structure of arrays vs. seq[obj]
19:56:25FromDiscord<guttural666> ArrayList in zig
19:56:26FromDiscord<odexine> each field gets its own array
19:56:35FromDiscord<odexine> instead of an array of objects
19:56:57FromDiscord<Robyn [She/Her]> Ahh, why would you want that though?
19:57:04FromDiscord<guttural666> 😄
19:57:07FromDiscord<odexine> it has performance benefits
19:57:21FromDiscord<Robyn [She/Her]> In reply to @chronos.vitaqua "`default(T).fieldPairs` should work": But yeah if you do this in a macro, why would it be an issue?
19:57:23FromDiscord<odexine> processing every object is faster
19:57:41FromDiscord<guttural666> In reply to @chronos.vitaqua "But yeah if you": never used macros, trying to figure this problem out rn 😄
19:57:44FromDiscord<Robyn [She/Her]> Ah I think I understand
19:58:55FromDiscord<guttural666> In reply to @chronos.vitaqua "Ah I think I": contiguous arrays of simple data are more cache friendly, so you can loop over an ID field faster and find the thing you're looking for faster etc.
19:59:18FromDiscord<guttural666> get the ID out, access the rest of the data with an ID etc
19:59:22FromDiscord<Robyn [She/Her]> Ah okay!
19:59:46FromDiscord<guttural666> (edit) "ID" => "index"
20:00:23FromDiscord<guttural666> I wonder why nobody has written macros to do this before in Nim, there is so much in the libs but not this
20:00:41FromDiscord<odexine> ?
20:00:42FromDiscord<guttural666> Zig supports this in the stdlib
20:01:13FromDiscord<odexine> https://github.com/liquidev/datarray
20:01:40FromDiscord<guttural666> In reply to @odexine "https://github.com/liquidev/datarray": correction: why is this not in the standard
20:01:59FromDiscord<odexine> because nim is "understaffed" ig underdevved
20:02:27FromDiscord<odexine> here in nim stdlib doesnt exactly mean better
20:02:43FromDiscord<odexine> lots of modules p much died when they got into the stdlib
20:02:45FromDiscord<guttural666> but they do have a shitload of other useful stuff written and ready to go, that why I was wondering
20:03:13FromDiscord<odexine> iirc nim is still considering whether to slim the stdlib or not, not sure
20:03:24*ntat quit (Quit: Leaving)
20:03:28FromDiscord<guttural666> okay makes sense
20:04:24FromDiscord<guttural666> I mean at least in my mind you'd have to rewrite a lot of sorting algos to support SOA, I did that once for quick sort in cpp
20:04:41FromDiscord<guttural666> every swap needs to be replicated in the other arrays etc
20:04:44FromDiscord<leorize> try PRing something in and you will figure the reason out real quick
20:05:25FromDiscord<guttural666> In reply to @leorize "try PRing something in": I mean there is so much there already, so I'm not complaining
20:06:18FromDiscord<guttural666> In reply to @odexine "https://github.com/liquidev/datarray": thanks for this
20:07:01FromDiscord<leorize> https://gist.github.com/alaviss/1e85643fda7bcc8d9d6330fed5711955 \<- try this if you want an SoA macro
20:07:17FromDiscord<leorize> I wrote it sometime ago but never put it to use, so it's probably not that good
20:07:40FromDiscord<guttural666> does Nim have a featured site, where the most popular and useful libs are displayed etc? some langs have that, it's pretty useful
20:08:06FromDiscord<guttural666> In reply to @leorize "I wrote it sometime": good learning experience for sure, so I'm going to look at it, thanks!
20:11:26FromDiscord<guttural666> I wonder if you'd have to really reimplement all the algos for arrays/vecs for SOA or if you could automate that somethow
20:11:35FromDiscord<guttural666> (edit) "somethow" => "somehow"
20:12:09FromDiscord<guttural666> maybe macros could do some wonders here
20:12:55FromDiscord<guttural666> I think quick sort was just duplicating the swap operations
20:13:01FromDiscord<leorize> if you have to do that then you might be using SoA wrong
20:15:04FromDiscord<guttural666> yeah? if you want the dependent arrays to also be sorted if you sort the ID array?
20:15:34FromDiscord<leorize> why would you sort the ids? it would invalidate all external references
20:17:45FromDiscord<guttural666> the references that hold an index?
20:18:09FromDiscord<leorize> but typically, yes, you only need to implement `swap` for sorts to work
20:18:33FromDiscord<leorize> try not to swap, though
20:18:48FromDiscord<leorize> it's slower than doing it with regular AoS
20:20:33FromDiscord<guttural666> maybe yeah
20:22:36FromDiscord<guttural666> I think I implemented that as a sort of the ID field in the past and recorded the swaps with a tuple of from to, then I applied all the swaps to the dependent arrays afterwards
20:23:20FromDiscord<leorize> that's typically a better way to do it
20:23:27FromDiscord<leorize> though just avoid it if you can afford to
20:24:02FromDiscord<guttural666> yeah for sure, but any sorting would require that
20:25:23FromDiscord<guttural666> I guess swapping everything while sorting is a cache disaster
20:29:17FromDiscord<leorize> I use a little hack some time where I create a list of sorted ids and consume those instead of touching the storage
20:29:21FromDiscord<leorize> it might even be faster to just make a new structure \:p
20:29:25FromDiscord<leorize> instead of trying to do the swaps in place
20:32:13FromDiscord<guttural666> yeah, I've thought about a seq[int] for the IDs and then a hashmap of ID->data
20:33:23FromDiscord<guttural666> but SOA would seem to solve that
20:33:44FromDiscord<leorize> there's a trick where you have internal and external ids
20:34:27FromDiscord<guttural666> oh, as an alias? that could also solve sorting
20:35:10FromDiscord<leorize> https://blog.molecular-matters.com/2013/05/17/adventures-in-data-oriented-design-part-3b-internal-references/ and https://blog.molecular-matters.com/2013/07/24/adventures-in-data-oriented-design-part-3c-external-references/ help shaped some of my designs
20:36:12FromDiscord<guttural666> bookmarking, thanks
20:57:14FromDiscord<marioboi3112> hey guys!
20:57:40FromDiscord<marioboi3112> i was wonderring if Nim was suitable for Software Development in general, would like to chat a bit with you guys about that
20:58:21FromDiscord<guttural666> what do you want to do with it?
21:00:55FromDiscord<marioboi3112> In reply to @guttural666 "what do you want": GUI/UI apps, game dev (3d and 2d) and fullstack development
21:02:41FromDiscord<leorize> nim appeal for full stack is still pretty weak imo
21:03:24FromDiscord<leorize> you can always pull it off faster with go than nim for the same or better performance
21:03:50FromDiscord<guttural666> personally as a relative noob: GUI is painful, I've tried the Qt translation lib a bit and it seems very messy / not working
21:05:24FromDiscord<odexine> IIRC people say the better libraries for Nim are mainly GTK
21:06:13FromDiscord<guttural666> for general CLI programming, I think Nim is very capable, there you can really profit from the exremely nice DX and extreme power of Nim (metaprogramming etc)
21:06:53FromDiscord<guttural666> In reply to @odexine "IIRC people say the": I'm learning so much today, thanks 😄 I really want to make my application GUI enabled and maybe that will help me
21:07:23FromDiscord<guttural666> C++ is a cluster fuck anyway, no wonder it's hard to integrate with those GUI libs
21:07:25FromDiscord<leorize> checkout owlkettle
21:08:08FromDiscord<odexine> In reply to @leorize "checkout owlkettle": git checkout owlkettle
21:09:20FromDiscord<guttural666> the nimqt stuff got me to opening a window, but I want all the tables and fancy stuff and it quickly broke down
21:09:33FromDiscord<guttural666> (edit) "window," => "window with buttons,"
21:11:33FromDiscord<guttural666> In reply to @marioboi3112 "GUI/UI apps, game dev": pointers vs. references in function interfaces was an issue last time I tried
21:11:46FromDiscord<guttural666> pointers vs. references in function interfaces was an issue last time I tried
21:32:07FromDiscord<Robyn [She/Her]> Just realised my ModernNet library is missing a folder required for it to work???
21:33:25FromDiscord<Robyn [She/Her]> I had this issue in other projects that I'm only realising now because I don't have a local copy, wtf how did I miss that
21:44:07FromDiscord<Robyn [She/Her]> Is it possible to cast a value to a type without copying it?
21:44:23FromDiscord<Robyn [She/Her]> I want to cast it, then return that value
21:44:34FromDiscord<Robyn [She/Her]> But while avoiding an unnecessary copy
21:47:41FromDiscord<Elegantbeef> @Robyn [She/Her] what's the type?
21:50:23FromDiscord<Robyn [She/Her]> I found `moveMem`, works like a charm
21:50:46FromDiscord<Elegantbeef> Uhh
21:50:53FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095> what's the type?": Unsigned int (with a specific size) to another number type (with the same size)
21:51:11FromDiscord<Elegantbeef> Why are you worried about copying ints?
21:51:25FromDiscord<Robyn [She/Her]> Eh, bored and wanted to microoptimise
21:51:42FromDiscord<Elegantbeef> But you're doing the same work
21:51:47FromDiscord<Robyn [She/Her]> I know ints are essentially free but I have nothing else to do
21:51:57FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "But you're doing the": Wdym?
21:52:10FromDiscord<Elegantbeef> `moveMem` on an int is identical to `cast[T](myInt)`
21:53:18FromDiscord<Robyn [She/Her]> Huh, why?
21:53:35FromDiscord<Robyn [She/Her]> Does it just do `moveMem` once optimised?
21:53:42FromDiscord<Elegantbeef> Cause integers are value types so moving mem and copying is identical
21:54:11FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=nhWYdWSwmrit
21:54:25FromDiscord<Elegantbeef> assignment is the same as `moveMem`
21:54:35FromDiscord<Elegantbeef> With fewer pointers
21:54:41FromDiscord<Robyn [She/Her]> Oh okay, I'll just cast it then
21:55:07FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=AICcIZXRovRB
21:55:09FromDiscord<Elegantbeef> Movemem is useful for when you're attempting to not disobey strict alias
21:55:15FromDiscord<Elegantbeef> But for primitives casting is fine
21:55:31FromDiscord<Elegantbeef> cute `elif`
21:55:58FromDiscord<Robyn [She/Her]> Thank you :)
21:56:06FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "Movemem is useful for": Strict alias? Wdym?
21:57:18FromDiscord<Elegantbeef> Why do you need the cast here?
21:57:18FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=HMmLPksmxdcx
21:57:25FromDiscord<Elegantbeef> You already do range checking so you can just use the return type you're writing to
21:57:55FromDiscord<Elegantbeef> Strict aliasing is a horrendous optimisation strategy that means `cast[ptr T](somePtrToNotVoidOrChar)` is invalid and causes UB
21:57:58FromDiscord<Robyn [She/Her]> Wdym? `T` could be a `float32` so
21:58:33FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "Strict aliasing is a": Ah
21:59:40FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=WhhdanymJvRK
22:01:34FromDiscord<Elegantbeef> It's just such an awful optimisation as it's so unexpected
22:01:35FromDiscord<Elegantbeef> Write your own allocator and throw a few casts and ... why is my code exploding
22:02:31FromDiscord<leorize> doesn't change the fact that it's still UB, though
22:05:12FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=iIAGsLogwoPW
22:05:14FromDiscord<Robyn [She/Her]> Unfortunate
22:05:31FromDiscord<Robyn [She/Her]> I can just do a when statement but this looked cleaner
22:05:46FromDiscord<Robyn [She/Her]> A when/case statement would work
22:05:49FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/staticcases.nim#L59-L63
22:06:12FromDiscord<Elegantbeef> Guess that should be static case
22:06:56FromDiscord<Elegantbeef> Throw that inside a template and there you go
22:07:10FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/staticcases.nim#L81-L92 is what you want
22:07:58FromDiscord<ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=gkWPSXpWTGDS
22:08:25FromDiscord<leorize> I think you just implemented it \:p
22:08:26FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "https://github.com/beef331/nimtrest/blob/master/sta": Eh, a when statement worked just as well but thanks
22:08:41FromDiscord<Elegantbeef> When statements are ugly!
22:09:39FromDiscord<Elegantbeef> To check if an numeric type can be implicitly casted you can do `compiles((var i: T = default(k))`
22:09:57FromDiscord<Elegantbeef> Or use a concept
22:10:11FromDiscord<Elegantbeef> Though a concept would be ugly
22:12:12FromDiscord<ezquerra> In reply to @Elegantbeef "To check if an": What is uglier the concept or the `when compiles`? 😅
22:12:24FromDiscord<Elegantbeef> Concept
22:12:32FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=sepNOSaQEymx
22:12:39FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "When statements are ugly!": It's in a template so
22:13:00FromDiscord<Elegantbeef> The check needs to be there
22:13:12FromDiscord<Elegantbeef> Atleast I imagine so
22:13:26FromDiscord<Elegantbeef> Your check is wrong
22:13:45FromDiscord<Elegantbeef> You only need to check if the smaller one is written to and you should return the amount written to
22:13:54FromDiscord<Elegantbeef> "the smaller one" ah yes brain
22:14:01FromDiscord<Elegantbeef> You only need to check if the array is large enough to write to
22:14:28FromDiscord<Robyn [She/Her]> `toBytesBE` returns an array, wouldn't that be an issue without the check?
22:15:25FromDiscord<Elegantbeef> you should do `oa[0..sizeof(T)] = value.toBytesBe(oa)`
22:15:30FromDiscord<Elegantbeef> and return `sizeof(T)`
22:16:00FromDiscord<Elegantbeef> This allows to implement this for other procedures for other types and it'll just work
22:17:52FromDiscord<Robyn [She/Her]> Alright, thanks!
22:20:51*advesperacit quit ()
22:22:41FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=emtixsCuwarK
22:23:54FromDiscord<Elegantbeef> your oa logic is wrong
22:23:59FromDiscord<Elegantbeef> `[0..<sizeof(T)]` returns a seq
22:24:04FromDiscord<Elegantbeef> But that's not causing the issue
22:24:42FromDiscord<Elegantbeef> You're passing to arguments to `toBytesBe`
22:24:43FromDiscord<Elegantbeef> two\
22:30:30FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=hHLbbTttewMj
22:30:44FromDiscord<Robyn [She/Her]> Can't see an obvious issue
22:32:21FromDiscord<Elegantbeef> @ezquerra to answer your question https://play.nim-lang.org/#pasty=fXBmAzTQJnlt
22:32:26FromDiscord<Elegantbeef> Also @Robyn [She/Her] why are you casting for `toBytesBe`?
22:35:04FromDiscord<Robyn [She/Her]> `toBytesBE` requires an unsigned int, it's from `endians2`
22:35:12FromDiscord<Elegantbeef> Heh
22:37:10FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=RCFPeuRjlkCL
22:37:36FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=ZVIYClMtcUMh
22:37:57FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=gdzYvhUAQkQL
22:38:21FromDiscord<Elegantbeef> Atleast if my bitwise math serves is proper
22:38:26FromDiscord<Elegantbeef> Nice compiler error 😄
22:38:46FromDiscord<Elegantbeef> Stop calling `toOpenArray` on the collection that is the size you want 😄
22:38:56FromDiscord<Elegantbeef> your byte array is the size you want always
22:39:02FromDiscord<Elegantbeef> If it's not you have big problems that the runtime will catch
22:39:37FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=LIpkQIZhdfLD
22:39:51FromDiscord<Elegantbeef> `array[0..0, byte]`
22:40:09FromDiscord<Robyn [She/Her]> Wait huh
22:40:12FromDiscord<Elegantbeef> methinks that's not `array[0..7, byte]`
22:41:16FromDiscord<Robyn [She/Her]> Why is that returning array[0..0]...
22:46:45FromDiscord<im__cynical> Any way to disable nim from checking for authenticode signitures?
22:47:44FromDiscord<Elegantbeef> What does that even mean
22:50:30*pbsds joined #nim
22:55:56FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=LJwwZscuZOZx
22:55:57FromDiscord<Robyn [She/Her]> Hm
22:56:31FromDiscord<Elegantbeef> Lol
22:56:49FromDiscord<Robyn [She/Her]> I'm confused on why this doesn't Just Work™️
22:57:25FromDiscord<Elegantbeef> Oh cause the proc I'm thinking of is only for seq and array apparently
22:57:31FromDiscord<Robyn [She/Her]> I could just use a loop and avoid this issue
22:57:34FromDiscord<Robyn [She/Her]> Ah
22:57:46FromDiscord<Robyn [She/Her]> So loop is the only way?
22:58:04FromDiscord<Elegantbeef> Apparently
22:58:16FromDiscord<Elegantbeef> Well you could use copymem
22:58:19FromDiscord<Elegantbeef> But that's just aloop
22:59:52FromDiscord<Robyn [She/Her]> How is copyMem a loop? Because it's just an array of ints?
23:00:13FromDiscord<Robyn [She/Her]> Also, wouldn't that fuck up with seqs because arrays and seqs order data differently?
23:00:32FromDiscord<Elegantbeef> They don't order data differently
23:02:17FromDiscord<Robyn [She/Her]> https://play.nim-lang.org/#pasty=cgKqHOWMfinK
23:02:31FromDiscord<Robyn [She/Her]> Unless I'm misinterpreting what this does
23:02:54FromDiscord<Elegantbeef> Right they're different data types
23:03:20FromDiscord<Robyn [She/Her]> Didn't a seq work by storing pointers to the allocated value?
23:03:40FromDiscord<Robyn [She/Her]> So using copyMem would just change where the pointer is pointing, instead of setting the value
23:04:19FromDiscord<Elegantbeef> If you improperly use it yes
23:04:47FromDiscord<Elegantbeef> cause seq is `(len: int, data: ptr (capacity: int, data: UncheckedArray[char]))`
23:04:54FromDiscord<Elegantbeef> But you don't use `copyMem` like a neanderthal
23:05:02FromDiscord<Elegantbeef> You properly copymem to the sequential part of the data
23:05:03FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "cause seq is `(len:": Aaah
23:05:09FromDiscord<Elegantbeef> You're using openArray anyway
23:05:15FromDiscord<Elegantbeef> So that completely removes the difference
23:05:15FromDiscord<Robyn [She/Her]> So to `data.data`
23:05:21FromDiscord<Robyn [She/Her]> Yeah :P
23:05:26FromDiscord<Elegantbeef> you `copyMem(oa[0].addr, ..., ...)`
23:05:27FromDiscord<Robyn [She/Her]> Oh wait
23:05:30FromDiscord<Robyn [She/Her]> Misunderstood
23:05:48FromDiscord<Robyn [She/Her]> Should I use `copyMem` instead of a loop?
23:06:13FromDiscord<Elegantbeef> that's between you and your god
23:06:27FromDiscord<Robyn [She/Her]> I'm an atheist-
23:06:33FromDiscord<Elegantbeef> So am I
23:06:43FromDiscord<Robyn [She/Her]> Who's my god-
23:07:14FromDiscord<Elegantbeef> I'm not going to change perfectly good language!
23:07:31FromDiscord<Elegantbeef> If you don't have a god that clearly means it's between you and you
23:07:40FromDiscord<Elegantbeef> So choose the one you prefer
23:07:54FromDiscord<Elegantbeef> I'd personally avoid `copyMem` and `addr` and any low level operation to appease the VM gods
23:10:57FromDiscord<Robyn [She/Her]> Fair
23:11:05FromDiscord<Robyn [She/Her]> But wouldn't casting anger them anyway?
23:12:18FromDiscord<Elegantbeef> Depends on the type, but probably
23:13:55FromDiscord<Elegantbeef> I think Nim implements casting for most primitives aside from `set`
23:15:39FromDiscord<Robyn [She/Her]> Oh then that's not an issue
23:17:06FromDiscord<Robyn [She/Her]> I kinda wanna use `deposit` and `extract` instead of `write` and `read` :p
23:19:12FromDiscord<Robyn [She/Her]> Would you say operating on my buffer type is fine to follow the sans-io philosophy? :p
23:19:36FromDiscord<Elegantbeef> I'm the wrong person to ask that to
23:20:59FromDiscord<Robyn [She/Her]> Yeah fair
23:21:04FromDiscord<Robyn [She/Her]> I think it's fine anyway
23:40:33*xutaxkamay quit (Read error: Connection reset by peer)
23:41:18*xutaxkamay joined #nim