00:07:52 | FromDiscord | <Robyn [She/Her]> In reply to @drugss "IMG-20241228-WA0002.jpg": <@&371760044473319454> |
00:58:56 | FromDiscord | <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:30 | FromDiscord | <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:35 | FromDiscord | <janakali> http://ithare.com/infographics-operation-costs-in-cpu-clock-cycles/ |
02:25:54 | FromDiscord | <treeform> In reply to @sys64 "So I benchmarked and...": It's common for optimizations to be very confusing. Threads doubly so. |
04:52:44 | FromDiscord | <Elegantbeef> Even moreso when people do not actually profile |
06:44:58 | * | proaxis_ is now known as proaxis |
06:47:31 | proaxis | according to the docs the walkDirRec iterator has the default value of yieldFilter = {pcFile} |
06:48:17 | proaxis | how do I specify to use pcFile and pcLinkToFile? I haven't seen curly braces used for default values before |
06:48:35 | FromDiscord | <Elegantbeef> It's a bit set so you just use curlies for both |
06:48:49 | FromDiscord | <Elegantbeef> `{pcFile, pcLinkToFile}` ez pz |
06:52:52 | proaxis | great, thanks |
08:50:07 | FromDiscord | <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:53 | FromDiscord | <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:45 | FromDiscord | <blackmius> source proc then implicitly receives env object containing data from outer scope |
09:00:00 | FromDiscord | <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:01 | FromDiscord | <riku5543> Thanks for the help though |
10:01:55 | * | beholders_eye joined #nim |
10:07:44 | FromDiscord | <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:23 | FromDiscord | <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:31 | FromDiscord | <itsuki7418> is nim a transpiler 2.2.0 ? |
11:43:11 | FromDiscord | <itsuki7418> https://media.discordapp.net/attachments/371759389889003532/1322892669495677029/00.PNG?ex=6772874e&is=677135ce&hm=bbbb85e034aaad79a06637ad2143864b6fa21f9e12751ca41b30f82862de787f& |
12:00:46 | FromDiscord | <solitudesf> maybe |
12:02:04 | FromDiscord | <demotomohiro> In reply to @itsuki7418 "is nim a transpiler": https://peterme.net/is-nim-a-transpiler.html |
12:08:32 | FromDiscord | <cmdr_argh_o7> Hey folks, gotten round to learning nim. |
12:09:20 | FromDiscord | <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:38 | FromDiscord | <nocturn9x> what would be the optimal way of extracting a compiled function from a Nim binary? |
12:32:45 | FromDiscord | <nocturn9x> I'm trying to check if it's being autovectorized correctly |
12:33:04 | FromDiscord | <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:09 | FromDiscord | <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:19 | FromDiscord | <nocturn9x> (edit) "godbold" => "godbolt" |
12:33:42 | FromDiscord | <nocturn9x> In reply to @itsuki7418 "": does it matter? |
12:33:52 | FromDiscord | <nocturn9x> clang is a C->LLVM transpiler and no one bats an eye |
12:33:58 | FromDiscord | <nocturn9x> who cares what language you target? |
12:34:10 | FromDiscord | <nocturn9x> rust "transpiles" to LLVM too |
12:34:11 | FromDiscord | <nocturn9x> so? |
12:34:21 | FromDiscord | <nocturn9x> why do people care that Nim specifically transpiles to nim |
12:34:24 | FromDiscord | <nocturn9x> transpiling is a shit term anyway |
12:34:35 | FromDiscord | <nocturn9x> (edit) "nim" => "C/C++" |
12:37:55 | FromDiscord | <zumi.dxy> psst, compiling to C is nim's biggest superpower |
12:37:58 | FromDiscord | <zumi.dxy> like, unironically |
12:38:10 | FromDiscord | <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:19 | FromDiscord | <nocturn9x> don't mind them |
12:38:23 | FromDiscord | <nocturn9x> In reply to @zumi.dxy "psst, compiling to C": fr |
12:38:27 | FromDiscord | <itsuki7418> i don't care about it |
12:38:28 | FromDiscord | <nocturn9x> it makes FFI stupid simple |
12:46:55 | FromDiscord | <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:23 | FromDiscord | <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:38 | FromDiscord | <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:27 | FromDiscord | <nocturn9x> In reply to @demotomohiro "When I want to": thx :) |
12:53:54 | FromDiscord | <nocturn9x> In reply to @sys64 "This is why I": Indeed |
12:55:52 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @nocturn9x "Indeed": Like, you can even link statically without needing dll or .a/.lib libraries |
13:01:01 | FromDiscord | <itsuki7418> In reply to @demotomohiro "There are reasons to": ok got it, but would mind telling me which c libs ? like what |
13:01:22 | FromDiscord | <itsuki7418> time.h ? stdio.h ? what ? |
13:02:52 | FromDiscord | <System64 ~ Flandre Scarlet> I wonder if it's possible to make SGDK bindings in Nim, I have not enough experience sadly |
13:13:26 | FromDiscord | <itsuki7418> In reply to @sys64 "I wonder if it's": me too but i have an idea |
13:14:08 | FromDiscord | <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:20 | FromDiscord | <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:44 | FromDiscord | <itsuki7418> In reply to @demotomohiro "`time.h` or `stdio.h` are": i see |
13:15:04 | FromDiscord | <itsuki7418> (edit) "wherever" => "whatever" |
13:15:10 | om3ga | Hi all! Have anyone tried to create multithreaded tcp server with nim? |
13:16:07 | om3ga | I have something not well expected here. acceptAddr returns the same socket on second connect |
13:16:33 | om3ga | joinThread or joinThreads are blocking functions |
13:17:29 | FromDiscord | <demotomohiro> You can search existing C library bindings or Nim libraries on: https://nimble.directory |
13:17:48 | om3ga | tried to pass client socket number to via thread arguments, - not works, not even compiles because it expects mutable arg |
13:18:14 | om3ga | demotomohiro thanks for the suggestion, but I would like to have the same but with strict nim |
13:18:44 | om3ga | so I used channels to pass sock number, it works |
13:19:01 | om3ga | but what to do with acceptAddr, or accept()? |
13:19:19 | om3ga | is there any substitutions? |
13:20:59 | om3ga | the 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:19 | om3ga | but why I'm getting the same socket |
13:22:24 | om3ga | oh, damn, I forgot to dereference address of the sock var to printout the socket number |
13:22:28 | om3ga | please ignore |
13:24:09 | om3ga | it definitely results with another socket number, but there's other issues too, second thread absolutely not accepts passed channel message |
13:24:33 | om3ga | I mean from the main procedure |
13:25:11 | om3ga | it may be related to that I not executed the joinThread(s) because they block execution |
13:27:05 | FromDiscord | <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:15 | FromDiscord | <aintea> In reply to @sys64 "Btw Is it possible": You have discord-presence plugin in neovim |
13:28:20 | om3ga | compiler not warns me, also I use locks when the things with sensitive parts of the code |
13:28:58 | om3ga | I see the issue probably is with channels, for some reason it not pass the socket number to idle thread |
13:29:11 | om3ga | maybe it shouldn't do that? |
13:29:12 | * | xet7 joined #nim |
13:30:27 | om3ga | I have ideas how to avoid channels with use of sharedMem, but that will result with messy code |
13:36:15 | om3ga | another 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:22 | om3ga | creation) |
13:45:46 | FromDiscord | <nocturn9x> you can create a `seq[ref Thread[TArg]]` |
13:45:57 | FromDiscord | <nocturn9x> then you can `add(new Thread[TArg])` to it |
13:46:20 | FromDiscord | <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:00 | om3ga | nocturn9x yeah, possible solution but risky |
13:53:15 | om3ga | I'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:39 | om3ga | probably this is not really the data race, and artefact of the sanitizer, but still |
14:03:39 | om3ga | there'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:47 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @itsuki7418 "me too but i": What's your idea? |
14:56:37 | FromDiscord | <albassort> can i check if a type is an enum using when? |
15:09:14 | Amun-Ra | when varname is EnumName |
15:09:27 | FromDiscord | <albassort> any enum |
15:09:35 | FromDiscord | <albassort> i need to see if the object type is an enum |
15:09:43 | Amun-Ra | when varname is enum |
15:09:53 | FromDiscord | <albassort> ok :D |
15:10:38 | Amun-Ra | ofc the type must be known compile-time |
15:11:39 | FromDiscord | <albassort> is there a way to set theory enums |
15:11:50 | FromDiscord | <albassort> i want a subset of an enum to be part of a bigger class |
15:11:53 | FromDiscord | <albassort> oh wait |
15:11:53 | FromDiscord | <albassort> sets |
15:11:56 | FromDiscord | <albassort> thank you |
15:27:29 | om3ga | I made it: https://play.nim-lang.org/#pasty=ZPYbZkTA |
15:27:48 | om3ga | resulted with littlebit ugly code, but it works |
15:28:03 | om3ga | and no data race |
15:30:40 | Amun-Ra | there is something like that with lock in stdlib… don't remember where |
15:33:20 | om3ga | damn, intense load test still produces data race |
15:33:53 | om3ga | sanitizer points on acceptAddr |
15:33:57 | om3ga | what the heck |
15:35:01 | om3ga | Amun-Ra, do you mean some issue with locks? |
15:35:35 | Amun-Ra | om3ga: no, I mean there is already something like this in stdlib, I could be wrong tho |
15:35:48 | Amun-Ra | ah, withLock |
16:01:14 | FromDiscord | <dawidek.2137> is there a way to deal with the insane exception dumps when using async? |
16:07:42 | om3ga | here it is: #1 tcpServer::startServer(var<serverObjects::SocketOpts>) tcpServer.nim:47 (logsd:arm64+0x10001c178) |
16:07:54 | om3ga | if thr[id].running: |
16:08:01 | om3ga | but why? |
16:08:24 | om3ga | I will check using valgrind later |
16:09:34 | om3ga | just in any case, sending updated code: https://play.nim-lang.org/#pasty=xnaTgJZi |
16:47:58 | * | thunder quit (Quit: Leaving) |
17:05:09 | FromDiscord | <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:51 | FromDiscord | <leorize> that's fine |
17:23:17 | FromDiscord | <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:45 | om3ga | well, valgrind reports data race too |
18:14:49 | om3ga | https://paste.laravel.io/ca12ab8d-4ff2-4f76-9f26-8d97186f6fab |
18:16:30 | om3ga | So it's definitely not due to thread sanitizer, or arm64 isa |
18:39:28 | om3ga | that's interesting https://paste.laravel.io/1c3fe5d5-3dda-45f3-909b-60dee1423f9b |
18:39:39 | om3ga | code 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:05 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=UHtWeoVc |
23:01:32 | FromDiscord | <Robyn [She/Her]> Yeah, it would |
23:01:36 | FromDiscord | <Robyn [She/Her]> Idk why I'd do this |
23:01:52 | FromDiscord | <Robyn [She/Her]> Don't wanna make a separate concept for asynchronous client implementors tho |
23:01:59 | FromDiscord | <Robyn [She/Her]> Not like I'm ever gonna use them tho lol |
23:22:27 | FromDiscord | <albassort> turns out beef is right |
23:22:43 | FromDiscord | <albassort> converting exceptions to results is stupid and it strips all the useful info from it |
23:23:17 | FromDiscord | <Elegantbeef> Damn I'm right for once |
23:23:38 | FromDiscord | <albassort> not for long, i will make a frankenstein normal class to hold the data |
23:23:48 | FromDiscord | <albassort> (edit) "class" => "object" |
23:24:23 | FromDiscord | <Elegantbeef> Why |
23:24:34 | FromDiscord | <albassort> i do not like try |
23:24:35 | * | proaxis quit (Quit: Leaving) |
23:24:38 | FromDiscord | <albassort> it is ugly |
23:24:48 | FromDiscord | <Elegantbeef> Why |
23:25:03 | FromDiscord | <albassort> i like results more |
23:25:03 | FromDiscord | <Elegantbeef> It's the same thing |
23:25:29 | FromDiscord | <Elegantbeef> They're logically the same thing, an if check after a call |
23:25:51 | FromDiscord | <Elegantbeef> Like what are you doing with the result presently? |
23:26:17 | FromDiscord | <albassort> it is what i've decided to stick to in this codebase |
23:28:02 | FromDiscord | <Elegantbeef> Well have fun |
23:28:59 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=CWRlZCln |
23:29:14 | FromDiscord | <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:24 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=tVfftOoT |
23:29:30 | FromDiscord | <Elegantbeef> So then don't predefine 😄 |
23:29:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=pMySKZyg |
23:30:34 | FromDiscord | <Elegantbeef> I don't get how the above is comparable though |
23:31:04 | FromDiscord | <Elegantbeef> Atleast in your example you didn't set x in the bad case, so I imagine you want to exit |
23:48:21 | FromDiscord | <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:36 | FromDiscord | <zumi.dxy> But that's more the fault of whatever code I'm calling |
23:48:53 | FromDiscord | <zumi.dxy> but the stdlib can be guilty of this as well |
23:49:41 | FromDiscord | <zumi.dxy> How useful are exception classes in practice, anyway? |
23:50:01 | FromDiscord | <zumi.dxy> "an error is an error" |
23:53:23 | FromDiscord | <Elegantbeef> You can add more data or disregard specific errors you don't care about |
23:53:47 | FromDiscord | <Elegantbeef> Or you might handle specific errors differently |
23:54:27 | FromDiscord | <Elegantbeef> It's akin to saying all error handling can be replaced by a boolean |