<< 26-02-2024 >>

00:10:38*rockcavera quit (Remote host closed the connection)
00:43:42termerElegantbeef Talking shit about me once again
00:44:05termerHow do the likely/unlikely hints generate worse code
00:44:16termerwhen I use them, I know that those things are more or less likely
00:48:12FromDiscord<Elegantbeef> Hey I was mostly jesting about the throwing them in 😄
00:48:33FromDiscord<Elegantbeef> But likely and unlikely need to be on the branch that is known to be slowed down by the predictor
00:52:05FromDiscord<Elegantbeef> So it might not actually slow down code and I might've been silly, but throwing likely around without benchmarking is just pollution!
01:04:28*Mister_Magister quit (Quit: bye)
01:06:21*Mister_Magister joined #nim
01:10:54termerYou already know how much I like to overdecorate things
01:10:57termerI only care if it slows things down
01:11:28termerlike I said on the forum, I don't trust compilers so I have to help them
01:11:34termerwith my stunning knowledge
01:51:00*rockcavera joined #nim
01:58:23FromDiscord<zumi.dxy> how does tcc generate faster code than gcc? less libc overhead?
01:59:36FromDiscord<Elegantbeef> Faster compiler not faster runtime
02:02:00FromDiscord<zumi.dxy> ohhh↵right↵i got those mixed up
02:07:32FromDiscord<im__cynical> sent a code paste, see https://play.nim-lang.org/#pasty=RbzXUQThXIaJ
02:09:29FromDiscord<Elegantbeef> `sizeof(fRename) + sizeof(lpwStream)` seems like the cause to me
02:30:50NimEventerNew question by b4ddev: How to fix this error : simple run error with the library faster_than_requests, see https://stackoverflow.com/questions/78058395/how-to-fix-this-error-simple-run-error-with-the-library-faster-than-requests
03:16:25*SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev)
03:16:49*SchweinDeBurg joined #nim
03:18:18*def- quit (Quit: -)
03:33:25FromDiscord<ipumpbuh4> @room
03:33:32FromDiscord<ipumpbuh4> How can I get nim installed on proxmox
03:35:09FromDiscord<leorize> you can just use choosenim but proxmox is probably not the best environment to install nim on
03:35:42FromDiscord<ipumpbuh4> But I use proxmox on my server and I code on my server so I need it
03:35:47FromDiscord<ipumpbuh4> Whats choosenim
03:37:19*def- joined #nim
03:48:22*def- quit (Quit: -)
03:49:19*def- joined #nim
04:02:55termerchoosenim is a program that installs nim
04:40:39*rockcavera quit (Remote host closed the connection)
04:47:17FromDiscord<im__cynical> how do I get hardware info
04:47:31FromDiscord<im__cynical> like the CPU name (i7, i3, i9, i5, whatever), ram amnt, etc
04:47:33FromDiscord<im__cynical> on windows
04:53:13termerCheck out the winim project https://github.com/khchen/winim
04:53:25termerthe info may also be available in the stdlib winlean module
04:53:48termermake sure you add `when defined(windows):` to make your windows code conditional, unless your program only runs on Windows to begin with
04:55:48arkanoidwhat are the right switches to statically compile libssl ?
04:56:26arkanoidI'm trying with dynlibOverride ssl but it complains "Error: undeclared identifier: 'newContext'"
04:57:31arkanoidit compiles with switch("d","ssl"), it doesnt with switch("dynlibOverride", "ssl"). If I enable both, it seems to ignore switch("dynlibOverride", "ssl")
04:59:24FromDiscord<␀ Array 🇵🇸 🍉> which distro are u using inside the vm/lxc? you can use your package manager to install nim. otherwise the choosenim script can be used on all distros
05:04:39FromDiscord<Elegantbeef> Arkanoid `nim c -r -d:ssl --dynlibOverride:"ssl" --passL:$(pkg-config --static --libs libssl) ./test.nim` works here
05:05:05arkanoidElegantbeef, are you using std/net newContext in your test?
05:05:11FromDiscord<Elegantbeef> Yes
05:05:35FromDiscord<Elegantbeef> `import std/net; var a = newContext()` is my entire code
05:06:30FromDiscord<Elegantbeef> No one asked, but pkg-config is amazing 😄
05:06:49arkanoidsure, it is
05:09:39FromDiscord<ipumpbuh4> I use proxmox
05:10:17FromDiscord<Elegantbeef> Though arkanoid I don't know if the above properly statically linked it
05:10:50FromDiscord<Elegantbeef> The procs are there but so is `dlopen` and `dlsym`
05:11:10arkanoidElegantbeef, it's not: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
05:11:37arkanoidI feel -ssl is not compatible with dynlibOverride
05:11:40arkanoidfor some reason
05:11:47FromDiscord<Elegantbeef> It has to be
05:12:01FromDiscord<Elegantbeef> dynlib override is a compiler feature `ssl` is in userspace
05:12:25FromDiscord<Elegantbeef> The stdlib uses the dynlib pragma not std/dynlib
05:13:35arkanoidI've tried your compilation line, but I was using this config.nims originally https://termbin.com/fsqz
05:14:19FromDiscord<Elegantbeef> Got an easy way to test this? Don't know how aside from writing a program that uses seccomp 😄
05:15:19FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-2-0/lib/wrappers/openssl.nim#L283 yea there is even a static link check
05:15:46FromDiscord<Elegantbeef> Oh I was wrong they do use dynlib in this module
05:16:31arkanoidmmm I might have found a way
05:16:36arkanoidbut it spits warnings
05:18:20*def- quit (Quit: -)
05:18:32arkanoidthis one is truly static: https://termbin.com/m2if
05:19:25*def- joined #nim
05:21:27FromDiscord<Elegantbeef> Now just use pkg-config for style points 😛
05:21:32FromDiscord<Elegantbeef> I joked cause apparently it does not remove duplicates
05:21:48FromDiscord<Elegantbeef> `pkg-config --static --libs libssl libcrypto` emits `-lssl -lcrypto -ldl -pthread -lcrypto -ldl -pthread`
05:23:37arkanoidwhat is missing with pkg-info is --static
05:24:16arkanoidnim wants --passL:"-static" but "pkg-config --static ..." strips it
05:31:36*def- quit (Quit: -)
05:38:48arkanoidI confirm that it does work
05:39:04arkanoidbut I wonder why pkg-config is ignoring --static
05:39:39FromDiscord<Elegantbeef> I don't think it is
05:40:03FromDiscord<Elegantbeef> I just think it expects you to do `-static $(pkg-config --static --libs libssl libcrypto)`
05:50:56*def- joined #nim
06:04:32*azimut quit (Ping timeout: 255 seconds)
07:10:28*advesperacit joined #nim
07:29:02*junaid_ joined #nim
07:58:00*tc424 quit (Ping timeout: 260 seconds)
08:22:26*tc424 joined #nim
08:33:40*ntat joined #nim
08:43:59*tc424 quit (Ping timeout: 260 seconds)
09:40:15*jmdaemon quit (Ping timeout: 268 seconds)
10:20:36*ntat quit (Quit: Leaving)
10:53:57*tc424 joined #nim
11:39:06FromDiscord<girvo> sent a code paste, see https://play.nim-lang.org/#pasty=lOOAVUNWRxkS
11:51:22FromDiscord<demotomohiro> You probably need to use Windows APIs.↵So you need to read documents about it written by microsoft employees.↵You will find them by googling or duckduckgoing with an api function/constant/type name.
11:53:10FromDiscord<girvo> yeah, was just hoping there was something higher level than walking the root\cimv2 namespace via COM GetObject etc. calls -- there's a fair bit of Windows automation stuff I can see on Nimble, but nothing USB specific. Hoped I'd missed something
11:53:36FromDiscord<girvo> Probably just gonna cheat and run a 500ms timer to just scan some output of a command and use that instead for now
12:33:19*attah quit (Ping timeout: 255 seconds)
12:34:07*attah joined #nim
12:35:27*azimut joined #nim
12:36:08*xet7 quit (Ping timeout: 260 seconds)
12:51:52*attah_ joined #nim
12:52:01*attah quit (Ping timeout: 272 seconds)
12:52:27*attah_ is now known as attah
13:06:14*junaid_ quit (Remote host closed the connection)
13:13:11*junaid_ joined #nim
13:19:12*rockcavera joined #nim
13:26:54FromDiscord<maker_of_mischief> is there a library that lets me generate images with plain rgb and arrays like pillow in python?
13:27:21FromDiscord<maker_of_mischief> sent a code paste, see https://play.nim-lang.org/#pasty=GsvkrfyFIgFZ
13:27:40FromDiscord<maker_of_mischief> (edit) "https://play.nim-lang.org/#pasty=zzGNpRxeGPOL" => "https://play.nim-lang.org/#pasty=SsZgxaOaRCZk"
13:28:15FromDiscord<maker_of_mischief> (edit) "https://play.nim-lang.org/#pasty=lIRASeojxbcs" => "https://play.nim-lang.org/#pasty=aznrjGUTCagb"
13:28:22FromDiscord<maker_of_mischief> (edit) "is there a library that lets me generate images with plain rgb and ... arrays" added "2d"
13:30:19FromDiscord<maker_of_mischief> nvm i found a really good one, Angluca/tigr-nim
13:30:56*junaid_ quit (Remote host closed the connection)
13:36:04FromDiscord<odexine> does pixie not allow you to do this?
14:22:48*xet7 joined #nim
14:25:54NimEventerNew thread by DMisener: Can ref variables reference non-ref variables?, see https://forum.nim-lang.org/t/11091
14:55:30*emery_ joined #nim
14:55:43*ehmry quit (Read error: Connection reset by peer)
15:00:23*ntat joined #nim
15:30:35*emery_ quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
15:31:01*ehmry joined #nim
15:38:26*rockcavera quit (Remote host closed the connection)
16:46:18*rockcavera joined #nim
17:31:26*rockcavera quit (Remote host closed the connection)
17:44:22*ntat quit (Quit: Leaving)
17:47:10*ntat joined #nim
17:48:41*jmdaemon joined #nim
18:06:47*SchweinD1 joined #nim
18:11:19*SchweinDeBurg quit (*.net *.split)
18:50:11*junaid_ joined #nim
19:02:41FromDiscord<Robyn [She/Her]> Wish I understood the code behind httpleast
19:03:13FromDiscord<Robyn [She/Her]> Kinda wanna see if I can use cps to implement a simple http server but I'm lost
19:20:04FromDiscord<leorize> i mean you can ask \:p
19:24:31FromDiscord<Robyn [She/Her]> I can! But I don't understand any of httpleast's code lmao
19:24:51FromDiscord<Robyn [She/Her]> I think I'm gonna try implementing a HTTP server using nim-sys and cps, and just see how it goes
19:25:17FromDiscord<leorize> for starters you can look at httpleast.nim and only that file
19:25:28FromDiscord<leorize> focus only on the stuff that said `leastQueue == "nim-sys"`
19:26:05FromDiscord<Robyn [She/Her]> Alright!
19:29:03FromDiscord<Robyn [She/Her]> Does httpleast only support posix OSes?
19:30:00FromDiscord<Robyn [She/Her]> And does posix include Windows?-
19:30:24FromDiscord<Robyn [She/Her]> It's in this weird state of being semi posix-compliant, I think?
19:31:41FromDiscord<griffith1deadly> nim-sys support windows as i knot
19:31:46FromDiscord<griffith1deadly> (edit) "knot" => "know"
19:33:07FromDiscord<leorize> httpleast only support posix when used in MT mode
19:33:14FromDiscord<leorize> the code to shard sockets isn't ported to windows yet
19:35:36*xutaxkamay_ joined #nim
19:37:16*xutaxkamay quit (Ping timeout: 246 seconds)
19:37:16*xutaxkamay_ is now known as xutaxkamay
19:38:00*ntat quit (Quit: Leaving)
19:40:37FromDiscord<Robyn [She/Her]> In reply to @leorize "httpleast only support posix": Ah, I think I understand? What posix specific code is it using though?
19:40:59FromDiscord<leorize> `fcntl` to duplicate sockets
19:42:13FromDiscord<Robyn [She/Her]> Ah okay
20:23:46termerRobyn If you want, I can show you my code that implements and HTTP server with CPS using leorize's nim-sys lib
20:24:09termer*implements an
20:31:47FromDiscord<Robyn [She/Her]> Ooh, perhaps! But I wanna try and figure it out myself, first
20:44:56*Guest70 joined #nim
20:49:08*Guest70 quit (Client Quit)
21:06:40*junaid_ quit (Remote host closed the connection)
21:15:35termerLook in the tests for sockets and you'll find some code you can reference for how to make a server with sys
21:15:46termerThat's how I got started
21:19:28FromDiscord<Robyn [She/Her]> Thanks for the tip!
21:30:07FromDiscord<djazz> playing with closure callbacks, passing ref to C library. `SIGSEGV: Illegal storage access. (Attempt to read from nil?)` thank you nim very helpful error
21:30:32FromDiscord<Elegantbeef> I feel like that's hard to improve on
21:30:44FromDiscord<djazz> probably because generic kind on type
21:30:46FromDiscord<Elegantbeef> As soon as you leave the confines of Nim it's down to the library 😄
21:30:51FromDiscord<Robyn [She/Her]> Seems that the reference was freed before it was accessed, seems like a pretty useful error :P
21:31:04FromDiscord<Elegantbeef> Unless that's a compiler error
21:31:04FromDiscord<djazz> this is when compiling nim ,not runtime
21:31:10FromDiscord<djazz> (edit) "this is when compiling ... nim" added "with"
21:31:22FromDiscord<Robyn [She/Her]> Ah
21:31:33FromDiscord<Robyn [She/Her]> I'm lost then
21:31:41FromDiscord<djazz> i got further with GC_ref()
21:31:55FromDiscord<Elegantbeef> It's a nil ref error due to some funkyness
21:32:10FromDiscord<djazz> type: `Socket[kind: static[SocketType]] = object`
21:32:10FromDiscord<Elegantbeef> Compile with a debug compiler to figure out how to work around it
21:32:36FromDiscord<djazz> parent proc sig: `proc connect(self: ref Socket[SOCK_STREAM]; ipaddr: ptr IpAddrT; port: Port; callback: SocketConnectCb): bool =`
21:32:48FromDiscord<Elegantbeef> `SocketType`?
21:33:01FromDiscord<djazz> (edit) "ref Socket[SOCK_STREAM]; ipaddr: ptr IpAddrT;" => "SocketAny; host: string;"
21:33:03FromDiscord<Elegantbeef> Ah the one in std/net
21:33:05FromDiscord<djazz> an enum
21:33:07FromDiscord<djazz> no
21:33:14FromDiscord<djazz> this is custom
21:33:25FromDiscord<Elegantbeef> `SocketAny` is what `Socket`?
21:33:36FromDiscord<djazz> `SocketAny = ref Socket[SOCK_STREAM] | ref Socket[SOCK_DGRAM] | ref Socket[SOCK_RAW]`
21:33:46FromDiscord<Elegantbeef> Ugh
21:33:57FromDiscord<Elegantbeef> Are those the three instances of sockets?
21:34:01FromDiscord<Elegantbeef> Or are there more enums
21:34:20FromDiscord<djazz> SocketType is an enum
21:34:34FromDiscord<Elegantbeef> I know
21:34:41FromDiscord<djazz> sent a code paste, see https://play.nim-lang.org/#pasty=SCMJPekjHGcw
21:34:50FromDiscord<Elegantbeef> But do you only have 3 values for the enum?
21:34:55FromDiscord<djazz> yeah
21:35:13FromDiscord<Elegantbeef> well `ref Socket` is the same as that
21:35:35FromDiscord<Elegantbeef> Using generics without parameters is an implicit typeclass
21:35:48NimEventerNew thread by arnetheduck: [arnetheduck] `nph` opinionated formatter v0.5, see https://forum.nim-lang.org/t/11093
21:37:32FromDiscord<Elegantbeef> I do wonder how that typeclass is parsed it might be parsed as `ref (Socket[X] | ref (Socket[Y] or ref Socket[Z]))`
21:38:09FromDiscord<Elegantbeef> Whether that's causing the error is another thing 😄
21:40:13FromDiscord<djazz> sent a code paste, see https://play.nim-lang.org/#pasty=hKUahyUupHsL
21:40:26FromDiscord<djazz> last line in that code
21:41:14FromDiscord<djazz> if i remove [kind] i still get nil
21:41:26FromDiscord<djazz> so i need SocketAny combined type
21:41:28FromDiscord<Elegantbeef> In that cause you probably want `ref distinct Socket` 😄
21:41:42FromDiscord<Elegantbeef> Typeclasses are bound to the same symbol inside a proc without that `distinct`
21:42:17FromDiscord<Elegantbeef> Do you use that enum for anything else?
21:42:26*xet7 quit (Remote host closed the connection)
21:42:59FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=ZNsbRJWTcieu
21:43:00FromDiscord<djazz> only as a allocator↵`proc newSocket(kind: static[SocketType]; ...): owned ref Socket[kind] =`
21:43:25FromDiscord<djazz> and callbacks for specific socket types
21:43:37FromDiscord<djazz> connect function for udp : `proc connect(self: ref Socket[SOCK_DGRAM]; ipaddr: IpAddrT; port: Port): bool =`
21:43:55FromDiscord<djazz> this worked great with var and without callbacks (:
21:44:02FromDiscord<Elegantbeef> Right that'd just be `ref Socket[UdpPcb]` 😄
21:44:18FromDiscord<djazz> Right
21:44:24FromDiscord<Elegantbeef> Wait a minute callbacks are these generic callbacks that expect a socket type?
21:44:39FromDiscord<djazz> yeah
21:44:47FromDiscord<Elegantbeef> Are you just forgeting to take in a `[Kind: static SocketType]` inside your callbacks?
21:44:54*xet7 joined #nim
21:46:10FromDiscord<Elegantbeef> Atleast I assume the socket callback is presently `proc(_: ref Socket, ...): ...`
21:46:32FromDiscord<Elegantbeef> Whereas it needs to be `proc[Kind: static socketType(_: ref Socket[Kind], ...): ....`
21:46:37FromDiscord<djazz> this generic function has a inner closure that then calls a callback, depending on the kind
21:46:54FromDiscord<Elegantbeef> So it's type erased?
21:46:59FromDiscord<djazz> probably
21:48:57FromDiscord<Elegantbeef> How much code is there?
21:49:09FromDiscord<Elegantbeef> Would I be daft to ask to see the entire code?
21:50:24FromDiscord<djazz> in a moment
21:54:26FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=lnndWOuzhABM
21:54:52FromDiscord<djazz> In reply to @Elegantbeef "Would I be daft": here is a working closure callback, no generics <https://github.com/daniel-j/picostdlib/blob/feature-async-socket/src/picostdlib/net/dns.nim>
21:55:04FromDiscord<Robyn [She/Her]> By type, I mean a 'struct' when compiled to C code
21:55:26FromDiscord<Robyn [She/Her]> Nvm, got the answer
21:56:19FromDiscord<djazz> In reply to @Elegantbeef "Would I be daft": entire code, currently working because im forcing the type from a pointer https://github.com/daniel-j/picostdlib/blob/feature-async-socket/src/picostdlib/net/picosocket.nim
21:56:38FromDiscord<djazz> line 511
21:57:21FromDiscord<djazz> I should try create a minimal example
21:57:34FromDiscord<djazz> not now its 11 pm heh
22:02:18*fallback quit (Read error: Connection reset by peer)
22:12:34FromDiscord<Elegantbeef> @Robyn [She/Her] Nim generics are monomorphic which means every usage generates an instance
22:17:39FromDiscord<Robyn [She/Her]> Thanks!
22:29:43FromDiscord<starkiller1493> how do I skip the mext iteration of a loop? in c you just do i++
22:29:48FromDiscord<starkiller1493> (edit) "mext" => "next"
22:30:05FromDiscord<Elegantbeef> Use a while loop, or use a condition with continue
22:31:13FromDiscord<starkiller1493> In reply to @Elegantbeef "Use a while loop,": oh right, i can just use a while loop. i'm dumb. thanks
22:31:34FromDiscord<Elegantbeef> You can also use your own iterator using a hack
22:32:24FromDiscord<Elegantbeef> But we won't talk about that
22:32:35FromDiscord<starkiller1493> that would be an overkill anyway
22:36:47FromDiscord<djazz> Elegantbeef: updated code, now http request works again
22:37:02FromDiscord<djazz> still needing the deref and reref hack
22:37:14FromDiscord<djazz> would getting rid of generics solve it ?
22:37:34FromDiscord<Elegantbeef> Hard to say I havent compiled the code
22:38:13FromDiscord<djazz> seems like it still fails
22:40:13FromDiscord<Elegantbeef> Where is "getHostByName" defined?
22:40:21FromDiscord<djazz> dns.nim
22:40:52FromDiscord<djazz> in same dir as picosocket.nim
22:41:13FromDiscord<Elegantbeef> No it's not that one does not take a proc
22:41:27*fallback joined #nim
22:41:33FromDiscord<djazz> refresh?
22:41:56FromDiscord<djazz> i posted the link earlier before i pushed code
22:44:54FromDiscord<Elegantbeef> Possibly worth noting I don't think you need the `dnsGetHostByNameCb`
22:45:09FromDiscord<Elegantbeef> you should be able to do `callBack.rawProc` and `callBack.rawEnv`
22:46:09FromDiscord<Elegantbeef> If `getHostByName` is empty does the code still explode?
22:47:08FromDiscord<djazz> i saw some about rawProc/rawEnv but found no examples
22:47:35FromDiscord<Elegantbeef> `rawProc` should be `proc(..., env: pointer)`
22:48:13FromDiscord<Elegantbeef> https://nim-lang.org/docs/intern.html#code-generation-for-closures
22:49:35FromDiscord<Elegantbeef> As such it's interoperable with your code assuming you do `cstring, ptr IpAddrT, arg: pointer`
22:49:55FromDiscord<Elegantbeef> Though you can actually do `arg: DnsCbState`
22:50:01FromDiscord<Elegantbeef> Wait that's wrong
22:50:31FromDiscord<Elegantbeef> Anyway I don't see anything that stands out as explosively bad
22:54:37FromDiscord<djazz> hmm
22:55:20FromDiscord<djazz> atleast i got it running async now
22:55:47FromDiscord<djazz> the tls stuff still freezes everything, since its not actually multithreaded
22:55:58FromDiscord<djazz> its interrupt driven
22:56:30FromDiscord<djazz> so https makes it freeze on connect for 3 secs, then its smooth and led is blinking while doing the fetching
22:56:45FromDiscord<djazz> the blocking io bothered me haha
22:57:44FromDiscord<djazz> from pico sdk docs `async_context_threadsafe_background provides an implementation of async_context that handles asynchronous work in a low priority IRQ, and there is no need for the user to poll for work.`
22:58:22FromDiscord<djazz> the alternative is manual polling or using FreeRTOS
23:00:45FromDiscord<djazz> night
23:13:09*advesperacit quit ()
23:21:29*rockcavera joined #nim
23:54:00FromDiscord<girvo> I’m working on some FreeRTOS specific bindings and a nicer Nim API around them @djazz — you might find it useful. I’m implementing a replacement for Channel with FreeRTOS’s primitives so that I can do a channel recv with a timeout