<< 21-04-2023 >>

00:04:20*progranner joined #nim
00:08:33*progranner quit (Ping timeout: 250 seconds)
00:09:53FromDiscord<Nilts> Is the "std/hash" module secure? The hashes are quite short
00:12:19*progranner joined #nim
00:15:41*progranner quit (Client Quit)
00:16:06*progranner joined #nim
00:19:17FromDiscord<Rika> theyre not for cryptographic purposes
00:20:30*progranner quit (Ping timeout: 252 seconds)
00:20:53FromDiscord<Nilts> In reply to @Rika "theyre not for cryptographic": then what hash should i use
00:21:02FromDiscord<Rika> sha?
00:21:37FromDiscord<Rika> https://github.com/cheatfate/nimcrypto/blob/master/nimcrypto/sha2.nim
00:22:37FromDiscord<Nilts> In reply to @Rika "https://github.com/cheatfate/nimcrypto/blob/master/": is sha2 fast?
00:22:56FromDiscord<Rika> are you sure you want to be concerned about speed before security?
00:23:16FromDiscord<Rika> well, rather, do you know that you need speed
00:23:29FromDiscord<Rika> but yes it can be assumed that it is fast
00:23:35FromDiscord<Rika> but it depends on what you need it for
00:23:40FromDiscord<Nilts> In reply to @Rika "are you sure you": no, I was just wondering if it was incredibly slow (I am making a website)
00:23:46FromDiscord<Nilts> In reply to @Rika "but it depends on": passwords?
00:23:52FromDiscord<Rika> sha2 is wildly used
00:24:07FromDiscord<Rika> for passwords it is recommended to go with another algorithm
00:24:17FromDiscord<Rika> like bcrypt or argon2
00:25:07FromDiscord<Nilts> In reply to @Rika "like bcrypt or argon2": are any of those in nimcrypto or another lib?
00:26:02FromDiscord<Rika> https://github.com/Ahrotahn/argon2 binding
00:26:14FromDiscord<amadan> https://github.com/PhilippMDoerner/nimword this also supports argon2
00:26:55FromDiscord<Rika> sure
00:29:24FromDiscord<Nilts> In reply to @Rika "https://github.com/Ahrotahn/argon2 binding": what should salt be (Sorry I am new)
00:29:31FromDiscord<Nilts> (edit) "new)" => "new to password hashing)"
00:29:51FromDiscord<Rika> random value that you store unmodified alongside the password
00:29:53FromDiscord<Rika> (edit) "random value that you store unmodified alongside the password ... " added "hash"
00:29:56FromDiscord<Rika> (edit) "random value that you store unmodified alongside the password hash ... " added "in the database"
00:30:31FromDiscord<Rika> https://www.globalsign.com/en/blog/what-is-password-salting maybe helps
00:40:21FromDiscord<Nilts> In reply to @Rika "random value that you": but then both are leaked in a database leak (if that happens)
00:40:34FromDiscord<Rika> In reply to @not logged in "but then both are": yes that is inevitable
00:40:55FromDiscord<Nilts> In reply to @Rika "yes that is inevitable": then how does it make it more secure?
00:40:55FromDiscord<Rika> without a salt, an adversary can precalculate a bunch of hashes for weak passwords
00:41:20FromDiscord<Rika> with a salt, the adversary then also needs to make the calculation with the salt
00:41:23FromDiscord<Rika> but the salt is random
00:41:31FromDiscord<Rika> so they cant really precalculate anymore
00:41:38FromDiscord<Nilts> In reply to @Rika "so they cant really": ah
00:42:17FromDiscord<Nilts> how large should it be, and is https://nim-lang.org/docs/sysrand.html suitable
00:43:03FromDiscord<Rika> sysrand is okay↡size should be more than 32 bytes iirc
00:43:29FromDiscord<Rika> wait
00:43:33FromDiscord<Rika> 32 bits
00:43:34FromDiscord<Nilts> In reply to @Rika "sysrand is okay size": 64 ok?
00:43:35FromDiscord<Rika> lo
00:43:57FromDiscord<Rika> wait
00:43:58FromDiscord<Nilts> In reply to @Rika "32 bits": wait so 16 bytes should be enough?
00:44:06FromDiscord<Rika> i'm still searching on how many bytes
00:44:07FromDiscord<Rika> or bits
00:44:18FromDiscord<Rika> because the data is conflicting and im not a cryptographic expert
00:44:37FromDiscord<Rika> `Salt Length: The authors of Argon2 recommend this parameter to be 128 bits, but say it can be reduced to 64 bits in the case of space constraints.`
00:45:46FromDiscord<Nilts> In reply to @Rika "`Salt Length: The authors": so go with that?
00:46:58FromDiscord<Rika> sure yes
00:47:23*rockcavera quit (Remote host closed the connection)
01:00:08FromDiscord<flora1> "I'll teach 10individuals how to earn $100,000 in 72 hours from the crypto market. But you will pay me 10% commission when you receive your profit. if interested send me a direct message by asking me (HOW) for more details on how to get startedhttps://t.me/FloraGordon
01:00:23*azimut joined #nim
01:05:01FromDiscord<βƒŸβƒŸ> <@&371760044473319454> crypto scam
01:07:50FromDiscord<Yepoleb> thanks
01:15:15FromDiscord<Rika> i misread as crypto spam and i was confused lmao
01:15:32FromDiscord<Rika> like "yes but i think your image of crypto is a bit wrong"
01:38:13FromDiscord<Dudugz> Can someone give me an example of threading in Nim to run two heavy tasks in parallel?
01:38:28FromDiscord<Dudugz> I'm not sure how I'm supposed to do this.
01:38:45*arkurious quit (Quit: Leaving)
01:39:33FromDiscord<Dudugz> And it would also be nice if you could tell me if I could have all the clients of a server running on one thread, like accept the connection and then create an object that handles that connection on one thread
01:54:19*ltriant quit (Read error: Connection reset by peer)
01:59:34*ltriant joined #nim
02:07:10FromDiscord<michaelb.eth> In reply to @Dudugz "And it would also": for that purpose, checkout mummy: https://github.com/guzba/mummy
02:07:31FromDiscord<michaelb.eth> > Mummy operates with this basic model: handle all socket IO on one thread and dispatch incoming HTTP requests and WebSocket events to a pool of worker threads. Your HTTP handlers probably won't even need to think about threads at all.
02:08:27FromDiscord<Dudugz> TCP tho, not http
02:08:32FromDiscord<Dudugz> But i'll check
02:08:37FromDiscord<michaelb.eth> ah, I see
02:09:09FromDiscord<Dudugz> Yea no, i'm using TCP server, not HTTP
02:09:21FromDiscord<Dudugz> mummy is purely http-oriented
02:09:46FromDiscord<michaelb.eth> sure, but I'm wondering if you could take some inspiration from some of its internals
02:10:12FromDiscord<michaelb.eth> I may have misunderstood your use case, though
02:10:22FromDiscord<michaelb.eth> (edit) removed "some"
02:11:10FromDiscord<Dudugz> Maybe, I wanted to understand how threading works in Nim but there is no useful article, the one I found spoke of system/threads which says it is not to be imported
02:11:22FromDiscord<Yardanico> I don't do multithreading stuff, but from some basic info iirc you can listen on the same port in different threads with SO_REUSEPORT?
02:11:45FromDiscord<Dudugz> It's not what I meant
02:12:06FromDiscord<Dudugz> I meant to accept the connection with the client and invoke a thread to handle the client
02:12:12FromDiscord<Yardanico> In reply to @Dudugz "Maybe, I wanted to": the note about the import is just because everything in system is always imported
02:12:23FromDiscord<Yardanico> Threads module is always imported when you have --threads:on
02:12:37FromDiscord<Dudugz> Yes but the example there is not very clear either
02:12:59FromDiscord<Yardanico> If you're getting errors in the IDE it's because you also have to add the switch to the config file for your main Nim file so it picks it up
02:13:03FromDiscord<Dudugz> Like thereads[i].createThread(i, func, (x, y))
02:13:18FromDiscord<Dudugz> (edit) "thereads[i].createThread(i," => "threads[i].createThread(i,"
02:13:29FromDiscord<Yardanico> In reply to @Dudugz "Like threads[i].createThread(i, func, (x,": that just creates a thread and passes some arguments to our
02:13:31FromDiscord<Yardanico> to it
02:13:52FromDiscord<michaelb.eth> In reply to @Dudugz "Maybe, I wanted to": one thing to be aware of is that the default memory model in 1.6 and earlier is different than the memory model in upcoming 2.0 (and its release candidates), and that has a bearing on inter-thread communication
02:14:45FromDiscord<Dudugz> Hmm
02:14:45FromDiscord<michaelb.eth> (edit) "In reply to @Dudugz "Maybe, I wanted to": one thing to be aware of is that the default memory model in 1.6 and earlier is different than the ... memory" added "default"
02:15:07FromDiscord<Yardanico> yeah, refc has local heap
02:15:23FromDiscord<Yardanico> arc/orc have a global one, but you still need to ensure that only one thread accesses same location
02:15:36FromDiscord<Yardanico> Since Nim refs aren't atomic
02:17:48FromDiscord<Elegantbeef> Well not really true that they cannot both access it
02:17:55FromDiscord<Elegantbeef> More just you have to ensure one thread is the owner
02:25:02*xet7 joined #nim
02:47:44FromDiscord<leorize> and you're limited to looking at the ref
02:47:49FromDiscord<leorize> copying it can be fatal
02:48:14FromDiscord<Elegantbeef> All the `{.cursor.}`sd
03:41:08FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4tTr
03:41:29FromDiscord<Rika> no
03:41:49FromDiscord<Dudugz> Hm, there isn't a decent example on the internet so I don't know how to do it
03:42:58FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4tTs
03:43:10FromDiscord<Dudugz> '-' what's the difference
03:43:25FromDiscord<Dudugz> does the same thing just stores the thread in a variable
03:43:37FromDiscord<Rika> im not sure what you meant then
03:43:55FromDiscord<Elegantbeef> create thread takes a `var Thread`
03:44:04FromDiscord<Rika> noit the type
03:44:06FromDiscord<Dudugz> Oh, got it
03:44:51FromDiscord<Elegantbeef> https://nim-lang.org/docs/threads.html#examples to b e fair there is an example
03:45:13FromDiscord<Dudugz> Not a good one tho
03:45:21FromDiscord<Dudugz> this example is confusing
03:46:33FromDiscord<Rika> i dont really see how
03:46:46FromDiscord<Rika> tehn again ofc
04:09:14FromDiscord<Yardanico> In reply to @Dudugz "this example is confusing": anything specific?
04:11:24FromDiscord<Yardanico> sent a long message, see http://ix.io/4tTz
04:11:35*azimut quit (Ping timeout: 255 seconds)
04:12:20*pharonix71 quit (Remote host closed the connection)
04:12:34*azimut joined #nim
04:12:53*pharonix71 joined #nim
04:13:48FromDiscord<Yardanico> I do agree that there should be more blog posts and examples on this, since it seems that everyone has to figure out how threads in Nim exactly work by themselves
04:13:50FromDiscord<Yardanico> :)
04:13:57FromDiscord<Yardanico> and info is scattered through a lot of forum topics and chats, e.g. https://forum.nim-lang.org/t/9309
04:14:26FromDiscord<Elegantbeef> Especially with orc being default it's certainly going to be needed
04:15:49FromDiscord<Yardanico> --threads:on by default is going to be a fun surprise to all the async users ;)
04:16:03FromDiscord<Yardanico> especially with new changes to gcsafe which made me cast(gcsafe) for telebot
04:16:30FromDiscord<Yardanico> on its own that didn't work btw, so I also added --threadAnalysis:off
04:16:52arkanoidI have a piece of code that works on linux but does not on windows. Initial debugging shows me that this seems related on how different is the linux and windows asyncdispatch implementation
04:17:04FromDiscord<Yardanico> and yes, just --threadAnalysis:off doesn't work, only when it's together with cast(gcsafe)
04:17:16FromDiscord<Yardanico> @Arkanoid that certainly can be the case since asyncdispatch has different implementations for selectors depending on the OS
04:18:20FromDiscord<Yardanico> https://nim-lang.org/docs/selectors.html has some info about it
04:25:20*derpydoo joined #nim
04:32:11*lucasta quit (Remote host closed the connection)
04:32:42*lucasta joined #nim
04:33:12*onetwo quit (Quit: The Lounge - https://thelounge.chat)
04:35:14arkanoidthanks. I've opened a github issue with minimal example for the relevant package
04:36:21FromDiscord<Yardanico> can you link it here too?
04:52:44arkanoidYardanico: https://github.com/simonkrauter/NiGui/issues/174
04:52:50FromDiscord<Yardanico> ohh, nigui
04:54:08arkanoidyes, I'm playing with it. it is nice, until I forced myself into using async with it. I went smooth with linux, but windows behaves weird
04:54:27arkanoidI'm now really into windows, so it is quite hard for me to understand what is going on
05:16:58FromDiscord<Bung> `..\config.nims(1, 2) Error: unknown warning: UnnamedBreak` how to solve this in devel ? I have remove `csources_v2` and run `build_all.bat`
05:17:22FromDiscord<Elegantbeef> Have you removed your build cache?
05:17:59FromDiscord<Bung> where it located ?
05:18:15FromDiscord<Elegantbeef> `~/.cache/nim/...`
05:18:54FromDiscord<Yardanico> and on windows it's in user folder
05:20:25*lucasta quit (Read error: Connection reset by peer)
05:21:04FromDiscord<Bung> `~/nimcache` right? I don't find `~/.cache/nim/`
05:21:19FromDiscord<Yardanico> In reply to @Bung "`~/nimcache` right? I don't": no, it should be ~/.cache/nim on linux at least
05:21:27FromDiscord<Yardanico> /home/yourname/.cache/nim/
05:22:16FromDiscord<Yardanico> this is if we're talking about generic nim cache, nim compiler saves cache in a separate folder
05:22:34FromDiscord<Yardanico> check your Nim folder, it should have a `nimcache` folder
05:23:30FromDiscord<Bung> oh, I see , thank you guys
05:41:00*advesperacit joined #nim
05:42:34*derpydoo quit (Quit: derpydoo)
05:43:30*ltriant quit (Read error: Connection reset by peer)
05:45:04*derpydoo joined #nim
05:48:44*ltriant joined #nim
06:46:45FromDiscord<JeysonFlores> sent a long message, see http://ix.io/4tU7
06:48:19FromDiscord<Elegantbeef> Your way is more sensible
06:48:21*PMunch joined #nim
06:48:25*Notxor joined #nim
06:49:38FromDiscord<JeysonFlores> what do you mean with "sensible"?
06:50:03FromDiscord<Elegantbeef> I mean it's what i do
06:50:34FromDiscord<JeysonFlores> oh I see
06:51:29FromDiscord<Elegantbeef> Then again i'd probably not use a callback, but i'm a weirdo that prefers static typing
06:54:29*adigitoleo_ joined #nim
07:15:12*cm quit (Ping timeout: 255 seconds)
07:29:32*Notxor quit (Remote host closed the connection)
07:33:42*Notxor joined #nim
07:37:45*Notxor quit (Remote host closed the connection)
07:39:34FromDiscord<Dudugz> In reply to @JeysonFlores "which is the right": well, not that i can opine much but the first version gives me a lot more trouble to read than the last
07:40:46FromDiscord<Dudugz> It makes the proc ugly and there is no real need to have the parameters on several lines, if you have several parameters then make an Options object
07:41:54*adigitoleo_ quit (Quit: adigitoleo_)
07:44:25FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4tUn
07:45:48FromDiscord<Dudugz> In reply to @Elegantbeef "Then again i'd probably": You're just not used to using FP :v I rather prefer it since it makes more sense than having a body out of thin air
07:45:55FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tUo
07:46:00FromDiscord<Yardanico> you'll be allocating heap memory for nothing
07:46:09FromDiscord<Dudugz> Hm, yes, I forgot
07:46:23FromDiscord<Dudugz> (edit) "https://play.nim-lang.org/#ix=4tUn" => "https://play.nim-lang.org/#ix=4tUp"
07:48:06FromDiscord<JeysonFlores> sent a code paste, see https://play.nim-lang.org/#ix=4tUs
07:48:41FromDiscord<Yardanico> In reply to @JeysonFlores "Is this a common": not very common, no
07:48:51FromDiscord<Dudugz> The thing is, Nim doesn't seem to have an exact pattern, you kind of pick and choose which one you prefer. And this pattern of using options is not exclusive to one language, I've seen it in several.
07:49:18*Notxor joined #nim
07:49:28FromDiscord<Yardanico> yes, Nim allows you to write in the style that you want, not in the style that some random tool forces you to :)
07:49:50FromDiscord<Yardanico> UFCS, partial case insensitivity, macros, functional vs imperative, OOP (methods) vs composition (object variants + procs), etc etc
07:50:07FromDiscord<Dudugz> Go, JS, TS, Java, Rust... You see this pattern more in libraries that export functions that offer a great deal of customization, i.e. you can customize most of the functionality from the library.
07:50:18FromDiscord<Dudugz> In reply to @Yardanico "yes, Nim allows you": Yea lol
07:50:25FromDiscord<JeysonFlores> In reply to @JeysonFlores "Is this a common": I'm not a big fan of making specific classes/types that only are used as intermediate abstractions since I tend to forgot their purpose and after some time I end up believing that piece of code is more important than what really is
07:51:08FromDiscord<Dudugz> Well, Nim doesn't seem to have interfaces, usually you create interfaces to serve as options.
07:51:47FromDiscord<Dudugz> In reply to @JeysonFlores "I'm not a big": So the objective was not well defined or the name was not clear enough πŸ€·β€β™‚οΈ
07:51:52FromDiscord<Elegantbeef> What?↡(@Dudugz)
07:52:53FromDiscord<Dudugz> Functional programming, you say you don't really like using procs in other procs. I'm used to it because of JS where you can do something like array.map((item) => item 2)
07:53:16FromDiscord<Yardanico> In reply to @Dudugz "Functional programming, you say": you can do same in Nim, even shorter
07:53:20FromDiscord<Yardanico> array.mapIt(it 2)
07:53:32FromDiscord<Elegantbeef> It's not about FP
07:53:37FromDiscord<Elegantbeef> It's about attaching type related operations to types
07:53:38FromDiscord<Dudugz> You seem to prefer having a block of nothing:↡array.map(item 2) // where does item come from?
07:53:47FromDiscord<Elegantbeef> No
07:53:55FromDiscord<Yardanico> @Dudugz you can always make your own version that forces you to explicitly name the variable
07:54:03FromDiscord<Yardanico> like array.mapCustom(it, it 2)
07:54:09FromDiscord<Dudugz> In reply to @Elegantbeef "It's about attaching type": Got it
07:54:12FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4tUv i already wrote a CLI prompter to demonstrate code reuse
07:54:22FromDiscord<Elegantbeef> https://www.jasonbeetham.com/codereuse.html bottom of this
07:54:40FromDiscord<Elegantbeef> In most cases it's just an interface for a given type
07:54:51FromDiscord<Elegantbeef> Nim provides generic interfaces for this
07:55:59FromDiscord<Dudugz> In reply to @Yardanico "<@265937132886032407> you can always": Nah, unnecessary, I'm not going to create an abstraction layer just for that, it just doesn't make sense since it takes away readability, it's not a matter of the name being ``It`` it's a matter of it being there implicitly
07:56:18FromDiscord<Elegantbeef> I mean `array.map[it](it 2)`
07:56:25FromDiscord<Elegantbeef> There are many ways to declare the variable πŸ˜„
07:56:50FromDiscord<Elegantbeef> I personally prefer `mapIt` which makes it clear
07:57:04FromDiscord<Yardanico> In reply to @Dudugz "Nah, unnecessary, I'm not": but `mapIt` says `it` directly
07:57:21FromDiscord<Elegantbeef> But we're not talking about FP anywho
07:57:32FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4tUw
07:57:34FromDiscord<Elegantbeef> If you're parsing a type it makes much more sense to make it a generic interface
07:57:55FromDiscord<Yardanico> In reply to @Dudugz "Welp ``array.map(it * 2)``": there will be no issues, since mapIt is a template
07:58:10FromDiscord<Yardanico> and it injects it by itself
07:58:18FromDiscord<Yardanico> and local scope variables shadow outer scope ones
07:58:26FromDiscord<Elegantbeef> What about the naming conflict of `array.map(proc(x: int): int = (let x = "hello";...))`
07:58:31FromDiscord<Dudugz> Yes, precisely, what if you wanted to use an external variable?
07:58:35FromDiscord<Yardanico> In reply to @Dudugz "Yes, precisely, what if": ??
07:58:39FromDiscord<Yardanico> you just use it, it'll work
07:58:45FromDiscord<Dudugz> '-' named it?
07:58:55FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tUx
07:58:57FromDiscord<Yardanico> works just fine
07:59:05FromDiscord<Elegantbeef> Yardanico they're proposing the silly case of what if you named a variable it and want to use it internally
07:59:07FromDiscord<Yardanico> it's only `it` that gets injected specifically into the code by the template
07:59:24FromDiscord<Dudugz> In reply to @Elegantbeef "What about the naming": It wouldn't actually be a conflict it would just be redeclaring x within the scope of the function
07:59:34FromDiscord<Elegantbeef> That's my point
07:59:45FromDiscord<Elegantbeef> It's a non issue unless you really write shit code
08:00:01FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tUA
08:00:06FromDiscord<Elegantbeef> Who writes that
08:00:07FromDiscord<Dudugz> yea lol, nobody would name a variable as ``it``
08:00:42FromDiscord<Elegantbeef> Even if you do write a variable named `it` you can just do `let otherName {.cursor.} = it`
08:00:56FromDiscord<Dudugz> Hm
08:01:43FromDiscord<Dudugz> well, since Nim doesn't seem to have something like a lambda or arrow function I understand why using this implicit syntax is better than creating a proc with the types and parameters
08:01:54FromDiscord<Elegantbeef> I mean it does have \`std/sugar
08:02:09FromDiscord<Dudugz> ``myArr.map(lambda it: it 2)`` seems more readable
08:02:13FromDiscord<Elegantbeef> I think the implicit is just better regardless
08:02:31FromDiscord<Elegantbeef> `myArr.map((it) => it 2)` is valid with `std/sugar`
08:02:43FromDiscord<Dudugz> Hm, that's nice then
08:04:38FromDiscord<Yardanico> In reply to @Dudugz "Hm, that's nice then": yes, but it's ~less efficient~
08:04:50FromDiscord<Yardanico> my performance 😒
08:04:55FromDiscord<Elegantbeef> Well it can be assuming the C compiler doesnt inline
08:05:08FromDiscord<Yardanico> i mean, it's a closure by default
08:05:24FromDiscord<Yardanico> so I don't think it will, although I don't know how well C compilers optimize Nim code
08:05:43FromDiscord<Elegantbeef> Right it's a closure
08:05:45FromDiscord<Elegantbeef> I take it back
08:06:25FromDiscord<Elegantbeef> Cannot even fix it cause people use the `=>` macrro
08:06:41FromDiscord<Elegantbeef> Unless that's also a closure i do not recall
08:10:01FromDiscord<Elegantbeef> But in closing the point was more just about that many things can just be implemented at a type level and do not need to have these pointer procs around
08:19:47FromDiscord<Bung> what have changed ? I do `.\koch.exe temp c tests/sets/t13764.nim` got error, but `.\koch.exe temp check tests/sets/t13764.nim` don't
08:21:35FromDiscord<leorize> `c` compiles to binary, `check` only runs sem
08:27:09FromDiscord<Bung> thanks! I see they are different level errors
08:54:56NimEventerNew thread by Oecophylla: Hex to bytes - How to convert , see https://forum.nim-lang.org/t/10118
09:25:31FromDiscord<Ras> sent a code paste, see https://play.nim-lang.org/#ix=4tVb
09:26:36*Notxor quit (Remote host closed the connection)
09:31:08FromDiscord<Ras> sent a code paste, see https://play.nim-lang.org/#ix=4tVe
09:58:06*jmdaemon quit (Ping timeout: 255 seconds)
10:21:19*PMunch quit (Ping timeout: 276 seconds)
10:49:48*derpydoo quit (Quit: derpydoo)
11:01:07*PMunch joined #nim
11:04:00*lain quit (Ping timeout: 252 seconds)
11:04:42*lain joined #nim
11:05:22FromDiscord<auxym> In reply to @Ras "hello! i'm trying to": IIRC it's just that `char` is not interchangeable with `uint8` in nim. `toSeq(someString)` returns `seq[char]`
11:05:47FromDiscord<Ras> makes sense
11:05:52FromDiscord<Ras> thanks
11:44:39NimEventerNew question by shirleyquirk: How can you get the sizeof an untyped type identifier, inside a macro?, see https://stackoverflow.com/questions/76072831/how-can-you-get-the-sizeof-an-untyped-type-identifier-inside-a-macro
12:27:16*kenran joined #nim
12:57:14FromDiscord<michaelb.eth> In reply to @Ras "hello! i'm trying to": you might find useful toBytes from stew/byteutils
12:58:08FromDiscord<michaelb.eth> https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L244
13:04:23FromDiscord<firasuke> so execProcesses starts commands in parallel, is there a particular order? also how do you store output and track exit status for the commands?
13:16:36*kenran quit (Remote host closed the connection)
13:29:23FromDiscord<voidwalker> @firasuke https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/osproc.nim#L362 obviously in the order they are given in the `cmds` array.
13:30:09FromDiscord<firasuke> oh ok interesting, and what about handling output and exit codes?
13:35:35FromDiscord<voidwalker> From reading the proc definition, I do not think this is possible, you only get one exit code for all, and no output ? :\
13:36:18FromDiscord<voidwalker> hmm unless afterRunEvent is meant for that
13:36:27FromDiscord<voidwalker> (edit) "afterRunEvent" => "`afterRunEvent`"
13:37:55FromDiscord<voidwalker> `afterRunEvent: proc (idx: int; p: Process) = nil` seems you get access to the index and the Process in that proc that you can define and pass to execProcesses
13:40:58FromDiscord<voidwalker> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/osproc.nim#L67
13:41:39FromDiscord<voidwalker> If someone can tell us if the fields of `ProcessObj` are exported by `Process = ref ProcessObj` (not sure?).
13:41:56FromDiscord<voidwalker> If yes, then your answer is in ` inStream, outStream, errStream: owned(Stream)↡ exitStatus: cint`
13:42:37*progranner joined #nim
13:43:28FromDiscord<firasuke> oh ok
13:44:49FromDiscord<voidwalker> yeah it seems they are all exported by using that syntax
13:45:45FromDiscord<voidwalker> So you must write a proc that handles the output stream read, exit status, and pass that when calling execProcesses
13:48:34FromDiscord<firasuke> so that proc should be passed as a parameter to execProcesses using afterRunEvent, and in that proc I can handle outStream and errStream and exitStatus
13:50:01FromDiscord<voidwalker> yeah, like this : https://github.com/juancarlospaco/nim-presentation-slides/blob/3236a03aef31dbabb43b34b3a486184f54fc077c/ejemplos/avanzado/multiprocess/multiprocess3.nim#L3
13:50:31FromDiscord<firasuke> oh interesting, thanks for the examples, much appreciated
13:51:38FromDiscord<firasuke> wonder if we can also contorl what workingDir is being used
14:03:35FromDiscord<voidwalker> well, this "convenience" proc, execProcesses, does not seem to take workingDir arguments.. it would have to be another array anyway, for each command
14:05:13FromDiscord<voidwalker> I believe the only way to do this, with this proc, would be to modify it, and use the modified file instead of the nim stdlib one
14:05:54FromDiscord<voidwalker> well, I guess that's a shitty solution. You could reimplement the proc and modify it to take workingDirs array. and use that instead
14:10:54*PMunch quit (Quit: Leaving)
14:31:14FromDiscord<firasuke> interesting
14:35:46FromDiscord<voidwalker> yeah, I guess nim's stdlib is not a magical swiss army knife.. I myself needed features not present in the procs two times now, and needed to mod them
14:37:10FromDiscord<firasuke> well I appreciate the clarity of the language which helps a lot
14:38:13*jmdaemon joined #nim
14:41:28*krux02 joined #nim
14:48:03*arkurious joined #nim
14:48:36*arkurious quit (Remote host closed the connection)
14:58:16*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:00:23*progranner joined #nim
15:02:19*Notxor joined #nim
15:09:38*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
15:09:56*jmdaemon joined #nim
15:11:10*al1ranger joined #nim
15:23:16*al1ranger quit (Quit: Leaving)
15:23:35*jmdaemon quit (Ping timeout: 264 seconds)
15:23:54*om3ga quit (Ping timeout: 255 seconds)
15:35:06FromDiscord<firasuke> I want to split a sequence into multiple sub sequences of length "X", I am using distribute, but it appears that distribute splits the sequence into "X" subsequences, when in fact I don't care about how many sub sequences are split into, but rather the length of each
15:44:09*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:44:45*progranner joined #nim
15:46:24*progranner quit (Client Quit)
15:47:03*progranner joined #nim
15:51:09FromDiscord<voidwalker> hmm
15:51:34FromDiscord<voidwalker> @firasuke maybe just do mySeq.distribute(mySeq.len div X) ?
15:52:04FromDiscord<firasuke> I was considering this as well, what about type casting and remainders?
15:52:14FromDiscord<firasuke> (edit) "was" => "am"
15:54:58FromDiscord<firasuke> Like it expects `int` not a float
15:59:00FromDiscord<voidwalker> Oh my bad, you want seqs not to exceed length X
16:01:56FromDiscord<voidwalker> let me think
16:04:23FromDiscord<voidwalker> So if you have a seq of len 16, and want to split into length 11, you would have one of len 11, and one of 5 for remainder?
16:04:33FromDiscord<Nerve> In reply to @firasuke "I want to split": You can do that math on how many subsequences of length X you can get from a seq, then call `distribute` with that length
16:04:39FromDiscord<Nerve> (edit) "that" => "the"
16:05:12FromDiscord<Nerve> (edit) "length" => "number"
16:05:15FromDiscord<voidwalker> If so, distribute won't work, as it distributes, as its name says, the elements evenly
16:05:29FromDiscord<Nerve> Oh, it's only evenly?
16:05:41FromDiscord<Nerve> Is there an equivalent to `take` in Nim?
16:05:56FromDiscord<voidwalker> sent a code paste, see https://paste.rs/QRF
16:07:25FromDiscord<firasuke> In reply to @voidwalker "So if you have": Not really, I want it to be split into sequences of X size, so 16 with 5 size would be split into 4 sequences, first three containing 5, and the last one containing 1
16:08:20FromDiscord<firasuke> sent a long message, see http://ix.io/4tWt
16:09:20FromDiscord<voidwalker> yeah, that's what I said
16:11:47FromDiscord<firasuke> Oh ok
16:12:56*azimut quit (Ping timeout: 255 seconds)
16:23:52FromDiscord<voidwalker> @firasuke it seems that there is no way to keep control of the max elements in the subsequences with `distribute`
16:24:16FromDiscord<firasuke> Hmm, so guess I'll be using an additional for loop
16:24:37FromDiscord<voidwalker> An array with 16 elements of max 5 subsequence, would need to have 5,5,5,1 elements
16:24:55FromDiscord<voidwalker> If you distribute 16 len sequence with distribute, you get 4,4,4,4
16:25:21FromDiscord<firasuke> Yup
16:25:23FromDiscord<voidwalker> (edit) "If you distribute 16 len sequence ... with" added "into 4 subsequences"
16:26:04FromDiscord<voidwalker> so diy proc for this, or write it in place : )
16:26:35FromDiscord<firasuke> 16 is just an example, for example a 100, I need 20 sub sequences length 5, not 5 sub sequences length 20 which is what distribute is doing
16:29:22FromDiscord<voidwalker> well if sequence length is divisible by the subsequence max Length, then this is achievable. .distribute(20) will do (20= 100 div 5)
16:29:33FromDiscord<voidwalker> (edit) "do" => "work."
16:33:00FromDiscord<guttural666> In reply to @Yardanico "you can make anything": that is what I am trying to do now πŸ˜›
16:37:31FromDiscord<guttural666> do I need a channel to give one thread an interrupt signal from another thread? I would just naively set a global variable to interrupt = true in one thread and then check that field periodically in the other thread?
16:38:45*cm joined #nim
16:41:24FromDiscord<Chronos [She/Her]> I'm thinking of maybe making my MC server impl from scratch again tbh
16:41:42FromDiscord<Chronos [She/Her]> And using WASM for a plugin system, but that means speed is more important
16:42:37FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4tWy
16:43:29FromDiscord<firasuke> Thanks, I'll try that
16:52:42FromDiscord<guttural666> @ElegantBeef I think you mentioned the other day that echo was thread safe, the manpage for threads has this example though? https://media.discordapp.net/attachments/371759389889003532/1099014861368852551/image.png
17:09:42FromDiscord<guttural666> hmm, VSCode / nimsuggest doesn't seem to be aware of the thread module, but that should be included in the system module, but it does compile, is this a bug in nimsuggest? https://media.discordapp.net/attachments/371759389889003532/1099019140016123944/image.png
17:12:06FromDiscord<jmgomez> try adding a nim.cfg file with `--threads:on`
17:12:53FromDiscord<guttural666> In reply to @jmgomez "try adding a nim.cfg": I do obviously compile with --threads:on, never heard about nim.cfg, gonna read up on that, thanks!
17:14:15FromDiscord<jmgomez> you can also use config.nims, it will try to read it to debbug your issue furhter you can check out: https://nim-lang.org/docs/nimsuggest.html↡There is `nimsuggest --stdin yourfile` you can inspect better there what's going on
17:14:28FromDiscord<jmgomez> (edit) "it to" => "it. To"
17:14:43FromDiscord<jmgomez> (edit) "furhter" => "further"
17:18:01FromDiscord<guttural666> perfect, VSCode/nimsuggest seems to be happy now, thanks for the tip!
17:18:32FromDiscord<guttural666> I previously just had an alias in my fishconfig to pass the compiler flags, but this is much better, also for git clones etc.
17:19:52FromDiscord<guttural666> threads to set interrupt signals also works like a charm, this is awesome
17:20:32FromDiscord<guttural666> would have preferred just an async readLine(stdin), but this works
17:25:36*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:27:26*progranner joined #nim
17:29:03*progranner quit (Client Quit)
17:30:04*progranner joined #nim
17:31:07FromDiscord<guttural666> I think enums should initialize to the first value, right?
17:32:47FromDiscord<guttural666> nah okay, need to init with enum.default
17:37:05*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:54:23*progranner joined #nim
18:05:23*lucasta joined #nim
18:07:00*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
18:14:06*progranner joined #nim
18:43:52*jmdaemon joined #nim
18:55:14*jmdaemon quit (Ping timeout: 250 seconds)
19:04:51FromDiscord<guttural666> seen this in Zig talk, is this somehow addressable in Nim? https://media.discordapp.net/attachments/371759389889003532/1099048116017188914/image.png
19:07:03FromDiscord<Yardanico> "hopeless" is some strong wording lol
19:07:07FromDiscord<Nerve> Reference counters are not hidden, garbage collectors can be bounded and manually triggered, arena allocation can obviate new allocations for a program's entire runtime. Nim supports these all AFAIK.
19:07:19FromDiscord<Nerve> (edit) "triggered," => "triggered which "unhides" them,"
19:07:29FromDiscord<Yardanico> In reply to @guttural666 "seen this in Zig": it probably is, but Nim was never meant to be used with explicit memory allocations everywhere
19:07:49FromDiscord<Yardanico> this point is only concerning languages like C, and Zig tries to be a competitor to C
19:07:59FromDiscord<Yardanico> it doesn't try to be a general-purpose high-level language, not with manual memory allocation ;)
19:09:00FromDiscord<Nerve> It is also fair to note that RC and GC are the only extant memory management approaches which near-as-makes-no-difference eliminate memory semantics in programs, such that business logic is all that remains.
19:09:48FromDiscord<guttural666> In reply to @Yardanico "this point is only": well, I think Nim should be a competitor to C as well, just as any other language, gotta go fast
19:11:09FromDiscord<Yardanico> In reply to @guttural666 "well, I think Nim": nim is already fast enough
19:11:10FromDiscord<guttural666> In reply to @Nerve "It is also fair": I am aware of this, but I also know that Discord people ditched Go because of GC and switched to Rust
19:11:22FromDiscord<Yardanico> i think nim would be a really different language if it had manual memory management
19:11:35FromDiscord<Yardanico> In reply to @guttural666 "I am aware of": yes, but Nim v2's "GC" isn't much different from Rust with ARC
19:11:45FromDiscord<guttural666> In reply to @Yardanico "yes, but Nim v2's": also aware
19:11:46FromDiscord<Nerve> There are good and bad GC strategies and implementations, Go's is famously poor and difficult to tune.
19:11:47FromDiscord<Yardanico> you have destructors/move semantics/etc and reference counting, which exists in Rust as well
19:11:54FromDiscord<Yardanico> ORC does add a cycle collector, but you can write your programs to avoid cycles
19:12:41FromDiscord<guttural666> I think my original question was: can you make Nim "pure" in the sense of ZIG and address these problems if you wanted to
19:12:57FromDiscord<Nerve> Just use RC
19:13:56FromDiscord<Yardanico> In reply to @guttural666 "I think my original": by not using any `ref` types or managed containers, yes
19:14:01FromDiscord<Yardanico> just use `alloc`/`dealloc`/`create`
19:14:16FromDiscord<Nerve> I should probably note here that RC is the default memory management strategy in C++ (`std::unique_ptr` and such)
19:14:17FromDiscord<Yardanico> you can still use destructors to ease manual memory management
19:14:28FromDiscord<Nerve> (edit) "I should probably note here that RC is the default ... memory" added "best-practice"
19:14:36FromDiscord<Yardanico> but "hidden memory allocations" goes directly against Nim the language as a whole
19:14:41FromDiscord<jmgomez> The issue left is strings and seqs though
19:14:42FromDiscord<Yardanico> (edit) ""hidden" => ""no hidden"
19:14:48FromDiscord<Yardanico> i said managed containers, yes
19:15:01FromDiscord<guttural666> In reply to @Nerve "Just use RC": I think that will not prevent hidden mem allocs in the stl and I think that is the point of Andrew Kelly et al
19:15:06FromDiscord<Yardanico> I know Zig enforces operators to just be default operators, while in Nim you can hide away a lot of complexity by overloading/templates/macros/etc
19:15:13FromDiscord<Yardanico> so really Nim wouldn't be the best language to try to enforce this
19:16:18FromDiscord<Nerve> In reply to @guttural666 "I think that will": If it's in the standard library then it's not hidden
19:16:58FromDiscord<jmgomez> It's hard to think a scenario where you will need to remove ref. That said, in NUE besides containers, we dont use ref but ptr everywhere. But thats just because UE has a mark and sweep GC
19:17:53FromDiscord<Nerve> Which is funny since UE is a realtime-constrained system. Is the foreign language interface for UE only for gameplay logic?
19:18:13FromDiscord<guttural666> In reply to @Nerve "If it's in the": it is if you your compiler doesn't tell you about that possibility, I think that is ZIGs approach
19:19:00FromDiscord<Nerve> In reply to @guttural666 "it is if you": I find it baffling that anybody would make use of a large standard library and not check if it makes heap allocations
19:19:04FromDiscord<guttural666> In reply to @jmgomez "It's hard to think": UE = Unreal Engine?
19:19:18FromDiscord<jmgomez> In reply to @Nerve "Which is funny since": Yeah, but you dont have that many objects alive all the time. In that sense, it's more performant that Unity's approach (Boehm?). Not sure what you mean with the later
19:19:21FromDiscord<Nerve> Anyone concerned about "perfect" software should avoid a standard library with any allocations
19:19:31FromDiscord<jmgomez> In reply to @guttural666 "UE = Unreal Engine?": yup
19:20:22FromDiscord<Nerve> In reply to @jmgomez "Yeah, but you dont": As in, are you only creating actors/governing interactions/swapping assets/executing rules? Or can you write shaders, rendering code, asset manipulation logic, physics, etc.
19:20:59FromDiscord<guttural666> In reply to @Nerve "Anyone concerned about "perfect"": sure sure, I don't think that is the issue here, I think ZIG people say that the compiler should tell you about this to enforce "perfect software"
19:21:08FromDiscord<huantian> In reply to @Nerve "Anyone concerned about "perfect"": Exactly, I think the main point is that Nim isn’t designed to be perfect but easy to use
19:21:23FromDiscord<huantian> However, you can still write perfect software, it just takes more effort
19:21:28FromDiscord<jmgomez> In reply to @Nerve "As in, are you": ah, well UE FFI is just C++ FFI which is C. The way we are hook is at different levels, but long story short you can do pretty much anything you can do in C++ at this point
19:22:46FromDiscord<jmgomez> Things that are not exposed, you can just manually bind and extend it in Nim (there are vfuncs implemented). More down the road I want to automatically bind the cpp side too
19:25:08FromDiscord<Nerve> Well, Zig and Rust are hype-driven projects in pursuit of some kind of "perfection" or purity ideal, and their hype momentum is going to do a lot of harm in the software world as people build projects with them which would be better served by automatic memory management, better modeling power, faster development velocity, etc. The evidence of this will be uncountable dead/abandoned projects.
19:25:28FromDiscord<guttural666> In reply to @Nerve "As in, are you": Nim is happy to this (C++ equivalent to vector.reserve) without handling bad alloc: https://media.discordapp.net/attachments/371759389889003532/1099053308464861184/image.png
19:25:33FromDiscord<Nerve> Maybe the projects have some pragmatism but I've yet to see much evidence
19:25:50FromDiscord<guttural666> (edit) "In reply to @Nerve "As in, are you": Nim is happy to ... this" added "do"
19:26:11FromDiscord<Nerve> (edit) "Maybe the ... projectsevidence." added "language" | "evidence" => "evidence."
19:26:16*om3ga joined #nim
19:27:15FromDiscord<Nerve> In reply to @guttural666 "Nim is happy to": Where is this function defined
19:27:33FromDiscord<guttural666> just does what vector.reserve does in C++
19:27:57FromDiscord<Yardanico> In reply to @guttural666 "Nim is happy to": That's not a stdlib function though, but it has similar ones
19:28:17FromDiscord<Yardanico> `setLen` for settings the length (filling with default values), and when creating containers you have `newSeqOfCap` or `newStringOfCap`
19:28:27FromDiscord<Yardanico> capacity will make it allocate memory for n items, but won't change the length
19:28:36FromDiscord<guttural666> In reply to @Yardanico "That's not a stdlib": yeah, it just does setLen on a seq to reserve the mem, then sets it back to the actual len
19:28:49FromDiscord<Yardanico> ah right, forgot about that :)
19:28:57FromDiscord<guttural666> thanks ElegantBeef haha
19:32:53FromDiscord<guttural666> my question was just, can you make Nim compatible to the standards of ZIG, because I hear a lot of this stuff in talks, I know you can turn GC off etc. etc. but the stl does not support custom allocators out of the box I think, you would have to rewrite stuff yourself
19:33:14FromDiscord<ricky> zg...
19:34:32FromDiscord<Yardanico> In reply to @guttural666 "my question was just,": you can do everything, it'd just be a completely different language
19:34:39FromDiscord<Yardanico> because it would require changing too much stuff
19:34:55FromDiscord<Yardanico> Zig is really an anti-thesis of NIm
19:35:12FromDiscord<Yardanico> as I said before, this is just a complete opposite of what Nim does https://media.discordapp.net/attachments/371759389889003532/1099055753958019133/image.png
19:36:26FromDiscord<Nerve> Same for Rust, total difference in philosophy. Rust makes it hard to write unsafe programs. Nim makes it easy to write safe programs. There is a distinct difference.
19:42:20FromDiscord<guttural666> I know the different philosophies guys, my question was a purely technical one πŸ˜›
19:42:39FromDiscord<Yardanico> but you know well yourself that from a technical perspective you can do anything given enough time
19:45:05FromDiscord<guttural666> In reply to @Yardanico "but you know well": suuure, I know you can do anything with Nim, I was just interested to hear about what people thought about that, when people say Nim is not able to do XYZ
19:46:09FromDiscord<guttural666> I know Nim is basically this https://media.discordapp.net/attachments/371759389889003532/1099058510915981342/image.png
19:46:18FromDiscord<Nerve> There is a direct correlation between the philosophy of a language and how difficult it is to do a given task that has a given alignment with that philosophy
19:46:46FromDiscord<Nerve> Philosophy informs design decisions, which determines the shape and interface of libraries, APIs, and language features
19:47:27FromDiscord<Nerve> So if Zig and Nim are philosophically misaligned, it's safe to say Nim can probably do the task but it won't be very Nim-ish
19:47:49FromDiscord<guttural666> In reply to @Nerve "So if Zig and": yes
19:48:49FromDiscord<guttural666> also ZIG has curlies and curlies are a pain in the ass to write on German keyboards
19:49:15FromDiscord<guttural666> indentation and text only is de way
19:57:47FromDiscord<Elegantbeef> What's "ZIG"?
19:59:11FromDiscord<Yardanico> NIM but the opposite
19:59:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tXf
19:59:26FromDiscord<Elegantbeef> You'll notice that it's indeed threadsafe
19:59:34FromDiscord<Elegantbeef> Ah that's what i though Yard
19:59:52FromDiscord<guttural666> In reply to @Elegantbeef "You'll notice that it's": okay, then the docs are wrong I think?
20:00:16FromDiscord<Elegantbeef> No?
20:00:23FromDiscord<guttural666> shouldn't have to lock stdout
20:00:39FromDiscord<Elegantbeef> You're right, but nothing says you have to
20:00:52FromDiscord<guttural666> In reply to @Elegantbeef "You're right, but nothing": misleading then ^^
20:01:00FromDiscord<guttural666> maybe old
20:01:24*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
20:02:36FromDiscord<Elegantbeef> Custom allocators are something i've considered making an RFC for that do it better than Zig, but do not think my solution is ideal
20:03:11FromDiscord<Elegantbeef> Custom allocators should be type bound, so something like `ref[int, Allocator = MyAllocator]` would be ideal in Nim
20:03:26FromDiscord<guttural666> In reply to @Elegantbeef "Custom allocators are something": that would work with overloading the stl procs I guess?
20:03:41FromDiscord<Elegantbeef> `string[Allocator = MyAllocator]` and so forth would have to be valid syntax and used
20:04:18FromDiscord<Elegantbeef> Well the idea is that a proc that takes `string` accepts all `string`s with any allocator
20:04:33*progranner joined #nim
20:04:33FromDiscord<Elegantbeef> but you could do allocator overloading since it'd be a generic parameter
20:04:59FromDiscord<guttural666> In reply to @Elegantbeef "but you could do": okay, nice
20:05:17FromDiscord<Elegantbeef> So like `proc(s: string[Allocator = NimAllocator])` and `proc(s: string[Allocator = MyAllocator])` are two separate procedures and could be overloaded
20:05:58FromDiscord<guttural666> yeah that would cover the pleeb use case and the advanced use case
20:06:46FromDiscord<Elegantbeef> It's the only premise that really fits with Nim
20:07:47FromDiscord<Phil> Awwww↡https://github.com/nim-lang/Nim/pull/21660#event-9066213244↡Phil sad now
20:11:03FromDiscord<Elegantbeef> It really should be a CT error anywho
20:11:45FromDiscord<Elegantbeef> Any upcast assignment should be a CT error
20:13:29FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tXj
20:13:37FromDiscord<Elegantbeef> This should not be valid
20:14:19FromDiscord<Elegantbeef> `assert sizeof(A()[]) != sizeof(B()[])`
20:14:24FromDiscord<jmgomez> beef FYI my pr for the modules that we discussed about a few weeks? ago got finally merged
20:14:32FromDiscord<Elegantbeef> Congrats
20:15:03FromDiscord<jmgomez> thanks!
20:16:26FromDiscord<jmgomez> btw what are your thoughts on allowing NimMain to be executed multiple times? No one seems to really care about it
20:16:51FromDiscord<Elegantbeef> It's supposed to be called once and most people have a `once: NimMain()`
20:18:31FromDiscord<jmgomez> thing is, I posted it on internals but with live++ which seems to work by doing a patch to the binary I need to call it again and it seems to fail only with 1.9 (1.6.x works) on exitProcs
20:20:17FromDiscord<Elegantbeef> Calling it multiple time is just wrong
20:21:07FromDiscord<jmgomez> so what solution do you propone to init globals?
20:21:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tXl
20:21:36FromDiscord<jmgomez> (edit) "propone" => "propose"
20:21:38FromDiscord<Elegantbeef> I mean calling it once is correct πŸ˜„
20:22:55FromDiscord<jmgomez> I mean, when I hook a dll it works fine calling it once, when the dll gets loaded. But since this tool only compiles the cpp that actually changed modules arent init if I dont call it or some are and some doesnt
20:23:24FromDiscord<jmgomez> When it's a dll the problem doesnt exist because all is fresh
20:24:08FromDiscord<Elegantbeef> Ah the issue is that you're using HCR and it does not properly reload the global data
20:24:21FromDiscord<jmgomez> right
20:24:25FromDiscord<Elegantbeef> I do not know what to say here
20:24:46FromDiscord<Elegantbeef> I'd argue the proper thing is to make Nim's HCR actually work
20:24:50FromDiscord<Elegantbeef> But that's a shit load of work
20:25:00FromDiscord<jmgomez> but that spins another dlls, right?
20:25:12FromDiscord<jmgomez> I mean, it's slower by definition
20:25:13FromDiscord<Elegantbeef> right
20:29:50FromDiscord<Elegantbeef> Well having the compiler handle it is just more sensible as it knows the shapes of thing
20:31:41FromDiscord<jmgomez> Yeah, I get that but as you said it's a lot of work and also it wouldnt be just to get working what already exists but also to do what Live++ is doing which I suppose is not a trivial thing to do.
20:32:19FromDiscord<jmgomez> I would be happy if the std doesnt crash and work as it used to work
20:32:37FromDiscord<guttural666> can I somehow save a slice of a seq to disk without copying? say I have a big seq that is async filled be another thread and I want to periodcally fetch all the new entries and save them to disk, I would prefer to just "view" a section of the seq and save that to disk without creating a new seq with a slice [last_looked_at..newest_entry]
20:33:05FromDiscord<Elegantbeef> `file.write(mySeq.toOpenArray(3, 5))`
20:33:22FromDiscord<Elegantbeef> `toOpenArray` is a view, but it cannot be stored to a variable
20:33:35FromDiscord<guttural666> just want to save that data to disk
20:33:38FromDiscord<Elegantbeef> Use it directly and problem solved
20:33:43FromDiscord<Elegantbeef> Just told you how
20:33:50FromDiscord<guttural666> okay, nice, gonna look at openArray
20:34:06FromDiscord<huantian> be careful you might turn into beef if you look at openArrays too much
20:34:10FromDiscord<guttural666> think you wrote on that topic on your notes that you posted?
20:34:19FromDiscord<Elegantbeef> Yea
20:34:36FromDiscord<Elegantbeef> https://www.jasonbeetham.com/codereuse.html to spam it yet again
20:34:56FromDiscord<guttural666> that would be safe if the seq does not move while I read right?
20:35:03FromDiscord<guttural666> thread safe I mean
20:35:11FromDiscord<Elegantbeef> Indeed
20:35:40FromDiscord<guttural666> which I could potentially guarantee with the reserve proc you proposed some days ago
20:36:01FromDiscord<guttural666> to do all this without locking
20:37:23*Notxor quit (Remote host closed the connection)
20:46:36*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
21:00:48*jmdaemon joined #nim
21:18:08FromDiscord<βƒŸβƒŸ> In reply to @guttural666 "I am aware of": .
21:18:30FromDiscord<βƒŸβƒŸ> when they switched they also changed their whole data structures i think
21:18:39FromDiscord<βƒŸβƒŸ> so its not to useful comparison
21:19:12FromDiscord<morgan> @treeform is the fidget export plugin on figma outdated or something? i'm getting some errors on code it generated
21:20:04FromDiscord<guttural666> In reply to @βƒŸβƒŸ "when they switched they": dunno I think I just read about this because of the Primeagen
21:21:39FromDiscord<βƒŸβƒŸ> you know what they say↡a nickel is half a dime
21:22:05*lucasta quit (Remote host closed the connection)
21:30:30FromDiscord<Elegantbeef> I thought a dime was two nickels
21:31:02FromDiscord<treeform> In reply to @MorganAlyssa "<@107140179025735680> is the fidget": Yes, sorry
21:31:18FromDiscord<DestyNova> In reply to @guttural666 "seen this in Zig": Seeing phrases like "hopeless" and "perfect software" makes it hard to take that seriously. And if "hidden memory allocations" makes a language hopeless, well why not continue that line of reasoning and say that the only "perfect" language is assembly?
21:32:32FromDiscord<morgan> In reply to @treeform "Yes, sorry": ok, i'm installing typescript rn to get the current one
21:36:33FromDiscord<Elegantbeef> @DestyNova\: the context matters so I hope it was in regard to something like Kernel or OS development πŸ˜„
21:38:28FromDiscord<voidwalker> What would be the shortest way to get Table[string, string] import/export to files ?
21:38:40FromDiscord<voidwalker> as in the fewest needed lines of code
21:38:47FromDiscord<voidwalker> (edit) "as in the fewest needed lines of code ... " added "and using only stdlib prefferably"
21:39:01FromDiscord<voidwalker> (edit) "prefferably" => "preferably"
21:39:02FromDiscord<Elegantbeef> Use Frosty or Flatty
21:39:13FromDiscord<Elegantbeef> Otherwise write your own serialiser
21:40:19FromDiscord<Elegantbeef> QED
21:40:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tXI
21:40:38FromDiscord<Elegantbeef> Could also just use std/json
21:56:22FromDiscord<ricky> sent a code paste, see https://play.nim-lang.org/#ix=4tXM
21:58:08*advesperacit quit ()
22:03:08FromDiscord<voidwalker> @ElegantBeef flatty looks very nice and simple, but it doesn't have proc variants that return the serialized string instead of putting it in a var
22:03:14FromDiscord<voidwalker> so I have to ` var s: string; toFlatty(s,cards); writeFile(readLine(stdin), s)`
22:03:57FromDiscord<voidwalker> instead of `writeFile(readLine(stdin), toFlatty(cards)`
22:04:01FromDiscord<Elegantbeef> `toFlatty` returns a string
22:04:05FromDiscord<voidwalker> (edit) "toFlatty(cards)`" => "toFlatty(cards))`"
22:04:14FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1099093259411804200/image.png
22:04:53FromDiscord<voidwalker> i was reading here: https://nimdocs.com/treeform/flatty/flatty.html
22:05:05FromDiscord<Elegantbeef> https://nimdocs.com/treeform/flatty/flatty.html#toFlatty%2CT
22:07:33FromDiscord<voidwalker> magic
22:09:07FromDiscord<Elegantbeef> No it's called overloading πŸ˜„
22:12:33FromDiscord<morgan> In reply to @treeform "Yes, sorry": i'm still getting the same error, it creates a "laInherit" for layoutAlign which doesn't seem to exist
22:13:01FromDiscord<morgan> (edit) ""laInherit"" => "`laInherit`""
22:40:09FromDiscord<morgan> just removed that for now. also ellipse doesn't exist yet
22:40:26FromDiscord<morgan> i think i just need circles so i'll replace them with rounded rectangles
22:44:04FromDiscord<voidwalker> no standard proc to find a key in a table if you know the value ? assuming values are unique
22:44:52FromDiscord<morgan> seems like fidget still needs a lot of work on instances
22:47:55FromDiscord<morgan> or at least the plugin does
23:01:13FromDiscord<Yardanico> In reply to @voidwalker "no standard proc to": i think you just iterate over values, since tables are hash tables
23:01:19FromDiscord<Yardanico> so there's no more efficient way
23:01:26FromDiscord<Yardanico> unless you sort the table of course
23:02:35FromDiscord<louis77> hey there, which data type would I use to model a JSON object? I've tried `OrderedTable[string, JsonNode]` but that gives me a very cryptic error message
23:02:52FromDiscord<Elegantbeef> `JsonNode` is what you'd use
23:03:08FromDiscord<louis77> `JsonNode` works obviously but that doesn't constrain to a proper JSON object which is a map of string->any
23:03:13FromDiscord<Yardanico> it does
23:03:19FromDiscord<Elegantbeef> `myJsonNode["hello"].getint`
23:03:31FromDiscord<Yardanico> i mean "any" can't happen in Nim because nim is statically typed, but JsonNode is an object variant that provides all possible JSON types
23:03:52FromDiscord<Elegantbeef> Nim is statically typed so it needs `getInt` and friends to extract data, but jsonnode is a variant type that in theory can any type
23:03:58FromDiscord<Elegantbeef> can represent any\
23:04:24FromDiscord<louis77> so coming from Go, I would use `map[string]interface{}` ... in Nim it is the JsonNode ?
23:04:39FromDiscord<Yardanico> you don't have a direct equivalent of that in Nim, what's your usecase?
23:04:57FromDiscord<Elegantbeef> Avoiding dynamically typed data is always best πŸ˜„
23:05:01FromDiscord<Yardanico> you can't just create a table that maps from a string to any type if you don't know the types beforehand
23:05:07FromDiscord<Yardanico> if you just want to do JSON, then use JsonNode, yeah
23:05:28FromDiscord<Yardanico> otherwise you generally use object variants, or maybe inheritance if that fits your use-case better
23:05:29FromDiscord<louis77> sent a code paste, see https://play.nim-lang.org/#ix=4tXT
23:05:39FromDiscord<Elegantbeef> What is the actually query though?
23:06:00FromDiscord<Elegantbeef> you can just use `std/json` and `std/jsonutils` to convert the data to your type
23:06:06FromDiscord<Yardanico> In reply to @louis77 "I get a JSON": yes that just works
23:06:13FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tXU
23:06:37FromDiscord<louis77> @Yardanico damn you are fast πŸ™‚
23:06:44FromDiscord<Yardanico> copilot wrote the json for me :)
23:07:04FromDiscord<Elegantbeef> Yea clearly was not yard he'd have used %\ πŸ˜›
23:07:10FromDiscord<louis77> just curious, why doesn't OrderedTable[string, JsonNode] not work?
23:07:17FromDiscord<Elegantbeef> What's the error?
23:07:46FromDiscord<louis77> sent a code paste, see https://play.nim-lang.org/#ix=4tXV
23:08:00*azimut joined #nim
23:08:00FromDiscord<Elegantbeef> You did `myTable = newJObject()`?
23:08:19FromDiscord<Elegantbeef> `myTable["key"] = newJObject()`
23:08:20FromDiscord<Yardanico> sent a code paste, see https://paste.rs/oRP
23:08:34FromDiscord<Yardanico> oh actually you don't need to import jsonutils here
23:09:02FromDiscord<Elegantbeef> That doesnt actually work though does it yard?
23:09:06FromDiscord<Elegantbeef> job\_id is an int
23:09:07FromDiscord<Yardanico> it works
23:09:11FromDiscord<morgan> In reply to @MorganAlyssa "i think i just": oof there's no vector or boolean stuff yet. guess i'll have to work on fidget a bit before i can really use it fully, tho i think i can work around it using images of the stuff and making procs for stuff
23:09:20FromDiscord<Yardanico> @beef but we have keys as strings
23:09:21FromDiscord<Yardanico> but values are JsonNode
23:09:26FromDiscord<Yardanico> job_id will just become a JsonNode
23:09:40FromDiscord<Elegantbeef> Ok i see
23:09:53FromDiscord<Yardanico> i half didn't expect it to work though :)
23:09:57FromDiscord<Elegantbeef> Awful dynamic typed code
23:13:33FromDiscord<louis77> ChatGPT is unfortunately very bad with Nim Code
23:13:44FromDiscord<Elegantbeef> Good
23:13:58FromDiscord<louis77> Copilot works well?
23:14:00FromDiscord<Yardanico> In reply to @louis77 "ChatGPT is unfortunately very": yes, because it's bad with everything that doesn't have millions of examples
23:14:13FromDiscord<Yardanico> In reply to @louis77 "Copilot works well?": it's better if you're writing in the context of Nim code already
23:14:18FromDiscord<louis77> Or anyone tried Tabnine with Nim?
23:14:28FromDiscord<Yardanico> i did a looong time ago, i think it'd be worse than copilot
23:18:59FromDiscord<louis77> JsonNode works pretty well - thank you guys
23:19:11FromDiscord<louis77> I've just started with Nim a few hours ago πŸ™‚
23:20:21FromDiscord<Rika> thats cool, p quick
23:24:30FromDiscord<Recruit_main707> i use chatgpt to explain me mathematical notations and expressions i dont know
23:24:38FromDiscord<Recruit_main707> it works surprisingly well
23:24:47FromDiscord<Elegantbeef> Living life dangerously i see
23:25:03FromDiscord<Recruit_main707> if you knew
23:26:55FromDiscord<Elegantbeef> I just think cunningham's law is fantastic and 1\:1 private chats with an LLM do not allow it
23:29:39FromDiscord<Recruit_main707> true, chatgpt is extremely prone to reassuring whatever you say
23:29:55FromDiscord<Elegantbeef> Wait are you a chatgpt?!
23:29:57FromDiscord<Elegantbeef> Fuuuuuk
23:30:17FromDiscord<Recruit_main707> as a language model, i am not designed to imitate human behaviour
23:30:25FromDiscord<Rika> beef wtf are you saying youre the bot here
23:30:29FromDiscord<Yardanico> exactly
23:30:37madpropsim the bot
23:30:49FromDiscord<Rika> man these gpt models are so prone to hallucination
23:30:56FromDiscord<Elegantbeef> "The truman show will continue after a break for our sponsors"
23:31:00FromDiscord<Recruit_main707> maybe the bot is the friends we made along the way
23:31:09FromDiscord<Yepoleb> Who are the bots here
23:31:16FromDiscord<Rika> what is a bot, really
23:31:18FromDiscord<Elegantbeef> Beep boop beep
23:31:29madpropsi don't know one day i woke up here
23:31:29FromDiscord<Yepoleb> Please raise your hand if you are human
23:31:34FromDiscord<Elegantbeef> A bot is just an undertrained LLM
23:31:51FromDiscord<Rika> no one has raised their hand
23:31:53FromDiscord<Rika> therefore
23:32:06FromDiscord<Yepoleb> All banned
23:32:21FromDiscord<Yardanico> πŸ”¨
23:32:35madpropsban halen
23:33:20FromDiscord<Yepoleb> You need a license for being a bot here
23:34:59FromDiscord<Recruit_main707> like, tell me this isnt cool https://media.discordapp.net/attachments/371759389889003532/1099116100467306536/image.png
23:35:17FromDiscord<Yardanico> In reply to @Recruit_main707 "like, tell me this": > not using latex rendering
23:35:31FromDiscord<Recruit_main707> and if someone knows confirm this is true because my teacher just slapped it in the board, no explanation and kept going
23:36:39FromDiscord<Elegantbeef> It might be cool, but is it correct
23:37:24FromDiscord<Recruit_main707> i mean, he is a theoretical mathematician, must be
23:38:04FromDiscord<Elegantbeef> I can barely do basic algebra so I cannot confirm nor deny it
23:38:06FromDiscord<Yepoleb> We just redefine reality to be like the bots claim
23:38:20FromDiscord<voidwalker> Any hackish shortcut to get all the console read/write activity in a string ? Without writing 10.000 .toLog commands
23:38:44FromDiscord<Elegantbeef> Maybe our understanding of math is wrong and gpt has gained function to understand iit
23:38:52FromDiscord<Elegantbeef> What do you mean void
23:38:54FromDiscord<voidwalker> (edit) "commands" => "commands. For self program, not for an external process"
23:39:11FromDiscord<voidwalker> (edit) "Any hackish shortcut to get all the console read/write ... activity" added "(echo/readLine(stdin)"
23:39:17FromDiscord<Yardanico> i think void just wants to redirect all stdout/stderr to a nim string
23:39:28FromDiscord<Yardanico> stdout/stderr output that's being printed by the same nim program
23:39:55FromDiscord<Yepoleb> Didn't pmunch write something for that
23:40:03FromDiscord<Yardanico> can't you do something like https://stackoverflow.com/questions/29154056/redirect-stdout-to-a-file
23:40:22FromDiscord<Yardanico> ah, well, but this is to a file
23:40:28FromDiscord<Elegantbeef> Yea you can redirect stdout and stderr to a file
23:40:29FromDiscord<Yardanico> void wants it to go inside a nim string
23:41:38FromDiscord<Yardanico> https://media.discordapp.net/attachments/371759389889003532/1099117770089709648/image.png
23:42:03FromDiscord<Elegantbeef> Yea a memfile and a cstring is like the best i can think
23:42:08FromDiscord<Yepoleb> https://github.com/PMunch/echooverride
23:42:21FromDiscord<Yepoleb> I found it
23:42:34FromDiscord<Yardanico> ah, the man-made horrors beyond comprehension (term-rewriting macros)
23:42:38FromDiscord<Yardanico> very powerful but also quite broken :P
23:42:51FromDiscord<Elegantbeef> In devel they're mostly fixed thanks to the noRewriite Fix
23:43:01FromDiscord<Yardanico> nah, strenc stuff is still broken
23:43:03FromDiscord<Elegantbeef> Coincidentally the best linter
23:43:11FromDiscord<Yardanico> but yes I'm lazy and can't report all issue properly or even find them
23:43:20FromDiscord<Elegantbeef> strenc?
23:43:40FromDiscord<Yardanico> <https://github.com/Yardanico/nim-strenc> a small silly trm that got created from a forum thread
23:43:54FromDiscord<Elegantbeef> Ah i see
23:44:07FromDiscord<Yardanico> you can check open issue for some fun
23:44:40FromDiscord<Elegantbeef> Still it's usable as a AST linter now, so I think it's in a better state now πŸ˜„
23:44:50FromDiscord<Yardanico> what do you mean by that
23:45:01FromDiscord<Elegantbeef> You can write a TRM to lint on an AST level
23:45:14FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/9739#64098
23:45:50FromDiscord<Elegantbeef> Any AST operation one wants to enforce or hint about you can do
23:46:15FromDiscord<Elegantbeef> Want to warn `seq[a..b]` can allocate you can
23:46:26FromDiscord<Yardanico> cursed
23:46:42FromDiscord<Elegantbeef> I think it's much better than having text based linting
23:49:18FromDiscord<Elegantbeef> Plus it's pluggable so you can easily write rules in user space
23:55:28FromDiscord<voidwalker> that PMunch project looks too hackish, needing a custom nim.cfg
23:55:51FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4tY8
23:55:51FromDiscord<Elegantbeef> It only needs it to enable it globally
23:56:32FromDiscord<voidwalker> and I also need one for readLine I guess :\
23:56:43FromDiscord<Elegantbeef> You'll thank me later
23:56:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tY9
23:57:03FromDiscord<Elegantbeef> Well obviously the global variable needs to be changed
23:57:25FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tYa
23:58:14FromDiscord<voidwalker> Why is that necessary ?