<< 08-11-2022 >>

00:00:01arkanoidAre all closures on the heap?
00:00:15arkanoidAre iterators on the heap?
00:00:25arkanoidAre closure iterators on the heap?
00:00:51arkanoidCan I help myself answering this question raising an error whenever I try to allocate anything?
00:03:28FromDiscord<Generic> closures are always on the heap
00:03:44FromDiscord<Generic> normal iterators are inlined and thus completely safe to use
00:04:51arkanoidGeneric, thanks, but are you sure about closure being always on the heap?
00:05:18FromDiscord<Generic> yes, closures to my knowledge always allocate their environment on the heap
00:05:35FromDiscord<Generic> there was a PR to put them on the heap when it's safe to do
00:05:42FromDiscord<Generic> but iirc it died
00:06:16arkanoidGeneric the manual says https://nim-lang.org/docs/manual.html#procedures-closures "The closure environment may be allocated on the heap or on the stack if the compiler determines that this would be safe."
00:08:12FromDiscord<Elegantbeef> It's always on the heap presently i believe
00:08:22FromDiscord<Elegantbeef> That's hand waving for the future afaik
00:08:58arkanoidOk. Well. Better write that in the manual, don't you think?
00:09:02FromDiscord<Elegantbeef> Stack only code means `object` and `array`
00:09:10arkanoidIs it possible to disable heap?
00:09:15FromDiscord<Elegantbeef> No
00:09:49FromDiscord<Elegantbeef> Just dont use `ref` `seq` or `string` and you're stack only
00:10:10arkanoidObject, array, static iterator, no closures, no dynamic collections. What else?
00:10:17FromDiscord<Elegantbeef> Unless it's for crypto the heap isnt that scary
00:10:26FromDiscord<Elegantbeef> That's literally it
00:10:44arkanoidI'm not into crypto, but embedded
00:10:56FromDiscord<Elegantbeef> `ref`/`seq`/`string`/`closure`s are the only heap data types
00:10:58arkanoidWell, at least I'm training myself for that
00:11:09FromDiscord<Elegantbeef> @Girvo\: is probably a great reference πŸ˜„
00:11:22arkanoidWell also tables and sets?
00:11:31arkanoidI mean dynamic sets
00:11:32FromDiscord<Elegantbeef> use `var T`, `toOpenArray` and `openArray[T]` for ultimate stack only experience
00:11:42FromDiscord<Elegantbeef> Tables and sets use `seq` or `ref`
00:11:51FromDiscord<Elegantbeef> well `sets` module
00:11:56FromDiscord<Elegantbeef> Builtin sets are stack allocated
00:11:56FromDiscord<Generic> and `{.experimental: "views".}`
00:12:09FromDiscord<Elegantbeef> I assume they want code to compile
00:12:12FromDiscord<Elegantbeef> So dont use views
00:12:54arkanoidWhat's the advantage of using openarrays if I can't use seqs but just arrays?
00:13:12*tk quit (Quit: Well, this is unexpected.)
00:13:12FromDiscord<Elegantbeef> you can do `toOpenArray`
00:13:29FromDiscord<Elegantbeef> And also can pass any `array` regardless of length
00:13:39*tk joined #nim
00:14:01FromDiscord<Generic> you can thus still use some parts of the standard library
00:14:02FromDiscord<Elegantbeef> `openArray[int]` accepts `[10]`, `[1, 2, 3, 4, 5, 6]`, and `[1, 2, 3, 4, 5].toOpenArray(0, 3)`
00:14:17FromDiscord<Generic> (though not merge sort, it allocates seqs internally)
00:14:30FromDiscord<Elegantbeef> especially with Nim2.0 adding `openArray[char]` overloads for `parseutils` and `unicode`
00:14:55FromDiscord<Elegantbeef> Oh boy i cant way for that release, excuse me whilst I brag about it some more πŸ˜„
00:15:09arkanoidOk, right, so I don't have to deal with the "length" generic type of array
00:15:24FromDiscord<Elegantbeef> You also can get 0 cost slices
00:15:39FromDiscord<Elegantbeef> Or near 0
00:15:50FromDiscord<Generic> if you'd make all functions generic by the array length, you'd instantiate a new function for every array length
00:15:56arkanoidIt works only for function arguments, if I remember correctly, right?
00:15:59FromDiscord<Generic> code size isn't free either
00:16:17FromDiscord<Generic> yes, though that's to change with views
00:17:44arkanoidWell actually the openarray[T] vs foo[L,T](arg: array[L,T]) is quite confusing. When should I prefer the first, and when the second?
00:18:08FromDiscord<Generic> always use openArray
00:18:15FromDiscord<Generic> I've already explained this
00:18:27FromDiscord<Generic> otherwise you'd have one instantiation of the proc per array length
00:18:48arkanoidGeneric, everytime I tried using views, I ended up giving up due to horrible compiler errors pointing somewhere else in the code
00:18:49FromDiscord<Elegantbeef> Only do the second if you hate yourself
00:19:34FromDiscord<Generic> yeah, it's unfortunately not ready yet for general use
00:19:39FromDiscord<Generic> though it'll be great once it is
00:20:10arkanoidGeneric, yes it looks really promising
00:21:30arkanoidHow does openarray works under the hood? I'm thinking how they can avoid the function duplication for every arraysize, in C
00:21:42arkanoidAnd not allocate on the heap
00:22:02arkanoidDo they pass a secret "length" param at runtime?
00:23:00FromDiscord<Generic> yes, in the generated C function it will expand into a pointer to the first element and an integer containing the length
00:25:08arkanoidNailed it! Thanks
00:26:08arkanoidWell, it seems the only missing part here is a like in the manual that says to not use closures "yet". Also a stack-only "no gc" page should be great!
00:27:14arkanoidIt applies non only to embedded, but most "secure and certified" applications avoid heap whenever possible
00:27:47FromDiscord<Elegantbeef> Well most people would say "use arc" so you can debug and still dont lose the stdlib
00:28:11FromDiscord<Elegantbeef> shit i'm outed as a print debugger
00:30:56FromDiscord<Generic> dont worry
00:31:29FromDiscord<Generic> I do print debugging too
00:31:37arkanoidWell, sure, but real hard-core embedded is still stack only.
00:32:02arkanoidPrint debug team member here
00:32:16arkanoidActually, dump has been my best evolution
00:32:23FromDiscord<Generic> are you programming one of those 128byte mcus?
00:34:43FromDiscord<auxym> !eval var y: set[range[0..24]] = {1, 2, 3}
00:34:48NimBotCompile failed: /usercode/in.nim(1, 28) Error: type mismatch: got 'set[range 0..65535(int)]' for '{1, 2, 3}' but expected 'set[range 0..24(int)]'
00:34:55FromDiscord<auxym> 😦
00:35:02FromDiscord<auxym> why?
00:35:23FromDiscord<Elegantbeef> Cause Nim doesnt do inverse inference
00:35:25FromDiscord<Generic> convert one two range 0..24
00:35:35FromDiscord<Generic> (edit) "one" => "1"
00:35:42FromDiscord<Generic> (edit) "two" => "to"
00:35:48FromDiscord<Elegantbeef> `{1, 2, 3}` is `set[0..65535]` as it has 0 information
00:36:13FromDiscord<Elegantbeef> Sets and arrays have this same semantics
00:36:26FromDiscord<Generic> well Nim does have incomplete types though
00:37:02FromDiscord<auxym> so, is there any way I can generate a `set[range[0..24]]` literal eg from a macro?
00:37:15FromDiscord<Generic> look what I wrote
00:37:17FromDiscord<Elegantbeef> Convert the first element to `range[0..24]`
00:37:32FromDiscord<Elegantbeef> `var y = {range[0..24](1), 2, 3}`
00:37:54FromDiscord<auxym> ah, ty. didn't know you could do range literals like that
00:38:05FromDiscord<Elegantbeef> Uhh
00:38:15FromDiscord<auxym> !eval var y = {range[0..24](1), 2, 3}; echo y
00:38:21NimBot{1, 2, 3}
00:38:38arkanoidDoes range types introduce overhead over normal types?
00:38:57FromDiscord<Elegantbeef> There are runtime checks
00:39:06FromDiscord<auxym> yes, they are runtime-checked, unless you like -d:danger
00:39:32FromDiscord<Elegantbeef> They're a nice idea but somewhat badly implemented in Nim, i still use them though
00:39:37FromDiscord<Elegantbeef> They're explicit and i love that
00:40:02arkanoidSo a range type means there's an implicit assert whenever a range type variable is written/assigned?
00:40:15FromDiscord<Generic> yes
00:40:40FromDiscord<auxym> (unless you compiled with -d:danger or --checks:off or the equivalent pragma)
00:40:58arkanoidSeems quite expensive
00:41:26arkanoidSurely I prefer having them, than not having them. Was just curios
00:41:35FromDiscord<Generic> in practice code contains surprisingly little arithmetic
00:41:55FromDiscord<Generic> compared to just pushing data around atleast
00:44:38FromDiscord<auxym> IMO, the safety is worth the cost in anything but a super tight loop. In which case you can push/pop checks:off just for your loop. Computers are fast these days.
00:45:54arkanoidI've recently tried to use ranged types together with scinim/measuremancer, but I failed to do so (don't remember exactly what is was complaining about). So I kept units but not ranged types
00:46:04FromDiscord<auxym> there's also an "implicit assert" (runtime bounds check) anytime you index a seq or array like `arr[i]`. C would happily read random memory past your array if you give it an invalid index
00:46:59arkanoidauxym I agree, safe checks are a quality feature
00:50:39*rockcavera quit (Remote host closed the connection)
00:52:35*rockcavera joined #nim
00:52:35*rockcavera quit (Changing host)
00:52:35*rockcavera joined #nim
00:53:20FromDiscord<albassort> Is there any way to convert a 16 byte string to time val
00:56:01FromDiscord<Elegantbeef> a 16 byte string of what
00:57:16arkanoidalbassort? String of chars? https://nim-lang.org/docs/times.html#parsing-and-formatting-dates
00:58:33arkanoidThere's a lot of info in 16 bytes, you can fit current timestamp nanoseconds and you still have space for your birthday
01:01:51FromDiscord<Elegantbeef> That's what big int wants you to believe
01:02:29FromDiscord<albassort> It's not my fault that posix uses 16 bytes for this
01:02:33FromDiscord<albassort> I was confused because of how big it is
01:03:14FromDiscord<Elegantbeef> Are comments are more "You can store time a lot of ways in 16 bytes"
01:03:17FromDiscord<Elegantbeef> Our comments even
01:03:39FromDiscord<albassort> Well yes but I gave the standard in which it is stored
01:03:50FromDiscord<albassort> posix timevals
01:04:05FromDiscord<albassort> Or at least that's the type name in c
01:04:19arkanoidhttps://nim-lang.org/docs/times.html#fromUnix%2Cint64
01:05:52arkanoidAre you looking for unix timestamps?
01:06:00FromDiscord<huantian> In reply to @Elegantbeef "They're a nice idea": One day range types will be perfect and so will the world
01:06:08FromDiscord<Rika> Are you sure it’s a string
01:06:32FromDiscord<Elegantbeef> Dont look now but there is a hidden `posix` module https://nim-lang.org/docs/posix.html
01:06:36FromDiscord<albassort> It's not a string it can be anything
01:06:39FromDiscord<albassort> I'm reading from a file
01:06:46FromDiscord<albassort> It's just 16 bytes long
01:07:04FromDiscord<albassort> Which is the weird part
01:07:08FromDiscord<Rika> Well, figure out what that thing is…
01:07:15FromDiscord<albassort> I know what it is
01:07:26arkanoidDoesn't seems so
01:07:28FromDiscord<Elegantbeef> Then convert it to your data and use `times` to make your time
01:07:33FromDiscord<Rika> https://www.gnu.org/software/libc/manual/html_node/Time-Types.html
01:07:43FromDiscord<Rika> See second to last entry
01:07:55FromDiscord<Rika> That’s your type no?
01:08:21FromDiscord<albassort> Perhaps
01:08:42FromDiscord<albassort> But then wouldn't it be 8 bytes
01:10:06FromDiscord<Elegantbeef> `long int`
01:10:34arkanoidNext question: endianess
01:10:51arkanoidI suggest you to hex dump it and read it by hand first
01:12:03FromDiscord<albassort> In reply to @Elegantbeef "`long int`": But do any of the procedures in time take long int tho
01:13:07FromDiscord<Elegantbeef> My point was `long int` is 8 bytes
01:13:10FromDiscord<Elegantbeef> 8 + 8 = 16
01:14:17FromDiscord<albassort> Actually first 8 bytes is probably time and the second is calander
01:14:26arkanoidalbassort: consider using binarylang for this kind of stuff
01:14:54arkanoidhttps://github.com/sealmove/binarylang
01:16:14FromDiscord<albassort> No but if this makes my life easier I should have known about this 2 years ago
01:17:14FromDiscord<albassort> When I get out the shower I'll show you a binary parser I had to do
01:17:58arkanoidYou can't expect to read a value if you don't know what it contains, especially if it is a composite binary value
01:19:01arkanoidJust hexdump it, solve the puzzle with pen and paper, read it with a binarylang decoder or some other custom machinery
01:19:44FromDiscord<Rika> I literally sent you what your type should be though
01:23:56arkanoidRika time_t is a 16byte long integer?
01:25:56FromDiscord<Rika> Not guaranteed
01:26:29FromDiscord<Rika> It’s only specified to be β€œa number” in ISO, β€œan integral type” in POSIX, and β€œsigned” in GNU
01:26:29arkanoidExactly. Better hex dump it
01:27:05FromDiscord<Rika> I am sure it is the type he is dealing with because he posted a picture in off topic
01:27:22FromDiscord<!!sharpcdf!!> sent a code paste, see https://play.nim-lang.org/#ix=4fgp
01:27:39*xet7 quit (Ping timeout: 260 seconds)
01:27:46FromDiscord<!!sharpcdf!!> oh shit
01:27:47FromDiscord<!!sharpcdf!!> nevermind
01:27:50FromDiscord<!!sharpcdf!!> ignore me
01:27:54FromDiscord<!!sharpcdf!!> im dumb
01:28:10FromDiscord<!!sharpcdf!!> why do i always figure out the error immediately after i ask about it πŸ’€
01:30:12*krux02 quit (Remote host closed the connection)
01:33:25FromDiscord<albassort> In reply to @Rika "I am sure it": I am sure as well
01:41:00FromDiscord<!!sharpcdf!!> how could i implement a way of self updating my app so that the end user wont need to manually download each release?
01:41:24FromDiscord<!!sharpcdf!!> i have this example but when i try to implement it i get an error: https://play.nim-lang.org/#ix=46lQ
01:41:36FromDiscord<!!sharpcdf!!> unhandled exception: file exists
01:41:37FromDiscord<huantian> make it linux only and then people will use a package manager
01:42:02FromDiscord<!!sharpcdf!!> In reply to @huantian "make it linux only": it is linux only xd i just dont have it on a package manager
01:42:05FromDiscord<!!sharpcdf!!> too lazy to add it
01:48:59FromDiscord<huantian> I would probably have yoru program spawn a seperate updater process
01:49:02FromDiscord<huantian> then close your main process
01:50:53FromDiscord<!!sharpcdf!!> thats what i was thinking but i dont know the proc to use to spawn the process without blocking the thread
01:53:27FromDiscord<!!sharpcdf!!> i guess startProcess will do what i want
01:57:53FromDiscord<scarf> i was finding a library similar to <https://typer.tiangolo.com>, got <https://github.com/c-blake/cligen/tree/476e595ac50d767e28fc75137ec25a00c71160de> but it lacks pretty-printing. does nim have a pretty-print library similar to <https://github.com/Textualize/rich>?
01:58:06FromDiscord<scarf> (edit) "<https://github.com/c-blake/cligen/tree/476e595ac50d767e28fc75137ec25a00c71160de>" => "<https://github.com/c-blake/cligen>"
02:02:09arkanoidscarf, look at treeform/print
02:03:09arkanoidRika, I didn't see the screenshot, so you must be right
02:05:09FromDiscord<scarf> In reply to @arkanoid "<@399454059184128010>, look at treeform/print": oh, i should also add that rich provides colored boxes, progress bar and spinners. print doesnt seem to provide them
02:06:33arkanoidNo, it doesn't. Sorry but I don't know a lot about terminal gui packages. Do you have already checked the curated list or the package index?
02:13:15FromDiscord<albassort> https://media.discordapp.net/attachments/371759389889003532/1039361929979887667/image.png
02:13:28FromDiscord<albassort> would binarylang help?
02:17:12arkanoidscarf: I see many TUI stuff here https://nimble.directory/search?query=terminal
02:17:39FromDiscord<albassort> In reply to @arkanoid "<@399454059184128010>: I see many": illwill ❀️
02:20:28arkanoidalbassort, with binarylang you can have subparsers, and here it seems you're doing exactly that
02:25:04*arkurious quit (Read error: Connection reset by peer)
02:46:02FromDiscord<Chem> sent a code paste, see https://paste.rs/m0p
02:46:22FromDiscord<Elegantbeef> You cannot return a `openarray`
02:46:30FromDiscord<Elegantbeef> it's a `seq[DataPageSlot]`
02:46:41FromDiscord<Elegantbeef> It
02:46:51FromDiscord<Elegantbeef> 's unsafe to return an `openarray` without a borrow checker
02:46:53FromDiscord<Chem> Ah, what is the equivalent to `std::span<T>` in Nim, a lightweight pointer-like view over memory/buffer?
02:47:01FromDiscord<Elegantbeef> `openarray`
02:47:07FromDiscord<Chem> why can't I return one then πŸ€”
02:47:16FromDiscord<Elegantbeef> Cause Nim cares about safety
02:47:23FromDiscord<Elegantbeef> You can do `(ptr T, int)` if you want
02:47:47FromDiscord<Chem> There's no way to return a reference to existing memory without allocating in Nim?
02:48:18FromDiscord<Chem> C# has `Span`, Java has `MemorySegment`, C++ has `Span`, I figured Nim must have something similar
02:48:29FromDiscord<Elegantbeef> Nim tries to be memory safe
02:49:23FromDiscord<Chem> Fair enough, thanks for answering my question πŸ™
02:52:26FromDiscord<Elegantbeef> There is an experimental view system which adds a borrow checker but until that's stable it's not done
02:52:43FromDiscord<exelotl> yeah, there is https://nim-lang.org/docs/manual_experimental.html#view-types but it's not in a good state to be used right now.
02:53:43FromDiscord<Chem> sent a code paste, see https://play.nim-lang.org/#ix=4fgG
02:53:51FromDiscord<Chem> May as well add another
02:54:33FromDiscord<Rika> Views is especially experimental
02:54:34FromDiscord<Elegantbeef> Eh views really doesnt work
02:54:36FromDiscord<Chem> That actually at least makes it almost compile
02:54:44FromDiscord<Chem> sent a code paste, see https://play.nim-lang.org/#ix=4fgH
02:54:53FromDiscord<Elegantbeef> `toOpenArray` also this code is unsafe anyway
02:56:38FromDiscord<Elegantbeef> hmmm maybe not
02:59:36FromDiscord<Chem> sent a long message, see http://ix.io/4fgK
03:00:28FromDiscord<Chem> sent a code paste, see https://paste.rs/xvY
03:01:03FromDiscord<Chem> And on startup I was going to call like `sharedAlloc0` or something to make `BUFFER_POOL_NUM_PAGES PageBuffer` and then hand out `ptr PageBuffer`
03:01:18FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fgO
03:01:36FromDiscord<Elegantbeef> Strict aliasing is a bitch here though πŸ˜„
03:02:22FromDiscord<Chem> Does that work if I need it to be a pointer to 4096-byte chunks too, because it'd just be like a `void`?
03:03:04FromDiscord<Elegantbeef> I mean the `SomePointer[T]` is for you to hand out
03:03:18FromDiscord<Chem> Ohhh got it, where `T` is the 4kb chunk
03:03:22FromDiscord<Chem> damn that's pretty easy
03:03:41FromDiscord<Elegantbeef> No T is the type you requested to be allocated
03:04:19FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fgR
03:04:43FromDiscord<Elegantbeef> Obviously between line 2 and 1 you insert you actual logic to grow/move the allocations
03:04:55FromDiscord<Elegantbeef> But be very weary strict aliasing is a bitch
03:05:41FromDiscord<Elegantbeef> https://news.ycombinator.com/item?id=11289995
03:06:36FromDiscord<Elegantbeef> Nim does tell the C compiler not to use it but it still can cause issues afaik
03:09:11FromDiscord<Chem> Can you `reinterpret_cast<>` things like pointers into arrays?↡Say if I have the pointer to the start of an array, can I cast it into a `seq`
03:09:31FromDiscord<Elegantbeef> You can but arrays and seqs are stored differently
03:09:35FromDiscord<Elegantbeef> `cast[T](a)`
03:10:11FromDiscord<Chem> Ah didn't think that would work out of the box, so just something like:
03:11:25FromDiscord<Chem> Oh I guess that the array needs a constant type parameter for the size
03:13:37FromDiscord<Elegantbeef> You'd have to use your own collection for dynamic allocated array
03:25:27FromDiscord<Chem> sent a code paste, see https://play.nim-lang.org/#ix=4fh0
03:25:31FromDiscord<Chem> What is the right way to say the final line πŸ€”
03:25:39FromDiscord<Elegantbeef> There isnt
03:25:45FromDiscord<Elegantbeef> Returning a seq like this will never work how you want
03:26:13FromDiscord<Chem> But this isn't a memory safety issue, because the start and end addresses are both valid
03:26:48FromDiscord<Elegantbeef> If you do `mySeq.add` you grow the sequence and now dont have a pointer in your address
03:27:50FromDiscord<Chem> sent a code paste, see https://play.nim-lang.org/#ix=4fh1
03:28:09FromDiscord<Chem> and you iterate by `sizeof(DataPageSlot)`
03:28:12FromDiscord<Rika> We’re not in C or C++
03:29:16FromDiscord<Chem> Fair enough πŸ˜…
03:29:34FromDiscord<Rika> I just got here so I’ll be reading back
03:30:20FromDiscord<Rika> You cannot cast into sequences
03:30:24FromDiscord<Rika> That’s not gonna work
03:30:39FromDiscord<Rika> The GC isn’t aware of the pointers you put into your cast sequence
03:30:48FromDiscord<Rika> Use a custom container
03:31:18FromDiscord<Rika> Why are you doing this by the way?
03:31:22FromDiscord<Rika> Wondering what’s it for
03:34:42FromDiscord<Elegantbeef> Seems like they want to make a custom allocator
03:34:45FromDiscord<Elegantbeef> Nim really doesnt do this well
03:35:34FromDiscord<Rika> Beef go recommend that language
03:35:55FromDiscord<Elegantbeef> Zig?
03:35:57FromDiscord<Chem> I'm working on database stuff in my sparetime (SQLite/Postgres, but shitty)
03:36:24FromDiscord<Elegantbeef> Odin?
03:36:31FromDiscord<Chem> Yeah I did an article on Zig actually, ha↡https://gavinray97.github.io/blog/io-uring-fixed-bufferpool-zig
03:36:34FromDiscord<Rika> Zig, wasn’t sure about Odin
03:36:47FromDiscord<Chem> I wanted to see what the Nim side of the pond was like, hadn't checked in on it in a while
03:36:58FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/remoterefs.nim something like this is really the best Nim can do
03:37:06FromDiscord<Rika> In Nim I believe what people do is just use malloc and replace that
03:37:10FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/tremoterefs.nim which looks like this in use
03:37:41FromDiscord<Elegantbeef> Yea Nim's solution is "replace the entire allocator"
03:37:56FromDiscord<Chem> I quite like a lot of the ideas in Nim, particularly the concepts stuff. The macros system terrifies me but I recognize it's powerful.
03:37:59FromDiscord<Elegantbeef> It doesnt do bring your own allocator like Zig or Odin do
03:38:17FromDiscord<Rika> Distinct pointers like what beef shows are one too but I believe he’s the only dingus who does it lol
03:38:31FromDiscord<Elegantbeef> I love me distincts
03:38:47FromDiscord<Rika> Distinctly
03:40:37FromDiscord<Elegantbeef> I personally like the idea of RemotRefs more than Zig/Odin's context/allocator
03:40:42FromDiscord<Elegantbeef> Allows RAII to work so you can get automatic memory management
03:41:36FromDiscord<Elegantbeef> Though thanks to Nim it can be a tinge iffy
03:41:47FromDiscord<Chem> Scala 3 has distinct types, they call them `opaque types` they're very nice there as well
03:42:20FromDiscord<Chem> I miss them a lot in languages they don't have them. Kotlin has a poverty version called `value classes` where you have to unwrap the type with `.value` and it's a bit shite.
03:43:28FromDiscord<Rika> In reply to @Chem "I miss them a": LMAO
03:52:18FromDiscord<Raynei486> is there a way to replace all chars that are not a specific char in a string
03:53:14FromDiscord<Elegantbeef> `str.replace({'\0'..'\255'} - {myChar}, otherChar)`
03:53:55FromDiscord<Raynei486> ?
03:53:58FromDiscord<Raynei486> actual black magic
03:54:01FromDiscord<Raynei486> care to explain?
03:54:27*sagax joined #nim
03:55:52FromDiscord<Elegantbeef> Nim bitsets
03:56:03FromDiscord<Elegantbeef> `strutils` has a replace that works on `set[char]`
03:56:42FromDiscord<Rika> sent a long message, see http://ix.io/4fh3
03:57:34FromDiscord<Elegantbeef> Oh It doesnt actually have one that works on set
03:59:24FromDiscord<Raynei486> I guess I'll hand craft my own for now
03:59:36FromDiscord<Raynei486> thanks for cool magic trick though πŸ‘
04:19:02FromDiscord<Cheesy Brik> Just asking for an idea I’m having, is it possible to compile objects to their bytes and then decompile them given the type later on (at runtime). Like decompiling β€œeee” to (string, 0b…) and later being able to get back the β€œeee” object?
04:21:53FromDiscord<Elegantbeef> Nim doesnt have much of RTTI, so while it's technically possible it's not really feasible. There are third party packages like `frosty` or `flatty`
04:26:19FromDiscord<ringabout> It is weird that https://github.com/mratsim/Arraymancer/blob/master/benchmarks/implementation/proc_method_closure_bench.nim in ARC/ORC has 10x difference between release and danger build.
04:26:35FromDiscord<ringabout> (edit) "It is weird that ... https://github.com/mratsim/Arraymancer/blob/master/benchmarks/implementation/proc_method_closure_bench.nim" added "the time of"
04:28:03FromDiscord<ringabout> `nim c -r --mm:orc --threads:off`
04:29:56FromDiscord<Elegantbeef> It's not 10 times here
04:30:19FromDiscord<ringabout> The metrics of Methods
04:30:25FromDiscord<Elegantbeef> closures are about 10% slower and methods 4 times
04:31:15FromDiscord<Elegantbeef> .28 vs .88
04:31:25FromDiscord<ringabout> `Methods 0.1950000000000001` vs `Methods 1.367` Sorry 7x
04:31:43FromDiscord<ringabout> It doesn't happen with `refc`.
04:32:02FromDiscord<Elegantbeef> Likely genericAssign checks?
04:32:22FromDiscord<Bung> https://github.com/nim-lang/Nim/issues/20177 so it's still related to threads?
04:32:50FromDiscord<ringabout> No, that's a known issue. I used `--threads:off`
04:33:22FromDiscord<Elegantbeef> Yea wrapping the methods with `{.checks: off.}` results in parity
04:34:30FromDiscord<ringabout> I see, nice
04:35:37FromDiscord<ringabout> It seems there is a regression because the methods should work 2x slower than refc, but now it is 7-8x slow.
04:36:00FromDiscord<Elegantbeef> I blame it on RTTI checks
04:36:00FromDiscord<ringabout> According to https://github.com/nim-lang/Nim/pull/19749#issuecomment-1110194449
04:36:51FromDiscord<Elegantbeef> With refc on my computer and the checks off it's like 1ms difference
04:36:58FromDiscord<ringabout> In reply to @flywind "According to https://github.com/nim-lang/Nim/pull/1": but it should be this slow after my PR https://github.com/nim-lang/Nim/pull/19749
04:36:58FromDiscord<Elegantbeef> It's within spitting distance
04:37:11FromDiscord<ringabout> (edit) "should" => "shouldn't"
04:37:26FromDiscord<Elegantbeef> Have you benchmarked it?
04:37:29FromDiscord<ringabout> RTTI checks is likely to have a regression.
04:37:44FromDiscord<Elegantbeef> I mean profiled
04:37:45FromDiscord<Elegantbeef> I know words
04:37:57FromDiscord<ringabout> In reply to @Elegantbeef "Have you benchmarked it?": I haven't
04:38:04FromDiscord<ringabout> (edit) "In reply to @Elegantbeef "Have you benchmarked it?": I haven't ... " added "profiled it."
04:38:47FromDiscord<ringabout> Since it is a separate issue to https://github.com/nim-lang/Nim/pull/20781
04:40:09FromDiscord<Elegantbeef> perf.svg https://media.discordapp.net/attachments/371759389889003532/1039398903491076237/perf.svg
04:40:14FromDiscord<Elegantbeef> Flamegraph shows the issue is were inside a string op for a long time
04:40:19FromDiscord<Elegantbeef> we're
04:41:13FromDiscord<huantian> In reply to @lantos "Is there a faster": huh I wonder if that's related to this
04:41:15FromDiscord<albassort> having a fun jsonutils moment where it wont deseralize
04:41:15FromDiscord<albassort> :D
04:41:17FromDiscord<Elegantbeef> Yes i know discord doesnt render svgs, download it πŸ˜„
04:41:47FromDiscord<ringabout> Sorry, my bad. object checks are disabled with danger mode.
04:42:35FromDiscord<Elegantbeef> I dont get why we're using strings for type comparisons
04:43:07FromDiscord<Elegantbeef> Given we cannot access the RTTI name field, cant we just emit an integer
04:43:18FromDiscord<ringabout> Yeah, it is for crossing dll boundries.
04:43:32FromDiscord<Elegantbeef> Oh right
04:43:59FromDiscord<ringabout> In reply to @Elegantbeef "Given we cannot access": It is going be implemented by my PR https://github.com/nim-lang/Nim/pull/20781
04:44:10FromDiscord<Elegantbeef> Seems like a thing that should be like `when defined(nimAsLib)` ....
04:45:23FromDiscord<albassort> just to make sure im not braindead
04:46:01FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4fhc
04:46:31FromDiscord<Rika> What?
04:46:40FromDiscord<Elegantbeef> That'll call your `toJsonHook`
04:47:27FromDiscord<albassort> In reply to @Rika "What?": im failing to understand what about the text i posted was so extraordinarily insane that you said "what?"
04:48:11FromDiscord<Rika> You put code without explaining your issue further
04:48:30FromDiscord<Rika> It β€œjust doesn’t work” isn’t really helpful
04:49:03FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4fhe
04:49:32FromDiscord<Elegantbeef> That code isnt parsing
04:51:22FromDiscord<albassort> alright i guess I'll just use something else
04:51:34FromDiscord<Elegantbeef> Lol
04:51:50FromDiscord<Elegantbeef> Excuse me whilst i step on a rake ask a question then grab a shovel
04:55:48FromDiscord<ChocolettePalette> Just make it work then what am I payibg you for \:&#47;↡(@Rika)
04:57:19FromDiscord<Elegantbeef> Shit you're getting paid rika?!
04:57:22FromDiscord<Elegantbeef> I knew something was up
04:58:07FromDiscord<albassort> no hes getting paybed
04:58:10FromDiscord<amadan> sent a code paste, see https://play.nim-lang.org/#ix=4fhi
04:58:14FromDiscord<albassort> In reply to @amadan "Are you using this": nope
04:58:55FromDiscord<Elegantbeef> Notice how they dont show the parsing logic
04:59:08FromDiscord<Elegantbeef> "Here's the serialising, why doesnt the parsing work?!"
04:59:20FromDiscord<amadan> weird works locally for me↡Thought it might be related to https://github.com/nim-lang/Nim/issues/20284
04:59:41FromDiscord<albassort> In reply to @Elegantbeef "Notice how they dont": what do you want me to show
04:59:45FromDiscord<albassort> its pretty simple
04:59:58FromDiscord<albassort> you write your json, you read your json, then you do from json
05:00:01FromDiscord<Elegantbeef> The parsing
05:00:06FromDiscord<albassort> ok ok
05:00:16FromDiscord<albassort> lemme show you the magic definition of a
05:01:08FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4fhl
05:01:22FromDiscord<Elegantbeef> And what's your json hook?
05:01:42FromDiscord<Elegantbeef> "I didnt make one"
05:01:47FromDiscord<albassort> ah i typoed it string when it needs to be char
05:02:16FromDiscord<Elegantbeef> Arent you glad you didnt grab the shovel
05:04:25FromDiscord<Rika> In reply to @Elegantbeef "Shit you're getting paid": What the fuck don’t out me
05:23:53*rockcavera quit (Remote host closed the connection)
05:30:23FromDiscord<pepperoni> i dont like nim syntax
05:31:08FromDiscord<scarf> In reply to @pepperoni "i dont like nim": which syntax do you like?
05:31:56FromDiscord<Elegantbeef> I'm going to jump into the rust discord and say "I dont like the rust syntax"
05:32:06FromDiscord<Elegantbeef> Like the fuck is the point of that other than to be contrarian
05:32:57FromDiscord<Rika> In reply to @pepperoni "i dont like nim": Thanks for your feedback?
05:33:21FromDiscord<pepperoni> they use no semi colons
05:33:35FromDiscord<scarf> In reply to @pepperoni "they use no semi": i am absolutely disguested by semicolons.
05:33:36FromDiscord<Elegantbeef> Cool
05:33:46FromDiscord<Elegantbeef> Rust uses curly braces could you imagine
05:33:47FromDiscord<scarf> (edit) "disguested" => "disgusted"
05:34:04FromDiscord<Elegantbeef> Let's not feed the troll and just carry on
05:34:50FromDiscord<pepperoni> no i came in here to say i dont like nim syntax and then not contribute anything to the conversation
05:35:33FromDiscord<Elegantbeef> Atleast the troll is honest
05:39:19FromDiscord<pepperoni> its kinda funny how you refer to me as "the troll" like im some mystical creature
05:39:48FromDiscord<pepperoni> all i did was say i dont like nim syntax i think your caring a tiny bit too much
05:41:58FromDiscord<Elegantbeef> That is the equivalent to walking into a coffee shop walking to someone sipping a coffee and saying "I dont like coffee" then sitting down at their table
05:49:39FromDiscord<Bung> https://github.com/nim-lang/Nim/issues/18080 it's like these args should store into temporary variable first ?
05:57:59*sagax quit (Read error: Connection reset by peer)
05:58:14*sagax joined #nim
06:02:21FromDiscord<Rika> In reply to @pepperoni "all i did was": You’re surprised people in a server specifically for something are reacting heavily to some random dude saying they don’t like that something for no reason?
07:08:16*kenran joined #nim
07:45:17*PMunch joined #nim
07:56:20FromDiscord<CSwine> is there contract propagation in nim?
08:02:34*sagax quit (Ping timeout: 260 seconds)
08:02:45PMunchWhat do you mean?
08:10:10FromDiscord<albassort> https://media.discordapp.net/attachments/371759389889003532/1039451753197871176/image.png
08:10:23FromDiscord<albassort> you guys think anyone will be interested in this in library form
08:10:42FromDiscord<albassort> or should i just keep it in my local collection of private code
08:11:33FromDiscord<Rika> Someone is bound to be interested
08:20:52*sagax joined #nim
08:24:40NimEventerNew thread by Dabod: Is it possible to borrow `UncheckedArray[T]` as `openArray[T]` then return from procedure?, see https://forum.nim-lang.org/t/9589
08:43:18FromDiscord<haxscramper> In reply to @CSwine "is there contract propagation": no
10:12:45*jjido joined #nim
10:18:34*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
11:19:29FromDiscord<albassort> how fast is bash
11:19:37FromDiscord<albassort> well issuing bash commands
11:20:10*genpaku quit (Read error: Connection reset by peer)
11:20:51*genpaku joined #nim
11:23:58FromDiscord<Rika> What magnitude of bash command invocation are you dealing with
11:24:05FromDiscord<albassort> im not sure yet
11:24:14FromDiscord<albassort> im doing some disgusting things
11:24:23FromDiscord<Rika> If you’re not going a lot of them then it doesn’t really matter
11:24:30FromDiscord<Rika> Going to do
11:59:40FromDiscord<ShalokShalom> In reply to @albassort "well issuing bash commands": You mean execCmd? That doesn't invoke necessarily bash, it does invole the default shell of the target system.
11:59:59FromDiscord<ShalokShalom> I don't think you will be constrained with the performance
12:01:10FromDiscord<ShalokShalom> @albassort And I do recommend you this lib, as it does make interacting with the shell a bliss↡↡https://github.com/Vindaar/shell
12:15:07FromDiscord<albassort> currently using it :D
12:15:15FromDiscord<albassort> down another rabbithole
12:15:58FromDiscord<fbpyr> @ShalokShalom\: thx for the link - that is a cool lib!! πŸ˜ƒ
12:24:51*kenran` joined #nim
12:29:11*kenran` quit (Remote host closed the connection)
12:46:41FromDiscord<banan|crab> does nom have a discord webhook api? i cant find one
12:53:31*ltriant quit (Ping timeout: 248 seconds)
13:05:03*disso_peach quit (Remote host closed the connection)
13:05:26*disso_peach joined #nim
13:08:28FromDiscord<Rika> arent discord webhooks just rest api calls
13:17:31*jmd_ quit (Ping timeout: 248 seconds)
13:19:33*ltriant joined #nim
13:25:08*ltriant quit (Ping timeout: 246 seconds)
13:53:39*arkurious joined #nim
14:03:47FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4fja
14:06:50FromDiscord<System64 ~ Flandre Scarlet> Nevermind, it's file.endOfFile()
14:23:50*estiquelapice quit (Ping timeout: 260 seconds)
14:29:18FromDiscord<banan|crab> In reply to @Rika "arent discord webhooks just": whats a rest api
14:34:55*derpydoo joined #nim
14:39:41FromDiscord<auxym> HTTP
14:41:47*rockcavera joined #nim
14:41:47*rockcavera quit (Changing host)
14:41:47*rockcavera joined #nim
14:54:51*ltriant joined #nim
14:59:39*ltriant quit (Ping timeout: 260 seconds)
15:00:32*PMunch quit (Quit: Leaving)
15:01:21FromDiscord<ChocolettePalette> Whats a http
15:05:38FromDiscord<ShalokShalom> In reply to @fbpyr "<@208199869301522432>\: thx for": Sure, sure, you are welcome↡↡The author is here at Discord and is very helpful
15:06:21FromDiscord<ShalokShalom> In reply to @banan|crab "does nim have a": There are Nim bot frameworks for Discord, it that helps?
15:06:52*pech joined #nim
15:09:34*disso_peach quit (Ping timeout: 260 seconds)
15:25:31FromDiscord<Cheesy Brik> What does the `of` keyword do
15:29:50FromDiscord<Cheesy Brik> How can I print all data of a class
15:29:58FromDiscord<Cheesy Brik> Like all the attributes and their values
15:32:04FromDiscord<Cheesy Brik> In reply to @demotomohiro "https://internet-of-tomohiro.netlify.app/nim/faq.en": What’s a general use case for getting the data from a list, like not having to hard code each type?
15:32:39*LuxuryMode joined #nim
15:35:00*ltriant joined #nim
15:42:14*ltriant quit (Ping timeout: 260 seconds)
15:55:53FromDiscord<Cheesy Brik> Does anyone have a better solution for seqs with multiple types?
15:57:14FromDiscord<System64 ~ Flandre Scarlet> Is it normal I have those weird compiler messages? https://media.discordapp.net/attachments/371759389889003532/1039569295295926312/message.txt
16:25:42Amun-Ratagged unions?
16:26:15FromDiscord<banan|crab> In reply to @ShalokShalom "There are Nim bot": but i want a webhook
16:26:41FromDiscord<ShalokShalom> @Amun-Ra You search for them?
16:27:15FromDiscord<haywireSSC> is there a way to apply a macro to some code I include?
16:30:42FromDiscord<ShalokShalom> how you mean?
16:30:47FromDiscord<ShalokShalom> like, example
16:31:59Amun-RaShalokShalom: no, I was replying to Cheesy
16:40:02FromDiscord<haywireSSC> In reply to @ShalokShalom "how you mean?": not a very good example but something like this https://media.discordapp.net/attachments/371759389889003532/1039580065299697724/image.png
16:40:13FromDiscord<dedraiaken> Is there a way to print the arc rewrites similar to `expandMacros`?
16:42:14FromDiscord<ShalokShalom> Ah, using the include keyword within a macro
16:44:42*kenran quit (Remote host closed the connection)
16:54:33FromDiscord<System64 ~ Flandre Scarlet> In reply to @Amun-Ra "tagged unions?": what's that?
16:58:29FromDiscord<haywireSSC> In reply to @ShalokShalom "Ah, using the include": yep
17:08:11FromDiscord<dlesnoff> In reply to @haywireSSC "is there a way": With imports it would not be possible, and I think with includes, it would first try to apply the macro before including the code
17:12:40FromDiscord<Kermithos> In reply to @banan|crab "does nim have a": its just a http post request to the webhook url with your message. You can use httpclient for that
17:24:13FromDiscord<ShalokShalom> In reply to @System64 "what's that?": https://en.wikipedia.org/wiki/Tagged_union
17:24:56FromDiscord<System64 ~ Flandre Scarlet> oh interesting
17:27:09FromDiscord<Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=4fkI
17:27:22FromDiscord<Slazaa> Hey, is there something similar to interfaces in Nim ? :o
17:28:21FromDiscord<Tanguy> (parseStmt returns a NimNode, you are free to do whatever with it)
17:28:41FromDiscord<ShalokShalom> @Slazaa https://github.com/nim-lang/RFCs/issues/39
17:29:40FromDiscord<Slazaa> Oh, so I can have them with a lib ?
17:30:05FromDiscord<Tanguy> There are some libs, but they are sub-par to actual compiler support, unfortunately
17:30:14FromDiscord<ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=4fkJ
17:30:41FromDiscord<ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=4fkK
17:55:14FromDiscord<haywireSSC> In reply to @Tanguy "<@536164435136479232> Would this work?": yep, ty
17:55:23FromDiscord<haywireSSC> I ended up doing something similar
18:09:23*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
18:11:24*Lord_Nightmare joined #nim
18:27:10FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4fl5
18:33:59FromDiscord<Horizon [She/Her]> Hey ElegentBeef, why does `loadWasmEnv` use a `uint32` for the stacksize?
18:34:17FromDiscord<Horizon [She/Her]> Nvm i just realized why
18:34:27FromDiscord<Horizon [She/Her]> `uint32` starts from 0
18:34:34FromDiscord<Horizon [She/Her]> I thought it was the other way around for a moment
18:40:18FromDiscord<dedraiaken> Is there a means to pre-allocate a trace reference similar to `newSeq[int](1000)`?
18:40:58FromDiscord<dedraiaken> sent a code paste, see https://paste.rs/jBt
19:20:37FromDiscord<Horizon [She/Her]> Does anyone know how I'd implement `fd_write`?
19:21:29FromDiscord<Horizon [She/Her]> I'm trying to implement the WASI API myself (because I'll have many instances of WASM interpreters running so, i need to keep them isolated with their own permissions and environment) but unsure how to implement it
19:22:38FromDiscord<ShalokShalom> https://wasmer.io/
19:22:45FromDiscord<ShalokShalom> Do you know Wasmer?
19:22:57FromDiscord<ShalokShalom> Idk if it can do this, but might be worth looking.
19:28:28FromDiscord<pouriya.jamshidi> Hi,↡↡Is there a way to just import a specific function from a library? E.g. only import the `sort` from `std/algorithm` and not the entire module
19:29:40FromDiscord<hotdog> In reply to @pouriya.jamshidi "Hi, Is there": `from std/algorithm import sort`
19:34:22FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "Idk if it can": That's not what i need since i already have a runtime :p
19:34:49FromDiscord<ShalokShalom> Yeah, I assume it has the feature you are looking for
19:34:53FromDiscord<ShalokShalom> with the isolation
19:35:04FromDiscord<ShalokShalom> but you may wanna use your specific runtime πŸ™‚
19:36:18FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "Yeah, I assume it": Nope, not what i need aha↡↡I need to implement my own custom WASI methods
19:36:26FromDiscord<ShalokShalom> ah
19:36:30FromDiscord<ShalokShalom> i understand
19:36:32FromDiscord<Horizon [She/Her]> But i don't know how I'm supposed to do that, there's not exactly any docs so
19:36:44FromDiscord<ShalokShalom> look at others?
19:37:31FromDiscord<Horizon [She/Her]> I'm trying but don't know where to find them rip
19:38:23*ltriant joined #nim
19:40:09FromDiscord<Horizon [She/Her]> Trying to poke around musl but yeah that's hard
19:47:24*ltriant quit (Ping timeout: 252 seconds)
20:06:17FromDiscord<banan|crab> In reply to @Kermithos "its just a http": ah
20:06:48FromDiscord<auxym> In reply to @Cheesy Brik "Does anyone have a": nim is statically typed, not sure what you are expecting? that link does mention the 3 standard ways. variants, inheritance and unions. inheritance would be `seq[RootObj]` which is similar to `ArrayList<Object>` in java/C#. But then in Nim you have to explicitly declare your types as `ref object of RootObj` so they inherit from RootObj (like `object` in java, python, etc)
20:08:45FromDiscord<Elegantbeef> @Horizon [She/Her]\: is it not just exporting a `fd_write` in the `wasi` module with the same signature?
20:09:19FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "<@909883978717204561>\: is it not": Wdym?
20:09:47FromDiscord<Horizon [She/Her]> I'm trying to implement file io but really confused, and i need to isolate it so it's mostly safe
20:13:07FromDiscord<Horizon [She/Her]> Implement as in, create a function with the functionality i need
20:15:23FromDiscord<Elegantbeef> I dont follow the issue
20:15:54FromDiscord<Elegantbeef> Make a host function, add it to the wasi module name and load it on creation of the runtime
20:21:54FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4flT
20:22:26FromDiscord<Elegantbeef> `--expandArc:procName`↡(@dedraiaken)
20:30:27FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "Make a host function,": Yes but the logic of the host function is what I'm struggling with
20:38:48FromDiscord<Elegantbeef> Well what are you stuck on?
20:53:31FromDiscord<Horizon [She/Her]> Everything πŸ˜…β†΅I don't really understand how to even begin, I've tried googling and poking around on how I'm supposed to implement it (using musl as a reference) but it's kinda big and intimidating :p
20:53:49FromDiscord<Horizon [She/Her]> Reason i want to implement this though is because it's like, one of the key things you'd want to just be supported
20:54:06FromDiscord<Horizon [She/Her]> Even if it'd be easier to write my own function for it
20:55:07FromDiscord<ShalokShalom> You like big challenges, yes? πŸ˜…
20:56:36FromDiscord<Horizon [She/Her]> What can i say, i chase the dopamine that my brain chemistry refuses to give me :p
20:57:12FromDiscord<dom96> @Horizon [She/Her] what are you building?
20:59:03FromDiscord<Horizon [She/Her]> I'm working on a ComputerCraft-like program (ComputerCraft is a mod that adds computers that can run Lua code and interact with the world in Minecraft) that can run untrusted WASM safely with the ability to do things like write files to it's own dedicated folder
20:59:47FromDiscord<Horizon [She/Her]> I want to make it so you can use WASI APIs instead of custom methods for most things that can be done (again, like writing and reading files)
20:59:56FromDiscord<ShalokShalom> @Horizon [She/Her] wouldnt it be simpler, to just reimplement Minecraft from scratch
21:00:02FromDiscord<ShalokShalom> At this point? πŸ˜„
21:00:17FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "<@909883978717204561> wouldnt it be": This isn't Minecraft at all tho-
21:00:29FromDiscord<Horizon [She/Her]> I just want a virtual computer-like thing for now
21:00:33FromDiscord<Horizon [She/Her]> That can run WASM
21:00:35FromDiscord<dom96> So you're implementing a custom WASM VM as well? πŸ™‚
21:00:55FromDiscord<Horizon [She/Her]> I have the runtime (wasm3), just need to implement WASI as i go now but that's a challenge
21:01:04FromDiscord<Horizon [She/Her]> In reply to @dom96 "So you're implementing a": Definitely not πŸ˜…
21:01:17FromDiscord<Elegantbeef> Yea I dont really think implementing WASI is all that it's cutout to bee πŸ˜„
21:01:41FromDiscord<Elegantbeef> Ostensibly you want IO and is a `proc writeFile(data: cstring, len: int)` really complex πŸ˜„
21:01:43FromDiscord<dom96> oh, if you're using an existing runtime, doesn't it already implement WASI for you?
21:01:59FromDiscord<Elegantbeef> It does but they want custom WASI that is sandboxed
21:02:44FromDiscord<Elegantbeef> Afaik all you really have to do is match the signatures and put the procedures in the right module, assuming similar behaviour you can just specify what happens with your API
21:03:19FromDiscord<ShalokShalom> Still think there are sandboxed WASIs already out there
21:03:27*krux02 joined #nim
21:03:41FromDiscord<dom96> yeah, WASM is all about sandboxing, I would expect the runtimes to offer some customisation for WASI sandboxing
21:03:47FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "Ostensibly you want IO": A write file proc isn't the problem, it's filling the called WASI methods (like `wasi_preview_snapshot1::fd_write`, i think that was the method signature)
21:04:13FromDiscord<Elegantbeef> You an just do the wine method and returning dummy values for procedures that are unimplemented
21:04:13FromDiscord<Horizon [She/Her]> In reply to @dom96 "yeah, WASM is all": Hm... I don't understand where to find that with wasm3 then, since googling wasn't helping... I'll ask in an issue
21:04:15FromDiscord<Elegantbeef> can\
21:04:29FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "You an just do": Fair aha
21:04:51FromDiscord<Elegantbeef> I mean you only need a subset of WASI, and as it's specialised you dont even need it to be feature parity
21:05:05FromDiscord<dom96> there is bound to be some good Discords about wasm where they can help you with this
21:05:12FromDiscord<dom96> maybe even wasm3 has one
21:05:25FromDiscord<ShalokShalom> In reply to @Event Horizon "Hm... I don't understand": Did you really look into wasmer? πŸ˜„
21:05:33FromDiscord<Elegantbeef> Wasmer's C-api sucks
21:05:35FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "I mean you only": Yup, but file io is something that'd need to be implemented :p
21:05:36FromDiscord<ShalokShalom> Since its exactly designed for that use case
21:05:36FromDiscord<Elegantbeef> So just shush about it
21:05:40FromDiscord<ShalokShalom> (Desktop)
21:05:53FromDiscord<Horizon [She/Her]> In reply to @dom96 "maybe even wasm3 has": Hm I'll look if they have one then
21:05:58FromDiscord<Elegantbeef> You cannot even query a fucking function
21:06:14FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "Did you really look": I did before settling with Beef's suggestion of wasm3
21:06:16FromDiscord<dom96> wasmtime is where it's at
21:06:29FromDiscord<Elegantbeef> I've looked at wasmtime, wasmer, wasmedge, wasm3
21:06:32FromDiscord<Horizon [She/Her]> Ah neat they have a discord
21:06:35FromDiscord<Elegantbeef> All but the last are actually sensible
21:06:47FromDiscord<Elegantbeef> wasm3's discord is pretty much dead
21:06:53FromDiscord<Horizon [She/Her]> In reply to @dom96 "wasmtime is where it's": Their Java bindings were completely broken when using it which didn't give the best impression :p
21:07:00FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "wasm3's discord is pretty": Ah
21:07:04FromDiscord<ShalokShalom> In reply to @Elegantbeef "All but the last": You mean all but the last are not sensible?
21:07:28FromDiscord<Elegantbeef> Wasmer's C-api is lacking, wasmedge requires docker for building and I could not build natively to remove any possible incompatibillities
21:07:29FromDiscord<Elegantbeef> Yes of course
21:08:12FromDiscord<ShalokShalom> Did you look at lumen?
21:08:19FromDiscord<Elegantbeef> Ok maybe wasmtime wasnt bad, i cannot recall at the moment
21:08:23FromDiscord<ShalokShalom> Not a wasm runtime, but just hitting my head
21:08:32FromDiscord<Elegantbeef> Wasm3 is the best, it's super small, and easy to embed in a C project
21:08:36FromDiscord<ShalokShalom> Are you interested in the BEAM?
21:08:42FromDiscord<Elegantbeef> The entire C-api is like 100 loc
21:08:44FromDiscord<ShalokShalom> In reply to @Elegantbeef "Wasm3 is the best,": Will remember that.
21:08:51FromDiscord<Elegantbeef> I dont do webdev
21:09:50FromDiscord<Elegantbeef> @Horizon [She/Her] did you look at wasm3's module for wasi?
21:09:59FromDiscord<dom96> i'll likely end up using wasm3 for what I'm planning anyway, mainly because it is built for embedded
21:10:21FromDiscord<Elegantbeef> You also cant beat https://github.com/beef331/wasm3/blob/master/src/wasm3/wasm3c.nim
21:10:40FromDiscord<Elegantbeef> Builds the runtime and imports it all in 200 loc
21:10:41FromDiscord<dom96> But there is something to be said about the safety guarantees that a Rust implementation brings
21:10:50FromDiscord<dom96> Maybe it works well enough for embedded too
21:10:52FromDiscord<ShalokShalom> Yeah, I guess you could count Graal also as a WA runtime
21:11:09FromDiscord<ShalokShalom> But its probably not the leanest of all options xD
21:11:11FromDiscord<Elegantbeef> Many of these runtimes are JIT'd so that's hardly a benefit↡(@dom96)
21:12:08FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "<@909883978717204561> did you look": I haven't seen it actually, i thought it only interacted with the system but i should probably look at it now properly
21:12:37FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "Yeah, I guess you": Oh god
21:12:52FromDiscord<Horizon [She/Her]> GraalWASM is the worst option you can use for embedding it into a java application
21:13:09FromDiscord<Elegantbeef> https://github.com/wasm3/wasm3/blob/main/source/m3_api_wasi.c#L784 there you go then
21:13:12FromDiscord<Horizon [She/Her]> I tried it but they have no way to interact with Java from WASM, without using GraalJS
21:13:20FromDiscord<Elegantbeef> That links all the definitions of WASI to the module
21:14:30FromDiscord<Elegantbeef> you may have to import more in Nim to do it with raw nim, but it's all the same
21:14:43FromDiscord<Elegantbeef> Plus someone has to extend callWasm to work on complicated procs
21:15:00FromDiscord<ShalokShalom> https://medium.com/graalvm/announcing-graalwasm-a-webassembly-engine-in-graalvm-25cd0400a7f2
21:15:17FromDiscord<ShalokShalom> In reply to @Event Horizon "I tried it but": Why GraalJS?
21:15:52FromDiscord<Elegantbeef> I really dont think any runtime will be as nice to use in Nim as Wasm3 is, it's such a simple API and doesnt use any complex features that it binds so easy
21:16:19FromDiscord<ShalokShalom> Even that 2019 article shows a way
21:16:24FromDiscord<Elegantbeef> Like it uses cstrings for errors, that's wild!
21:16:28FromDiscord<ShalokShalom> And that without JS
21:17:19*ltriant joined #nim
21:18:12FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "Why GraalJS?": Let me clarify: You're unable to expose your own methods to GraalWASM directly from Java, since it was primarily made for GraalJS, with the purpose of using WASM as a scripting language
21:18:51FromDiscord<ShalokShalom> I like their stance of interpreted vs JIT↡↡https://github.com/wasm3/wasm3#motivation
21:19:07FromDiscord<ShalokShalom> I did not know, JITs are that much more complicated
21:19:40FromDiscord<Horizon [She/Her]> Goal was to use it within a Java program, that article doesn't show how to export a Java method to WASM, which is just not doable with the current API
21:19:43FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4fmd
21:20:15FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "*Plus someone has to": XD yeah as i need it, I'll improve on it aha
21:20:29FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4fmd" => "https://play.nim-lang.org/#ix=4fmg"
21:20:52FromDiscord<ShalokShalom> In reply to @Event Horizon "Goal was to use": And did you speak to the team?
21:21:03FromDiscord<ShalokShalom> Like, is this planned
21:21:06FromDiscord<Elegantbeef> why dont you just do `"info_hash": urlEncodeString(sha1hash)`?
21:21:13FromDiscord<ShalokShalom> Or are they just happy with it?
21:21:35FromDiscord<voidwalker> @ElegantBeef because that replaces the % char with %25 or something like that
21:22:04FromDiscord<voidwalker> the url encode function for the URI replaces only special chars.
21:22:18FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "https://github.com/wasm3/wasm3/blob/main/source/m3_": God it looks so complicated 😭
21:22:27FromDiscord<Elegantbeef> It's really not that bad
21:22:52FromDiscord<Elegantbeef> `SuppressLookUpFailure` just checks if `m3_LinkRawFunction` returns an error
21:22:57FromDiscord<voidwalker> @ElegantBeef https://nim-lang.org/docs/uri.html#encodeUrl%2Cstring `This means that characters in the set {'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~'} are carried over to the result. All other characters are encoded as %xx where xx denotes its hexadecimal value.`
21:23:23FromDiscord<Elegantbeef> how is it any different than what you're doing though?
21:23:24FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "And did you speak": I did, they said it isn't their highest priority but is on the roadmap
21:23:43FromDiscord<ShalokShalom> I see
21:23:50FromDiscord<ShalokShalom> Thanks for the information
21:24:19FromDiscord<voidwalker> `info_hash: urlencoded 20-byte SHA1 hash of the value of the info key from the Metainfo file. Note that the value will be a bencoded dictionary, given the definition of the info key above.`
21:24:54FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "It's really not that": https://haste.powercord.dev/pehipixuje
21:25:06FromDiscord<voidwalker> Is this something the library should support, you think ? Since I am really supposed to encode the byte values, not their ascii hexadecimal string equivalent
21:25:23FromDiscord<Elegantbeef> No clue void i dont do web related
21:25:47FromDiscord<Elegantbeef> Yea horizon `callWasm` is meant to handle the `apiReturnType` and `getArg` stuff, but does not presently
21:26:32FromDiscord<Horizon [She/Her]> That's a snippet and looks... Yeah, how would i exactly modify that to implement custom access checking logic
21:27:12FromDiscord<Elegantbeef> you can do whatever you want inside, as long as the error semantics match
21:27:49FromDiscord<Horizon [She/Her]> Ah alright, I'll look at starting to make `callWasm` be more complete tomorrow when i have free time
21:28:00FromDiscord<Elegantbeef> You could have a filestream you write to in there, it really doesnt matter that much, as long as it works as the API needs
21:28:15FromDiscord<Elegantbeef> I mean i'd suggest working on making it work then making it clean
21:28:21FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "You could have a": Yeah i get that
21:28:47FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "I mean i'd suggest": Complete does mean work, can't make guarantees on clean even during the 'cleanup' stage aha
21:34:20FromDiscord<guttural666> simplest/fastest way to extract x separated strings from a string to a seq[string]?
21:35:00FromDiscord<voidwalker> @ElegantBeef I'm now thinking I should be able to pass a string that has the raw byte values I need to encode. How do I get from `sha1hash = "d55be2cd263efa84aeb9495333a4fabc428a4250"` to 213 (d5 in hex) and so on ? Is there such a function in nim ?
21:35:33FromDiscord<Elegantbeef> `fromHex`?
21:40:23*arkurious quit (Quit: Leaving)
21:41:53FromDiscord<voidwalker> yep, that would work for individual bytes
21:43:02FromDiscord<Elegantbeef> There is also `parseHexStr`
21:47:54*derpydoo quit (Quit: derpydoo)
21:49:03FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4fms
21:49:55FromDiscord<voidwalker> I still cannot understand why noone bothered to make even the most minmalistic torrent client in nim.. I mean it's a very rewarding thing to program, if you ask me
22:01:22*jmdaemon joined #nim
22:04:16FromDiscord<guttural666> In reply to @guttural666 "simplest/fastest way to extract": split iterator it is πŸ˜›
22:05:43FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4fmz
22:06:01FromDiscord<Elegantbeef> The two people using Go with Nim
22:06:09FromDiscord<jmgomez> I guess no way you can mix it with ORC but nothing stops you to use it as dll or something
22:06:16FromDiscord<jmgomez> How they are using it?
22:06:34FromDiscord<Elegantbeef> I'm making a joke, no clue if it's actually used
22:06:46FromDiscord<jmgomez> I dont know anything about Go but their reflection system seems good enough to autogen nim wrappers
22:07:13FromDiscord<jmgomez> And it has tons of third party libs
22:07:36FromDiscord<jmgomez> In reply to @Elegantbeef "I'm making a joke,": xD
22:10:50FromDiscord<jmgomez> Do you know if there is an RFC for it (mm:go)?
22:11:04FromDiscord<jmgomez> (edit) "an" => "a"
22:12:12FromDiscord<Elegantbeef> No clue
22:19:15*ltriant quit (Ping timeout: 260 seconds)
22:22:07FromDiscord<Horizon [She/Her]> In reply to @Elegantbeef "The two people using": I'm not actually using it lmao, was just interested in how feasible seamless Go and Nim interop is
22:24:18FromDiscord<Horizon [She/Her]> In reply to @jmgomez "And it has tons": It's definitely possible but tbh, i wouldn't recommend it
22:24:34FromDiscord<Horizon [She/Her]> Golang produces big binaries even with optimisation args passed and such tbh
22:24:45FromDiscord<Horizon [She/Her]> Ugh i should work on Nim JVM again but burnt out
22:26:06qwrgccgo might make smaller binaries, but i never cared enough about go to try it out...
22:27:42FromDiscord<jmgomez> In reply to @Event Horizon "It's definitely possible but": Im thinking in something that would automatically generate bindings wrappers for a given Go package. The size of the packages doesnt really for most things, what's important is the availability of the pkgs. For instance, most important third party package has oficial apis for Go (think of MongoDb, Redis, to name a few)
22:28:24FromDiscord<jmgomez> (edit) removed "important"
22:29:40FromDiscord<Horizon [She/Her]> In reply to @qwr "gccgo might make smaller": Fair
22:30:06FromDiscord<Horizon [She/Her]> In reply to @jmgomez "Im thinking in something": Fair enough, definitely is doable
22:40:14*ltriant joined #nim
23:09:56*lampi joined #nim
23:10:03FromDiscord<guttural666> what do you ppl think about ZIG? find that very attractive as well, but surely not as convenient as Nim
23:30:44*estiquelapice joined #nim
23:33:04FromDiscord<ShalokShalom> In reply to @guttural666 "what do you ppl": You can use Zig CC from Nim.
23:33:17FromDiscord<Elegantbeef> It's a better C, i dont want to write C
23:33:47FromDiscord<guttural666> well it's a much better C as far as I could tell
23:33:48FromDiscord<ShalokShalom> https://github.com/enthus1ast/zigcc
23:34:01FromDiscord<ShalokShalom> Zig is too complicated for me
23:34:16FromDiscord<ShalokShalom> Just like Haxe, but with even more convoluted syntax
23:34:20FromDiscord<ShalokShalom> Nim is simple.
23:34:26FromDiscord<guttural666> dunno Haxe
23:34:32FromDiscord<ShalokShalom> On the surface... πŸ˜‹
23:34:45FromDiscord<ShalokShalom> In reply to @guttural666 "dunno Haxe": It compiles to 16 different languages
23:34:49FromDiscord<ShalokShalom> Or so πŸ˜›
23:35:10FromDiscord<ShalokShalom> And has couple of good game engines written in
23:35:31FromDiscord<ShalokShalom> Good language, good type inference
23:36:21FromDiscord<ShalokShalom> Curly braces and semicolons πŸ˜›
23:36:58FromDiscord<guttural666> I think Nim needs a) docs with dedicated pages for topics and b) people talking about lng stuff in a high quality manner, cpp has so much going for it in those two areas
23:37:13FromDiscord<guttural666> I still watch the cppcon talks because of their quality
23:37:37FromDiscord<guttural666> zig needs those things as well
23:38:57FromDiscord<Elegantbeef> Sure but odin exist πŸ˜œβ†΅(@guttural666)
23:39:39FromDiscord<guttural666> Odin, yeah, I would honestly prefer any of those lng to C/CPP
23:44:18FromDiscord<guttural666> what pissed my off a bit in ZIG is that it was expected of noobs to "just provide your own allocator" and while I would be able to learn the necessary things to implement my own and that topic is on my bucket list and I watched a bunch of interesting videos about it, thats just something I didn't want to do at that timed
23:44:54FromDiscord<Elegantbeef> It's Zig not Zig
23:45:47FromDiscord<guttural666> what Nim does well is that it allows people do just jump in and do stuff, same with Linux distros with Calamares
23:46:37FromDiscord<guttural666> true == true Elegan πŸ˜›
23:53:46FromDiscord<ShalokShalom> In reply to @guttural666 "I think Nim needs": Do you know Cyo?
23:54:03FromDiscord<ShalokShalom> Its a Nim relative, with cleaned up codebase
23:54:21FromDiscord<guttural666> another lng?
23:54:41FromDiscord<ShalokShalom> Its basically Nim
23:54:50FromDiscord<ShalokShalom> Just prepared for future contributions
23:55:20FromDiscord<ShalokShalom> https://github.com/nim-works/nimskull
23:55:28FromDiscord<guttural666> so basically somebody wrote a DSL in Nim which was basically Nim but better
23:55:29FromDiscord<guttural666> hahaha
23:55:36FromDiscord<ShalokShalom> The renaming is an ongoing effort πŸ˜„
23:55:45FromDiscord<ShalokShalom> In reply to @guttural666 "so basically somebody wrote": No, its a fork
23:55:56FromDiscord<ShalokShalom> That shares about 30% of its code today
23:56:04FromDiscord<ShalokShalom> A revamped Nim, if you so will.
23:56:09FromDiscord<guttural666> naaah man, not gonna look at yet another lng or fork
23:56:16FromDiscord<guttural666> way too much as it is
23:56:54FromDiscord<guttural666> we should concentrate on doing our best and killing shite old lngs