<< 29-12-2024 >>

00:07:52FromDiscord<Robyn [She/Her]> In reply to @drugss "IMG-20241228-WA0002.jpg": <@&371760044473319454>
00:58:56FromDiscord<bostonboston> Y'all think they got cartnite?
01:18:33*ensyde quit (Ping timeout: 252 seconds)
01:20:15*kotrcka joined #nim
01:30:06*cm quit (Quit: Bye.)
01:31:46*kotrcka quit (Read error: Connection reset by peer)
02:25:30FromDiscord<janakali> In reply to @sys64 "So I benchmarked and...": Spinning new threads is slow, it's one of the slowest things your CPU can do, so unless you do a lot of work on each thread it will be slower.
02:25:35FromDiscord<janakali> http://ithare.com/infographics-operation-costs-in-cpu-clock-cycles/
02:25:54FromDiscord<treeform> In reply to @sys64 "So I benchmarked and...": It's common for optimizations to be very confusing. Threads doubly so.
04:52:44FromDiscord<Elegantbeef> Even moreso when people do not actually profile
06:44:58*proaxis_ is now known as proaxis
06:47:31proaxisaccording to the docs the walkDirRec iterator has the default value of yieldFilter = {pcFile}
06:48:17proaxishow do I specify to use pcFile and pcLinkToFile? I haven't seen curly braces used for default values before
06:48:35FromDiscord<Elegantbeef> It's a bit set so you just use curlies for both
06:48:49FromDiscord<Elegantbeef> `{pcFile, pcLinkToFile}` ez pz
06:52:52proaxisgreat, thanks
08:50:07FromDiscord<riku5543> What's the difference between .nimcall. and .closure.? I'm looking into passing a proc as an argument to another proc and I'm not sure if one would be better than the other, or what the implications of it are. Like what is the "environment" of a closure?
08:51:21*ntat joined #nim
08:52:53FromDiscord<blackmius> In reply to @riku5543 "What's the difference between": if your proc is using variables from outer scope (defined outside the proc) it is closure
08:58:45FromDiscord<blackmius> source proc then implicitly receives env object containing data from outer scope
09:00:00FromDiscord<riku5543> Alright that makes a lot of sense. I noticed I could assign any proc when the object gets created, but I can't assign another proc to it afterwards, unless it's been called previously for some reason haha. But I don't think reassigning makes sense in the context I'm working with so it's probably not too important. But I wonder what you'd do in that case
09:03:01FromDiscord<riku5543> Thanks for the help though
10:01:55*beholders_eye joined #nim
10:07:44FromDiscord<nick.stokoe> Apologies, I don't know how that post happened or what it means. Only just noticed it!
10:31:19*beholders_eye quit (Ping timeout: 264 seconds)
11:34:22*beholders_eye joined #nim
11:35:23FromDiscord<System64 ~ Flandre Scarlet> In reply to @janakali "Spinning new threads is": Is it possible to cache the threads so they're ready when I need them?
11:42:31FromDiscord<itsuki7418> is nim a transpiler 2.2.0 ?
11:43:11FromDiscord<itsuki7418> https://media.discordapp.net/attachments/371759389889003532/1322892669495677029/00.PNG?ex=6772874e&is=677135ce&hm=bbbb85e034aaad79a06637ad2143864b6fa21f9e12751ca41b30f82862de787f&
12:00:46FromDiscord<solitudesf> maybe
12:02:04FromDiscord<demotomohiro> In reply to @itsuki7418 "is nim a transpiler": https://peterme.net/is-nim-a-transpiler.html
12:08:32FromDiscord<cmdr_argh_o7> Hey folks, gotten round to learning nim.
12:09:20FromDiscord<cmdr_argh_o7> I'm mainly experience with C++, I learned Python last year.
12:13:43*beholders_eye quit (Ping timeout: 245 seconds)
12:30:32*coldfeet joined #nim
12:32:38FromDiscord<nocturn9x> what would be the optimal way of extracting a compiled function from a Nim binary?
12:32:45FromDiscord<nocturn9x> I'm trying to check if it's being autovectorized correctly
12:33:04FromDiscord<nocturn9x> and godbold isn't terribly useful since Nim won't compile the function unless it's used, and using it is not super trivial
12:33:09FromDiscord<nocturn9x> (edit) "and godbold isn't terribly useful since Nim won't compile the function unless it's used, and using it is not super trivial ... " added "without all the context"
12:33:19FromDiscord<nocturn9x> (edit) "godbold" => "godbolt"
12:33:42FromDiscord<nocturn9x> In reply to @itsuki7418 "": does it matter?
12:33:52FromDiscord<nocturn9x> clang is a C->LLVM transpiler and no one bats an eye
12:33:58FromDiscord<nocturn9x> who cares what language you target?
12:34:10FromDiscord<nocturn9x> rust "transpiles" to LLVM too
12:34:11FromDiscord<nocturn9x> so?
12:34:21FromDiscord<nocturn9x> why do people care that Nim specifically transpiles to nim
12:34:24FromDiscord<nocturn9x> transpiling is a shit term anyway
12:34:35FromDiscord<nocturn9x> (edit) "nim" => "C/C++"
12:37:55FromDiscord<zumi.dxy> psst, compiling to C is nim's biggest superpower
12:37:58FromDiscord<zumi.dxy> like, unironically
12:38:10FromDiscord<itsuki7418> In reply to @nocturn9x "does it matter?": i have no clue about transpiling it is just that people kept talking about it and caught my interest so i kept digging on it
12:38:19FromDiscord<nocturn9x> don't mind them
12:38:23FromDiscord<nocturn9x> In reply to @zumi.dxy "psst, compiling to C": fr
12:38:27FromDiscord<itsuki7418> i don't care about it
12:38:28FromDiscord<nocturn9x> it makes FFI stupid simple
12:46:55FromDiscord<demotomohiro> In reply to @nocturn9x "what would be the": When I want to see how Nim or GCC optimize code, I add `--passC:"-S -masm=intel"` compile option to ask GCC to generate asm and stop.↵This article might help: https://internet-of-tomohiro.pages.dev/nim/nimruntimecheckoptimize.en
12:49:23FromDiscord<demotomohiro> In reply to @itsuki7418 "i have no clue": There are reasons to output C code:↵- C language is supported in many platforms↵- A lot of effort has been spent to C compilers for long time to generate optimized executable file. Nim can use that optimizer to generate fast code.↵- There are a lot of mature C/C++ libraries. Nim can easily use them.
12:52:06*FromDiscord quit (Remote host closed the connection)
12:52:19*FromDiscord joined #nim
12:52:38FromDiscord<System64 ~ Flandre Scarlet> In reply to @nocturn9x "it makes FFI stupid": This is why I love Nim↵Nim has the best FFI I've ever seen!
12:53:27FromDiscord<nocturn9x> In reply to @demotomohiro "When I want to": thx :)
12:53:54FromDiscord<nocturn9x> In reply to @sys64 "This is why I": Indeed
12:55:52FromDiscord<System64 ~ Flandre Scarlet> In reply to @nocturn9x "Indeed": Like, you can even link statically without needing dll or .a/.lib libraries
13:01:01FromDiscord<itsuki7418> In reply to @demotomohiro "There are reasons to": ok got it, but would mind telling me which c libs ? like what
13:01:22FromDiscord<itsuki7418> time.h ? stdio.h ? what ?
13:02:52FromDiscord<System64 ~ Flandre Scarlet> I wonder if it's possible to make SGDK bindings in Nim, I have not enough experience sadly
13:13:26FromDiscord<itsuki7418> In reply to @sys64 "I wonder if it's": me too but i have an idea
13:14:08FromDiscord<demotomohiro> In reply to @itsuki7418 "ok got it, but": `time.h` or `stdio.h` are standard libraries in C. You can call functions on them if you want but Nim's standard lib is better.↵There are many libraries written in C and Nim can use them.
13:14:20FromDiscord<itsuki7418> just check an already written one in c++ or c or wherever the language u understand and try to do the same in nim my opinion 😄
13:14:44FromDiscord<itsuki7418> In reply to @demotomohiro "`time.h` or `stdio.h` are": i see
13:15:04FromDiscord<itsuki7418> (edit) "wherever" => "whatever"
13:15:10om3gaHi all! Have anyone tried to create multithreaded tcp server with nim?
13:16:07om3gaI have something not well expected here. acceptAddr returns the same socket on second connect
13:16:33om3gajoinThread or joinThreads are blocking functions
13:17:29FromDiscord<demotomohiro> You can search existing C library bindings or Nim libraries on: https://nimble.directory
13:17:48om3gatried to pass client socket number to via thread arguments, - not works, not even compiles because it expects mutable arg
13:18:14om3gademotomohiro thanks for the suggestion, but I would like to have the same but with strict nim
13:18:44om3gaso I used channels to pass sock number, it works
13:19:01om3gabut what to do with acceptAddr, or accept()?
13:19:19om3gais there any substitutions?
13:20:59om3gathe manual says that acceptAddress Blocks until a connection is being made from a client. When a connection is made sets client to the client socket and address to the address of the connecting client.
13:21:19om3gabut why I'm getting the same socket
13:22:24om3gaoh, damn, I forgot to dereference address of the sock var to printout the socket number
13:22:28om3gaplease ignore
13:24:09om3gait definitely results with another socket number, but there's other issues too, second thread absolutely not accepts passed channel message
13:24:33om3gaI mean from the main procedure
13:25:11om3gait may be related to that I not executed the joinThread(s) because they block execution
13:27:05FromDiscord<demotomohiro> I have never tried to write mutithreaded tcp server, but I wonder Nim's socket library is thread safe?↵C APIs Nim calls are thread safe?
13:27:15FromDiscord<aintea> In reply to @sys64 "Btw Is it possible": You have discord-presence plugin in neovim
13:28:20om3gacompiler not warns me, also I use locks when the things with sensitive parts of the code
13:28:58om3gaI see the issue probably is with channels, for some reason it not pass the socket number to idle thread
13:29:11om3gamaybe it shouldn't do that?
13:29:12*xet7 joined #nim
13:30:27om3gaI have ideas how to avoid channels with use of sharedMem, but that will result with messy code
13:36:15om3gaanother variant is to create single thread right after acceptAddr, but when the first one still exist, second thread results with data race (on second thread
13:36:22om3gacreation)
13:45:46FromDiscord<nocturn9x> you can create a `seq[ref Thread[TArg]]`
13:45:57FromDiscord<nocturn9x> then you can `add(new Thread[TArg])` to it
13:46:20FromDiscord<nocturn9x> so you don't need to use the same thread object and risk data races if the previous one started on it hasn't finished yet
13:52:00om3ganocturn9x yeah, possible solution but risky
13:53:15om3gaI'm trying to avoid heap as much as possible. Now I reverted the code to the thread args variant, still getting strange data race, even with locks
13:53:39om3gaprobably this is not really the data race, and artefact of the sanitizer, but still
14:03:39om3gathere's indeed data race, crazy... Client connected from: 127.0.0.1. Socket: 5 ... Thread 7271613 got request to send to socket 65535
14:17:35*marcus quit (Remote host closed the connection)
14:19:26*marcus joined #nim
14:36:47FromDiscord<System64 ~ Flandre Scarlet> In reply to @itsuki7418 "me too but i": What's your idea?
14:56:37FromDiscord<albassort> can i check if a type is an enum using when?
15:09:14Amun-Rawhen varname is EnumName
15:09:27FromDiscord<albassort> any enum
15:09:35FromDiscord<albassort> i need to see if the object type is an enum
15:09:43Amun-Rawhen varname is enum
15:09:53FromDiscord<albassort> ok :D
15:10:38Amun-Raofc the type must be known compile-time
15:11:39FromDiscord<albassort> is there a way to set theory enums
15:11:50FromDiscord<albassort> i want a subset of an enum to be part of a bigger class
15:11:53FromDiscord<albassort> oh wait
15:11:53FromDiscord<albassort> sets
15:11:56FromDiscord<albassort> thank you
15:27:29om3gaI made it: https://play.nim-lang.org/#pasty=ZPYbZkTA
15:27:48om3garesulted with littlebit ugly code, but it works
15:28:03om3gaand no data race
15:30:40Amun-Rathere is something like that with lock in stdlib… don't remember where
15:33:20om3gadamn, intense load test still produces data race
15:33:53om3gasanitizer points on acceptAddr
15:33:57om3gawhat the heck
15:35:01om3gaAmun-Ra, do you mean some issue with locks?
15:35:35Amun-Raom3ga: no, I mean there is already something like this in stdlib, I could be wrong tho
15:35:48Amun-Raah, withLock
16:01:14FromDiscord<dawidek.2137> is there a way to deal with the insane exception dumps when using async?
16:07:42om3gahere it is: #1 tcpServer::startServer(var<serverObjects::SocketOpts>) tcpServer.nim:47 (logsd:arm64+0x10001c178)
16:07:54om3gaif thr[id].running:
16:08:01om3gabut why?
16:08:24om3gaI will check using valgrind later
16:09:34om3gajust in any case, sending updated code: https://play.nim-lang.org/#pasty=xnaTgJZi
16:47:58*thunder quit (Quit: Leaving)
17:05:09FromDiscord<dawidek.2137> In reply to @dawidek.2137 "is there a way": Should i ask questions like this here? 🤔
17:07:17*ntat quit (Remote host closed the connection)
17:07:32*ntat joined #nim
17:13:51FromDiscord<leorize> that's fine
17:23:17FromDiscord<nitely_> In reply to @dawidek.2137 "is there a way": that has been improved in devel. The error msg contains an "Async traceback" section with a more brief traceback
18:14:45om3gawell, valgrind reports data race too
18:14:49om3gahttps://paste.laravel.io/ca12ab8d-4ff2-4f76-9f26-8d97186f6fab
18:16:30om3gaSo it's definitely not due to thread sanitizer, or arm64 isa
18:39:28om3gathat's interesting https://paste.laravel.io/1c3fe5d5-3dda-45f3-909b-60dee1423f9b
18:39:39om3gacode build fails with musl libc
21:06:42*ntat quit (Remote host closed the connection)
21:07:03*ntat joined #nim
21:46:15*ntat quit (Read error: Connection reset by peer)
21:47:41*ntat joined #nim
22:07:51*beholders_eye joined #nim
22:17:57*ntat quit (Quit: Leaving)
22:25:58*coldfeet quit (Quit: Lost terminal)
23:01:05FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=UHtWeoVc
23:01:32FromDiscord<Robyn [She/Her]> Yeah, it would
23:01:36FromDiscord<Robyn [She/Her]> Idk why I'd do this
23:01:52FromDiscord<Robyn [She/Her]> Don't wanna make a separate concept for asynchronous client implementors tho
23:01:59FromDiscord<Robyn [She/Her]> Not like I'm ever gonna use them tho lol
23:22:27FromDiscord<albassort> turns out beef is right
23:22:43FromDiscord<albassort> converting exceptions to results is stupid and it strips all the useful info from it
23:23:17FromDiscord<Elegantbeef> Damn I'm right for once
23:23:38FromDiscord<albassort> not for long, i will make a frankenstein normal class to hold the data
23:23:48FromDiscord<albassort> (edit) "class" => "object"
23:24:23FromDiscord<Elegantbeef> Why
23:24:34FromDiscord<albassort> i do not like try
23:24:35*proaxis quit (Quit: Leaving)
23:24:38FromDiscord<albassort> it is ugly
23:24:48FromDiscord<Elegantbeef> Why
23:25:03FromDiscord<albassort> i like results more
23:25:03FromDiscord<Elegantbeef> It's the same thing
23:25:29FromDiscord<Elegantbeef> They're logically the same thing, an if check after a call
23:25:51FromDiscord<Elegantbeef> Like what are you doing with the result presently?
23:26:17FromDiscord<albassort> it is what i've decided to stick to in this codebase
23:28:02FromDiscord<Elegantbeef> Well have fun
23:28:59FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=CWRlZCln
23:29:14FromDiscord<Elegantbeef> Especially with raises I tend towards APIs that use exceptions cause they're more intuitive to bubble out of a proc where an error happens
23:29:24FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=tVfftOoT
23:29:30FromDiscord<Elegantbeef> So then don't predefine 😄
23:29:53FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=pMySKZyg
23:30:34FromDiscord<Elegantbeef> I don't get how the above is comparable though
23:31:04FromDiscord<Elegantbeef> Atleast in your example you didn't set x in the bad case, so I imagine you want to exit
23:48:21FromDiscord<zumi.dxy> the thing I don't like about checked exceptions is that sometimes the compiler error is just: `Can raise unlisted exception: Exception`
23:48:36FromDiscord<zumi.dxy> But that's more the fault of whatever code I'm calling
23:48:53FromDiscord<zumi.dxy> but the stdlib can be guilty of this as well
23:49:41FromDiscord<zumi.dxy> How useful are exception classes in practice, anyway?
23:50:01FromDiscord<zumi.dxy> "an error is an error"
23:53:23FromDiscord<Elegantbeef> You can add more data or disregard specific errors you don't care about
23:53:47FromDiscord<Elegantbeef> Or you might handle specific errors differently
23:54:27FromDiscord<Elegantbeef> It's akin to saying all error handling can be replaced by a boolean