<< 29-07-2022 >>

00:12:04FromDiscord<Prestige> Maybe ask on the forum
00:55:59FromDiscord<LaughingBubba> Hi all, when working with JSON data, should the $ operator be able to cast a JsonNode as String? Here's what I came across when going through the Nim In Action book https://gist.github.com/LaughingBubba/4e45bb1a4fc8dbb3152e055480c928d4
00:57:14FromDiscord<!Patitotective> you just `jsonNode.getStr()`
00:58:34FromDiscord<LaughingBubba> I get that, I just don't understand why $ doesnt just fail at compile time?
00:59:01FromDiscord<!Patitotective> because `$` is used to stringify something↵stringify in the sense of printing
00:59:10FromDiscord<LaughingBubba> ah
00:59:18FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=45Yu
00:59:30FromDiscord<!Patitotective> result is implicitly declared as `var result: Message`
00:59:41FromDiscord<!Patitotective> and automatically returned
01:00:31FromDiscord<LaughingBubba> ^^^ Thats what I ended up doing & I understand the implicit result (I dont have to use it tho)
01:01:15FromDiscord<LaughingBubba> So I basically didnt understand proper usage of $
01:01:57FromDiscord<LaughingBubba> It's like a substitution variable in a JS typed literal
01:02:14FromDiscord<LaughingBubba> Thanks @!Patitotective
01:02:31FromDiscord<!Patitotective> :]
01:03:00FromDiscord<!Patitotective> https://nim-lang.org/docs/json.html#overview-reading-values
01:07:03*CyberTailor quit (Remote host closed the connection)
01:08:17*CyberTailor joined #nim
01:25:23FromDiscord<Professor Actual Factual> sent a code paste, see https://play.nim-lang.org/#ix=45YC
01:58:46*Guest23 joined #nim
02:02:09*Guest23 quit (Client Quit)
02:38:11FromDiscord<#!/rip/luke> How can I convert a sequence to a json array
02:38:44*arkurious quit (Quit: Leaving)
02:56:50FromDiscord<!Patitotective> In reply to @ripluke "How can I convert": `% mySeq`
02:56:55FromDiscord<!Patitotective> horrible macro name, i know
02:57:37FromDiscord<#!/rip/luke> In reply to @Patitotective "`%* mySeq`": Ok
02:58:39FromDiscord<#!/rip/luke> In reply to @Patitotective "`%* mySeq`": In std/json?
02:59:04FromDiscord<!Patitotective> ofc
02:59:55FromDiscord<#!/rip/luke> And how is it returned? As a string?
03:00:50FromDiscord<!Patitotective> as a JsonNode
03:01:21FromDiscord<#!/rip/luke> Ok
03:50:22FromDiscord<neon_> Hey guys, how would i go about reading a file by specified number of bytes starting at a specific byte
03:51:22FromDiscord<Girvo> _waves hello_
03:52:04FromDiscord<neon_> ive looked into readBytes but when i make a seq[uint8] with the size of the chunk i wanna read, if i wanna read further than that i obviously get an out of index error cause readBytes writes to the same index in my seq im reading from (so seq[offset] which doesnt exist)
03:53:05FromDiscord<Girvo> In reply to @Patitotective "horrible macro name, i": Yeah oof that one is a bit rough haha
03:54:04FromDiscord<neon_> sent a code paste, see https://play.nim-lang.org/#ix=45Z1
03:54:32FromDiscord<neon_> (edit) "https://play.nim-lang.org/#ix=45Z1" => "https://play.nim-lang.org/#ix=45Z2"
03:55:12FromDiscord<neon_> is there a way to make readBytes write to chunks[0] instead of chunks[pos] cause otherwise id have a big array of uints for larger files
03:55:20FromDiscord<Girvo> @neon_ Can you use FileStream or nah?
03:56:13FromDiscord<neon_> i've looked into it but as far as i understood peekData also does the same so writes to buff[pointer] to bufLength
03:56:26FromDiscord<neon_> (edit) "to" => "from"
03:57:42FromDiscord<neon_> wait i misread it
03:58:11FromDiscord<neon_> sent a code paste, see https://play.nim-lang.org/#ix=
03:58:16FromDiscord<Girvo> Yeah
03:58:23FromDiscord<neon_> holy shit thanks
03:58:25FromDiscord<Girvo> I believe so anyway 🙂
03:58:44FromDiscord<Girvo> Its what I was looking for myself just then haha I knew theres a proc for `std/streams` that can do it
03:59:32FromDiscord<Girvo> `readData` can also specifically take a `slice` as well, so you could give it the `0..chunkSize-1` slice
03:59:43FromDiscord<Girvo> (edit) "`readData` can also specifically take a `slice` as well, so you could give it the `0..chunkSize-1` slice ... " added "which will put it at that position in the `buffer` pointer"
03:59:45FromDiscord<Girvo> I believe anyway
03:59:56FromDiscord<Girvo> I haven't written FileStream code in a loooong while
04:01:05FromDiscord<Girvo> As an aside, is `byte` vs `uint8` just preference? I've been using them both in our firmware, as a sort of "future developer reading this" helper that `uint8` is used as an actual (small) number, and `byte` is used as, well, a low level byte lol
04:02:48FromDiscord<neon_> Just personal preference like everything is stored as binary anyway and uint(number) just helps me visualize how many bytes it takes up
04:04:13FromDiscord<neon_> but im no expert on this
04:05:40FromDiscord<Girvo> Yeah fair enough! They're basically type aliases of one another anyway as far as I remember
04:06:16FromDiscord<neon_> Yeah afik i think its the same and the conventions came from windows naming their sizes weirdly like nibble and word
04:06:28FromDiscord<Girvo> I just really like `array[ArrSize, byte]` for the buffers and such I'm working with in embedded haha. Makes it a lot nicer than C's `char` arrays
04:06:35FromDiscord<neon_> when i see word i have no clue how much that is in binary ofc i could memorize it but it just confuses me
04:07:03FromDiscord<Girvo> Haha a word is 2 bytes 🙂
04:07:23FromDiscord<Girvo> Where a byte is `n` bits defined per-platform! It's an odd convention
04:07:46FromDiscord<Girvo> But handy, as the Modbus driver I'm working on has to deal with both byte _and_ word-order endianness
04:07:54FromDiscord<neon_> I know but just in my perspective like for someone seeing some code for the first time if he wasnt exclusively developing low level code it can quickly confuse the user
04:08:41FromDiscord<neon_> ah yes the industrial standards gotta love their flexibility that usually makes it a pain to implement XD
04:08:59FromDiscord<Girvo> Man Modbus RTU was basically invented in the 1970s and it _feels_ like it lol
04:09:46FromDiscord<neon_> I love how the ethernet version of modbus is literally just modbus but with the ip overhead
05:31:46*pch joined #nim
05:32:04FromDiscord<Girvo> Haha yeah Modbus RTU-over-TCP is fascinating
05:32:18FromDiscord<Girvo> And then just to be confusing there is Modbus TCP which is a different thing altogether
05:32:21FromDiscord<Girvo> Woooooo 😭
06:07:46FromDiscord<Girvo> As an aside, anyone got any experience with compressing small strings/messages? I'm looking at either binding `shoco` or using some other system that lets me generate a de/compression dictionary ahead-of-time so the messages can be as small as possible
06:12:08FromDiscord<huantian> Have you tried base64 😛
06:12:54FromDiscord<huantian> In seriousness I haven’t looked at that kind of compression, kind of an interesting concept though
06:13:07FromDiscord<Girvo> haha 🙂
06:13:39FromDiscord<Girvo> The main reason things like brotli, LZ4 and other algorithms don't work on small files/strings is the dictionary it shares with it is the same size as the bloody string itself lol
06:13:58FromDiscord<huantian> Yeah that makes sense
06:14:02FromDiscord<huantian> Wrapping shoco seems pretty easy though, just two functions
06:14:07FromDiscord<Girvo> But if you amortise that cost by generating it for your entire data set ahead of time, you can get some impressive compression even of small sets of bytes
06:14:20FromDiscord<Girvo> Yeah its why I was looking at it!
06:14:30FromDiscord<Girvo> Any C library that is that simple to bind always gets my attention lol
06:14:38FromDiscord<Girvo> (If there isn't a Nim version on it's own)
06:14:57FromDiscord<4zv4l> is there any kind of `readUntilDelimiter` in Nim ?
06:15:12FromDiscord<Girvo> Like `readUntil` @4zv4l
06:15:14FromDiscord<Girvo> (edit) "@4zv4l" => "@4zv4l?"
06:15:22FromDiscord<4zv4l> is it implemented for socket ?
06:15:30FromDiscord<huantian> In reply to @Girvo "(If there isn't a": I don’t know of any but I have done zero searching
06:15:54FromDiscord<Girvo> @huantian I had a look and didn't find much haha
06:16:04FromDiscord<Girvo> @4zv4l yeah I know there is one that works, give me a sec and I'll find what the proc is
06:16:06FromDiscord<4zv4l> In reply to @Girvo "Like `readUntil` <@329196212282458112>?": in which lib is it ?
06:16:14FromDiscord<4zv4l> In reply to @Girvo "<@329196212282458112> yeah I know": thanks !
06:16:20FromDiscord<Girvo> @4zv4l I got the symbol name wrong, one second 🙂
06:16:46FromDiscord<Rika> In reply to @Girvo "The main reason things": zstd has an AOT dictionary system as well
06:16:46FromDiscord<Girvo> `parseUntil` is what I was thinking of I think
06:16:59FromDiscord<Girvo> @Rika Yeah I was literally just reading about that! Might be the way to go
06:17:21FromDiscord<Girvo> @4zv4l https://nim-lang.org/docs/parseutils.html#parseUntil%2Cstring%2Cstring%2Cchar%2Cint
06:17:28FromDiscord<Girvo> Though it works on `string` which might not be what you're looking for
06:17:46FromDiscord<Girvo> Theres a better solution though
06:17:55FromDiscord<Girvo> (edit) "though" => "though, I just can't think of it lol"
06:17:55FromDiscord<Rika> In reply to @Girvo "<@259277943275126785> Yeah I was": Probably since it is more commonly found; unfortunately I don’t think most Nim libraries support the node
06:19:03FromDiscord<4zv4l> In reply to @Girvo "Though it works on": well my issue for now is that my client never stop reading since I send more than a line, I tried all `recv` proc but nonce worked it always waited for more data to come, so I was wondering if there was a `readUnil` or something similar, then I can just add a delimiter
06:19:34FromDiscord<Girvo> Could use `std/socketstreams` and hack something up with `peekChar` or whatever data you're lokoing at from `std/streams`
06:21:32FromDiscord<Girvo> @4zv4l Are you trying to get it to break/stop on a newline?
06:24:46FromDiscord<4zv4l> it has to read more than some lines
06:24:48FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zg
06:24:56FromDiscord<Girvo> Could use `stream.readLine()` and parse/work with it per-line
06:25:17FromDiscord<4zv4l> I just don't know why with the exact same code in C it works but in Nim it doesn't work that way
06:25:25FromDiscord<Girvo> Otherwise you'll have to do it per-line
06:25:34FromDiscord<Girvo> Post the C and Nim code somewhere?
06:25:52FromDiscord<4zv4l> In reply to @4zv4l "": Nim code
06:26:27FromDiscord<Girvo> Thats a socketstream ReadStream yeah?
06:26:29FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zh
06:26:44FromDiscord<4zv4l> not yet
06:26:54FromDiscord<4zv4l> but I'm trying to change it since you made me discover that
06:27:12FromDiscord<Girvo> Okay 🙂 Give that a try, as I believe that works the same way you're expecting
06:27:30FromDiscord<4zv4l> In reply to @Girvo "Thats a socketstream ReadStream": I didn't find socketstream in the stream lib
06:27:36FromDiscord<Girvo> `import socketstream`
06:27:46FromDiscord<Girvo> It is it's own lib in the standard library 🙂
06:27:49FromDiscord<Girvo> https://nim-lang.org/docs/socketstreams.html
06:27:50FromDiscord<4zv4l> oh so in another lib alright
06:28:23FromDiscord<4zv4l> oh but can I open a read/write socketstream ?
06:28:29FromDiscord<4zv4l> or I have to open two socketstream then ?
06:28:36FromDiscord<Girvo> You open two socketstreams I believe
06:28:47FromDiscord<Girvo> Makes it clearer I find anyway!
06:29:07FromDiscord<4zv4l> alright I'll try that ^^
06:31:46FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zi
06:32:05FromDiscord<Girvo> But `readLine` is better IMO
06:32:17FromDiscord<4zv4l> yeah i'll try with the readline first
06:32:30FromDiscord<4zv4l> but so I also need to rewrite the server code right ?
06:32:36FromDiscord<4zv4l> since it has to accept two sockets
06:32:56FromDiscord<Girvo> Possibly yeah
06:33:19FromDiscord<4zv4l> alright I found
06:33:21FromDiscord<4zv4l> `The WriteSocketStream allows both reading and writing`
06:33:26FromDiscord<Girvo> Oh nice haha
06:33:26FromDiscord<4zv4l> so only one socket
06:33:33FromDiscord<Girvo> It's been a while since I've used this stuff!
06:34:10FromDiscord<Girvo> Yeah literally the last time I worked with this was 2017 haha for Nim v0.14.3
06:35:04FromDiscord<Girvo> @Rika I wonder if zlib is a good fit for embedded. Surely right? Especially with dicts pre-calculated
06:36:34FromDiscord<Girvo> Oh there is `miniz` which is built specifically for that use-case, and again is a `.c` and `.h` file. Interesting. If it can accept zlib dicts it should be good to go
06:37:37FromDiscord<Girvo> Ah crap lol
06:37:42FromDiscord<Girvo> >No support for gzip headers or zlib static dictionaries
06:37:49FromDiscord<Girvo> (edit) ">No" => "> No"
06:37:51FromDiscord<Girvo> So much for that!
06:41:09FromDiscord<Girvo> Oh nice. `zstd` supports static memory allocation as of 2017
06:44:38FromDiscord<Rika> In reply to @Girvo "<@259277943275126785> I wonder if": Zlib and Zstd are different
06:45:19FromDiscord<Girvo> @Rika yeah sorry I've been staring at both haha
06:45:36FromDiscord<Rika> Depends on how restrained you are really
06:45:39FromDiscord<Rika> Either should be fine
06:46:14FromDiscord<Girvo> Not really to be honest, its an ESP32-S3 with 2MB of extra PSRAM lol but I still am trying to keep an eye on making sure the right libraries are chosen as it needs to do a _lot_ all at the same time
06:47:13FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zj
06:47:29FromDiscord<4zv4l> the indentation isn't well made sorry xD
06:47:32FromDiscord<Girvo> Oof it ate your formatting there so I can't count lines haha
06:47:38FromDiscord<4zv4l> discord made it weird
06:47:40FromDiscord<Girvo> What is on line 19?
06:47:45FromDiscord<Girvo> `stdout.write "$ "` yeah?
06:47:56FromDiscord<Girvo> Wait no `stream.write(input)`?
06:48:02FromDiscord<4zv4l> `stream.write(input)`
06:48:06FromDiscord<Girvo> Okay one moment
06:48:06FromDiscord<4zv4l> this is line 19
06:48:21FromDiscord<Girvo> Show me your `import` block?
06:48:49FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zk
06:48:53FromDiscord<Girvo> Add `import streams`
06:49:02FromDiscord<Elegantbeef> Jesus christ here i thought the chat was dead but the bridge was just dead
06:49:18FromDiscord<Girvo> Hah I wondered why it seemed so quiet here without ya 😉
06:49:36FromDiscord<Elegantbeef> Your guy's messages just poured in
06:49:47FromDiscord<4zv4l> they didn't write that I need to add that lib did they ?
06:50:02FromDiscord<Girvo> Doesn't seem like it in the example
06:50:10FromDiscord<Girvo> And I'm not sure it will fix it, but it's worth a try!
06:50:29FromDiscord<Elegantbeef> socketstreams does not export sockets
06:50:32FromDiscord<Elegantbeef> well streams i mean
06:50:54FromDiscord<Girvo> @ElegantBeef The example in the docs doesn't have `import streams` so any one who copy pastes it is gonna run into some fun lol
06:50:55FromDiscord<Elegantbeef> It's odd it doesnt
06:51:18FromDiscord<Girvo> It uses `write` and `readLine` while never importing `streams` itself haha
06:51:19FromDiscord<Elegantbeef> Memfiles doesnt export it either
06:51:34FromDiscord<Elegantbeef> Guess the thing for memfiles is "if you dont need it you dont need it"
06:51:42FromDiscord<Elegantbeef> Well you fix their problem then suggest they make a PR 😛
06:51:43FromDiscord<Girvo> Yeah memfiles I can kind of understand
06:51:49FromDiscord<Elegantbeef> It's the Nim way
06:52:39FromDiscord<Girvo> Yeah I will for this I think lol. But yeah @4zv4l `readLine` and `write` are procs from `std/streams` which we didn't import yet. The example on the `std/socketstreams` docs page is incomplete it looks like!
06:53:01FromDiscord<4zv4l> how can I read until the server doesn't send anything ?
06:53:40FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zl
06:54:15FromDiscord<Elegantbeef> It's a blocking operation
06:54:16FromDiscord<Elegantbeef> Which means your CPU will be held hostage until it's done
06:54:40FromDiscord<Girvo> Which is why `asyncsocketstreams` exists! weeeeee
06:54:48FromDiscord<Elegantbeef> Yep
06:54:50FromDiscord<Girvo> (edit) "`asyncsocketstreams`" => "`asyncstreams`"
06:55:03FromDiscord<Elegantbeef> Async allows you to wait on IO to not block your CPU until you want to
06:55:09FromDiscord<4zv4l> In reply to @Girvo "Which is why `asyncstreams`": I'm really new to that async stuff
06:55:21FromDiscord<4zv4l> so if you could explain me how to implement that
06:55:25FromDiscord<4zv4l> could be nice xD
06:55:34FromDiscord<4zv4l> cause the only async I know is the Zig one
06:55:44FromDiscord<4zv4l> which is just a ping pong game between functions
06:55:47FromDiscord<Girvo> Ah fair. Had much experience with Javascript async?
06:55:56FromDiscord<Girvo> It's sort of similar
06:56:00FromDiscord<4zv4l> never used async in js but I got the spirit
06:56:12FromDiscord<Girvo> in-so-much as it's all just `Future[T]` based
06:56:14FromDiscord<4zv4l> my uncle explained me someday
06:56:32FromDiscord<Girvo> @4zv4l Is all this just over a TCP socket you're reading/writing to?
06:57:10FromDiscord<4zv4l> sent a long message, see http://ix.io/45Zm
06:57:10FromDiscord<Girvo> If so, now you're finding out why HTTP as a protocol exists over the top of TCP 🙂 Any why it sends a `Length` header etc.
06:57:15FromDiscord<4zv4l> my C implementation is quite simple
06:57:21FromDiscord<Girvo> But okay cool!
06:58:03FromDiscord<Girvo> Silly suggestion: make sure what you're writing has a newline terminator
06:58:06FromDiscord<4zv4l> actually my C and Zig implementation both works the same way↵with basic `read()`/`write()` and that's why I don't know why in Nim↵the recv is blocking
06:58:10FromDiscord<Girvo> Otherwise `readLine` will never finish
06:58:12FromDiscord<4zv4l> while in others it won't wait to fill the butter
06:58:32FromDiscord<Elegantbeef> there is a nonblocking `recv` with a timeout
06:58:59FromDiscord<Girvo> https://nim-lang.org/docs/net.html#recv%2CSocket%2Cpointer%2Cint%2Cint
06:59:13FromDiscord<Girvo> Timeout is defined as `-1` by default isn't it, beef?
06:59:25FromDiscord<Elegantbeef> In the non pointer version yes
06:59:40FromDiscord<Elegantbeef> The pointer version doesnt have an optional timeout
06:59:44FromDiscord<Girvo> Ah true
07:00:02FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zn
07:00:03FromDiscord<4zv4l> that's with the readline loop
07:00:32FromDiscord<4zv4l> In reply to @Elegantbeef "there is a nonblocking": I tried that one with timeout but the data wasn't put in the buffer it seems so it would print nothing after the timeout
07:04:20FromDiscord<Girvo> @4zv4l Give me a moment, I'm writing a snippet to test this myself
07:05:20FromDiscord<Elegantbeef> What are we even trying to do anywho?
07:13:37FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zr
07:16:03FromDiscord<Elegantbeef> You cannot use `await` in a non async procedure
07:17:20FromDiscord<Girvo> @4zv4l For your simple version, did you try `socket.setBlocking(false)`? Its the `nativesockets` version which is identical to your `C` and Zig versions, I'd think
07:21:15FromDiscord<4zv4l> nativesockets seem to be annoying to deal with in Nim xD
07:21:25FromDiscord<4zv4l> connect set non blocking on default socket ?
07:21:39FromDiscord<4zv4l> In reply to @Elegantbeef "You cannot use `await`": those were async proc since they're from asyncnet I guess
07:22:50FromDiscord<Rika> He means your handle procedure should be async as well
07:23:34FromDiscord<4zv4l> In reply to @Rika "He means your handle": oh okok xD
07:23:56FromDiscord<4zv4l> but why ?
07:24:42FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zu
07:24:48FromDiscord<Girvo> Pong
07:24:51FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zv
07:25:03FromDiscord<Girvo> Works 🙂 They echo `"hello"` back at each other haha
07:25:24FromDiscord<Girvo> (edit) "https://play.nim-lang.org/#ix=45Zu" => "https://play.nim-lang.org/#ix=45Zw"
07:25:45FromDiscord<4zv4l> thanks, what if the server send multiple lines back ?
07:26:14FromDiscord<4zv4l> because that's the main issue here, I did succeed using readline getting one result but the server send many lines back sometimes
07:26:16FromDiscord<Girvo> Thats left to the reader to work out 😉 The key thing is, you need a delimiter. For `readLine`, `\r\L` is the delimiter it's looking for
07:26:38FromDiscord<Girvo> Many lines is fine, if they're `\n`! Because that is not `\r\L`
07:26:39FromDiscord<4zv4l> I didn't know \r\L
07:26:51FromDiscord<4zv4l> alright I'll test that
07:26:54FromDiscord<Girvo> https://nim-lang.org/docs/net.html#readLine%2CSocket%2Cstring%2Cint
07:27:00FromDiscord<Girvo> > Reads a line of data from socket.↵> ↵> If a full line is read \r\L is not added to line, however if solely \r\L is read then line will be set to it.
07:27:02FromDiscord<Girvo> 🙂
07:27:08FromDiscord<4zv4l> even tho I would have liked that my c and nim program were compatible between them
07:27:45FromDiscord<Girvo> What does your C program rely on? Or you're just doing character by character with `recv` alone?
07:27:55FromDiscord<4zv4l> no no I send once and read once
07:28:04FromDiscord<Girvo> What do you send once and read once?
07:28:59FromDiscord<4zv4l> sent a long message, see https://paste.rs/F37
07:29:12FromDiscord<Rika> In reply to @4zv4l "but why ?": That’s how async works
07:29:15FromDiscord<4zv4l> https://media.discordapp.net/attachments/371759389889003532/1002477890102886462/server.c
07:29:51FromDiscord<4zv4l> https://media.discordapp.net/attachments/371759389889003532/1002478044675571712/client.c
07:30:14FromDiscord<4zv4l> and so I was just trying to make that but in Nim
07:30:38FromDiscord<4zv4l> In reply to @Rika "That’s how async works": but why a function must be async to await for an async function ?
07:31:44FromDiscord<4zv4l> In reply to @4zv4l "": so just `send()` and `recv()`
07:31:55FromDiscord<huantian> In reply to @4zv4l "but why a function": Because monads 😛
07:32:07FromDiscord<huantian> But really you have to think about what await does
07:32:14FromDiscord<4zv4l> In reply to @huantian "Because monads 😛": idk others languages that well but in Zig that's not how it works
07:32:47FromDiscord<4zv4l> it waits for the other function to either finish or suspend
07:33:25FromDiscord<huantian> If you want to wait for an async r to finish in a synchronous context, use waitFor
07:34:04FromDiscord<Girvo> Oh I see, you're just `read`-ing the `sizeof(buff)`. That's easy to replicate in Nim if you really want to! Just set a max size for your buffer, and `recv` or `read` that amount of bytes into it, either an `array[size, char]` or a `seq[char]`
07:34:36FromDiscord<Girvo> @huantian Technically `Future[T]` isn't a monad per-se 😉
07:34:51FromDiscord<huantian> In reply to @Elegantbeef "You cannot use `await`": Maybe we should backport that change to stable 😛
07:35:16FromDiscord<huantian> In reply to @Girvo "<@300050030923087872> Technically `Future[T]` isn't": It is if you squint realllllllly hard
07:35:30FromDiscord<4zv4l> In reply to @Girvo "Oh I see, you're": so I make a buffer instead of a string right ?
07:35:35FromDiscord<4zv4l> an array of char I meant
07:35:56FromDiscord<4zv4l> In reply to @Girvo "Oh I see, you're": yeah but so even if the size of buff isn't read it won't wait for it
07:36:03FromDiscord<Girvo> sent a code paste, see https://paste.rs/t46
07:36:27FromDiscord<Girvo> @4zv4l Thats easily solved. Use `import nativesockets` instead of `import net` and run `socket.setBlocking(false)`
07:36:30FromDiscord<huantian> Future is a monad depending on the implementation right?
07:36:39FromDiscord<Girvo> Now it will behave the same way you're expecting, if I'm reading it right
07:36:42FromDiscord<4zv4l> In reply to @Girvo "<@329196212282458112> Thats easily solved.": yeah but then to setup the socket that's more annoying xD
07:37:01FromDiscord<Girvo> Correct! But thats what `nativesockets` _is_ -- its a thin wrapper over your C-level OS-level socket stuff
07:37:04FromDiscord<4zv4l> I'm still trying to get something simpler than C 😢
07:37:18FromDiscord<Rika> In reply to @4zv4l "idk others languages that": You also probably pass the dispatcher to every async function in Zig
07:39:21FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45ZT
07:40:01FromDiscord<Girvo> But learning async programming is well worth it too, and less complex than it sounds, I promise
07:40:19FromDiscord<Rika> Ah I see what you mean
07:40:30FromDiscord<Rika> Nim async is not built in to the language like in Zig
07:40:37FromDiscord<Girvo> Yeah Zig's async is quite interesting
07:40:44FromDiscord<Girvo> It's attempting to be "colourless"
07:40:47FromDiscord<Rika> Async is instead implemented as a library in Nim
07:40:51FromDiscord<Girvo> Which is a valiant effort IMO
07:41:02FromDiscord<Rika> Except it doesn’t look like it is really
07:41:13FromDiscord<Rika> Because you still seem to have to match pairs somewhere
07:41:34FromDiscord<Girvo> Welllllll it is, ish. If you do some seriously funky shit at runtime you can break it's current approach, but you'd have to try really hard to do so
07:41:38FromDiscord<Rika> I don’t understand what’s so bad about the colouring anyway
07:41:47FromDiscord<huantian> Does zig use cps?
07:41:59FromDiscord<huantian> Wait what does color even mean
07:42:10FromDiscord<Girvo> Well the upside is new programmers get less confused by async/await and `Future[T]` or `Promise<T>` or etc. etc. etc. haha
07:42:14FromDiscord<Rika> It’s the “async only in async” kind of thing
07:42:25FromDiscord<Rika> Informally called colouring because of a blog post
07:43:05FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45ZV
07:43:21FromDiscord<Girvo> Having to explicitly mark a function as `async` means it creeps its way up your call stack as any caller now needs to be `async` as well, in other languages
07:43:36FromDiscord<Rika> Except you can just wait for in Nim 🙂
07:43:41FromDiscord<huantian> Isn’t that how it works in Nim kinda
07:43:45FromDiscord<Rika> It is
07:43:46FromDiscord<Girvo> Haha which is why I said "other languages" 😉
07:43:48FromDiscord<Rika> That’s what he means
07:43:58FromDiscord<Rika> Zig doesn’t need this is basically what he says
07:44:05FromDiscord<Rika> Or rather does away with it
07:44:15FromDiscord<Girvo> `waitFor` letting you just go "screw this, block til it's done" is nice
07:44:23FromDiscord<Girvo> (edit) "`waitFor` letting you just go "screw this, block til it's done" ... is" added "in a non-async-marked proc"
07:44:34FromDiscord<huantian> Yeah like pythons asyncio.run
07:45:06FromDiscord<Rika> Basically “it’s just too complicated for new programmers to understand” is the argument against colouring
07:45:40FromDiscord<huantian> So that means in async functions you don’t call await at all?
07:45:46FromDiscord<Rika> And so instead of figuring out a way to make it easier to understand colouring, people are trying to do away with it instead
07:45:55FromDiscord<Rika> I don’t know how it works in Zig
07:46:45FromDiscord<huantian> In reply to @Rika "And so instead of": I mean we kinda scared 4z away lol
07:47:04FromDiscord<Rika> ~~honestly IMO Zig is a write only language to me~~
07:47:14FromDiscord<Rika> In reply to @huantian "I mean we kinda": That’s another thing
07:47:31FromDiscord<4zv4l> how do I connect() with a nativesocket ?
07:47:49FromDiscord<4zv4l> `proc connect(s: SocketHandle; name: ptr SockAddr; namelen: SockLen)`↵how do I get the SockAddr ?
07:48:23FromDiscord<4zv4l> so it's like the exact same as in C↵why I can't just say nonblocking on default socket ?
07:54:02FromDiscord<4zv4l> won't I make a thread just to read from that stream just because the default socket is blocking T-T
07:54:37FromDiscord<huantian> I’m pretty sure the solution to your problems is async
07:55:09FromDiscord<4zv4l> but if it waits for the function to read in async or not the function will never finish
07:55:33FromDiscord<4zv4l> since it's multiple line
07:55:34FromDiscord<huantian> You don’t have to wait for the function to read
07:55:48FromDiscord<huantian> Maybe actually idk how sockets work I’ve never used it
07:55:54FromDiscord<huantian> But I think you want asyncCheck
07:57:25FromDiscord<4zv4l> it's waiting forever https://media.discordapp.net/attachments/371759389889003532/1002484980376678480/unknown.png
07:58:21FromDiscord<huantian> It’s blocking on recv yes?
07:58:35FromDiscord<4zv4l> yessss
07:58:44FromDiscord<4zv4l> that's the "only" issue
07:58:48FromDiscord<huantian> Move the echo to recv
07:58:52FromDiscord<4zv4l> the issue I'm fighting since yesterday
07:59:06FromDiscord<huantian> Then asyncCheck it instead of waitFor
07:59:14FromDiscord<huantian> Change the other waitFor to await
07:59:19FromDiscord<huantian> And make handle async
07:59:38FromDiscord<huantian> (edit) "And make handle async ... " added "(the one on the bottom I think)"
08:00:18FromDiscord<4zv4l> `/home/azz/Documents/rev_nim/client/client.nim(21, 21) Error: type mismatch: got <Future[system.string]>↵but expected one of:↵proc echo(x: varargs[typed, `$`])`
08:00:40FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=460m
08:06:05FromDiscord<4zv4l> alright it doesn't send anything
08:06:13FromDiscord<4zv4l> the send isn't working
08:06:27FromDiscord<huantian> Wait hold on lemme see this again
08:07:19FromDiscord<huantian> Why not just use recvLine?
08:07:38FromDiscord<4zv4l> because the server send many lines
08:08:18FromDiscord<huantian> Well it’s not a normal newline
08:08:28FromDiscord<huantian> Right?
08:08:38FromDiscord<huantian> Or am I reading the docs wrong
08:08:42FromDiscord<4zv4l> well I can try that but for now
08:08:45FromDiscord<4zv4l> the send isn't working
08:08:48FromDiscord<4zv4l> so I can't even try the recv
08:10:32FromDiscord<huantian> Well I don’t think you need async at all
08:10:43FromDiscord<huantian> Since the client should block until the server has stopped sending
08:11:33FromDiscord<huantian> You would want async if you needed to keep receiving data from the server and do other things at the same time
08:11:37FromDiscord<4zv4l> I just need the receive to be non blocking
08:11:41FromDiscord<4zv4l> but
08:11:59FromDiscord<huantian> Why should receive be non blocking?
08:12:03FromDiscord<4zv4l> except maybe with the nativesockets which are the same as in C so I don't even wanna try
08:12:10FromDiscord<4zv4l> I mean
08:12:28FromDiscord<4zv4l> my C and Zig implementation of this↵both simply `read()`
08:12:34FromDiscord<4zv4l> if the buffer isn't filled they still continue
08:12:37FromDiscord<huantian> Your client won’t be doing anything else while it’s still getting info from the server right?
08:13:22FromDiscord<Elegantbeef> Does Zig/C use unbuffered sockets by default?
08:13:40FromDiscord<4zv4l> In reply to @huantian "Your client won’t be": yeah it's just a ping pong
08:13:52FromDiscord<4zv4l> In reply to @Elegantbeef "Does Zig/C use unbuffered": yeah they aren't buffered by default
08:13:55FromDiscord<huantian> Then why do you need to rely on unbuffered socket behavior
08:14:03FromDiscord<huantian> Can’t you use readLine
08:14:09FromDiscord<Elegantbeef> Then make the Nim socket unbuffered 😄
08:14:13FromDiscord<Elegantbeef> Then you can just use recv
08:14:24FromDiscord<4zv4l> because I want my c program to be compatible with the Nim one and vice versa
08:14:29FromDiscord<4zv4l> In reply to @Elegantbeef "Then make the Nim": how ?
08:14:36FromDiscord<Elegantbeef> https://nim-lang.org/docs/net.html#newSocket%2Ccint%2Ccint%2Ccint
08:14:45FromDiscord<Elegantbeef> `buffered = false` in your `newSocket` constructor
08:17:37FromDiscord<4zv4l> finally
08:17:38FromDiscord<4zv4l> omg
08:17:40FromDiscord<4zv4l> xD
08:17:40FromDiscord<4zv4l> damn
08:17:52FromDiscord<4zv4l> thank you
08:17:59FromDiscord<Elegantbeef> Who'd have thought reading the docs on recv would help 😛
08:19:42FromDiscord<4zv4l> well looked into it really↵just didn't think about buffering ↵but of course now it sounds obvious
08:19:56FromDiscord<Rika> Well none of us seemed to know the sockets of Zig was unbuffered and Nim was
08:20:40FromDiscord<4zv4l> Zig is really low level so nothing is buffered by default
08:20:48FromDiscord<Elegantbeef> I joke but i sat down and read "if the buffer isn't filled they still continue" so it kicked in instantly to me
08:21:27FromDiscord<4zv4l> is there a trim function to remove the \n ?↵because I tried stdout.write but the newline is still there so I guess it's in the string
08:21:45FromDiscord<Elegantbeef> `strip`
08:21:51FromDiscord<4zv4l> except trimzero fom strutils I don't find a trim function
08:21:53FromDiscord<#!/rip/luke> Let's say I had a version command in my cli tool, what would be the best way to say if it was a release or a debug build
08:22:07FromDiscord<Girvo> `v1.0.0-debug`
08:22:18FromDiscord<#!/rip/luke> No like how can I tell
08:22:19FromDiscord<Girvo> Or `-dbg`
08:22:34FromDiscord<Rika> There’s defined(release) no?
08:22:35FromDiscord<Elegantbeef> `when defined(debug)`?
08:22:41FromDiscord<Girvo> Haha you all beat me to it
08:22:45FromDiscord<Elegantbeef> I dont recall which is defined
08:22:51FromDiscord<Rika> Both are
08:22:55FromDiscord<#!/rip/luke> In reply to @Elegantbeef "`when defined(debug)`?": Isn't that for a .nimble file?
08:23:00FromDiscord<Rika> Works in Nim too
08:23:07FromDiscord<#!/rip/luke> Ok
08:23:18FromDiscord<#!/rip/luke> So it's compile time right?
08:23:23FromDiscord<Rika> Yes
08:23:28FromDiscord<Elegantbeef> `when` is compile time yes
08:23:33FromDiscord<Rika> How would something become debug without recompilation 😛
08:23:58FromDiscord<Elegantbeef> Binary patching!
08:24:17FromDiscord<Rika> One hell of a patch
08:25:26FromDiscord<huantian> It’s probably be easier to go the other way
08:25:29FromDiscord<#!/rip/luke> In reply to @Elegantbeef "`when` is compile time": So can I have it set a var?
08:25:51FromDiscord<huantian> Yeah
08:26:01FromDiscord<Elegantbeef> No need for a var but yes
08:26:06FromDiscord<Elegantbeef> `const isDebug = defined(debug)`
08:26:07FromDiscord<Girvo> In reply to @Rika "How would something become": Do some JIT compilation of your own code and have it instrument based on a runtime variable? 😄 haha
08:26:17FromDiscord<Rika> Cursed
08:26:17FromDiscord<#!/rip/luke> In reply to @Elegantbeef "`const isDebug = defined(debug)`": Oh
08:26:36FromDiscord<#!/rip/luke> I was gonna do an if statement but thats probably better
08:31:25FromDiscord<Girvo> In reply to @Elegantbeef "Does Zig/C use unbuffered": For C it depends on your OS's socket implementation lol
08:32:23FromDiscord<Elegantbeef> Sure but we're talking about their use case
08:33:23FromDiscord<Elegantbeef> So that's kinda like "What did you put out the campfire with?" "Oh some people use water bombers to put out fires"
08:33:51FromDiscord<Girvo> Hey now, technically correct is the best kind -- and C the language doesn't specify _anything_ about buffering on sockets, that's up to the operating system
08:33:54FromDiscord<Elegantbeef> You're not wrong but the context is important!
08:34:20FromDiscord<Girvo> So understanding where an answer comes from matters too, IMO 🙂
08:34:54FromDiscord<Girvo> In reply to @Elegantbeef "So that's kinda like": Using water bombers to put out fires is pretty common here in aus these days lol 😭
08:39:44FromDiscord<Phil> Fun fact, there is now a webpage that allows you to monitor the collapse for maximum depression:↵https://fosspost.org/foss-post-collapse-monitor-program/
08:41:06FromDiscord<Elegantbeef> Luckily we're not the only planet capable of life in the universe
08:41:09FromDiscord<Rika> “This is the idea of this small app; it is a web browser…”
08:47:40FromDiscord<Girvo> In reply to @Isofruit "Fun fact, there is": Yay... 😭
08:49:54FromDiscord<Phil> In reply to @Rika "“This is the idea": I also find web browsers to be truly tiny and light weight apps
08:50:21FromDiscord<Elegantbeef> phil have you got into the alcohol early today?
08:50:23FromDiscord<Phil> Maybe I should add a /s to the end of that statement for clarity
08:51:03FromDiscord<Phil> Started dealing with testing in angular at 08:00 am this morning, equivalent effects beef
08:51:43FromDiscord<Phil> (edit) "Started dealing with testing in angular at 08:00 am this morning, ... equivalenteffects," added "they have" | "effects" => "effects,"
08:53:31FromDiscord<Girvo> Oh man I do not miss Angular
08:53:39FromDiscord<Girvo> v1 _or_ any of them that came after
08:56:56FromDiscord<Phil> I mean, writing the code isn't bad
08:57:16FromDiscord<Phil> What is really annoying about Angular is that you have to inject everything and its mother for testing, making it hyper complicated for some reason
08:57:55FromDiscord<Phil> I pretty much appreciate it being opinionated, same for rxjs
08:58:12FromDiscord<Phil> But damn writing tests in that thign
08:58:59FromDiscord<Rika> > heard about this now↵> recalls being assigned a project at work which uses angular and rxjs
08:59:02FromDiscord<Rika> I’m in danger
09:00:53*rockcavera quit (Remote host closed the connection)
09:00:58FromDiscord<Phil> Is it the test bits that scare you or rxjs?
09:04:47FromDiscord<jmgomez> Taking about RxJs is there any known attempt to make RxNim?
09:04:54FromDiscord<jmgomez> (edit) "Taking" => "Talking"
09:06:07FromDiscord<Rika> I tried
09:06:15FromDiscord<Rika> Hard to understand the intervals
09:06:16FromDiscord<Rika> Internals
09:08:10FromDiscord<jmgomez> wouldnt make a wrapper around Future work?
09:11:14NimEventerNew thread by Drkameleon: Compiler error on Windows that doesn't occur on Mac/Linux, see https://forum.nim-lang.org/t/9332
09:39:16FromDiscord<#!/rip/luke> How can I set a GitHub actions cpu arch
09:48:31FromDiscord<#!/rip/luke> Are there any good examples of nim cross compiling in GitHub actions
09:48:39FromDiscord<#!/rip/luke> Like for Mac windows linux
09:48:50FromDiscord<#!/rip/luke> And arm x86 and i386
10:10:41FromDiscord<t8m8> When I tried to create an account at https://forum.nim-lang.org/, I got the message "Unknown error occurred" and could not create an account. Do you know what could be the cause?
10:17:17FromDiscord<flywind> I don't know, How about refreshing the page? Here are the issues regarding the Nim forum https://github.com/nim-lang/nimforum/issues
10:20:11FromDiscord<4zv4l> why does Nim is called Nim ?
10:29:02FromDiscord<t8m8> In reply to @flywind "I don't know, How": I looked at the issue https://github.com/nim-lang/nimforum/issues/327 and it appears that someone else is having the same problem. I will wait for an update. Thank you🙂
10:29:39FromDiscord<Phil> In reply to @4zv4l "why does Nim is": Was originally called nimrod, origin of the name
10:30:48FromDiscord<4zv4l> ooh Nimrod is a game ?
10:30:55FromDiscord<flywind> In reply to @t8m8 "I looked at the": Hi, did you create the account but not receive the comfirmed emails?
10:31:10FromDiscord<flywind> (edit) "emails?" => "email?"
10:31:34FromDiscord<jmgomez> In reply to @4zv4l "ooh Nimrod is a": https://www.wikiwand.com/en/Nimrod
10:33:35FromDiscord<flywind> In reply to @flywind "Hi, did you create": If so, you can tell @ moderators your acount name and ask them to help you active your account.
10:34:09FromDiscord<t8m8> In reply to @flywind "Hi, did you create": To be exact, once I created the account, I did not receive a confirmation email (it was not in my spam mail either), so I deleted the account and tried to create it again. When I did so, I got an "Unknown error occurred" message and was unable to create an account.
10:34:54FromDiscord<flywind> In reply to @t8m8 "To be exact, once": Yeah, this is a known issue => https://github.com/nim-lang/nimforum/issues/218
10:38:17FromDiscord<t8m8> In reply to @flywind "Yeah, this is a": oh, I see😣
10:38:59FromDiscord<t8m8> <@&371760044473319454> Can you please confirm that the account t8m8 exists on the nim forum?
10:40:29FromDiscord<impbox [ftsf]> https://forum.nim-lang.org/profile/t8m8
10:41:40NimEventerNew Nimble package! util - Small utilities that isn't large enough to have a individual modules, see https://github.com/thisago/util
10:41:41FromDiscord<t8m8> In reply to @impbox "https://forum.nim-lang.org/profile/t8m8": I see. It looks like you have succeeded in deleting it🤔
10:42:11FromDiscord<impbox [ftsf]> In reply to @t8m8 "I see. It looks": i don't know if it ever existed, but it's a 404 at the moment
10:42:36FromDiscord<impbox [ftsf]> would have to check the forum source to see what that means
10:47:28FromDiscord<dom96> it means its deleted
10:47:34FromDiscord<dom96> (edit) "its" => "it's"
10:48:01FromDiscord<dom96> and the forum right now has a bug and doesn't allow you to recreate an account with a deleted account's nickname
10:50:27FromDiscord<#!/rip/luke> How can I make an image grayscale with pixie
10:52:46FromDiscord<t8m8> In reply to @dom96 "and the forum right": Thank you. I just got restricted from using the same email, so I'll try later with a different account name 🙂
10:56:42FromDiscord<t8m8> By the way, is it possible to have a Japanese(日本語) text channel added to the language-specific category of the discord for the Japanese community?
10:57:54FromDiscord<flywind> In reply to @t8m8 "By the way, is": There is also a dedicated Nim discord server.
10:58:10FromDiscord<flywind> (edit) "In reply to @t8m8 "By the way, is": There is also a dedicated ... Nim" added "japanese"
11:01:47FromDiscord<t8m8> In reply to @flywind "There is also a": Oh my, I didn't know! Thanks for letting me know.
11:01:57FromDiscord<flywind> In reply to @t8m8 "Oh my, I didn't": https://discord.com/invite/3umT33kQhS
11:03:50FromDiscord<t8m8> In reply to @flywind "https://discord.com/invite/3umT33kQhS": Thank you! 🙌
11:04:11FromDiscord<flywind> You are welcome
11:36:24*CyberTailor quit (Read error: Connection reset by peer)
11:37:51*CyberTailor joined #nim
11:41:36*CyberTailor quit (Remote host closed the connection)
11:42:31*CyberTailor joined #nim
12:44:54FromDiscord<Vindaar> Still think it would be a good idea to have a Japanese channel (and the extra server could maybe be linked in the description of it)
13:09:21FromDiscord<4zv4l> just read this ↵> Nim's VM is portable and can be embedded inside a browser↵Why does Nim use a vm ?
13:31:07FromDiscord<konsumlamm> for compile time function evaluation
13:31:45FromDiscord<konsumlamm> i.e. only at compile time
13:32:14FromDiscord<konsumlamm> the code that you're running in the end is a native binary
13:36:02FromDiscord<4zv4l> alright thanks !
13:37:37FromDiscord<4zv4l> I'm currently doing a student job in a company in Belgium that made chargers for electric cars↵for now they use Java for their backend and deal with the OCPP protocol, is there any OCPP lib in Nim ? I'm not from the dev team but they told me that once we will split the backend in containers with kubernetes, we could use another language for differents parts
13:54:42FromDiscord<t8m8> In reply to @Vindaar "Still think it would": I think so too!
13:55:23*arkurious joined #nim
14:22:56*CyberTailor quit (Remote host closed the connection)
14:25:07*rockcavera joined #nim
14:25:07*rockcavera quit (Changing host)
14:25:07*rockcavera joined #nim
14:26:03*CyberTailor joined #nim
14:26:24*gsalazar joined #nim
14:42:34*LuxuryMode quit (Quit: Connection closed for inactivity)
16:04:46FromDiscord<!!sharpcdf!!> In reply to @4zv4l "I'm currently doing a": I didn't find any on nimble, but there might be some on GitHub that haven't been published
16:06:08*gsalazar quit (Read error: Connection reset by peer)
16:06:24*gsalazar joined #nim
16:52:08reversem3[m]How would you generate ECC key using proc ecKeygen*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey;
16:52:08reversem3[m] kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br_ec_keygen"
16:52:44reversem3[m] * How would you generate ECC key using `proc ecKeygen\*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey;
16:52:44reversem3[m] kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br\_ec\_keygen"`
17:00:16reversem3[m]How would I generate private/public key using bearssl ? Looking through the abi I found this How would you generate ECC key using `proc ecKeygen\*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey; kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br\_ec\_keygen"`
17:00:57reversem3[m]When I try to call ecKeygen() I dont' even get an error just a undeclared identifier
17:01:38reversem3[m]unctions taking a XxxContext* use var and not ptr
17:01:43reversem3[m]s/unctions/functions/, s/*/\*/
17:11:35*LuxuryMode joined #nim
17:22:00FromDiscord<reversem3> Ok so you can use br\_ec\_keygen↵Error\: expression 'brEcKeygen' is of type 'proc (ctx\: ptr ptr PrngClass, impl\: ptr EcImpl, sk\: ptr EcPrivateKey, keybuf\: ptr byte, curve\: cint)\: int{.cdecl, noSideEffect, gcsafe.}' and has to be used (or discarded); for a function call use ()
17:50:57*xet7 joined #nim
17:59:54*pch quit (Quit: Leaving)
18:00:52FromDiscord<Professor Actual Factual> In reply to @4zv4l "I'm currently doing a": Probably not?↵Seems to specific.↵You can either mame your own or try to port a cpp or c library to nim via c2nim
18:33:33FromDiscord<4zv4l> Well it exists in Go, Python, Ruby, Java so why not in Nim ? XD
18:36:32FromDiscord<Generic> because nobody cared to write one already
18:36:45FromDiscord<Generic> you know where most libraries come from?
18:37:04FromDiscord<Rika> theres a lot more people using go python ruby java
18:37:25FromDiscord<Rika> theres a higher likelihood for someone who cares in those communities
18:37:46FromDiscord<Generic> to be a bit less snarky, be the change you want to see in the world
18:43:45*gsalazar quit (Ping timeout: 268 seconds)
18:44:02FromDiscord<hotdog> In reply to @4zv4l "Well it exists in": You could probably bind to one of the existing libraries
18:48:08*vicecea quit (Remote host closed the connection)
18:48:39*vicecea joined #nim
18:58:30FromDiscord<reversem3> What do you mean ?
19:00:47FromDiscord<!!sharpcdf!!> Use c2nim or futhark
19:00:53FromDiscord<hotdog> if there's a C/C++/JS library use that Nim backend to interface with it, or use the python one with pynim. The best thing would be to create a pure Nim library, but sometimes this is quicker
19:08:03FromDiscord<domosokrat> A `nimble search bearssl` spits out https://github.com/status-im/nim-bearssl
19:08:55FromDiscord<reversem3> Yeah thats what I have been using but can't figure it out
19:09:10FromDiscord<reversem3> ow would I generate private/public key using bearssl ? Looking through the abi I found this How would you generate ECC key using proc ecKeygen\(rngCtx\: ptr ptr PrngClass; impl\: ptr EcImpl; sk\: ptr EcPrivateKey; kbuf\: pointer; curve\: cint)\: uint {.importcFunc, importc\: "br\_ec\_keygen"
19:26:05FromDiscord<domosokrat> I would probably start with https://github.com/status-im/BearSSL/blob/acc70b1be60a6f321e2da618cd35d901b1a598a4/inc/bearssl_ec.h and the other header files to get the documentation of the function and its arguments
19:37:58FromDiscord<reversem3> ok , interesting thanks
19:40:50FromDiscord<domosokrat> hope it helps
20:46:17*rockcavera quit (Ping timeout: 245 seconds)
20:47:44FromDiscord<reversem3> kind of https://github.com/status-im/BearSSL/blob/acc70b1be60a6f321e2da618cd35d901b1a598a4/inc/bearssl_rand.h
20:48:11*rockcavera joined #nim
20:48:11*rockcavera quit (Changing host)
20:48:11*rockcavera joined #nim
20:51:39*tiorock joined #nim
20:51:39*tiorock quit (Changing host)
20:51:39*tiorock joined #nim
20:51:39*rockcavera is now known as Guest491
20:51:39*tiorock is now known as rockcavera
20:54:20*Guest491 quit (Ping timeout: 255 seconds)
21:09:39FromDiscord<reversem3> Yeah I don't get it
21:49:30FromDiscord<#!/rip/luke> Is it possible to wrap a go library in nim?
21:51:58FromDiscord<!Patitotective> In reply to @ripluke "Is it possible to": compile it to c 😎
21:52:11FromDiscord<#!/rip/luke> How do u compile go to c
21:52:13FromDiscord<!Patitotective> it could maybe work if you make a dll
21:52:18FromDiscord<!Patitotective> In reply to @ripluke "How do u compile": i was joking
21:52:21FromDiscord<#!/rip/luke> Oh
21:52:27FromDiscord<#!/rip/luke> Lol I'm not a go dev
21:52:51FromDiscord<#!/rip/luke> Hmm if I wanted to use a js library would I HAVE to compile to js?
21:53:24FromDiscord<voidwalker> what does array[^1], ^2. etc mean ?
21:53:33FromDiscord<voidwalker> hard to google
21:53:54FromDiscord<!Patitotective> In reply to @voidwalker "what does array[^1], ^2.": backward index
21:53:56FromDiscord<!Patitotective> (edit) "backward" => "backwards"
21:54:10FromDiscord<voidwalker> so ^1 is len-1 ?
21:54:11FromDiscord<!Patitotective> last element, second last element...
21:54:15FromDiscord<!Patitotective> In reply to @voidwalker "so ^1 is len-1": yes
21:54:38FromDiscord<!Patitotective> In reply to @ripluke "Hmm if I wanted": https://nim-lang.org/docs/jsffi.html
21:54:49FromDiscord<!Patitotective> id say yes
21:55:17FromDiscord<#!/rip/luke> Ah
21:55:21FromDiscord<#!/rip/luke> That sucks
21:55:34FromDiscord<#!/rip/luke> Guess I'll have to write it myself
21:56:10FromDiscord<!Patitotective> you can always try to do it and maybe magically work
22:00:33FromDiscord<!Patitotective> https://media.discordapp.net/attachments/371759389889003532/1002697159126306866/unknown.png
22:03:24FromDiscord<!Patitotective> https://nim-lang.org/docs/backends.html#nim-code-calling-the-backend-javascript-invocation-example
23:50:19*CyberTailor quit (Ping timeout: 268 seconds)
23:50:43FromDiscord<!!sharpcdf!!> i didnt even know there were js library bindings for nim 😅
23:51:08*CyberTailor joined #nim
23:51:59FromDiscord<!!sharpcdf!!> In reply to @ripluke "Is it possible to": i think you can make a c wrapper for a go library
23:52:13FromDiscord<!!sharpcdf!!> and then make a nim wrapper for the c wrapper xd
23:52:17FromDiscord<!!sharpcdf!!> idk i havent used go in a bit
23:52:29FromDiscord<#!/rip/luke> I've never used go 💀
23:52:36FromDiscord<!!sharpcdf!!> 💀
23:52:59FromDiscord<!!sharpcdf!!> In reply to @ripluke "I've never used go": https://medium.com/learning-the-go-programming-language/calling-go-functions-from-other-languages-4c7d8bcc69bf
23:53:22FromDiscord<!!sharpcdf!!> not that difficult
23:53:31FromDiscord<!!sharpcdf!!> golang is pretty modern
23:53:41FromDiscord<!!sharpcdf!!> syntax is a bit odd though
23:54:34FromDiscord<#!/rip/luke> Oh
23:55:56FromDiscord<!!sharpcdf!!> you'd probably have to manually make the exports though, i doubt that the go library you want to use has a dll/so for use