00:12:04 | FromDiscord | <Prestige> Maybe ask on the forum |
00:55:59 | FromDiscord | <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:14 | FromDiscord | <!Patitotective> you just `jsonNode.getStr()` |
00:58:34 | FromDiscord | <LaughingBubba> I get that, I just don't understand why $ doesnt just fail at compile time? |
00:59:01 | FromDiscord | <!Patitotective> because `$` is used to stringify something↵stringify in the sense of printing |
00:59:10 | FromDiscord | <LaughingBubba> ah |
00:59:18 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=45Yu |
00:59:30 | FromDiscord | <!Patitotective> result is implicitly declared as `var result: Message` |
00:59:41 | FromDiscord | <!Patitotective> and automatically returned |
01:00:31 | FromDiscord | <LaughingBubba> ^^^ Thats what I ended up doing & I understand the implicit result (I dont have to use it tho) |
01:01:15 | FromDiscord | <LaughingBubba> So I basically didnt understand proper usage of $ |
01:01:57 | FromDiscord | <LaughingBubba> It's like a substitution variable in a JS typed literal |
01:02:14 | FromDiscord | <LaughingBubba> Thanks @!Patitotective |
01:02:31 | FromDiscord | <!Patitotective> :] |
01:03:00 | FromDiscord | <!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:23 | FromDiscord | <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:11 | FromDiscord | <#!/rip/luke> How can I convert a sequence to a json array |
02:38:44 | * | arkurious quit (Quit: Leaving) |
02:56:50 | FromDiscord | <!Patitotective> In reply to @ripluke "How can I convert": `% mySeq` |
02:56:55 | FromDiscord | <!Patitotective> horrible macro name, i know |
02:57:37 | FromDiscord | <#!/rip/luke> In reply to @Patitotective "`%* mySeq`": Ok |
02:58:39 | FromDiscord | <#!/rip/luke> In reply to @Patitotective "`%* mySeq`": In std/json? |
02:59:04 | FromDiscord | <!Patitotective> ofc |
02:59:55 | FromDiscord | <#!/rip/luke> And how is it returned? As a string? |
03:00:50 | FromDiscord | <!Patitotective> as a JsonNode |
03:01:21 | FromDiscord | <#!/rip/luke> Ok |
03:50:22 | FromDiscord | <neon_> Hey guys, how would i go about reading a file by specified number of bytes starting at a specific byte |
03:51:22 | FromDiscord | <Girvo> _waves hello_ |
03:52:04 | FromDiscord | <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:05 | FromDiscord | <Girvo> In reply to @Patitotective "horrible macro name, i": Yeah oof that one is a bit rough haha |
03:54:04 | FromDiscord | <neon_> sent a code paste, see https://play.nim-lang.org/#ix=45Z1 |
03:54:32 | FromDiscord | <neon_> (edit) "https://play.nim-lang.org/#ix=45Z1" => "https://play.nim-lang.org/#ix=45Z2" |
03:55:12 | FromDiscord | <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:20 | FromDiscord | <Girvo> @neon_ Can you use FileStream or nah? |
03:56:13 | FromDiscord | <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:26 | FromDiscord | <neon_> (edit) "to" => "from" |
03:57:42 | FromDiscord | <neon_> wait i misread it |
03:58:11 | FromDiscord | <neon_> sent a code paste, see https://play.nim-lang.org/#ix= |
03:58:16 | FromDiscord | <Girvo> Yeah |
03:58:23 | FromDiscord | <neon_> holy shit thanks |
03:58:25 | FromDiscord | <Girvo> I believe so anyway 🙂 |
03:58:44 | FromDiscord | <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:32 | FromDiscord | <Girvo> `readData` can also specifically take a `slice` as well, so you could give it the `0..chunkSize-1` slice |
03:59:43 | FromDiscord | <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:45 | FromDiscord | <Girvo> I believe anyway |
03:59:56 | FromDiscord | <Girvo> I haven't written FileStream code in a loooong while |
04:01:05 | FromDiscord | <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:48 | FromDiscord | <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:13 | FromDiscord | <neon_> but im no expert on this |
04:05:40 | FromDiscord | <Girvo> Yeah fair enough! They're basically type aliases of one another anyway as far as I remember |
04:06:16 | FromDiscord | <neon_> Yeah afik i think its the same and the conventions came from windows naming their sizes weirdly like nibble and word |
04:06:28 | FromDiscord | <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:35 | FromDiscord | <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:03 | FromDiscord | <Girvo> Haha a word is 2 bytes 🙂 |
04:07:23 | FromDiscord | <Girvo> Where a byte is `n` bits defined per-platform! It's an odd convention |
04:07:46 | FromDiscord | <Girvo> But handy, as the Modbus driver I'm working on has to deal with both byte _and_ word-order endianness |
04:07:54 | FromDiscord | <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:41 | FromDiscord | <neon_> ah yes the industrial standards gotta love their flexibility that usually makes it a pain to implement XD |
04:08:59 | FromDiscord | <Girvo> Man Modbus RTU was basically invented in the 1970s and it _feels_ like it lol |
04:09:46 | FromDiscord | <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:04 | FromDiscord | <Girvo> Haha yeah Modbus RTU-over-TCP is fascinating |
05:32:18 | FromDiscord | <Girvo> And then just to be confusing there is Modbus TCP which is a different thing altogether |
05:32:21 | FromDiscord | <Girvo> Woooooo 😭 |
06:07:46 | FromDiscord | <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:08 | FromDiscord | <huantian> Have you tried base64 😛 |
06:12:54 | FromDiscord | <huantian> In seriousness I haven’t looked at that kind of compression, kind of an interesting concept though |
06:13:07 | FromDiscord | <Girvo> haha 🙂 |
06:13:39 | FromDiscord | <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:58 | FromDiscord | <huantian> Yeah that makes sense |
06:14:02 | FromDiscord | <huantian> Wrapping shoco seems pretty easy though, just two functions |
06:14:07 | FromDiscord | <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:20 | FromDiscord | <Girvo> Yeah its why I was looking at it! |
06:14:30 | FromDiscord | <Girvo> Any C library that is that simple to bind always gets my attention lol |
06:14:38 | FromDiscord | <Girvo> (If there isn't a Nim version on it's own) |
06:14:57 | FromDiscord | <4zv4l> is there any kind of `readUntilDelimiter` in Nim ? |
06:15:12 | FromDiscord | <Girvo> Like `readUntil` @4zv4l |
06:15:14 | FromDiscord | <Girvo> (edit) "@4zv4l" => "@4zv4l?" |
06:15:22 | FromDiscord | <4zv4l> is it implemented for socket ? |
06:15:30 | FromDiscord | <huantian> In reply to @Girvo "(If there isn't a": I don’t know of any but I have done zero searching |
06:15:54 | FromDiscord | <Girvo> @huantian I had a look and didn't find much haha |
06:16:04 | FromDiscord | <Girvo> @4zv4l yeah I know there is one that works, give me a sec and I'll find what the proc is |
06:16:06 | FromDiscord | <4zv4l> In reply to @Girvo "Like `readUntil` <@329196212282458112>?": in which lib is it ? |
06:16:14 | FromDiscord | <4zv4l> In reply to @Girvo "<@329196212282458112> yeah I know": thanks ! |
06:16:20 | FromDiscord | <Girvo> @4zv4l I got the symbol name wrong, one second 🙂 |
06:16:46 | FromDiscord | <Rika> In reply to @Girvo "The main reason things": zstd has an AOT dictionary system as well |
06:16:46 | FromDiscord | <Girvo> `parseUntil` is what I was thinking of I think |
06:16:59 | FromDiscord | <Girvo> @Rika Yeah I was literally just reading about that! Might be the way to go |
06:17:21 | FromDiscord | <Girvo> @4zv4l https://nim-lang.org/docs/parseutils.html#parseUntil%2Cstring%2Cstring%2Cchar%2Cint |
06:17:28 | FromDiscord | <Girvo> Though it works on `string` which might not be what you're looking for |
06:17:46 | FromDiscord | <Girvo> Theres a better solution though |
06:17:55 | FromDiscord | <Girvo> (edit) "though" => "though, I just can't think of it lol" |
06:17:55 | FromDiscord | <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:03 | FromDiscord | <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:34 | FromDiscord | <Girvo> Could use `std/socketstreams` and hack something up with `peekChar` or whatever data you're lokoing at from `std/streams` |
06:21:32 | FromDiscord | <Girvo> @4zv4l Are you trying to get it to break/stop on a newline? |
06:24:46 | FromDiscord | <4zv4l> it has to read more than some lines |
06:24:48 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zg |
06:24:56 | FromDiscord | <Girvo> Could use `stream.readLine()` and parse/work with it per-line |
06:25:17 | FromDiscord | <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:25 | FromDiscord | <Girvo> Otherwise you'll have to do it per-line |
06:25:34 | FromDiscord | <Girvo> Post the C and Nim code somewhere? |
06:25:52 | FromDiscord | <4zv4l> In reply to @4zv4l "": Nim code |
06:26:27 | FromDiscord | <Girvo> Thats a socketstream ReadStream yeah? |
06:26:29 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zh |
06:26:44 | FromDiscord | <4zv4l> not yet |
06:26:54 | FromDiscord | <4zv4l> but I'm trying to change it since you made me discover that |
06:27:12 | FromDiscord | <Girvo> Okay 🙂 Give that a try, as I believe that works the same way you're expecting |
06:27:30 | FromDiscord | <4zv4l> In reply to @Girvo "Thats a socketstream ReadStream": I didn't find socketstream in the stream lib |
06:27:36 | FromDiscord | <Girvo> `import socketstream` |
06:27:46 | FromDiscord | <Girvo> It is it's own lib in the standard library 🙂 |
06:27:49 | FromDiscord | <Girvo> https://nim-lang.org/docs/socketstreams.html |
06:27:50 | FromDiscord | <4zv4l> oh so in another lib alright |
06:28:23 | FromDiscord | <4zv4l> oh but can I open a read/write socketstream ? |
06:28:29 | FromDiscord | <4zv4l> or I have to open two socketstream then ? |
06:28:36 | FromDiscord | <Girvo> You open two socketstreams I believe |
06:28:47 | FromDiscord | <Girvo> Makes it clearer I find anyway! |
06:29:07 | FromDiscord | <4zv4l> alright I'll try that ^^ |
06:31:46 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zi |
06:32:05 | FromDiscord | <Girvo> But `readLine` is better IMO |
06:32:17 | FromDiscord | <4zv4l> yeah i'll try with the readline first |
06:32:30 | FromDiscord | <4zv4l> but so I also need to rewrite the server code right ? |
06:32:36 | FromDiscord | <4zv4l> since it has to accept two sockets |
06:32:56 | FromDiscord | <Girvo> Possibly yeah |
06:33:19 | FromDiscord | <4zv4l> alright I found |
06:33:21 | FromDiscord | <4zv4l> `The WriteSocketStream allows both reading and writing` |
06:33:26 | FromDiscord | <Girvo> Oh nice haha |
06:33:26 | FromDiscord | <4zv4l> so only one socket |
06:33:33 | FromDiscord | <Girvo> It's been a while since I've used this stuff! |
06:34:10 | FromDiscord | <Girvo> Yeah literally the last time I worked with this was 2017 haha for Nim v0.14.3 |
06:35:04 | FromDiscord | <Girvo> @Rika I wonder if zlib is a good fit for embedded. Surely right? Especially with dicts pre-calculated |
06:36:34 | FromDiscord | <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:37 | FromDiscord | <Girvo> Ah crap lol |
06:37:42 | FromDiscord | <Girvo> >No support for gzip headers or zlib static dictionaries |
06:37:49 | FromDiscord | <Girvo> (edit) ">No" => "> No" |
06:37:51 | FromDiscord | <Girvo> So much for that! |
06:41:09 | FromDiscord | <Girvo> Oh nice. `zstd` supports static memory allocation as of 2017 |
06:44:38 | FromDiscord | <Rika> In reply to @Girvo "<@259277943275126785> I wonder if": Zlib and Zstd are different |
06:45:19 | FromDiscord | <Girvo> @Rika yeah sorry I've been staring at both haha |
06:45:36 | FromDiscord | <Rika> Depends on how restrained you are really |
06:45:39 | FromDiscord | <Rika> Either should be fine |
06:46:14 | FromDiscord | <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:13 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zj |
06:47:29 | FromDiscord | <4zv4l> the indentation isn't well made sorry xD |
06:47:32 | FromDiscord | <Girvo> Oof it ate your formatting there so I can't count lines haha |
06:47:38 | FromDiscord | <4zv4l> discord made it weird |
06:47:40 | FromDiscord | <Girvo> What is on line 19? |
06:47:45 | FromDiscord | <Girvo> `stdout.write "$ "` yeah? |
06:47:56 | FromDiscord | <Girvo> Wait no `stream.write(input)`? |
06:48:02 | FromDiscord | <4zv4l> `stream.write(input)` |
06:48:06 | FromDiscord | <Girvo> Okay one moment |
06:48:06 | FromDiscord | <4zv4l> this is line 19 |
06:48:21 | FromDiscord | <Girvo> Show me your `import` block? |
06:48:49 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zk |
06:48:53 | FromDiscord | <Girvo> Add `import streams` |
06:49:02 | FromDiscord | <Elegantbeef> Jesus christ here i thought the chat was dead but the bridge was just dead |
06:49:18 | FromDiscord | <Girvo> Hah I wondered why it seemed so quiet here without ya 😉 |
06:49:36 | FromDiscord | <Elegantbeef> Your guy's messages just poured in |
06:49:47 | FromDiscord | <4zv4l> they didn't write that I need to add that lib did they ? |
06:50:02 | FromDiscord | <Girvo> Doesn't seem like it in the example |
06:50:10 | FromDiscord | <Girvo> And I'm not sure it will fix it, but it's worth a try! |
06:50:29 | FromDiscord | <Elegantbeef> socketstreams does not export sockets |
06:50:32 | FromDiscord | <Elegantbeef> well streams i mean |
06:50:54 | FromDiscord | <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:55 | FromDiscord | <Elegantbeef> It's odd it doesnt |
06:51:18 | FromDiscord | <Girvo> It uses `write` and `readLine` while never importing `streams` itself haha |
06:51:19 | FromDiscord | <Elegantbeef> Memfiles doesnt export it either |
06:51:34 | FromDiscord | <Elegantbeef> Guess the thing for memfiles is "if you dont need it you dont need it" |
06:51:42 | FromDiscord | <Elegantbeef> Well you fix their problem then suggest they make a PR 😛 |
06:51:43 | FromDiscord | <Girvo> Yeah memfiles I can kind of understand |
06:51:49 | FromDiscord | <Elegantbeef> It's the Nim way |
06:52:39 | FromDiscord | <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:01 | FromDiscord | <4zv4l> how can I read until the server doesn't send anything ? |
06:53:40 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zl |
06:54:15 | FromDiscord | <Elegantbeef> It's a blocking operation |
06:54:16 | FromDiscord | <Elegantbeef> Which means your CPU will be held hostage until it's done |
06:54:40 | FromDiscord | <Girvo> Which is why `asyncsocketstreams` exists! weeeeee |
06:54:48 | FromDiscord | <Elegantbeef> Yep |
06:54:50 | FromDiscord | <Girvo> (edit) "`asyncsocketstreams`" => "`asyncstreams`" |
06:55:03 | FromDiscord | <Elegantbeef> Async allows you to wait on IO to not block your CPU until you want to |
06:55:09 | FromDiscord | <4zv4l> In reply to @Girvo "Which is why `asyncstreams`": I'm really new to that async stuff |
06:55:21 | FromDiscord | <4zv4l> so if you could explain me how to implement that |
06:55:25 | FromDiscord | <4zv4l> could be nice xD |
06:55:34 | FromDiscord | <4zv4l> cause the only async I know is the Zig one |
06:55:44 | FromDiscord | <4zv4l> which is just a ping pong game between functions |
06:55:47 | FromDiscord | <Girvo> Ah fair. Had much experience with Javascript async? |
06:55:56 | FromDiscord | <Girvo> It's sort of similar |
06:56:00 | FromDiscord | <4zv4l> never used async in js but I got the spirit |
06:56:12 | FromDiscord | <Girvo> in-so-much as it's all just `Future[T]` based |
06:56:14 | FromDiscord | <4zv4l> my uncle explained me someday |
06:56:32 | FromDiscord | <Girvo> @4zv4l Is all this just over a TCP socket you're reading/writing to? |
06:57:10 | FromDiscord | <4zv4l> sent a long message, see http://ix.io/45Zm |
06:57:10 | FromDiscord | <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:15 | FromDiscord | <4zv4l> my C implementation is quite simple |
06:57:21 | FromDiscord | <Girvo> But okay cool! |
06:58:03 | FromDiscord | <Girvo> Silly suggestion: make sure what you're writing has a newline terminator |
06:58:06 | FromDiscord | <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:10 | FromDiscord | <Girvo> Otherwise `readLine` will never finish |
06:58:12 | FromDiscord | <4zv4l> while in others it won't wait to fill the butter |
06:58:32 | FromDiscord | <Elegantbeef> there is a nonblocking `recv` with a timeout |
06:58:59 | FromDiscord | <Girvo> https://nim-lang.org/docs/net.html#recv%2CSocket%2Cpointer%2Cint%2Cint |
06:59:13 | FromDiscord | <Girvo> Timeout is defined as `-1` by default isn't it, beef? |
06:59:25 | FromDiscord | <Elegantbeef> In the non pointer version yes |
06:59:40 | FromDiscord | <Elegantbeef> The pointer version doesnt have an optional timeout |
06:59:44 | FromDiscord | <Girvo> Ah true |
07:00:02 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zn |
07:00:03 | FromDiscord | <4zv4l> that's with the readline loop |
07:00:32 | FromDiscord | <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:20 | FromDiscord | <Girvo> @4zv4l Give me a moment, I'm writing a snippet to test this myself |
07:05:20 | FromDiscord | <Elegantbeef> What are we even trying to do anywho? |
07:13:37 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=45Zr |
07:16:03 | FromDiscord | <Elegantbeef> You cannot use `await` in a non async procedure |
07:17:20 | FromDiscord | <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:15 | FromDiscord | <4zv4l> nativesockets seem to be annoying to deal with in Nim xD |
07:21:25 | FromDiscord | <4zv4l> connect set non blocking on default socket ? |
07:21:39 | FromDiscord | <4zv4l> In reply to @Elegantbeef "You cannot use `await`": those were async proc since they're from asyncnet I guess |
07:22:50 | FromDiscord | <Rika> He means your handle procedure should be async as well |
07:23:34 | FromDiscord | <4zv4l> In reply to @Rika "He means your handle": oh okok xD |
07:23:56 | FromDiscord | <4zv4l> but why ? |
07:24:42 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zu |
07:24:48 | FromDiscord | <Girvo> Pong |
07:24:51 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45Zv |
07:25:03 | FromDiscord | <Girvo> Works 🙂 They echo `"hello"` back at each other haha |
07:25:24 | FromDiscord | <Girvo> (edit) "https://play.nim-lang.org/#ix=45Zu" => "https://play.nim-lang.org/#ix=45Zw" |
07:25:45 | FromDiscord | <4zv4l> thanks, what if the server send multiple lines back ? |
07:26:14 | FromDiscord | <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:16 | FromDiscord | <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:38 | FromDiscord | <Girvo> Many lines is fine, if they're `\n`! Because that is not `\r\L` |
07:26:39 | FromDiscord | <4zv4l> I didn't know \r\L |
07:26:51 | FromDiscord | <4zv4l> alright I'll test that |
07:26:54 | FromDiscord | <Girvo> https://nim-lang.org/docs/net.html#readLine%2CSocket%2Cstring%2Cint |
07:27:00 | FromDiscord | <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:02 | FromDiscord | <Girvo> 🙂 |
07:27:08 | FromDiscord | <4zv4l> even tho I would have liked that my c and nim program were compatible between them |
07:27:45 | FromDiscord | <Girvo> What does your C program rely on? Or you're just doing character by character with `recv` alone? |
07:27:55 | FromDiscord | <4zv4l> no no I send once and read once |
07:28:04 | FromDiscord | <Girvo> What do you send once and read once? |
07:28:59 | FromDiscord | <4zv4l> sent a long message, see https://paste.rs/F37 |
07:29:12 | FromDiscord | <Rika> In reply to @4zv4l "but why ?": That’s how async works |
07:29:15 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1002477890102886462/server.c |
07:29:51 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1002478044675571712/client.c |
07:30:14 | FromDiscord | <4zv4l> and so I was just trying to make that but in Nim |
07:30:38 | FromDiscord | <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:44 | FromDiscord | <4zv4l> In reply to @4zv4l "": so just `send()` and `recv()` |
07:31:55 | FromDiscord | <huantian> In reply to @4zv4l "but why a function": Because monads 😛 |
07:32:07 | FromDiscord | <huantian> But really you have to think about what await does |
07:32:14 | FromDiscord | <4zv4l> In reply to @huantian "Because monads 😛": idk others languages that well but in Zig that's not how it works |
07:32:47 | FromDiscord | <4zv4l> it waits for the other function to either finish or suspend |
07:33:25 | FromDiscord | <huantian> If you want to wait for an async r to finish in a synchronous context, use waitFor |
07:34:04 | FromDiscord | <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:36 | FromDiscord | <Girvo> @huantian Technically `Future[T]` isn't a monad per-se 😉 |
07:34:51 | FromDiscord | <huantian> In reply to @Elegantbeef "You cannot use `await`": Maybe we should backport that change to stable 😛 |
07:35:16 | FromDiscord | <huantian> In reply to @Girvo "<@300050030923087872> Technically `Future[T]` isn't": It is if you squint realllllllly hard |
07:35:30 | FromDiscord | <4zv4l> In reply to @Girvo "Oh I see, you're": so I make a buffer instead of a string right ? |
07:35:35 | FromDiscord | <4zv4l> an array of char I meant |
07:35:56 | FromDiscord | <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:03 | FromDiscord | <Girvo> sent a code paste, see https://paste.rs/t46 |
07:36:27 | FromDiscord | <Girvo> @4zv4l Thats easily solved. Use `import nativesockets` instead of `import net` and run `socket.setBlocking(false)` |
07:36:30 | FromDiscord | <huantian> Future is a monad depending on the implementation right? |
07:36:39 | FromDiscord | <Girvo> Now it will behave the same way you're expecting, if I'm reading it right |
07:36:42 | FromDiscord | <4zv4l> In reply to @Girvo "<@329196212282458112> Thats easily solved.": yeah but then to setup the socket that's more annoying xD |
07:37:01 | FromDiscord | <Girvo> Correct! But thats what `nativesockets` _is_ -- its a thin wrapper over your C-level OS-level socket stuff |
07:37:04 | FromDiscord | <4zv4l> I'm still trying to get something simpler than C 😢 |
07:37:18 | FromDiscord | <Rika> In reply to @4zv4l "idk others languages that": You also probably pass the dispatcher to every async function in Zig |
07:39:21 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45ZT |
07:40:01 | FromDiscord | <Girvo> But learning async programming is well worth it too, and less complex than it sounds, I promise |
07:40:19 | FromDiscord | <Rika> Ah I see what you mean |
07:40:30 | FromDiscord | <Rika> Nim async is not built in to the language like in Zig |
07:40:37 | FromDiscord | <Girvo> Yeah Zig's async is quite interesting |
07:40:44 | FromDiscord | <Girvo> It's attempting to be "colourless" |
07:40:47 | FromDiscord | <Rika> Async is instead implemented as a library in Nim |
07:40:51 | FromDiscord | <Girvo> Which is a valiant effort IMO |
07:41:02 | FromDiscord | <Rika> Except it doesn’t look like it is really |
07:41:13 | FromDiscord | <Rika> Because you still seem to have to match pairs somewhere |
07:41:34 | FromDiscord | <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:38 | FromDiscord | <Rika> I don’t understand what’s so bad about the colouring anyway |
07:41:47 | FromDiscord | <huantian> Does zig use cps? |
07:41:59 | FromDiscord | <huantian> Wait what does color even mean |
07:42:10 | FromDiscord | <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:14 | FromDiscord | <Rika> It’s the “async only in async” kind of thing |
07:42:25 | FromDiscord | <Rika> Informally called colouring because of a blog post |
07:43:05 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=45ZV |
07:43:21 | FromDiscord | <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:36 | FromDiscord | <Rika> Except you can just wait for in Nim 🙂 |
07:43:41 | FromDiscord | <huantian> Isn’t that how it works in Nim kinda |
07:43:45 | FromDiscord | <Rika> It is |
07:43:46 | FromDiscord | <Girvo> Haha which is why I said "other languages" 😉 |
07:43:48 | FromDiscord | <Rika> That’s what he means |
07:43:58 | FromDiscord | <Rika> Zig doesn’t need this is basically what he says |
07:44:05 | FromDiscord | <Rika> Or rather does away with it |
07:44:15 | FromDiscord | <Girvo> `waitFor` letting you just go "screw this, block til it's done" is nice |
07:44:23 | FromDiscord | <Girvo> (edit) "`waitFor` letting you just go "screw this, block til it's done" ... is" added "in a non-async-marked proc" |
07:44:34 | FromDiscord | <huantian> Yeah like pythons asyncio.run |
07:45:06 | FromDiscord | <Rika> Basically “it’s just too complicated for new programmers to understand” is the argument against colouring |
07:45:40 | FromDiscord | <huantian> So that means in async functions you don’t call await at all? |
07:45:46 | FromDiscord | <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:55 | FromDiscord | <Rika> I don’t know how it works in Zig |
07:46:45 | FromDiscord | <huantian> In reply to @Rika "And so instead of": I mean we kinda scared 4z away lol |
07:47:04 | FromDiscord | <Rika> ~~honestly IMO Zig is a write only language to me~~ |
07:47:14 | FromDiscord | <Rika> In reply to @huantian "I mean we kinda": That’s another thing |
07:47:31 | FromDiscord | <4zv4l> how do I connect() with a nativesocket ? |
07:47:49 | FromDiscord | <4zv4l> `proc connect(s: SocketHandle; name: ptr SockAddr; namelen: SockLen)`↵how do I get the SockAddr ? |
07:48:23 | FromDiscord | <4zv4l> so it's like the exact same as in C↵why I can't just say nonblocking on default socket ? |
07:54:02 | FromDiscord | <4zv4l> won't I make a thread just to read from that stream just because the default socket is blocking T-T |
07:54:37 | FromDiscord | <huantian> I’m pretty sure the solution to your problems is async |
07:55:09 | FromDiscord | <4zv4l> but if it waits for the function to read in async or not the function will never finish |
07:55:33 | FromDiscord | <4zv4l> since it's multiple line |
07:55:34 | FromDiscord | <huantian> You don’t have to wait for the function to read |
07:55:48 | FromDiscord | <huantian> Maybe actually idk how sockets work I’ve never used it |
07:55:54 | FromDiscord | <huantian> But I think you want asyncCheck |
07:57:25 | FromDiscord | <4zv4l> it's waiting forever https://media.discordapp.net/attachments/371759389889003532/1002484980376678480/unknown.png |
07:58:21 | FromDiscord | <huantian> It’s blocking on recv yes? |
07:58:35 | FromDiscord | <4zv4l> yessss |
07:58:44 | FromDiscord | <4zv4l> that's the "only" issue |
07:58:48 | FromDiscord | <huantian> Move the echo to recv |
07:58:52 | FromDiscord | <4zv4l> the issue I'm fighting since yesterday |
07:59:06 | FromDiscord | <huantian> Then asyncCheck it instead of waitFor |
07:59:14 | FromDiscord | <huantian> Change the other waitFor to await |
07:59:19 | FromDiscord | <huantian> And make handle async |
07:59:38 | FromDiscord | <huantian> (edit) "And make handle async ... " added "(the one on the bottom I think)" |
08:00:18 | FromDiscord | <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:40 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=460m |
08:06:05 | FromDiscord | <4zv4l> alright it doesn't send anything |
08:06:13 | FromDiscord | <4zv4l> the send isn't working |
08:06:27 | FromDiscord | <huantian> Wait hold on lemme see this again |
08:07:19 | FromDiscord | <huantian> Why not just use recvLine? |
08:07:38 | FromDiscord | <4zv4l> because the server send many lines |
08:08:18 | FromDiscord | <huantian> Well it’s not a normal newline |
08:08:28 | FromDiscord | <huantian> Right? |
08:08:38 | FromDiscord | <huantian> Or am I reading the docs wrong |
08:08:42 | FromDiscord | <4zv4l> well I can try that but for now |
08:08:45 | FromDiscord | <4zv4l> the send isn't working |
08:08:48 | FromDiscord | <4zv4l> so I can't even try the recv |
08:10:32 | FromDiscord | <huantian> Well I don’t think you need async at all |
08:10:43 | FromDiscord | <huantian> Since the client should block until the server has stopped sending |
08:11:33 | FromDiscord | <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:37 | FromDiscord | <4zv4l> I just need the receive to be non blocking |
08:11:41 | FromDiscord | <4zv4l> but |
08:11:59 | FromDiscord | <huantian> Why should receive be non blocking? |
08:12:03 | FromDiscord | <4zv4l> except maybe with the nativesockets which are the same as in C so I don't even wanna try |
08:12:10 | FromDiscord | <4zv4l> I mean |
08:12:28 | FromDiscord | <4zv4l> my C and Zig implementation of this↵both simply `read()` |
08:12:34 | FromDiscord | <4zv4l> if the buffer isn't filled they still continue |
08:12:37 | FromDiscord | <huantian> Your client won’t be doing anything else while it’s still getting info from the server right? |
08:13:22 | FromDiscord | <Elegantbeef> Does Zig/C use unbuffered sockets by default? |
08:13:40 | FromDiscord | <4zv4l> In reply to @huantian "Your client won’t be": yeah it's just a ping pong |
08:13:52 | FromDiscord | <4zv4l> In reply to @Elegantbeef "Does Zig/C use unbuffered": yeah they aren't buffered by default |
08:13:55 | FromDiscord | <huantian> Then why do you need to rely on unbuffered socket behavior |
08:14:03 | FromDiscord | <huantian> Can’t you use readLine |
08:14:09 | FromDiscord | <Elegantbeef> Then make the Nim socket unbuffered 😄 |
08:14:13 | FromDiscord | <Elegantbeef> Then you can just use recv |
08:14:24 | FromDiscord | <4zv4l> because I want my c program to be compatible with the Nim one and vice versa |
08:14:29 | FromDiscord | <4zv4l> In reply to @Elegantbeef "Then make the Nim": how ? |
08:14:36 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/net.html#newSocket%2Ccint%2Ccint%2Ccint |
08:14:45 | FromDiscord | <Elegantbeef> `buffered = false` in your `newSocket` constructor |
08:17:37 | FromDiscord | <4zv4l> finally |
08:17:38 | FromDiscord | <4zv4l> omg |
08:17:40 | FromDiscord | <4zv4l> xD |
08:17:40 | FromDiscord | <4zv4l> damn |
08:17:52 | FromDiscord | <4zv4l> thank you |
08:17:59 | FromDiscord | <Elegantbeef> Who'd have thought reading the docs on recv would help 😛 |
08:19:42 | FromDiscord | <4zv4l> well looked into it really↵just didn't think about buffering ↵but of course now it sounds obvious |
08:19:56 | FromDiscord | <Rika> Well none of us seemed to know the sockets of Zig was unbuffered and Nim was |
08:20:40 | FromDiscord | <4zv4l> Zig is really low level so nothing is buffered by default |
08:20:48 | FromDiscord | <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:27 | FromDiscord | <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:45 | FromDiscord | <Elegantbeef> `strip` |
08:21:51 | FromDiscord | <4zv4l> except trimzero fom strutils I don't find a trim function |
08:21:53 | FromDiscord | <#!/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:07 | FromDiscord | <Girvo> `v1.0.0-debug` |
08:22:18 | FromDiscord | <#!/rip/luke> No like how can I tell |
08:22:19 | FromDiscord | <Girvo> Or `-dbg` |
08:22:34 | FromDiscord | <Rika> There’s defined(release) no? |
08:22:35 | FromDiscord | <Elegantbeef> `when defined(debug)`? |
08:22:41 | FromDiscord | <Girvo> Haha you all beat me to it |
08:22:45 | FromDiscord | <Elegantbeef> I dont recall which is defined |
08:22:51 | FromDiscord | <Rika> Both are |
08:22:55 | FromDiscord | <#!/rip/luke> In reply to @Elegantbeef "`when defined(debug)`?": Isn't that for a .nimble file? |
08:23:00 | FromDiscord | <Rika> Works in Nim too |
08:23:07 | FromDiscord | <#!/rip/luke> Ok |
08:23:18 | FromDiscord | <#!/rip/luke> So it's compile time right? |
08:23:23 | FromDiscord | <Rika> Yes |
08:23:28 | FromDiscord | <Elegantbeef> `when` is compile time yes |
08:23:33 | FromDiscord | <Rika> How would something become debug without recompilation 😛 |
08:23:58 | FromDiscord | <Elegantbeef> Binary patching! |
08:24:17 | FromDiscord | <Rika> One hell of a patch |
08:25:26 | FromDiscord | <huantian> It’s probably be easier to go the other way |
08:25:29 | FromDiscord | <#!/rip/luke> In reply to @Elegantbeef "`when` is compile time": So can I have it set a var? |
08:25:51 | FromDiscord | <huantian> Yeah |
08:26:01 | FromDiscord | <Elegantbeef> No need for a var but yes |
08:26:06 | FromDiscord | <Elegantbeef> `const isDebug = defined(debug)` |
08:26:07 | FromDiscord | <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:17 | FromDiscord | <Rika> Cursed |
08:26:17 | FromDiscord | <#!/rip/luke> In reply to @Elegantbeef "`const isDebug = defined(debug)`": Oh |
08:26:36 | FromDiscord | <#!/rip/luke> I was gonna do an if statement but thats probably better |
08:31:25 | FromDiscord | <Girvo> In reply to @Elegantbeef "Does Zig/C use unbuffered": For C it depends on your OS's socket implementation lol |
08:32:23 | FromDiscord | <Elegantbeef> Sure but we're talking about their use case |
08:33:23 | FromDiscord | <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:51 | FromDiscord | <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:54 | FromDiscord | <Elegantbeef> You're not wrong but the context is important! |
08:34:20 | FromDiscord | <Girvo> So understanding where an answer comes from matters too, IMO 🙂 |
08:34:54 | FromDiscord | <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:44 | FromDiscord | <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:06 | FromDiscord | <Elegantbeef> Luckily we're not the only planet capable of life in the universe |
08:41:09 | FromDiscord | <Rika> “This is the idea of this small app; it is a web browser…” |
08:47:40 | FromDiscord | <Girvo> In reply to @Isofruit "Fun fact, there is": Yay... 😭 |
08:49:54 | FromDiscord | <Phil> In reply to @Rika "“This is the idea": I also find web browsers to be truly tiny and light weight apps |
08:50:21 | FromDiscord | <Elegantbeef> phil have you got into the alcohol early today? |
08:50:23 | FromDiscord | <Phil> Maybe I should add a /s to the end of that statement for clarity |
08:51:03 | FromDiscord | <Phil> Started dealing with testing in angular at 08:00 am this morning, equivalent effects beef |
08:51:43 | FromDiscord | <Phil> (edit) "Started dealing with testing in angular at 08:00 am this morning, ... equivalenteffects," added "they have" | "effects" => "effects," |
08:53:31 | FromDiscord | <Girvo> Oh man I do not miss Angular |
08:53:39 | FromDiscord | <Girvo> v1 _or_ any of them that came after |
08:56:56 | FromDiscord | <Phil> I mean, writing the code isn't bad |
08:57:16 | FromDiscord | <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:55 | FromDiscord | <Phil> I pretty much appreciate it being opinionated, same for rxjs |
08:58:12 | FromDiscord | <Phil> But damn writing tests in that thign |
08:58:59 | FromDiscord | <Rika> > heard about this now↵> recalls being assigned a project at work which uses angular and rxjs |
08:59:02 | FromDiscord | <Rika> I’m in danger |
09:00:53 | * | rockcavera quit (Remote host closed the connection) |
09:00:58 | FromDiscord | <Phil> Is it the test bits that scare you or rxjs? |
09:04:47 | FromDiscord | <jmgomez> Taking about RxJs is there any known attempt to make RxNim? |
09:04:54 | FromDiscord | <jmgomez> (edit) "Taking" => "Talking" |
09:06:07 | FromDiscord | <Rika> I tried |
09:06:15 | FromDiscord | <Rika> Hard to understand the intervals |
09:06:16 | FromDiscord | <Rika> Internals |
09:08:10 | FromDiscord | <jmgomez> wouldnt make a wrapper around Future work? |
09:11:14 | NimEventer | New thread by Drkameleon: Compiler error on Windows that doesn't occur on Mac/Linux, see https://forum.nim-lang.org/t/9332 |
09:39:16 | FromDiscord | <#!/rip/luke> How can I set a GitHub actions cpu arch |
09:48:31 | FromDiscord | <#!/rip/luke> Are there any good examples of nim cross compiling in GitHub actions |
09:48:39 | FromDiscord | <#!/rip/luke> Like for Mac windows linux |
09:48:50 | FromDiscord | <#!/rip/luke> And arm x86 and i386 |
10:10:41 | FromDiscord | <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:17 | FromDiscord | <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:11 | FromDiscord | <4zv4l> why does Nim is called Nim ? |
10:29:02 | FromDiscord | <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:39 | FromDiscord | <Phil> In reply to @4zv4l "why does Nim is": Was originally called nimrod, origin of the name |
10:30:48 | FromDiscord | <4zv4l> ooh Nimrod is a game ? |
10:30:55 | FromDiscord | <flywind> In reply to @t8m8 "I looked at the": Hi, did you create the account but not receive the comfirmed emails? |
10:31:10 | FromDiscord | <flywind> (edit) "emails?" => "email?" |
10:31:34 | FromDiscord | <jmgomez> In reply to @4zv4l "ooh Nimrod is a": https://www.wikiwand.com/en/Nimrod |
10:33:35 | FromDiscord | <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:09 | FromDiscord | <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:54 | FromDiscord | <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:17 | FromDiscord | <t8m8> In reply to @flywind "Yeah, this is a": oh, I see😣 |
10:38:59 | FromDiscord | <t8m8> <@&371760044473319454> Can you please confirm that the account t8m8 exists on the nim forum? |
10:40:29 | FromDiscord | <impbox [ftsf]> https://forum.nim-lang.org/profile/t8m8 |
10:41:40 | NimEventer | New Nimble package! util - Small utilities that isn't large enough to have a individual modules, see https://github.com/thisago/util |
10:41:41 | FromDiscord | <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:11 | FromDiscord | <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:36 | FromDiscord | <impbox [ftsf]> would have to check the forum source to see what that means |
10:47:28 | FromDiscord | <dom96> it means its deleted |
10:47:34 | FromDiscord | <dom96> (edit) "its" => "it's" |
10:48:01 | FromDiscord | <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:27 | FromDiscord | <#!/rip/luke> How can I make an image grayscale with pixie |
10:52:46 | FromDiscord | <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:42 | FromDiscord | <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:54 | FromDiscord | <flywind> In reply to @t8m8 "By the way, is": There is also a dedicated Nim discord server. |
10:58:10 | FromDiscord | <flywind> (edit) "In reply to @t8m8 "By the way, is": There is also a dedicated ... Nim" added "japanese" |
11:01:47 | FromDiscord | <t8m8> In reply to @flywind "There is also a": Oh my, I didn't know! Thanks for letting me know. |
11:01:57 | FromDiscord | <flywind> In reply to @t8m8 "Oh my, I didn't": https://discord.com/invite/3umT33kQhS |
11:03:50 | FromDiscord | <t8m8> In reply to @flywind "https://discord.com/invite/3umT33kQhS": Thank you! 🙌 |
11:04:11 | FromDiscord | <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:54 | FromDiscord | <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:21 | FromDiscord | <4zv4l> just read this ↵> Nim's VM is portable and can be embedded inside a browser↵Why does Nim use a vm ? |
13:31:07 | FromDiscord | <konsumlamm> for compile time function evaluation |
13:31:45 | FromDiscord | <konsumlamm> i.e. only at compile time |
13:32:14 | FromDiscord | <konsumlamm> the code that you're running in the end is a native binary |
13:36:02 | FromDiscord | <4zv4l> alright thanks ! |
13:37:37 | FromDiscord | <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:42 | FromDiscord | <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:46 | FromDiscord | <!!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:08 | reversem3[m] | How would you generate ECC key using proc ecKeygen*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey; |
16:52:08 | reversem3[m] | kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br_ec_keygen" |
16:52:44 | reversem3[m] | * How would you generate ECC key using `proc ecKeygen\*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey; |
16:52:44 | reversem3[m] | kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br\_ec\_keygen"` |
17:00:16 | reversem3[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:57 | reversem3[m] | When I try to call ecKeygen() I dont' even get an error just a undeclared identifier |
17:01:38 | reversem3[m] | unctions taking a XxxContext* use var and not ptr |
17:01:43 | reversem3[m] | s/unctions/functions/, s/*/\*/ |
17:11:35 | * | LuxuryMode joined #nim |
17:22:00 | FromDiscord | <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:52 | FromDiscord | <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:33 | FromDiscord | <4zv4l> Well it exists in Go, Python, Ruby, Java so why not in Nim ? XD |
18:36:32 | FromDiscord | <Generic> because nobody cared to write one already |
18:36:45 | FromDiscord | <Generic> you know where most libraries come from? |
18:37:04 | FromDiscord | <Rika> theres a lot more people using go python ruby java |
18:37:25 | FromDiscord | <Rika> theres a higher likelihood for someone who cares in those communities |
18:37:46 | FromDiscord | <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:02 | FromDiscord | <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:30 | FromDiscord | <reversem3> What do you mean ? |
19:00:47 | FromDiscord | <!!sharpcdf!!> Use c2nim or futhark |
19:00:53 | FromDiscord | <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:03 | FromDiscord | <domosokrat> A `nimble search bearssl` spits out https://github.com/status-im/nim-bearssl |
19:08:55 | FromDiscord | <reversem3> Yeah thats what I have been using but can't figure it out |
19:09:10 | FromDiscord | <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:05 | FromDiscord | <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:58 | FromDiscord | <reversem3> ok , interesting thanks |
19:40:50 | FromDiscord | <domosokrat> hope it helps |
20:46:17 | * | rockcavera quit (Ping timeout: 245 seconds) |
20:47:44 | FromDiscord | <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:39 | FromDiscord | <reversem3> Yeah I don't get it |
21:49:30 | FromDiscord | <#!/rip/luke> Is it possible to wrap a go library in nim? |
21:51:58 | FromDiscord | <!Patitotective> In reply to @ripluke "Is it possible to": compile it to c 😎 |
21:52:11 | FromDiscord | <#!/rip/luke> How do u compile go to c |
21:52:13 | FromDiscord | <!Patitotective> it could maybe work if you make a dll |
21:52:18 | FromDiscord | <!Patitotective> In reply to @ripluke "How do u compile": i was joking |
21:52:21 | FromDiscord | <#!/rip/luke> Oh |
21:52:27 | FromDiscord | <#!/rip/luke> Lol I'm not a go dev |
21:52:51 | FromDiscord | <#!/rip/luke> Hmm if I wanted to use a js library would I HAVE to compile to js? |
21:53:24 | FromDiscord | <voidwalker> what does array[^1], ^2. etc mean ? |
21:53:33 | FromDiscord | <voidwalker> hard to google |
21:53:54 | FromDiscord | <!Patitotective> In reply to @voidwalker "what does array[^1], ^2.": backward index |
21:53:56 | FromDiscord | <!Patitotective> (edit) "backward" => "backwards" |
21:54:10 | FromDiscord | <voidwalker> so ^1 is len-1 ? |
21:54:11 | FromDiscord | <!Patitotective> last element, second last element... |
21:54:15 | FromDiscord | <!Patitotective> In reply to @voidwalker "so ^1 is len-1": yes |
21:54:38 | FromDiscord | <!Patitotective> In reply to @ripluke "Hmm if I wanted": https://nim-lang.org/docs/jsffi.html |
21:54:49 | FromDiscord | <!Patitotective> id say yes |
21:55:17 | FromDiscord | <#!/rip/luke> Ah |
21:55:21 | FromDiscord | <#!/rip/luke> That sucks |
21:55:34 | FromDiscord | <#!/rip/luke> Guess I'll have to write it myself |
21:56:10 | FromDiscord | <!Patitotective> you can always try to do it and maybe magically work |
22:00:33 | FromDiscord | <!Patitotective> https://media.discordapp.net/attachments/371759389889003532/1002697159126306866/unknown.png |
22:03:24 | FromDiscord | <!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:43 | FromDiscord | <!!sharpcdf!!> i didnt even know there were js library bindings for nim 😅 |
23:51:08 | * | CyberTailor joined #nim |
23:51:59 | FromDiscord | <!!sharpcdf!!> In reply to @ripluke "Is it possible to": i think you can make a c wrapper for a go library |
23:52:13 | FromDiscord | <!!sharpcdf!!> and then make a nim wrapper for the c wrapper xd |
23:52:17 | FromDiscord | <!!sharpcdf!!> idk i havent used go in a bit |
23:52:29 | FromDiscord | <#!/rip/luke> I've never used go 💀 |
23:52:36 | FromDiscord | <!!sharpcdf!!> 💀 |
23:52:59 | FromDiscord | <!!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:22 | FromDiscord | <!!sharpcdf!!> not that difficult |
23:53:31 | FromDiscord | <!!sharpcdf!!> golang is pretty modern |
23:53:41 | FromDiscord | <!!sharpcdf!!> syntax is a bit odd though |
23:54:34 | FromDiscord | <#!/rip/luke> Oh |
23:55:56 | FromDiscord | <!!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 |