<< 18-06-2024 >>

00:01:10FromDiscord<zumi.dxy> Result/Option is a form of monad right?
00:03:17FromDiscord<Robyn [She/Her]> No idea
00:09:35*xet7 quit (Ping timeout: 264 seconds)
00:17:18lx12ucyhow do you guys think i should check if a given path to a directory is valid?
00:17:32FromDiscord<Elegantbeef> `createDir`
00:17:46lx12ucywait thats actually genius
00:17:50FromDiscord<Elegantbeef> `existsOrCreateDir`
00:17:52FromDiscord<Elegantbeef> rather
00:18:00lx12ucyoh yeah
00:18:08lx12ucywell
00:18:25lx12ucyi mean i dont want to create it if it doesnt exist
00:18:29lx12ucyi just want to see if it does
00:18:39FromDiscord<Elegantbeef> Checking whether something is a valid path is a fun task
00:20:34FromDiscord<Elegantbeef> Why do you need to know that it's valid?
00:21:10lx12ucyi'm making a thing that scans a directory you give it for subdirectories
00:21:28lx12ucyand saving that directory you give it to yaml if its valid
00:21:57FromDiscord<Elegantbeef> So then why do you need to validate that it's a path, call `walkDir` inside a `try except` if it errors do not add it
00:22:11lx12ucyalright
00:22:35lx12ucythank you
00:22:41*xet7 joined #nim
00:26:34lx12ucyhow does walkDir get used? i'm trying `echo walkDir(paramStr(2))` but its giving an error
00:26:45FromDiscord<Elegantbeef> It's an iterator
00:26:54FromDiscord<Elegantbeef> so `for x in walkDir(path, checkDir = true): ...`
00:27:03lx12ucyohhhh right
00:27:06lx12ucythanks
00:53:56*SchweinDeBurg joined #nim
01:32:36FromDiscord<sOkam! 🫐> what was the pragma for importing everything from a module, including the private fields of objects?
01:33:34FromDiscord<sOkam! 🫐> I know about `import someModule {.all.}` but it doesn't seem to import private fields, and I think I recall that functionality being done in a different way 🤔
01:36:06FromDiscord<kots> https://nim-lang.github.io/Nim/importutils.html#privateAccess%2Ctypedesc
01:36:08FromDiscord<kots> Probably this
01:36:26FromDiscord<sOkam! 🫐> yep, that was it! ty ty
02:09:33*SchweinDeBurg quit (Quit: WeeChat 4.4.0-dev)
02:23:42FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#pasty=IQosNsIw
02:24:33FromDiscord<sOkam! 🫐> (edit) "https://play.nim-lang.org/#pasty=CSSWiJUr" => "https://play.nim-lang.org/#pasty=cbTPBolm"
02:25:17FromDiscord<sOkam! 🫐> (edit) "https://play.nim-lang.org/#pasty=vcagmRwd" => "https://play.nim-lang.org/#pasty=jRDirHOF"
02:40:05FromDiscord<Elegantbeef> `instantiationInfo(fullPaths = true).fileName.parentDir()`?
02:51:01FromDiscord<sOkam! 🫐> tyty
03:53:08*SchweinDeBurg joined #nim
04:35:06FromDiscord<basilajith> How do I insert a NULL value in an insert statement for db_postgres?
04:54:29*rockcavera quit (Remote host closed the connection)
05:54:34FromDiscord<albassort> what is the proc to convert a byte to bits?
05:54:58FromDiscord<albassort> I know theres procedures to operate on it but i need to see it so i can know how to operate on it
05:57:49*PMunch joined #nim
06:04:23Amun-Rawhat do you mean, byte to bits?
06:04:44Amun-Raas in, iterate an octet in a series of bits?
06:05:02Amun-Rain→as?
06:09:09FromDiscord<leorize> a byte is already bits?
06:15:07FromDiscord<_nenc> sent a code paste, see https://play.nim-lang.org/#pasty=EAhUpbuC
06:19:33FromDiscord<albassort> In reply to @Amun-Ra "what do you mean,": See this is the problem, it's that there's no type to represent bits so actually creating a bit array and representing it is not possible
06:19:42FromDiscord<albassort> You need a sequence of infs
06:19:48FromDiscord<albassort> (edit) "infs" => "ints"
06:20:00FromDiscord<albassort> I mean I wanted a bit array that I can look at
06:20:32FromDiscord<leorize> does std/bitops not do it for you?
06:20:37FromDiscord<albassort> (edit) "ints" => "bools"
06:20:44FromDiscord<albassort> Well I read through it and it doesn't look like it has any output like that
06:20:54FromDiscord<albassort> You would need to do what nenc said
06:21:24FromDiscord<leorize> why would you want a bit array?
06:21:38FromDiscord<albassort> So I can look at the data of a bit field for debugging
06:21:49FromDiscord<leorize> `strutils.toBin` is a simple one to use
06:21:56FromDiscord<leorize> no cruft from array syntax
06:22:02FromDiscord<albassort> Oh yes that's right
06:22:05FromDiscord<leorize> just pure 1 and 0s
06:22:06FromDiscord<albassort> I forgot about that procedure
06:22:27FromDiscord<albassort> Lol
06:22:51FromDiscord<albassort> I feel like it should be in bitops in some form though
06:22:56FromDiscord<albassort> Perhaps used in an example
06:24:46FromDiscord<albassort> It's weird how the brains work, I was fixated on one task but if you asked me "how can I create a bit string from an integer" I would be like oh yeah there's a procedure in strutils
06:25:47FromDiscord<albassort> (edit) "brains" => "brain" | "brainwork, I was fixated on ... onespecific" added "doing something in" | "task" => "specific way," | "strutils" => "strutils."
06:26:01FromDiscord<albassort> I guess this is why rubber duck debugging works so well.
06:26:10FromDiscord<albassort> Anyway, thank you.
06:26:36FromDiscord<albassort> (edit) "work," => "works,"
06:26:51*disso_pch quit (Quit: Leaving)
06:41:29*ntat joined #nim
07:05:10*redj joined #nim
07:07:49PMunchHmm, where is the Nimble path on Windows?
07:19:14FromDiscord<Elegantbeef> `%USERDATA%/.nimble` iirc
07:41:37*lx12ucy quit (Quit: WeeChat 4.3.2)
07:46:53FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=skRhbcQN
07:46:58FromDiscord<albassort> whats up with this
07:47:19FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=wYkEinCj
07:47:50FromDiscord<albassort> the first 4 are ↵1100 ↵but the value is ↵0010
07:48:25FromDiscord<leorize> it depends on the definition of significance by bitops
07:48:44FromDiscord<ieltan> I have a dream
07:48:44FromDiscord<albassort> (edit) "first 4 are ↵1100 ↵but" => "output is ↵11000100↵but" | "↵0010" => "↵00100100"
07:48:51FromDiscord<leorize> bitops define the greater number means higher significance
07:48:59FromDiscord<albassort> (edit) "↵00100100" => "↵00100011"
07:49:04FromDiscord<albassort> its backwards
07:49:06FromDiscord<albassort> yeo
07:49:07FromDiscord<albassort> (edit) "yeo" => "yep"
07:49:18FromDiscord<leorize> it's not backwards
07:49:32FromDiscord<leorize> not to the computer, that is
07:49:41FromDiscord<albassort> well, i meant the output from what i defined
07:50:00FromDiscord<albassort> i only saw it when i wrote it out here
07:50:05FromDiscord<leorize> the good ol' human numbers vs computer numbers
07:50:17FromDiscord<albassort> In reply to @leorize "the good ol' human": is this platform dependent?
07:50:21FromDiscord<leorize> nope
07:50:28FromDiscord<ieltan> Memory regions in Nim that are easy to use and you can choose whether you allocate on the heap/stack. And they work with builtins types too
07:50:39FromDiscord<leorize> I mean, it will be if you use larger int size
07:50:46FromDiscord<leorize> but for that int size it's the same everywhere
07:50:49FromDiscord<albassort> yeah but thats endian
07:51:01FromDiscord<albassort> why do we write the bits backwards to compared to the computer?
07:51:15FromDiscord<albassort> (edit) removed "to"
07:51:49FromDiscord<leorize> backwards is just a mental construct
07:52:41FromDiscord<ieltan> It's a shame `mm:regions` didn't pan out but maybe it's possible to turn it into a nimble package...
07:53:20FromDiscord<albassort> i understand, but, why is it that, I write the message as 0b0010_0011 but the computer preforms operations in the other direction
07:53:24FromDiscord<ieltan> But it won't work with builtins types unless ungodly amounts of hacks are done
07:53:40FromDiscord<albassort> why not have us humans write it the other way
07:54:46FromDiscord<leorize> I mean, you have the decimal `142`
07:55:03FromDiscord<leorize> `1` is larger than `4` here because `1` meant `100` but `4` meant `40`
07:55:23FromDiscord<leorize> this is just how humans interpret numbers since forever
07:55:57FromDiscord<leorize> it might be easier to imagine wrt `testBit` if you think of it as testing `2^n`
08:02:45FromDiscord<albassort> so basically: computers bad
08:05:31FromDiscord<basilajith> sent a code paste, see https://play.nim-lang.org/#pasty=UFmnlNFA
08:05:58FromDiscord<ieltan> looks like `mm:region` is implemented as a stack which is neat but then I thought about how `realloc` would work then...
08:07:04FromDiscord<albassort> In reply to @basilajith "Is there an elegant/simpler": well using strformat may make it look somewhat better
08:07:16FromDiscord<albassort> the next thing i would do is declare them to individual variables so you know how they make up the output
08:07:34FromDiscord<albassort> (edit) "the next thing i would do is declare them to individual variables so you know how they make up the output ... " added "more intuitively"
08:07:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=YDOKNYjJ
08:08:10FromDiscord<Elegantbeef> What does that mean?↵(@ieltan)
08:08:22FromDiscord<albassort> that works too but but i think using strscans should be a last resort and this isn't an actual use for it
08:08:22FromDiscord<Elegantbeef> Bump the stack and return the old block to the pool
08:08:38FromDiscord<Elegantbeef> Strscans should be a first resort 😛
08:08:49FromDiscord<Elegantbeef> I pity the fool that uses `split`
08:09:09FromDiscord<basilajith> Well, I am reading values from a large XLSX spreadsheet.
08:09:26FromDiscord<albassort> ok so yeah, strscans will work because its unreadable anyway
08:09:43FromDiscord<albassort> it will also likely be faster
08:09:53FromDiscord<basilajith> In reply to @albassort "ok so yeah, strscans": ?
08:10:22FromDiscord<albassort> sorry i misunderstood
08:10:28FromDiscord<albassort> yeah don't listen to beef
08:10:34FromDiscord<albassort> hes joking anyway i think
08:10:41FromDiscord<Elegantbeef> Not really
08:11:03FromDiscord<Elegantbeef> If you can use strscans use it over manually splitting strings
08:12:02FromDiscord<albassort> most languages have a split function, no other language to my knowledge uses the strscans syntax
08:12:07FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=PvYinxkn
08:12:18FromDiscord<Elegantbeef> Cool we're using Nim
08:12:24FromDiscord<Elegantbeef> So why would we not use the tools that are here
08:12:39FromDiscord<basilajith> Yeah, looking through `strscans`.
08:12:50FromDiscord<Elegantbeef> Depending what you're parsing strscans is king imo
08:12:51FromDiscord<albassort> ok but the penalty is readability, and less intuitive code
08:13:08FromDiscord<albassort> and the data is already split here
08:13:18FromDiscord<albassort> because its CSV parsing
08:13:24FromDiscord<basilajith> I just want to keep it as readable as possible for some future dev in my org.
08:13:24FromDiscord<albassort> (edit) "because its ... CSV" added "already pased"
08:13:26FromDiscord<albassort> (edit) removed "parsing"
08:13:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=TfNSBKzV
08:13:53FromDiscord<Elegantbeef> `names.len == 3`\
08:14:28FromDiscord<albassort> In reply to @basilajith "Is there an elegant/simpler": 1. yes. 2. they don't use split here, i presume they already used a csv parser
08:14:36FromDiscord<Elegantbeef> If you read their message `fullName` is implied to be a single string
08:14:48FromDiscord<Elegantbeef> > fullName = # string value of unknown length and all CAPS with first name, middle name, and last name (in that order) e.g. "CLARK JOSEPH KENT"
08:15:14FromDiscord<albassort> it could look like this ↵CLARK, JOSEPH, KENT
08:15:18FromDiscord<albassort> in the CSV
08:15:33FromDiscord<Elegantbeef> Right but that's not what it says in their message
08:15:44FromDiscord<Elegantbeef> `fullName` is said to be a string
08:15:51FromDiscord<Elegantbeef> So if you're parsing a string, use strscans
08:15:55FromDiscord<albassort> yeah and that string could be fullname = csv[0]
08:15:58FromDiscord<Elegantbeef> If you have CSV data why are we slicing
08:16:07FromDiscord<Elegantbeef> That's not a fullname then
08:16:10FromDiscord<albassort> fullname[0] = first
08:16:14FromDiscord<albassort> (edit) "=" => "is"
08:16:31FromDiscord<Elegantbeef> Hey I read their message and it's ambiguous the type, we should force all messages to pass type checking!
08:16:46FromDiscord<Elegantbeef> Write a procedure to capitalize then use that if that's what the concern is
08:16:58FromDiscord<Elegantbeef> If parsing a fixed format string is the concern used strscans
08:17:13FromDiscord<Elegantbeef> If anything else is concerning use a hand written parser
08:17:41FromDiscord<ieltan> In reply to @Elegantbeef "What does that mean?": I mean what if I have a `string` and I exceed it's capacity but the memory lives deeps in the memory region stack?
08:18:18FromDiscord<ieltan> Fwiw I didnt have a formal CS education so these are kinda new things to me
08:18:51FromDiscord<Elegantbeef> 😛
08:19:00FromDiscord<ieltan> In reply to @Elegantbeef "Bump the stack and": At the risk of sounding idiotic, I don't know what "bump the stack" means
08:19:40FromDiscord<Elegantbeef> The region based allocator does not use the stack it uses a stack
08:19:45FromDiscord<ieltan> I do know usually the stack doesn't need such a thing as realloc because everything is fixed size
08:20:13FromDiscord<Elegantbeef> You can have a free list of blocks that you can return when allocating a new value
08:20:43FromDiscord<Elegantbeef> Yea you're conflating the idea of stack memory with the stack data type
08:20:52FromDiscord<Elegantbeef> Stack memory is a form of the stack data type
08:21:05FromDiscord<Elegantbeef> It's a first in last out queue
08:21:06FromDiscord<ieltan> In reply to @Elegantbeef "The region based allocator": Oh ok lol but I'm still confused
08:22:07FromDiscord<Elegantbeef> So when you go "Alloc 8 bytes" you move the region pointer up 8, when you then go "Reallocate these 8 bytes to a 32byte block" you return the 8 byte block to a pool, then allocate the 32byte block moving the region pointer up 32
08:22:14FromDiscord<leorize> you might want to look into bump allocators
08:22:29FromDiscord<leorize> there are extensive information out there about this stuff
08:22:45FromDiscord<Elegantbeef> Do bump allocators generally have any reuse?
08:23:02FromDiscord<Elegantbeef> Seems like an easy win to have a priority sorted list based off size
08:24:10FromDiscord<basilajith> In reply to @Elegantbeef "Right but that's not": Yeah, it's a single string within a cell in a row in the Excel sheet.
08:24:31FromDiscord<Elegantbeef> A single space seperated string?
08:24:45FromDiscord<Elegantbeef> Always having 3 names? 😄
08:25:36FromDiscord<Elegantbeef> It is perfectly fine to just to do what I did above with a `str.toOpenArray(rune.size, str.find(' '))` 😄
08:25:44FromDiscord<Elegantbeef> Super easy peasy
08:26:08FromDiscord<Elegantbeef> Also leo I looked into swift and the sdl2 bindings are lack lusuter it seems
08:26:42FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=bneggvhq
08:27:18FromDiscord<Elegantbeef> > OpenGL can load any OpenGL function up to OpenGL 4.5.
08:27:24FromDiscord<Elegantbeef> They're really just out to piss me off!
08:28:08FromDiscord<Elegantbeef> Do wonder if swift has a futharky thing of it's own
08:28:22FromDiscord<basilajith> In reply to @Elegantbeef "Always having 3 names?": Sadly, no.
08:28:36FromDiscord<Elegantbeef> Well then yea skip strscans as it'd be messy
08:28:44FromDiscord<Elegantbeef> Do a simple `find` and slice
08:56:24*ntat quit (Quit: Leaving)
09:02:33*coldfeet joined #nim
09:04:15FromDiscord<nocturn9x> is there any reliable way to track when and how allocations are being made in nim?
09:04:42FromDiscord<nocturn9x> I am 99% certain I am doing something stupid and inadvertently copying an object a gazillion times
09:04:55*coldfeet quit (Remote host closed the connection)
09:05:01FromDiscord<nocturn9x> because way too much time is spent into libc calls, most likely malloc/free
09:05:21PMunchDefinitely not malloc free though since Nim uses mmap munmap
09:05:26FromDiscord<nocturn9x> Nim _will_ pass large objects by ref internally if they're too big right?
09:05:32FromDiscord<nocturn9x> In reply to @PMunch "Definitely not malloc free": same thing
09:05:34PMunchYou could try to run with malloc enabled and a memory profiler
09:05:37FromDiscord<nocturn9x> memory stuff
09:05:46FromDiscord<nocturn9x> I already use -d:useMalloc
09:05:53FromDiscord<nocturn9x> because nim's default allocator is shit with threads
09:05:55FromDiscord<nocturn9x> and I use mimalloc
09:05:59FromDiscord<nocturn9x> for a nice performance bump
09:07:16PMunchUhm, so you rip out Nims allocator, then enables malloc and plugs in another allocator instead?
09:07:43PMunchInteresting approach
09:07:54PMunchBut try to disable mimalloc and use a memory analyzer
09:08:12PMunchThat should tell you about copying
09:11:27FromDiscord<nocturn9x> oke
09:11:32FromDiscord<nocturn9x> In reply to @PMunch "Uhm, so you rip": yeah
09:11:35FromDiscord<nocturn9x> I statically link it in
09:12:09FromDiscord<nocturn9x> `perf mem` should do the trick
09:31:11*coldfeet joined #nim
09:53:23*coldfeet quit (Remote host closed the connection)
10:26:12*xtr00 joined #nim
10:43:36*m5zs7k quit (Ping timeout: 268 seconds)
10:44:44*m5zs7k joined #nim
11:04:56FromDiscord<nocturn9x> nope
11:05:00FromDiscord<nocturn9x> doesn't work on AMD
11:05:05FromDiscord<nocturn9x> what memory profilers could I try?
11:07:21PMunchNot sure. Another option would be to use `--wrap` and have every `malloc`call print something out to a file
11:31:45*redj_ joined #nim
11:33:52FromDiscord<frusadev> Hello, is there anything like flutter in nim?
11:36:41*redj quit (*.net *.split)
11:36:44*nisstyre quit (*.net *.split)
11:36:45*ormiret quit (*.net *.split)
11:43:20FromDiscord<albassort> flutter is developed by a trillion dollar company
11:43:40FromDiscord<albassort> So no, nothing quite as intuitive
11:44:25*nisstyre joined #nim
11:44:25*ormiret joined #nim
11:44:42FromDiscord<albassort> interacting with it might not be impossible, though. But I don't know enough to help beyond that.
11:45:30FromDiscord<albassort> dart as C ffi
11:45:35FromDiscord<albassort> :)
11:47:10Amun-Raalbassort: looks like you need some kind of bit stream
11:47:25FromDiscord<albassort> is that message delayed?
11:47:47Amun-Ranope, I lurk here from time to time
11:48:35FromDiscord<albassort> Well, no. I was just confused on how bitTest worked.
11:48:46FromDiscord<albassort> everything is working now
11:48:49Amun-Raah
11:56:32FromDiscord<nocturn9x> can anyone explain to me
11:56:41FromDiscord<nocturn9x> why a subtraction is being compiled to _46_ assembly instructions? https://media.discordapp.net/attachments/371759389889003532/1252592825246158859/image.png?ex=6672c779&is=667175f9&hm=8d84f82c81b8f5ae69053fdbb3d756ab3c4d67edd03ffac60d2e28fdf0c632be&
11:58:12Amun-Rais that a release build?
11:58:44Amun-Rait that's signed subtraction and -d=danger is not set there always be some checks
11:58:44FromDiscord<nocturn9x> it's a danger build with `--debugger:native`
11:59:02FromDiscord<nocturn9x> `Score` is a `distinct int32`
11:59:08FromDiscord<nocturn9x> which is the value being subtracted there
11:59:18FromDiscord<nocturn9x> In reply to @Amun-Ra "it that's signed subtraction": okay but _forty-six_ instructions?
12:00:26Amun-Rahttps://godbolt.org/z/9M6K9a8sb
12:00:30FromDiscord<nnsee> In reply to @nocturn9x "why a subtraction is": looks like it's doing SIMD
12:00:50FromDiscord<nocturn9x> the question is why is it taking 0.77 seconds of execution time
12:00:55FromDiscord<nocturn9x> isn't SIMD supposed to be _faster_
12:02:06FromDiscord<nocturn9x> In reply to @Amun-Ra "https://godbolt.org/z/9M6K9a8sb": ok so that's correct, just `sub`
12:02:44FromDiscord<odexine> to note this is with -d:danger
12:02:51FromDiscord<odexine> without -g
12:02:58FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=xoIOMNRk
12:03:05FromDiscord<nocturn9x> this is my nim.cfg
12:03:16FromDiscord<nocturn9x> In reply to @odexine "without -g": that's supposed to add debugging symbols
12:03:19FromDiscord<odexine> iirc there was an issue with defines in nim.cfg?
12:03:30FromDiscord<nocturn9x> it does work
12:03:34FromDiscord<nocturn9x> if I change it stuff changes
12:03:36FromDiscord<nocturn9x> so it works
12:03:49FromDiscord<odexine> perhaps it no longer applies
12:04:00FromDiscord<nocturn9x> the issue is why is nim compiling `a - b` t
12:04:05FromDiscord<nocturn9x> (edit) "t" => "to a gazillion instructions"
12:04:07FromDiscord<nocturn9x> or rather, clang
12:05:14Amun-Raevent non-exportc one behaves the same https://godbolt.org/z/abeh87653
12:05:57FromDiscord<nocturn9x> I tried this as well
12:06:00FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=kOZMCtlL
12:06:02FromDiscord<nocturn9x> same behavior
12:06:20FromDiscord<odexine> sent a code paste, see https://play.nim-lang.org/#pasty=AiPCAVCH
12:06:54Amun-Rawhat's .eg?
12:06:56FromDiscord<nocturn9x> ah nevermind
12:06:59FromDiscord<nocturn9x> `Score` is justr int32
12:07:01FromDiscord<nocturn9x> (edit) "justr" => "just"
12:07:29FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=HRGSCnqv
12:07:33FromDiscord<nocturn9x> (edit) "https://play.nim-lang.org/#pasty=yGbtuTUJ" => "https://play.nim-lang.org/#pasty=NikuyzTn"
12:07:33FromDiscord<nnsee> works here https://godbolt.org/z/6afbv7eno
12:07:40FromDiscord<nocturn9x> these are the arrays
12:07:43FromDiscord<nnsee> it doesn't have clang in the nim machines though
12:07:47FromDiscord<nnsee> so this is gcc
12:07:49FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=bZEakMcK
12:08:05FromDiscord<nocturn9x> the curiois thing is that it only seems to happen with `endGameScores`
12:08:13FromDiscord<nocturn9x> I don't have the same execution time on `middleGameScores`
12:08:33FromDiscord<nocturn9x> and it's not the only lines of this array that's problematic, a similar `x[i] += [...]` has the same execution time
12:08:39FromDiscord<nocturn9x> which is ~0.83 seconds
12:08:45FromDiscord<nocturn9x> (edit) "curiois" => "curious"
12:08:47Amun-Raperhaps these instructions apply to operations on the whole table?
12:08:58*ntat joined #nim
12:09:02FromDiscord<nocturn9x> why would the compiler pick that if it's slower
12:09:11FromDiscord<nocturn9x> and why would it not do the same for the other array
12:09:26Amun-Rasearch me…
12:11:14FromDiscord<ringabout> Did you try other allocator or `--threads:off`?
12:11:18FromDiscord<ringabout> (edit) "allocator" => "allocators"
12:12:01FromDiscord<nocturn9x> uhm
12:12:06FromDiscord<nocturn9x> I can't turn off threads lmao
12:12:08FromDiscord<nocturn9x> I use them
12:12:18FromDiscord<nocturn9x> I _am_ using other allocators
12:12:25FromDiscord<nocturn9x> because nim's own allocator is garbage and malloc is slow as fuck
12:14:34Amun-Raisn't mmap the default?
12:15:40*nisstyre quit (*.net *.split)
12:15:41*ormiret quit (*.net *.split)
12:15:46FromDiscord<nocturn9x> -d:useMalloc...
12:16:29Amun-Raa) -d=usemalloc b) complain malloc is slow - pick one ;)(
12:16:41FromDiscord<nocturn9x> if the default allocator wasn't trash I would us that
12:16:48FromDiscord<odexine> usemalloc to swap it to mimalloc
12:16:50FromDiscord<nocturn9x> I'm passing -d:useMalloc and then linking mimalloc
12:16:55FromDiscord<nocturn9x> folks
12:16:57Amun-RaI see
12:16:58FromDiscord<nocturn9x> I'm already doing that
12:17:00FromDiscord<nocturn9x> I said that like 10 times
12:17:02FromDiscord<nocturn9x> lol
12:17:12*nisstyre joined #nim
12:17:13*ormiret joined #nim
12:17:18FromDiscord<odexine> im pointing it out
12:17:20Amun-Rareading backlog? ain't nobody got time for that
12:17:28FromDiscord<odexine> reading? i can barely
12:17:29FromDiscord<ringabout> What about C code?
12:17:45FromDiscord<ringabout> Maybe it's just clang
12:17:46FromDiscord<nocturn9x> good luck with that
12:17:51FromDiscord<nocturn9x> the C code is unreadable
12:17:57FromDiscord<nocturn9x> In reply to @ringabout "Maybe it's just clang": gcc is like 2x slower
12:18:02FromDiscord<nocturn9x> so I would like to keep clang
12:19:09FromDiscord<nocturn9x> some things just make no sense in this profiler output
12:19:15FromDiscord<nocturn9x> some variable assignments take 0.24 seconds
12:19:19FromDiscord<nocturn9x> (of course that's total time)
12:19:35FromDiscord<nocturn9x> but still, that's literally just `let sideToMove = position.sideToMove`
12:20:05Amun-RaI wanted to play with amduprof, but it fails to install because its kernel module is not signed
12:20:18FromDiscord<nocturn9x> I downloaded it from AMD's website
12:20:22FromDiscord<nocturn9x> the version in AUR is borked
12:20:29Amun-Rasame
12:21:21FromDiscord<ringabout> Well, you can focus on the single function in the c code. Like you can wrapper the `+=` into a function with the name like `fxxx` or something and search it from nimcache. That's how I debug the Nim code
12:21:34FromDiscord<nocturn9x> `endGameScores[piece.color] += ENDGAME_VALUE_TABLES[piece.color][piece.kind][sq]`
12:21:40FromDiscord<nocturn9x> this single line is being compiled to over 30 instructions
12:21:46FromDiscord<nocturn9x> and takes 0.75 seconds of total execution time
12:21:49FromDiscord<nocturn9x> that is nonsense
12:22:00FromDiscord<nocturn9x> it's 3 loads and a store lol
12:22:15FromDiscord<nocturn9x> and an addition
12:22:52FromDiscord<ringabout> Yeah, we need to know whether Nim generate inefficient C code or Clang generate inefficient instructions
12:22:59FromDiscord<nocturn9x> the fuck is this compiler doing
12:23:00FromDiscord<ringabout> (edit) "generate" => "generates" | "generate" => "generates"
12:23:44FromDiscord<nocturn9x> also for some reason gcc generates shit code
12:23:46FromDiscord<nocturn9x> way slower
12:25:46FromDiscord<sOkam! 🫐> how would you UnitTest the shape of a `type T = object`? 🤔
12:26:10FromDiscord<nocturn9x> if anyone has the time or expertise
12:26:17FromDiscord<nocturn9x> https://git.nocturn9x.space/nocturn9x/heimdall/src/branch/master/heimdall/heimdallpkg/eval.nim#L427
12:26:21FromDiscord<nocturn9x> this is one of the affected lines
12:26:35FromDiscord<nocturn9x> the other one being https://git.nocturn9x.space/nocturn9x/heimdall/src/branch/master/heimdall/heimdallpkg/eval.nim#L232
12:26:59FromDiscord<nocturn9x> does the compiler hate that array or something?
12:27:07FromDiscord<nocturn9x> all stuff being done on it is slower than the other one
12:31:57FromDiscord<nocturn9x> `tyArray4Xw5nlWCQQmIGQycE1eMGw endGameScores; `
12:32:00FromDiscord<nocturn9x> there, this is the array
12:33:10FromDiscord<nocturn9x> my god why is the code generated by nim so fucking garbage
12:33:18FromDiscord<nocturn9x> there's lines longer than the declaration of independence
12:33:35FromDiscord<nocturn9x> I understand it's not supposed to be human readable, but this seems purposelly designed to be as unreadable as possible
12:33:42FromDiscord<nocturn9x> it's one step away from being minified
12:34:13FromDiscord<zumi.dxy> meanwhile V's codegen is supposed to be "readable" but man that one still looks like multiple files `cat`ted together
12:34:25FromDiscord<zumi.dxy> last i tried, anyway
12:34:54FromDiscord<ringabout> In reply to @nocturn9x "I understand it's not": You can also use `--expandArc:evaluate` to check whether it generates lots of temps
12:35:19FromDiscord<zumi.dxy> I just use `clang-format` to ease the pain
12:35:25FromDiscord<nocturn9x> I also see a lot of `nimZeroMem` and `NimCopyMem`
12:35:33FromDiscord<nocturn9x> which should probably not be there but oh wll
12:35:34FromDiscord<nocturn9x> (edit) "wll" => "well"
12:35:35FromDiscord<ringabout> It might copy when you access arrays or seqs
12:36:21FromDiscord<nocturn9x> why would it do that
12:36:39FromDiscord<ringabout> If they are value types, they are copied
12:38:14FromDiscord<nocturn9x> they are int32 lol
12:38:18FromDiscord<nocturn9x> wtf is there to copy with copyMem
12:38:25FromDiscord<nocturn9x> they ain't pointers
12:38:49FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=yefeYKQz
12:38:51Amun-Raso, something else is being copies
12:38:53FromDiscord<nocturn9x> seems like it's just initializing it
12:38:53Amun-Rad*
12:39:14FromDiscord<nocturn9x> this is what the subtraction compiles into
12:39:18FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=siNIgSxv
12:39:27FromDiscord<nocturn9x> so it ain't nim that's the problem
12:40:33Amun-RaI wonder what that asm would look like if you opt for size
12:40:46FromDiscord<ringabout> Where is `endGameScores`?
12:42:43FromDiscord<nocturn9x> `--opt:size`?
12:42:51FromDiscord<nocturn9x> won't that clash with `-d:danger`?
12:43:13*rockcavera joined #nim
12:43:30FromDiscord<odexine> not really?
12:44:21FromDiscord<nocturn9x> `--opt:size` makes the code so much slower
12:45:14FromDiscord<nocturn9x> makes sense
12:46:32FromDiscord<nocturn9x> https://paste.nocturn9x.space/lHlmQ0_hZbfqWSYlJf-XD
12:46:40FromDiscord<nocturn9x> this is the relevant `--expandArc:evaluate` bit
12:47:53FromDiscord<nocturn9x> `color_1 = chckRange(res, White, None)`
12:47:56FromDiscord<nocturn9x> this is kinda concerning
12:48:04FromDiscord<nocturn9x> is this supposed to be there with `-d:danger`?
12:52:10FromDiscord<ringabout> `chckRange` is handled in backends. It won't generate check if danger is enabled. It still shows in IR
12:52:37FromDiscord<nocturn9x> ok
12:52:59FromDiscord<nocturn9x> ugh, trying to figure out the performance issues of this engine has been such a pain in the ass
12:53:11FromDiscord<nocturn9x> I never know when nim is sneakily copying something behind my back
12:57:13FromDiscord<asbjorn2> In reply to @ieltan "A2, welcome to pain.": thanks for this advice. I finally managed to get the last of my parallelism/memory bugs fixed, mostly thanks to `SharedPtr`
12:57:51FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=ZRNpuHjN
12:57:56FromDiscord<nocturn9x> this is an array of `NI32`s
12:57:56FromDiscord<asbjorn2> ..or at least I hope that was the last of my shared memory bugs 🙏
12:57:59FromDiscord<nocturn9x> why tf is it making a cast
12:58:07FromDiscord<nocturn9x> In reply to @asbjorn2 "..or at least I": spoiler: no
12:58:18FromDiscord<nocturn9x> I've done my fair share of nim parallel stuff and it's truly garbage
12:58:50FromDiscord<asbjorn2> I'll try to manage my expectations 🤣
13:07:38FromDiscord<ieltan> In reply to @asbjorn2 "thanks for this advice.": Use sanitizers to make sure you've really fixed all of them
13:07:42FromDiscord<ieltan> And np
13:08:09FromDiscord<asbjorn2> what sanitizers? do you have a tool to recommend?
13:08:19*ntat quit (Remote host closed the connection)
13:08:26FromDiscord<ieltan> In reply to @nocturn9x "I've done my fair": Well, when you're at rock bottom you can only go up, something like that
13:08:37*ntat joined #nim
13:10:11FromDiscord<ieltan> In reply to @asbjorn2 "what sanitizers? do you": They're tools that can detect memory and thread safety issues in your program, they're mandatory if you want to make sure you have no bugs. You simply cannot make a serious project without them.
13:10:27FromDiscord<nocturn9x> In reply to @ieltan "Well, when you're at": lol
13:10:54FromDiscord<nocturn9x> also
13:11:10FromDiscord<nocturn9x> I don't get the same timings when I compile without `-g` and `--debugger:native`
13:11:59FromDiscord<nocturn9x> not even by a long shot
13:12:00FromDiscord<asbjorn2> In reply to @ieltan "They're tools that can": does valgrind/helgrind work well with nim? is this the kind of tool you're referring to?
13:12:24FromDiscord<nocturn9x> In reply to @nocturn9x "I don't get the": thanks nim!
13:12:29FromDiscord<nocturn9x> very useful to debug
13:16:32PMunch@asbjorn2, I've used valgrind and helgrind to profile Nim code, works a treat
13:16:41FromDiscord<ieltan> you can use it too that works
13:16:48FromDiscord<ieltan> i was referring to asan/tsan more specifically
13:17:10FromDiscord<ieltan> just remember to compile with `-d:useMalloc`
13:17:35FromDiscord<ieltan> and `--debugger:native` i guess
13:38:07*rockcavera quit (Remote host closed the connection)
13:39:19FromDiscord<imagio> sent a long message, see https://pasty.ee/dpPjgkKf
13:39:24FromDiscord<imagio> sent a code paste, see https://play.nim-lang.org/#pasty=ZtcxSHOL
13:41:53FromDiscord<imagio> ...also I probably should have posted this in the forum instead of here since it's a bit long
13:46:35FromDiscord<zumi.dxy> Effect tags? https://nim-lang.org/docs/manual.html#effect-system
13:49:45FromDiscord<imagio> Effect-ts is entirely different than nim's "Effect" system AFAICT. They just happen to use the same name.
13:52:39FromDiscord<ieltan> Well I don't know what would be the equivalent of the `R` type in Nim
13:53:41FromDiscord<ieltan> that sounds like Nim's `{.raises: [CatchableError].}` https://media.discordapp.net/attachments/371759389889003532/1252622266827673610/image.png?ex=6672e2e5&is=66719165&hm=d0b2164ce632059e09b866dbb3a38544dc7f00b88a1c7cdcd73de6f9633cb7e5&
13:54:58FromDiscord<ieltan> Nim can track errors using the type system too but you still have to use `try-except`
13:55:43FromDiscord<Robyn [She/Her]> Could always use https://github.com/arnetheduck/nim-results with a custom return type
13:56:13FromDiscord<imagio> I'm really more curious about how one would model a type with 3 generic parameters and then write combinators that manipulate those generics. Like how `flatMap` is `<A,E,R>(self: Effect<A,E,R>, fn: <B,E1,R1>(v: A) => Effect<B, E1, R1>) => Effect<B, E | E1, R | R1>`
13:57:48FromDiscord<ieltan> https://github.com/arnetheduck/nim-results is a good example on how you can achieve that especially the `map` / `flatMap` functions
13:57:57FromDiscord<ieltan> nice one robyn
13:58:46FromDiscord<imagio> In reply to @chronos.vitaqua "Could always use https://github.com/arnetheduck/nim": Ah cool, thanks for the link, I'll check that one out
13:59:30FromDiscord<ieltan> im not sure you can return a `Result[T, E | E2]` though
13:59:47FromDiscord<ieltan> Nim's union is not like typescript i think
14:00:41FromDiscord<ieltan> btw a lot of the docs in it is kinda outdated
14:01:23FromDiscord<ieltan> but the code should work fine
14:02:16FromDiscord<ieltan> oh boy i forgot they do this weird conditional compilation stuff making the thing unreadable
14:02:56FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#pasty=iRlRjOGV
14:03:13FromDiscord<imagio> yeah I was scratching my head about why that's necessary
14:04:09FromDiscord<ieltan> In reply to @imagio "yeah I was scratching": they were working around some nim bug
14:04:26FromDiscord<ieltan> its fixed now i dunno why they didnt revert the workaround
14:05:35FromDiscord<zumi.dxy> well people still use old versions
14:05:43FromDiscord<zumi.dxy> especially on "stable" distros
14:05:43FromDiscord<imagio> Can nim infer a union return type like the flatMap example above?
14:06:14FromDiscord<ieltan> In reply to @zumi.dxy "well people still use": Ahh fair enough
14:07:06FromDiscord<zumi.dxy> choosenim or compiling a new version is an option, sure↵but i don't think people want to go through that hassle unless absolutely necessary
14:07:58FromDiscord<ieltan> I mean
14:08:02FromDiscord<ieltan> People have to update anyways
14:08:08FromDiscord<ieltan> (security fixes)
14:08:25FromDiscord<imagio> sent a code paste, see https://play.nim-lang.org/#pasty=MRaDgtaC
14:13:17*lucasta joined #nim
14:13:20FromDiscord<anuke> Anyone know why setting up Nim on CI has been so slow these past couple of days? It seems to be downloading Nim from the site at 5 kb/s, which is horrendous. Is something wrong with the site? https://media.discordapp.net/attachments/371759389889003532/1252627206245584958/image.png?ex=6672e77e&is=667195fe&hm=553eda9cc3382f232595e85ce7db7c063bbde68e4e07463557c38c5f334aa55b&
14:15:19FromDiscord<anuke> Likely related to the 2.0.6 release...?
14:15:48FromDiscord<albassort> i downloaded 2.6 using choosenim and it was fine
14:16:03FromDiscord<albassort> today
14:16:29FromDiscord<imagio> sent a code paste, see https://play.nim-lang.org/#pasty=AuWtdYDj
14:16:40FromDiscord<anuke> In reply to @albassort "i downloaded 2.6 using": Choosenim may use a different system than the CI setup script
14:17:19FromDiscord<imagio> (edit) "https://play.nim-lang.org/#pasty=ziSiGJxp" => "https://play.nim-lang.org/#pasty=tqWIPtKx"
14:17:37FromDiscord<imagio> (edit) "https://play.nim-lang.org/#pasty=tzDiOvRv" => "https://play.nim-lang.org/#pasty=JUimITqu"
14:19:00*PMunch quit (Quit: Leaving)
14:24:13FromDiscord<Robyn [She/Her]> In reply to @ieltan "im not sure you": True
14:26:49FromDiscord<ringabout> In reply to @anuke "Anyone know why setting": Isn't it at the start phase https://media.discordapp.net/attachments/371759389889003532/1252630601870082149/image.png?ex=6672eaa8&is=66719928&hm=0838cd06f3ce93596626af969bcd95a49f9da348819da9188063a537d84429e6&
14:27:42FromDiscord<anuke> Oh, I missed that, my bad
14:27:44FromDiscord<anuke> What is the issue, then?
14:27:58FromDiscord<anuke> Could it be a problem with the action? It's happening across multiple repos
14:30:05FromDiscord<ieltan> @imagio `E0 | E1` in nim means "restrict that generic to only one of those two types". Nim does infer generics but it works differently than typescript
14:32:17FromDiscord<ringabout> In reply to @anuke "Anyone know why setting": Probably cache issues. It might improve after it has been downloaded. server cdn or cache action
14:32:50FromDiscord<ieltan> I'm not even sure if I understand how union works in typescript but I'm pretty sure it's different than Nim's
14:33:08FromDiscord<ieltan> (edit) "I'm not even sure if I understand how ... union" added "type"
14:40:29FromDiscord<imagio> In reply to @ieltan "I'm not even sure": In TS the meaning is similar to "E0 or E1". In TS it doesn't have to be literally E0 or E1 but rather any type that satisfies E0 or E1 because TS is for some reason dogmatic about structural typing. In most cases however you usually have a discriminator in the type which TS can use to narrow so it really does become "E0 or E1".
14:41:12FromDiscord<imagio> (edit) "typing." => "typing even when nominal types make sense."
14:57:57FromDiscord<anuke> I tried downgrading to 2.0.4, and it downloads 2.0.6 for setup anyway. Bizarre behavior. https://media.discordapp.net/attachments/371759389889003532/1252638437568151612/image.png?ex=6672f1f4&is=6671a074&hm=0e2ef38d8d4499affefb5df0eada30f43eb1aaa77b7a64bba23b514e44903251&
15:25:21FromDiscord<albassort> In reply to @anuke "Choosenim may use a": what is the cl setup script?
15:33:45*xet7 quit (Remote host closed the connection)
15:37:23FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#pasty=hbdgPrGm
16:10:51*xet7 joined #nim
16:21:19*lucasta quit (Quit: Leaving)
17:09:31*rockcavera joined #nim
17:13:00*tiorock joined #nim
17:13:00*tiorock quit (Changing host)
17:13:00*tiorock joined #nim
17:13:00*rockcavera is now known as Guest8713
17:13:00*Guest8713 quit (Killed (copper.libera.chat (Nickname regained by services)))
17:13:00*tiorock is now known as rockcavera
18:05:39*coldfeet joined #nim
18:24:19*xtr00 quit (Quit: Client closed)
18:27:21*SchweinDeBurg quit (Quit: WeeChat 4.4.0-dev)
18:33:59FromDiscord<imagio> sent a code paste, see https://play.nim-lang.org/#pasty=MjZGpAJO
18:46:40FromDiscord<demotomohiro> In reply to @imagio "Hmm nim 2.0.6 is": It seems failed to compile and link `koch.nim`.↵`nim c --listcmd koch.nim` provide more info.
18:47:45FromDiscord<demotomohiro> `--listcmd` prints commands Nim issues to compile and link generated C files.
19:33:30*ntat quit (Quit: Leaving)
19:45:51*jjido joined #nim
19:55:14FromDiscord<rakgew> @xkonti \: quite enjoy your nim streams!↵from a recent recoring I watched, it sounded like you might be interested in code reordering?\:↵https://nim-lang.org/docs/manual_experimental.html#code-reordering (but maybe you have found it already)
20:21:52*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
20:37:28FromDiscord<fakuivan> what is the consensus around calling unary functions without parentheses?
20:40:47FromDiscord<leorize> it depends™
20:42:59FromDiscord<fakuivan> what do formatters do?
20:51:49FromDiscord<leorize> formatters doesn't change any of this
20:53:35*coldfeet quit (Remote host closed the connection)
21:04:31FromDiscord<xkonti> In reply to @rakgew "<@244832576215318528> \: quite enjoy": I'm very glad to hear that ❤️↵I might have perused through this option. Now I'll definitely check it out as it would make it so much easier to keep things organized. Thanks!
21:04:52FromDiscord<Elegantbeef> Nooooo
21:04:57FromDiscord<Elegantbeef> Top to bottom code is just the best! 😄
21:07:43*jjido joined #nim
21:08:59*rockcavera quit (Ping timeout: 264 seconds)
21:15:56FromDiscord<frusadev> Hello. Does anyone know how to copy all the contents of a dir to another one?
21:16:43FromDiscord<nnsee> `cp -r mydir1/ mydir2/`↵?
21:16:51FromDiscord<nnsee> oh, i just realized you probably mean within nim
21:16:58FromDiscord<frusadev> Yeah haha
21:18:41FromDiscord<nnsee> you probably want to walk the files recursively and copy them to the destination dir one by one
21:19:05FromDiscord<nnsee> as in https://nim-lang.org/docs/osdirs.html#walkDirRec.i,string
21:19:37FromDiscord<frusadev> thanks
21:43:16*rockcavera joined #nim
22:25:08FromDiscord<demotomohiro> You can use `copyDir`:↵https://nim-lang.org/docs/osdirs.html#copyDir%2Cstring%2Cstring
22:38:18FromDiscord</-+> Is Nim programming a garbage collector
22:39:12FromDiscord<juancarlospaco> Nim is a programming language.
22:46:52FromDiscord<Elegantbeef> Let's be honest with how I write code I'm the garbage collector
23:01:42FromDiscord<Robyn [She/Her]> It's shown in how you speak too! Though you make more shit behind you sooo
23:04:18FromDiscord<realqquantum> sent a code paste, see https://play.nim-lang.org/#pasty=AWaKZUuc
23:04:45FromDiscord<realqquantum> (edit) "https://play.nim-lang.org/#pasty=RknEjnwd" => "https://play.nim-lang.org/#pasty=qMWKsntP"
23:05:10*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
23:05:47FromDiscord<leorize> since you're SELECT-ing, you'll want https://nim-lang.org/docs/db_sqlite.html#getAllRows%2CDbConn%2CSqlQuery%2Cvarargs%5Bstring%2C%5D instead
23:06:14FromDiscord<realqquantum> ill try it rn thanks
23:06:53FromDiscord<realqquantum> worked, thanks!
23:22:11*lx12ucy joined #nim
23:22:40lx12ucywhat would be the best way to find the unix timestamp of when a directory was last modified?
23:28:01FromDiscord<leorize> use getFileInfo\: https://nim-lang.org/docs/os.html#getFileInfo%2CFile
23:28:19FromDiscord<leorize> the FileInfo struct has lastWriteTime, which is what you want
23:28:48FromDiscord<Elegantbeef> There is also `getLastModificationTime()`
23:30:31lx12ucyjust found `getLastModificationTime()`, i'll try this