<< 16-04-2022 >>

00:33:55*noeontheend joined #nim
01:05:00*vicfred quit (Quit: Leaving)
01:51:10FromDiscord<Forest> Anyone know if i could make an iOS app with Nim? Specifically using Naylib? Or is that not feasible now because of Apple removing OpenGL stuff
01:52:30FromDiscord<Forest> Actually that's probably a question better asked in the Raylib discord server
01:52:57FromDiscord<Forest> But how would i have one codebase for different platforms that have different APIs?
01:53:46FromDiscord<Forest> sent a code paste, see https://play.nim-lang.org/#ix=3Vgf
01:54:36FromDiscord<Anuke> https://github.com/treeform/glfm has examples for an iOS app, it's probably a good place to start.
01:57:32FromDiscord<Forest> Thanks!
02:00:04*noeontheend quit (Ping timeout: 250 seconds)
02:09:59FromDiscord<kunaltyagi (Kunal Tyagi)> Newbie question\: should I be using make with nimc or are there better recommendations?
02:11:24FromDiscord<kunaltyagi (Kunal Tyagi)> I found koch, but it's a bit confusing
02:19:35FromDiscord<Elegantbeef> You can use `nake` or just `nimble` tasks
02:21:40FromDiscord<kunaltyagi (Kunal Tyagi)> Thanks, will look at those
02:22:37FromDiscord<aph> how should i limit the range of what an integer can store, i'm trying to make a type thats `0..127`, would `mod` work?
02:22:51FromDiscord<Elegantbeef> `var a: 0..127`
02:22:57FromDiscord<aph> ohhh
02:23:06FromDiscord<aph> that's cool ngl
02:24:09FromDiscord<aph> thx beef
02:36:20FromDiscord<Anuke> Isn't nake basically dead? I don't see anyone using it, and the repo maintainer doesn't seem to be around
02:36:41FromDiscord<Anuke> It doesn't seem to offer anything over nimble tasks
02:36:56FromDiscord<Elegantbeef> It's compiled Nim so isnt limited to nimscript/Nimvm
02:37:34FromDiscord<!Patitotective> In reply to @Anuke "Isn't nake basically dead?": i use it 👀
02:39:47FromDiscord<Anuke> I haven't run into many nimscript limitations with it, but I suppose my buildscripts haven't been that complex either
02:41:44FromDiscord<!Patitotective> i use it because niprefs (npeg) doesn't work inside nimvm for some reason so🤷‍♂️
02:45:02*arkurious quit (Quit: Leaving)
02:45:44FromDiscord<TryAngle> is there a way to consistenly give a relative path?
02:46:24FromDiscord<TryAngle> like `../assets` and `assets` or maybe `<name>/assets`
02:46:31FromDiscord<TryAngle> depending on where the script got executed
02:47:32FromDiscord<!Patitotective> i have a main module at the top of my project dir, and all paths depend on it↵if you need to pass the path to another module you could pass the absolute path 🤷‍♂️
02:48:49FromDiscord<TryAngle> hmm neither works↵Ive written a script that downloads assets from another page for my project and I want the script to be executable if you are in <project>/scripts and <project>/
02:48:58FromDiscord<TryAngle> (edit) removed "if you are"
02:53:36FromDiscord<!Patitotective> you could make a config file at `project/` where you define all the paths (and maybe the read function of the file converts them to absolutes paths from the `project/`) so the only path you need to "hardcode" is the one of the config file
02:54:21FromDiscord<huantian> you could have a helper function which walks up directories until it finds your project base that would have a `.git` fodler
03:02:03*vicfred joined #nim
03:08:29FromDiscord<!Patitotective> hey @ElegantBeef do you remember the `igBegin/igEnd` macro thing? there seems to be a problem with overloaded procedures↵how should i get the overloaded procedures? 🤨
03:08:51FromDiscord<!Patitotective> (edit) "procedures?" => "procedures from the macro?"
03:12:34FromDiscord<Forest> Anyone have an idea of how I'd structure a program that's supposed to target Android, PC and the web?
03:19:03FromDiscord<TryAngle> sent a long message, see http://ix.io/3Vgo
03:19:56FromDiscord<Forest> Thanks! The GUI library itself is crossplatform but there's definitely code for specific for each platform that'll need to be done
03:21:19FromDiscord<TryAngle> I have the same thing rn with winapi and an api to work on most unix distros and I do it like that
03:22:20FromDiscord<Forest> Ah fair
03:23:07FromDiscord<Forest> @!Patitotective a reason for using platform specific code is for purchases, i can't exactly use Google play purchases on the web now can i lol
03:23:46FromDiscord<!Patitotective> big project
03:24:25FromDiscord<Forest> Yeah lol, or at least I'm planning to
03:26:57FromDiscord<!Patitotective> sounds interesting ~~stealable~~
03:27:52FromDiscord<Forest> Not if i never release the source code lol
03:29:46FromDiscord<!Patitotective> In reply to @Forest "Not if i never": just to see how you're managing cross-platform stuff ~~steal~~ 👀
03:30:19FromDiscord<Forest> Fair lol
03:30:27FromDiscord<Forest> In reply to @TryAngle "really depends on what": But it's just this essentially
03:32:10FromDiscord<!Patitotective> then gonna take a look at try angle's code ~~steal~~ 👀
03:32:41FromDiscord<Forest> Lol
03:55:45FromDiscord<TryAngle> In reply to @Patitotective "then gonna take a": haven't published that yet either 😳
03:55:51FromDiscord<TryAngle> but will soon'ish
03:56:05FromDiscord<TryAngle> writing library atm and implementing that in rift once it's done
03:58:42FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vgt
03:59:06FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3Vgt" => "https://play.nim-lang.org/#ix=3Vgu"
03:59:15FromDiscord<Elegantbeef> Ew
03:59:31FromDiscord<TryAngle> In reply to @Elegantbeef "Ew": why lol
03:59:51FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/FlI
04:00:31FromDiscord<TryAngle> sent a code paste, see https://paste.rs/KwZ
04:00:49FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3Vgw" => "https://play.nim-lang.org/#ix=3Vgx"
04:02:45FromDiscord<TryAngle> I'm getting literally downvoted on a discord
04:02:49FromDiscord<TryAngle> I'm crying
04:03:18FromDiscord<TryAngle> https://tenor.com/view/oh-the-misery-everybody-wants-gif-25104633
04:03:31FromDiscord<!Patitotective> the link is funnier than the gif
04:03:45FromDiscord<TryAngle> https://tenor.com/view/oh-the-misery-everybody-wants-gif-25104633
04:03:50FromDiscord<TryAngle> oh true
04:07:24FromDiscord<Elegantbeef> if they have the same api you can just use a const but unlikely
04:07:43FromDiscord<Rika> In reply to @Patitotective "hey <@145405730571288577> do you": We warned you about it though
04:08:46FromDiscord<!Patitotective> In reply to @Rika "We warned you about": :C
04:09:15FromDiscord<!Patitotective> no overload procedures in macros? :[
04:09:18FromDiscord<!Patitotective> (edit) "overload" => "overloaded"
04:10:16FromDiscord<Rika> You can probably but it’s something I’d say “too complicated for me to go through
04:10:33FromDiscord<Rika> I’d just go with a simpler solution at this point
04:11:13FromDiscord<Rika> Like sure you can get beef to fix it
04:11:23FromDiscord<Rika> Can you maintain it yourself in the future though
04:11:28FromDiscord<!Patitotective> In reply to @Rika "I’d just go with": what kind of solution? :o
04:11:36FromDiscord<Rika> In reply to @Patitotective "what kind of solution?": Manually.
04:11:49FromDiscord<!Patitotective> In reply to @Rika "Like sure you can": all my code is going to end up being written by beef 💀
04:12:21FromDiscord<!Patitotective> In reply to @Rika "Manually.": m-manually?↵thats not what a programmer would say
04:14:07FromDiscord<Rika> In reply to @Patitotective "m-manually? thats not what": It’s not what an amateur programmer would say but there’s a point where you’re exerting more effort making something automatic than just doing it manually
04:17:46FromDiscord<!Patitotective> well, its to time to go to sleep thinking if its worth ~~how to name this library~~
04:17:48FromDiscord<!Patitotective> 🌃
04:18:32FromDiscord<Rika> In reply to @Rika "It’s not what an": It’s just my judgment
04:18:39FromDiscord<Rika> If you really want just wait for beef then
04:19:24FromDiscord<!Patitotective> now im confused
04:19:29FromDiscord<!Patitotective> anyways, thanks and gn
04:20:35FromDiscord<TryAngle> u can write a script for vscode lol
04:21:29FromDiscord<TryAngle> that inserts igEnd<..>s for u
04:25:42NimEventerNew Nimble package! stdarg - A wrapper for <stdarg.h>, see https://github.com/sls1005/stdarg
04:30:30FromDiscord<huantian> hey rika you know a thing or two about suru right
04:32:53FromDiscord<huantian> I was originally going to plan on making a bar for each download "thread", and one total download bar, but then I realized that probably wouldn't work
04:33:46FromDiscord<huantian> at least if I want the bar totals to be file sizes ig? maybe I can have it be a fixed value out of 100
04:34:24FromDiscord<creikey> sent a code paste, see https://paste.rs/JPb
04:34:35FromDiscord<huantian> oh boy do I have a concept for you
04:34:45FromDiscord<Rika> In reply to @huantian "hey rika you know": bro i fucking made it
04:34:52FromDiscord<creikey> In reply to @huantian "oh boy do I": I heard about concepts but I ctrl f'd for them on the manual and couldn't find them
04:35:09FromDiscord<Rika> you can change the totals to whatever number
04:35:21FromDiscord<huantian> can I change the totals after I call setup tho
04:35:35FromDiscord<Rika> i think that's how i made it to be
04:35:35FromDiscord<huantian> In reply to @creikey "I heard about concepts": they're in the experimental section <https://nim-lang.org/docs/manual_experimental.html#concepts>
04:35:44FromDiscord<Rika> bar[0].total = ... or something i forget
04:35:48FromDiscord<huantian> ok then I think I'm doing something wrong
04:35:49FromDiscord<creikey> ah I see they're experimental
04:35:55FromDiscord<creikey> why?
04:35:56FromDiscord<creikey> like do they work
04:36:15FromDiscord<Rika> they work but not completely stably
04:36:27FromDiscord<Rika> but they work well enough
04:36:45FromDiscord<creikey> In reply to @Rika "they work but not": how can a type be "unstable"
04:36:47FromDiscord<creikey> like the compiler actually stops working?
04:36:57FromDiscord<Rika> internal errors yeah
04:36:59FromDiscord<Rika> bugs
04:37:12FromDiscord<creikey> this syntax is looking very wonkky
04:37:14FromDiscord<Rika> "oh this matched even if it isnt supposed to:
04:37:19FromDiscord<creikey> I can kinda read it but like not really
04:38:04FromDiscord<creikey> maybe this is silly but like why even have concepts? just do like `x: any` and then x is valid if its usage in the procedure compiles
04:38:12FromDiscord<creikey> that's like the same thing right
04:38:16FromDiscord<creikey> oh wait isn't that what templates do
04:38:21FromDiscord<Elegantbeef> Lacks concrete explanation
04:39:03FromDiscord<Rika> its just another guarantee
04:39:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3VgD
04:39:10FromDiscord<creikey> cool
04:39:11FromDiscord<creikey> sent a code paste, see https://paste.rs/Kp4
04:39:14FromDiscord<Rika> theres more to it
04:39:22FromDiscord<creikey> I think it's time I finally read the nim manula
04:39:23FromDiscord<creikey> (edit) "manula" => "manual"
04:41:42FromDiscord<huantian> oh I forgot to call bar.update
04:43:58FromDiscord<Rika> bruh
04:44:01FromDiscord<Rika> okay
04:44:15FromDiscord<Rika> suru's still pretty wonky though ill admit
04:44:53FromDiscord<Rika> kinda because i never really needed a progress bar so i dont have much incentive to work more on it
04:47:23*slowButPresent quit (Quit: leaving)
04:47:58FromDiscord<TryAngle> what does that mean exactly?
04:48:00FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3VgF
04:48:14FromDiscord<Elegantbeef> images is stack allocated and cannot safely be captured
04:48:24FromDiscord<huantian> what in the world is happening here, I think I'm breaking something https://media.discordapp.net/attachments/371759389889003532/964749073766830170/unknown.png
04:48:28FromDiscord<Elegantbeef> Use a ref table if you want this to work
04:48:31FromDiscord<TryAngle> In reply to @Elegantbeef "images is stack allocated": so I would need images = ref ?
04:48:33FromDiscord<TryAngle> (edit) "?" => "...?"
04:48:45FromDiscord<Elegantbeef> Yes do \`newTable
04:49:00FromDiscord<Elegantbeef> and drop the `var`
04:50:18FromDiscord<huantian> wow my code is so jank!
04:51:42FromDiscord<Rika> In reply to @huantian "what in the world": i got the same bug, somethings fucked
04:55:28FromDiscord<TryAngle> In reply to @Elegantbeef "Yes do \`newTable": wokrs 🥺
05:00:14FromDiscord<huantian> In reply to @Rika "i got the same": with a different thing?
05:03:31FromDiscord<Rika> the issue is basically that you're incrementing more than total lol
05:03:44FromDiscord<Rika> i dont check that because uh i dont know what i'd do if it goes over, raise an exception?
05:04:14FromDiscord<huantian> yeahhh not sure
05:04:26FromDiscord<huantian> I think keeping it like this is fine, it's a pretty obvious error ig
05:04:45FromDiscord<Rika> i still think it should be caught some way
05:04:58FromDiscord<Rika> but i dont know if an exception would be appreciated xd
05:05:02FromDiscord<Rika> i guess it will
05:05:04FromDiscord<huantian> hm how do I have it inc only by the amount progressed...
05:05:09FromDiscord<huantian> (edit) "progressed..." => "progressed since the last inc"
05:05:21FromDiscord<Rika> how are you getting the progress in the first place
05:12:07FromDiscord<huantian> async httpclients have a callback for that ↵<https://nim-lang.org/docs/httpclient.html#progress-reporting>
05:13:41FromDiscord<sOkam!> Is it possible to make the output of a function be discarded automatically, without having to do `discard theThing()` on every call?
05:14:03FromDiscord<Rika> In reply to @huantian "async httpclients have a": ok so you can set progress with bar.progress =
05:14:23FromDiscord<Rika> In reply to @sOkam! "Is it possible to": on the function definition put pragma `{.discardable.}` i believe
05:15:44FromDiscord<huantian> what exactly is the delay parameter I'm passing in to update? is is the time since last update?
05:16:33FromDiscord<Rika> its uh delay for the bar, otherwise it'll update too quickly
05:16:42FromDiscord<Rika> you dont have to
05:16:50FromDiscord<Rika> theres a default value, 8 millis
05:16:59FromDiscord<huantian> ah ok
05:17:11FromDiscord<huantian> I've been passing in the miliseconds since the last time update was called 😅
05:17:21FromDiscord<huantian> (edit) "miliseconds" => "seconds"
05:17:30FromDiscord<Rika> the update value is in nanoseconds because i have infinite wisdom
05:17:33FromDiscord<Rika> so just dont xd
05:18:08FromDiscord<Rika> before beef murders me this was way before, i think around 2020 i made this
05:18:36FromDiscord<huantian> is there a way I can override the speed value the bar shows?
05:19:07FromDiscord<huantian> probably not but I'll still ask
05:19:13FromDiscord<Rika> no
05:19:19FromDiscord<Rika> is it wrong?
05:19:38FromDiscord<huantian> nah it's fine, just onProgressChanged gives a probably more accurate speed value
05:20:02FromDiscord<Rika> yeah i havent thought about overriding the speed thing because that's not really something you'd consider for a progress bard
05:20:02FromDiscord<Rika> (edit) "bard" => "bar\"
05:23:36*rockcavera quit (Ping timeout: 248 seconds)
05:25:55FromDiscord<huantian> <https://github.com/huantianad/rd-downloader/blob/master/src/rd_downloader.nim>↵my current code if you wanna critique my poorly thought out code↵I swear I'll make some of it less horrendous soon™️
05:30:41FromDiscord<Rika> it looks fine
05:33:27FromDiscord<huantian> I wonder how much I would have to put in to get progressbars kinda similar to pacman
05:34:25FromDiscord<sOkam!> Is `return 0` needed at the end of the main function, like in C?↵Or is that done automatically?
05:34:29FromDiscord<huantian> but I think i'd have to make my own progress bar from scratch
05:34:38FromDiscord<huantian> nah no return 0 is needed
05:34:50FromDiscord<huantian> in fact a main method isn't needed
05:34:56*zeus-supreme joined #nim
05:35:20FromDiscord<sOkam!> well, you need a core function that runs the show. Was meaning that one 🙂
05:35:49FromDiscord<sOkam!> Or a core file, if you want to ignore things being inside procs
05:36:14FromDiscord<huantian> yeah I know what ya mean, I do like having a main function usually too
05:36:20FromDiscord<huantian> at least for applications
05:37:12FromDiscord<sOkam!> whats the return value of an app made in nim when it successfully runs? is it 0 automatically?
05:37:25FromDiscord<huantian> mhm
05:37:31FromDiscord<sOkam!> or is that even a thing here at all 🤔
05:38:06FromDiscord<huantian> I mean I don't think you can have a program not return an exit code 😛
05:38:09FromDiscord<Rika> the "return value" is 0
05:38:23*zeus-supreme1 quit (Ping timeout: 256 seconds)
05:38:39FromDiscord<huantian> use `quit` to exit with a non-zero exit code↵<https://nim-lang.org/docs/system.html#quit%2Cint>
05:38:46FromDiscord<Elegantbeef> If there is no unhandled exception it returns 0 otherwise it returns `Quit.failure`
05:39:05FromDiscord<sOkam!> handy. tyty
05:58:05*rockcavera joined #nim
05:58:05*rockcavera quit (Changing host)
05:58:05*rockcavera joined #nim
05:58:49FromDiscord<beans> Is there a library(or builtin way) that generates nim objects from json objects that I can unmarshal into? I'm writing an API wrapper and some of the endpoints return some realllly long json objects 😅
05:59:35FromDiscord<huantian> yeah but I cannot remember the name of it
05:59:44FromDiscord<huantian> wait no is it https://github.com/jiro4989/nimjson
06:00:14FromDiscord<beans> That's exactly what I was looking for, thanks
06:00:41FromDiscord<huantian> if your api provides a json schema or something, it might be better to use that
06:05:24FromDiscord<TryAngle> is there a way to get the user home path on windwos / linux / mac?
06:05:34FromDiscord<Elegantbeef> `getHomeDir`
06:06:10FromDiscord<TryAngle> In reply to @Elegantbeef "`getHomeDir`": what is it's result for linux / mac ?
06:06:30FromDiscord<TryAngle> windows not linux
06:06:46FromDiscord<huantian> C:\Users\username
06:06:54FromDiscord<huantian> There’s a funny name for this but I can’t remember
06:07:10FromDiscord<Valdar> getCurrentDir()
06:07:25FromDiscord<Valdar> oh, home..
06:07:35FromDiscord<TryAngle> In reply to @huantian "C:\Users\username": ok ty
06:07:50FromDiscord<creikey> why is it like this? why is panic/exception platform dependent? does this just mean you can never use exceptions as valid code? https://media.discordapp.net/attachments/371759389889003532/964769065140899900/unknown.png
06:07:53FromDiscord<Valdar> (edit) "getCurrentDir()" => "~~getCurrentDir()~~"
06:08:09FromDiscord<Elegantbeef> It's not platform specific
06:08:12FromDiscord<Elegantbeef> It's flag specific
06:08:18FromDiscord<Rika> Defects and CatchableErrors are different kinds of exceptions
06:08:20FromDiscord<Elegantbeef> And if you use try except on a fucking defect i'll find you
06:08:38FromDiscord<Rika> i personally disagree about defects existing so try me bitch
06:08:46FromDiscord<huantian> At some point I’ve caught rangeDefect for input handling hehe
06:08:48FromDiscord<TryAngle> sent a long message, see http://ix.io/3VgL
06:09:02FromDiscord<TryAngle> (edit) "http://ix.io/3VgL" => "http://ix.io/3VgM"
06:09:11FromDiscord<huantian> Well Linux has .config and .local/share
06:09:22FromDiscord<huantian> I don’t know the conventions for window
06:09:45FromDiscord<TryAngle> (edit) "http://ix.io/3VgM" => "https://paste.rs/VtC"
06:10:07FromDiscord<Elegantbeef> If only there was a `getConfigDir`
06:10:15FromDiscord<huantian> Ikr
06:12:07FromDiscord<huantian> Also I wish getFilename was specified that it worked on directories
06:12:33FromDiscord<huantian> Though perhaps it’s obvious
06:13:54FromDiscord<huantian> Hm what is the windows version of Linux ~/.local/share
06:14:15FromDiscord<TryAngle> In reply to @Elegantbeef "If only there was": XD
06:15:12FromDiscord<TryAngle> nim is so nice ppl will lose their job because it's too efficient to use once it gets more popular
06:17:10FromDiscord<TryAngle> is there a way to autocreate a diretory with writeFile if the directory does not exist?
06:17:21FromDiscord<TryAngle> writeFile autocreates a file but not the entire dir
06:17:24FromDiscord<huantian> Exists or crest dir something something
06:17:47FromDiscord<huantian> Oh you mean create dirs up to the file
06:18:09FromDiscord<TryAngle> In reply to @huantian "Oh you mean create": yes
06:18:56FromDiscord<Rika> In reply to @huantian "Hm what is the": appdata roaming?
06:29:01FromDiscord<Valdar> In reply to @huantian "Hm what is the": There is C:\Users\Public if that is what you mean. public share with no admin requirement
06:42:32*rockcavera quit (Remote host closed the connection)
06:49:30FromDiscord<Rika> yes but no, isnt `~/.local/share/` still part of the user's home though
06:51:10FromDiscord<Rika> sent a code paste, see https://paste.rs/RSK
06:52:02FromDiscord<Rika> `/usr/share Architecture-independent (shared) data.`
06:54:40FromDiscord<Rika> so maybe its local or roaming, idk which
07:13:03FromDiscord<huantian> iirc roaming gets shared across multiple computers that have the same user account
07:13:11FromDiscord<huantian> While local is local to a specific imputed
07:13:14FromDiscord<huantian> Computer
07:13:21FromDiscord<TryAngle> how can I compare via value and not for "ptr"?
07:13:33FromDiscord<TryAngle> or something is off 🤔
07:13:56FromDiscord<Rika> In reply to @huantian "iirc roaming gets shared": so its equivalent to roaming
07:14:06FromDiscord<Rika> unless is local only computer-local
07:14:08FromDiscord<Rika> i dont remember it being such
07:14:42FromDiscord<Rika> yeah its not computer-local
07:14:50FromDiscord<Rika> so appdata roaming is likely best analogue
07:15:40FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3VgY
07:15:41FromDiscord<TryAngle> when I assert them
07:16:42FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/C34
07:16:46FromDiscord<Elegantbeef> Maybe with a few more `()` but meh
07:17:02FromDiscord<Elegantbeef> And perhaps not overload `==`
07:17:06FromDiscord<TryAngle> In reply to @Elegantbeef "Maybe with a few": wdym?
07:17:17FromDiscord<TryAngle> sent a code paste, see https://paste.rs/Uh0
07:17:27FromDiscord<Elegantbeef> So then what's the issue?
07:17:43FromDiscord<TryAngle> In reply to @Elegantbeef "So then what's the": I have no idea lol
07:17:54FromDiscord<TryAngle> I get assertion defect
07:18:33FromDiscord<Elegantbeef> What's the type definition?
07:18:57FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vh0
07:19:36FromDiscord<TryAngle> oh!
07:20:12FromDiscord<TryAngle> sent a code paste, see https://paste.rs/XHN
07:22:36FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vh3
07:23:32FromDiscord<Rika> ? are you sure thats where it errors
07:24:44FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vh4
07:24:50FromDiscord<TryAngle> removing this line it works
07:25:26FromDiscord<Rika> print them both and see if tehyre the sam?
07:25:28FromDiscord<Rika> (edit) "sam?" => "same?"
07:26:16FromDiscord<TryAngle> In reply to @Rika "print them both and": yes
07:26:27FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vh5
07:26:34FromDiscord<Rika> print repr
07:27:23FromDiscord<Elegantbeef> This is a hell of a proc https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/times.nim#L1407-L1411
07:28:43FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3Vh7
07:29:02FromDiscord<Rika> loooooool
07:29:26FromDiscord<TryAngle> because $ does not contain ns
07:35:41FromDiscord<TryAngle> ok doing formt and parse with "yyyy-MM-dd'T'HH:mm:sszzz:fffffffff" works now
07:35:54FromDiscord<TryAngle> thanks 🥺 ↵didn't know about repr()↵cool command
07:44:50*Gustavo6046 quit (Quit: Goodbye! Leave messages at my XMPP @ [email protected] or my Discord Gustavo6046#9009 or possibly my Mastodon [email protected] – I don't check my email often since it's full of crap, but in any case, [email protected])
08:14:19FromDiscord<untoreh> is my pc slow or was this gif edited to look fast? 🙂 https://raw.githubusercontent.com/inim-repl/INim/master/readme.gif my commands are definitely not that fast
08:14:41*yoyojambo joined #nim
08:15:30*yoyojambo quit (Client Quit)
08:15:47*yoyojambo joined #nim
08:15:53FromDiscord<Rika> Could be a fast typed
08:15:58FromDiscord<Rika> Typer
08:16:02FromDiscord<Rika> Not unimaginable
08:16:09*yoyojambo quit (Client Quit)
08:16:52FromDiscord<untoreh> I mean, the eval (compile) time, between you press enter, and get the output
08:17:41FromDiscord<TryAngle> how can I shorten `newString(40)` to i'ts real length ?
08:17:57FromDiscord<Elegantbeef> you want `newStringOfCap`
08:18:15FromDiscord<TryAngle> In reply to @Elegantbeef "you want `newStringOfCap`": no
08:18:19FromDiscord<TryAngle> I'm using it for imgui
08:18:22FromDiscord<TryAngle> text
08:18:32FromDiscord<Elegantbeef> Find the first `\0` that's the new length
08:18:44FromDiscord<TryAngle> last time u told me I want newString(40) 😂
08:18:57FromDiscord<TryAngle> In reply to @Elegantbeef "Find the first `\0`": oh, that make sense thanks
08:19:03FromDiscord<Rika> In reply to @TryAngle "I'm using it for": Shouldn’t it return the new length?
08:19:13FromDiscord<Elegantbeef> nah it just returns if it mutated iirc
08:19:52FromDiscord<TryAngle> I'm having lot of issues storing and reading / writing that value outside of imgui
08:20:02FromDiscord<TryAngle> espcieally it eats my file endings 😡
08:21:36FromDiscord<Rika> Nom
08:59:25FromDiscord<jmgomez> how do you model a variant type that has fields in common with other variants but not all?
08:59:52FromDiscord<Elegantbeef> You name them slightly differently presently
08:59:58FromDiscord<Elegantbeef> There is an RFC to allow duplicate case statements
09:00:25FromDiscord<jmgomez> ok, thanks
09:28:55*neceve joined #nim
09:33:20*jmdaemon quit (Ping timeout: 250 seconds)
09:36:13*wyrd quit (Remote host closed the connection)
09:41:24*wyrd joined #nim
10:03:49*kenran joined #nim
10:06:28FromDiscord<d4rckh> sent a code paste, see https://paste.rs/D0w
10:06:41FromDiscord<Yardanico> In reply to @d4rckh "I am using argparse": required type for default: Option[system.string] but expression 'default = some(@[""])' is of type: Option[seq[string]]
10:06:48FromDiscord<Yardanico> you're passing a sequence of strings but it expects a string
10:06:55FromDiscord<Yardanico> i guess it maybe doesn't support default for multiple?
10:06:57FromDiscord<d4rckh> well it errors if i give it a string too
10:07:04FromDiscord<Yardanico> In reply to @d4rckh "well it errors if": it shouldn't
10:07:07FromDiscord<Yardanico> try `default = some(""`)
10:07:11FromDiscord<Yardanico> (edit) "some(""`)" => "some("")`"
10:07:28FromDiscord<d4rckh> sent a code paste, see https://paste.rs/3ax
10:07:31FromDiscord<d4rckh> its so weird
10:08:05FromDiscord<Yardanico> yeah I think it's an argparse bug then
10:08:36FromDiscord<Yardanico> i don't know that would be a good way of fixing this in argparse itself. I guess one way is to always have the seq[string] argument, and just take the first element without `multiple`
10:08:43FromDiscord<Yardanico> you can open an issue in argparse
10:08:51FromDiscord<Yardanico> also can you give me the code?
10:09:07FromDiscord<d4rckh> one sec, let me make a new branch
10:09:07FromDiscord<Yardanico> ah nvm i can try myself
10:09:11FromDiscord<d4rckh> okay then
10:09:23FromDiscord<d4rckh> let me know if it works for you, if not ill open an issue
10:09:32FromDiscord<enthus1ast> i'm quite happy with cligen for my command line stuff
10:10:36FromDiscord<d4rckh> i might consider changing argparse with something else because i need more features like having my arguments categorized, my program has like 21 argumentsw
10:10:37FromDiscord<d4rckh> (edit) "argumentsw" => "arguments"
10:10:56FromDiscord<Yardanico> In reply to @enthus1ast "i'm quite happy with": well cligen is nice for simple stuff, but IMO it lacks a bit for more complex CLI apps
10:11:12FromDiscord<Yardanico> and I don't like the fact that it has too much additional code for a CLI library (although nim has DCE so it's not a big deal)
10:11:17FromDiscord<Yardanico> and also the fact that it uses some unsafe Nim features
10:12:17FromDiscord<enthus1ast> yes thats true, cligen does a lot automatically and you cannot do all possible commandline apps with it↵(@Yardanico)
10:12:35FromDiscord<enthus1ast> but the "bang for the bucks" is quite good,
10:12:58FromDiscord<enthus1ast> 2-3 lines for a fully fledged command line app is good imho
10:13:18FromDiscord<Yardanico> ah btw @d4rckh is there any reason you actually need `header` to have one empty string by default?
10:13:21FromDiscord<Yardanico> you can just check the length
10:13:33FromDiscord<Yardanico> `if opts.header.len > 0: do stuff with headers`
10:14:23FromDiscord<d4rckh> well i want it to be empty by default, i tried default=some(@[]) but that also errored, thought i need to add at least an element
10:14:45FromDiscord<Yardanico> wdym?
10:14:50FromDiscord<Yardanico> it's empty by default already
10:14:54FromDiscord<d4rckh> actually not supplying default would work
10:14:55FromDiscord<Yardanico> Nim sequences are empty by default
10:14:59FromDiscord<d4rckh> right
10:15:06FromDiscord<Yardanico> but yeah it's still a bug in argparse
10:15:13FromDiscord<d4rckh> okay, ill open an issue later today then
10:18:32*ltriant quit (Ping timeout: 248 seconds)
10:23:11FromDiscord<d4rckh> @Yardanico https://github.com/iffy/nim-argparse/issues/76
10:23:18FromDiscord<d4rckh> (edit) "@Yardanico ... https://github.com/iffy/nim-argparse/issues/76" added "here"
10:50:29*ltriant joined #nim
11:05:06FromDiscord<5Q> sent a long message, see https://paste.rs/B2V
11:05:46FromDiscord<5Q> sent a code paste, see https://paste.rs/dAS
11:22:42FromDiscord<Yardanico> @5Q in win32 api (and a lot of other C APIs) if the return value is 0, the function _failed_
11:22:50FromDiscord<5Q> nevermind, my error-checking is wrong, I should use .FAILED to see if the function failed or not
11:22:51FromDiscord<Yardanico> and if the return value is non-zero (like in your case), it succeeded
11:23:00FromDiscord<5Q> yeah, just figured that out↵(@Yardanico)
11:23:13FromDiscord<Yardanico> wait actually not a lot of other C apis :P
11:23:17FromDiscord<Yardanico> i just know that win32 api does that
11:24:05FromDiscord<5Q> but weird that the WINBOOL to bool conversion doesn't work as expected, that it converts 1 to false
11:24:25FromDiscord<Yardanico> ?
11:24:32FromDiscord<Yardanico> i think it's correct as it's just simple type conversion
11:24:37FromDiscord<Yardanico> in all languages 1 means true
11:24:46FromDiscord<Yardanico> oh
11:24:54FromDiscord<5Q> there you can see that res = 1, but the (not res) is true
11:25:11FromDiscord<Yardanico> huh
11:25:19FromDiscord<Yardanico> sorry, i don't know win32 api and winim that well, maybe they do that
11:26:45FromDiscord<5Q> by the way, I see in winim they use converters, where can I learn about them? I couldn't find anything about them in the documentaiton
11:28:06FromDiscord<5Q> nevermind, found them in macros
11:29:41FromDiscord<5Q> so, is it a procedure that gets called when you, for example, pass a sequence to the if statement, and that converter returns false if it's empty?
11:35:41FromDiscord<@Legioneroff:matrix.org> What about vacancies for junior at Nim language?
11:37:36FromDiscord<5Q> sent a code paste, see https://play.nim-lang.org/#ix=3VhZ
11:42:17FromDiscord<d4rckh> whats a quick way of checking if the at least one string in a sequence contains a substring?
11:42:57FromDiscord<Yardanico> In reply to @d4rckh "whats a quick way": i don't think there's a "quick way", you'll have to iterate over all elements until you find one that has a substring
11:43:07FromDiscord<d4rckh> thanks, ill probably use filter
11:43:28FromDiscord<Yardanico> filter will be a bit slower, better use anyIt
11:43:36FromDiscord<Yardanico> https://nim-lang.org/docs/sequtils.html#anyIt.t%2Cuntyped%2Cuntyped
11:43:46FromDiscord<Yardanico> `mystrings.anyIt("substring" in it)`
11:43:52FromDiscord<Yardanico> import std/[sequtils, strutils]
11:44:27FromDiscord<d4rckh> oh, thanks
11:44:42FromDiscord<Yardanico> but you won't know the index though
11:44:52FromDiscord<d4rckh> i dont need it
12:00:45*kenran quit (Quit: WeeChat info:version)
12:05:33*zeus-supreme1 joined #nim
12:08:49*zeus-supreme quit (Ping timeout: 256 seconds)
12:20:26*slowButPresent joined #nim
12:29:47FromDiscord<untoreh> is there a pragma to override destructors?
12:45:50*xet7 quit (Remote host closed the connection)
12:47:47*xet7 joined #nim
13:11:39*wyrd quit (Remote host closed the connection)
13:12:02*wyrd joined #nim
13:14:43*arkurious joined #nim
13:24:15FromDiscord<Rika> No, what’s the issue exactly though ?
13:28:22*kenran joined #nim
13:33:51FromDiscord<deech> sent a code paste, see https://paste.rs/ZF8
13:36:29FromDiscord<renghen> hi I do not know if this is the right channel, can anyone point me on how to compile nim to web assembly and updated tutorial would be nice
14:06:15FromDiscord<demotomohiro> https://github.com/treeform/nim_emscripten_tutorial
14:26:01FromDiscord<@Legioneroff:matrix.org> What about vacancies for junior at Nim language?
14:28:51FromDiscord<Rika> not many
14:29:03FromDiscord<Rika> there are barely any jobs at all
15:00:56*lumo_e joined #nim
15:02:13*kenran quit (Quit: WeeChat info:version)
15:22:25*lumo_e quit (Ping timeout: 246 seconds)
15:23:28*lumo_e joined #nim
15:25:14FromDiscord<0ffh> sent a long message, see http://ix.io/3ViW
15:25:34FromDiscord<0ffh> (edit) "sent" => "In reply to @5Q "I've done some digging,": ``result = if x == FALSE: false else: true``↵The reason for code like above is" | "long message, see http://ix.io/3ViW" => "mystery to me. Whats wrong with just going like blow?↵``result = x != FALSE``"
15:27:35FromDiscord<Yardanico> In reply to @renghen "hi I do not": You can either use emscripten as demotomohiro said, or use WASI SDK
15:28:21FromDiscord<Yardanico> You can check https://github.com/aduros/wasm4/tree/main/cli/assets/templates/nim for an example of WASI SDK usage
15:28:36FromDiscord<Yardanico> It's for wasm-4, but it's the same principle
15:28:59FromDiscord<Yardanico> In reply to @0ffh "``result = if x": Or just result = bool(x)
15:34:25FromDiscord<0ffh> In reply to @Yardanico "Or just result =": Right, even better!↵Although I'm surprised a bit: Even for a ``distinct int`` without any ``borrow``-ing you can cast to bool just like that. I wouldn't have expected that.
15:35:46FromDiscord<Yardanico> well this is not a cast, this is a type conversions
15:35:51FromDiscord<Yardanico> (edit) "conversions" => "conversion"
15:36:19FromDiscord<Yardanico> Nim has casts with `cast`, but they're unsafe as they just treat memory as another type
15:36:41FromDiscord<0ffh> Pardon my sloppy language. 😅
15:37:01FromDiscord<Yardanico> type conversions are safe and checked (for things like inherited objects)
15:37:18NimEventerNew thread by Tcheran: Seeking advices for a C programming book, see https://forum.nim-lang.org/t/9110
15:37:59FromDiscord<0ffh> In reply to @Yardanico "type conversions are safe": Right, thanks, but why does one even exist for a ``distinct int`` is what I marveling at?
15:38:12FromDiscord<0ffh> (edit) "I" => "I'm"
15:38:16FromDiscord<Yardanico> Maybe you misunderstood distinct
15:38:31FromDiscord<Yardanico> You can convert distinct types to their original types or the ones they're compatible with
15:38:35FromDiscord<Yardanico> With type conversions
15:41:02FromDiscord<0ffh> sent a long message, see http://ix.io/3ViZ
15:41:18FromDiscord<0ffh> (edit) "http://ix.io/3ViZ" => "http://ix.io/3Vj0"
15:41:32FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#type-relations-convertible-relation has some more info about conversions
15:42:26FromDiscord<Solitude> In reply to @0ffh "Yeah, I would have": you can convert any ordinal to any other ordinal
15:43:43FromDiscord<Yardanico> Explicitly yes
15:44:48FromDiscord<0ffh> That's good to know, thanks y'all!
15:59:00*lumo_e quit (Ping timeout: 250 seconds)
15:59:32FromDiscord<!Patitotective> In reply to @TryAngle "u can write a": i dont think im the person that uses vs code 💀
15:59:46FromDiscord<!Patitotective> (edit) "In reply to @TryAngle "u can write a": i dont think im the ... person" added "kind of"
16:06:19FromDiscord<TryAngle> In reply to @Patitotective "i dont think im": what u using 🥺
16:06:52FromDiscord<TryAngle> sublime
16:07:28FromDiscord<TryAngle> In reply to @Patitotective "i dont think im": I even use the propietery from AUR 😈
16:07:47FromDiscord<TryAngle> (edit) "In reply to @Patitotective "i dont think im": I even use the propietery from AUR ... 😈" added "instead of the oss version"
16:08:33FromDiscord<!Patitotective> AUR? did you mean debian or flatpak?
16:17:13*slowButPresent quit (Quit: leaving)
16:33:03FromDiscord<TryAngle> In reply to @Patitotective "AUR? did you mean": no
16:33:08FromDiscord<TryAngle> I only use snapd
16:34:04FromDiscord<TryAngle> snapd > flatpak > appimage > pacman > aur
16:34:36FromDiscord<!Patitotective> appimages can't be compared to package managers↵appimages don't require installation
16:34:42FromDiscord<TryAngle> (edit) "snapd > flatpak > appimage > ... pacman" added "aur >" | removed "> aur"
16:37:53FromDiscord<TryAngle> In reply to @Patitotective "appimages can't be compared": u can make it one if you are brave enough 😳
16:38:37FromDiscord<!Patitotective> wdym? make a appimages package maanger??
16:39:54FromDiscord<TryAngle> In reply to @Patitotective "wdym? make a appimages": just write shell script add it to path↵and all appimages in one folder↵so u can do like (if we call that script pacimage↵`$ pacimage <appimagename>`
16:40:06FromDiscord<TryAngle> (edit) "pacimage↵`$" => "pacimage)↵`$"
16:40:22FromDiscord<!Patitotective> there's already appimage-launcher
16:40:37FromDiscord<TryAngle> 😔
16:41:16*oddish quit (Quit: nyaa~)
16:44:13FromDiscord<jmgomez> hey guys, is there a way to retrieve all defined types at compile time?
16:44:27*oddish joined #nim
16:47:03*rockcavera joined #nim
16:47:03*rockcavera quit (Changing host)
16:47:03*rockcavera joined #nim
16:48:12FromDiscord<Rika> why?
16:48:16FromDiscord<Rika> no i dont think so
16:48:30FromDiscord<Rika> you can check if a type is defined if you know the name though
16:48:41FromDiscord<Rika> what're you trying to do?
16:50:26FromDiscord<jmgomez> I would like to check for all user defined types that has certain pramas in it
16:50:37FromDiscord<jmgomez> (edit) "pramas" => "pragma"
16:52:19FromDiscord<huantian> Could you have the pragma add the type to a compile time table?
16:53:52FromDiscord<jmgomez> yes, that would work. Im just new to macros so problably there are options that Im not considering. ↵Is there an example of that somewhere?
16:56:42*vicfred quit (Quit: Leaving)
17:00:56*vicfred joined #nim
17:37:57FromDiscord<Yayko> sent a long message, see https://paste.rs/3a1
17:39:11*T-urbo joined #nim
17:39:43*T-urbo quit (Client Quit)
17:42:36FromDiscord<spoon> i mean right now i'm learning polymorph to switch to an entity component system, but currently i have an "entity" class that the player and enemies inherit from, as well as a separate class for tiles which things like walls and floors inherit from
17:43:41FromDiscord<spoon> (edit) "class" => "object" | "class" => "ref object"
17:48:33FromDiscord<leorize> the gamedev channel is probably better for this question
17:50:20FromDiscord<leorize> using ref vs value objects depends a lot on your data structures and their requirements which varies wildly from domain to domain
17:51:36FromDiscord<Yayko> In reply to @spoon "i mean right now": Ok thank you very much, it helps me a little better to understand, you use refs when you have a lot of similar object to create/store right? for example if you make an online game, would your character become a ref object?
17:51:57FromDiscord<leorize> from the little stuff I heard about gamedev though, is that you should avoid focusing on one object and focus more on the fact you will process a lot of them at once
17:52:09FromDiscord<leorize> but for starters I think ref objects are very easy to understand and use
17:54:04FromDiscord<spoon> well, the players will probably all be instances of the same player object, ref objects are used for when two objects share a lot of the same features, but the one inheriting has different features. like, in my case, all entities have a position but only the player has an inventory, so it inherits from entity, and only the item drop has a description, but still has a world position, so it has its own ref object of entity
17:54:42FromDiscord<spoon> (edit) "different" => "additional"
17:56:12FromDiscord<spoon> In reply to @leorize "from the little stuff": yeah, that's what entity component systems are for, since it uses a data-oriented approach. but OOP is fine for simplistic stuff that doesn't require a ton of separate instances
18:01:11FromDiscord<Yayko> In reply to @spoon "well, the players will": Ok, thank you very much, you really helped me!! 🙂↵The Nim community is really cool 😄
18:05:10FromDiscord<Yayko> In reply to @spoon "yeah, that's what entity": When I went to see some info on rust I came across this famous "ECS"↵I don't know at all what it is but it seems to be powerful, I see that there are a lot of people talking about it among the Rustacean
18:08:50FromDiscord<spoon> sent a long message, see http://ix.io/3VjI
18:10:44FromDiscord<spoon> there are a bunch of nuances im not experienced enough to go into detail about too, though
18:12:02FromDiscord<leorize> this is a good book to read if you wish to understand the concepts behind such a system\: https://dataorienteddesign.com/dodbook/
18:12:26FromDiscord<leorize> for something more gamedev-geared, you can watch pretty much any talks from Mike Acton
18:18:26*pro joined #nim
18:26:54FromDiscord<!Patitotective> im totally new to async/web stuff and i want to use https://download-directory.github.io/ to download a directory but ive no idea how to do it 🤷‍♂️ ↵should i use puppy?
18:30:42FromDiscord<huantian> you can also use https://nim-lang.org/docs/httpclient.html#downloadFile%2CAsyncHttpClient%2C%2Cstring↵if you'd like
18:31:09FromDiscord<Zoom> [Yayko#1726](https://matrix.to/#/%40_discord_897838441453191218%3At2bot.io) if your game has any considerable number of entities, I'd look into "data-orienting" your logic before going full ECS or OOP.
18:32:43FromDiscord<Zoom> Look up that talk by Mike Acton (it's on C++ but language is not really relevant to the topic)
18:34:14FromDiscord<!Patitotective> In reply to @huantian "you can also use": so, for example, if i wanted to download https://github.com/nimgl/nimgl/tree/master/src i would use this link https://download-directory.github.io?url=https://github.com/nimgl/nimgl/tree/master/src↵but then how do i wait until the download is ready?
18:34:29FromDiscord<!Patitotective> because it zips the directory
18:34:48*zeus-supreme joined #nim
18:35:14FromDiscord<huantian> I have no idea how the website works, but you need a direct link
18:37:25*zeus-supreme1 quit (Read error: Connection reset by peer)
18:38:07FromDiscord<spoon> you mean like async await?
18:38:25FromDiscord<huantian> it might be easier just to download the entire git repo
18:38:33FromDiscord<huantian> and unzip and move stuff around yourself
18:39:05FromDiscord<spoon> i wish git had a pull command for a subfolder, i had to download an entire game source just to get something out of the tools folder
18:39:15FromDiscord<spoon> clone command rather
18:39:18FromDiscord<huantian> i mean, you can use svn 😛
18:39:29FromDiscord<!Patitotective> i wanted to avoid that cause the `.git` folder weighs 118MB 💀
18:39:59FromDiscord<huantian> the zip download doesn't come with a .git
18:40:10FromDiscord<huantian> https://github.com/nimgl/nimgl/archive/refs/heads/master.zip https://media.discordapp.net/attachments/371759389889003532/964958392974180362/unknown.png
18:40:45FromDiscord<huantian> or use the release zips if you want to make it more reproducible ig
18:45:29FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3VjS
18:45:57FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3VjT
18:46:31FromDiscord<Zoom> Do you remember you can always do `git clone --depth 1 --shallow-submodules` to lighten up the .git and traffic?
18:46:40FromDiscord<huantian> In reply to @Patitotective "im getting 404 😕": `await client.downloadFile("https://github.com/nimgl/nimgl/archive/refs/heads/master.zip", "master.zip")`
18:46:55FromDiscord<huantian> pass full url to url, second argument is name of file on disk
18:47:23FromDiscord<!Patitotective> amazing, thanks ❤️
18:47:45*lumo_e joined #nim
18:50:43FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3VjU
18:50:53FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3VjU" => "https://play.nim-lang.org/#ix=3VjV"
18:51:06FromDiscord<huantian> good thing they already have that written for you↵https://nim-lang.org/docs/locks.html#withLock.t%2CSysLock%2Cuntyped
18:52:19FromDiscord<TryAngle> In reply to @huantian "good thing they already": .....
18:52:25FromDiscord<TryAngle> thank you great gods of nim language
18:52:36FromDiscord<TryAngle> I shall learn to read your wise documentation
18:54:58FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3VjY
18:55:24FromDiscord<TryAngle> (edit) "https://play.nim-lang.org/#ix=3VjY" => "https://play.nim-lang.org/#ix=3VjZ"
19:02:55*Gustavo6046 joined #nim
19:04:54*Gustavo6046 quit (Remote host closed the connection)
19:05:18*Gustavo6046 joined #nim
19:23:46*vicfred quit (Quit: Leaving)
19:28:57*jmdaemon joined #nim
19:30:16FromDiscord<@Legioneroff> Why the Nim more popular than Crystal language? 🤔
19:30:39FromDiscord<huantian> because nim better
19:30:51FromDiscord<Elegantbeef> It's older, and didnt have oddities with it's cross platform API
19:32:31FromDiscord<huantian> also you don't need to ask in 3 different rooms lol
19:33:04*neceve quit (Ping timeout: 250 seconds)
19:33:13FromDiscord<spoon> i just looked at it and it already reminds me of java
19:34:00FromDiscord<@Legioneroff> Thanks dude!
19:34:34FromDiscord<Elegantbeef> Eh crystal is ruby but a system language supposedly
19:34:49FromDiscord<spoon> does it have the same everything as an object philosophy because i saw an example of creating a parser to parse stuff
19:35:10FromDiscord<@Legioneroff> Crystal? They talked that in is C with Ruby syntax.↵(@spoon)
19:35:10FromDiscord<Elegantbeef> Yea it's OOP afaik
19:36:03*jjido joined #nim
19:36:19FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3Vke
19:36:29FromDiscord<spoon> is it multiparadigm at least because i hate java and forced oop
19:36:46FromDiscord<Elegantbeef> Ugh i hate you phil so many wasted operations
19:38:02FromDiscord<Phil> I would start caring if it would actually matter for performance more than the SQL query
19:38:31FromDiscord<Elegantbeef> Cmon look at that beaut!
19:38:31FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Vkg
19:39:05FromDiscord<spoon> that just looks like code golf
19:39:13FromDiscord<@Legioneroff> Which is older, Crystal? They seem to be a couple of years apart.
19:39:18FromDiscord<Elegantbeef> Well it's actually faster
19:39:20FromDiscord<Elegantbeef> Nim is older
19:39:30FromDiscord<TryAngle> is there a database implementation in nim 🤔 ↵I think it would be a perfect language for such thing
19:39:40FromDiscord<TryAngle> tbh is there on thing where nim is not a prefect thing for ??
19:40:06FromDiscord<TryAngle> probably university because they want to draw their insane UML diagramms everywhere .. .
19:40:09FromDiscord<Phil> In reply to @spoon "that just looks like": I think his approach is actually pretty neat, you avoid looping over the same array twice
19:40:26FromDiscord<leorize> the major thing that kept crystal from popularity is the fact it can't run on windows for a long time
19:40:41FromDiscord<Elegantbeef> You also avoid allocating 3 sequences for 1 operation
19:40:46FromDiscord<Phil> In reply to @TryAngle "tbh is there on": I mean, hypothetically or as in, right now? Because the ecosystem isn't quite there
19:40:54FromDiscord<leorize> actually, I'm still not sure if today's crystal can run on windows
19:41:03FromDiscord<spoon> In reply to @TryAngle "tbh is there on": yea, databases are something ive needed, but std/tables are hash tables so maybe theres something there?
19:41:07FromDiscord<Elegantbeef> It can but i think some parts of libraries dont work
19:41:15FromDiscord<spoon> i know there are mongo bindings (limited ones)
19:41:30FromDiscord<Elegantbeef> That's what i was talking about leorize, it's windows support was at least poop
19:41:34FromDiscord<spoon> In reply to @Isofruit "I think his approach": icic
19:41:41FromDiscord<huantian> I don't really see why you'd want to make a pure nim database, guess it oculd be cool, but seem unnessary
19:41:58FromDiscord<TryAngle> In reply to @Isofruit "I mean, hypothetically or": hypothetically
19:42:27FromDiscord<TryAngle> it's literally C with Rust memory management and the syntax of python not a single downside lmao
19:43:04FromDiscord<Elegantbeef> Uhh "literally C" 😀
19:43:31FromDiscord<Phil> In reply to @TryAngle "it's literally C with": Take that back! The way nim doesn't expose you to pointer madness unless you want to is way saner!
19:43:33FromDiscord<@Legioneroff> And I always thought it was a positive effect. 🤗
19:43:39FromDiscord<TryAngle> In reply to @Isofruit "Take that back! The": ok true
19:44:08FromDiscord<TryAngle> In reply to @Elegantbeef "Uhh "literally C" 😀": like this is the most based thing I've ever seen↵https://github.com/PMunch/futhark↵I love it
19:45:07FromDiscord<Phil> I generally agree with you, really liking the language. I'd love to work more closely with some people that are more into procedural programming to look at the patterns they use or the way they approach problems since at work OOP with some functional mixed in is pretty much all I'm getting.
19:45:16FromDiscord<Elegantbeef> Ok but zig does the same 😛
19:45:34FromDiscord<Phil> Which bleeds into how I use nim a lot
19:45:37FromDiscord<TryAngle> In reply to @Elegantbeef "Ok but zig does": but Zig has no Elegentbeef 🥺
19:45:39FromDiscord<Elegantbeef> With Nim you write you code like OOP just without methods
19:45:49FromDiscord<Elegantbeef> Let's be honest not having me is a benefit i'm a fuckwit
19:46:05FromDiscord<spoon> java ruined oop for me
19:46:18FromDiscord<Phil> I mean, so far I'm basically writing what I would in java but without having my legs sawed off because "java knows better"
19:46:20FromDiscord<leorize> if you look at the biggest subcommunity of Nim, the gamedev folks, you will find that the majority runs Windows
19:46:36FromDiscord<TryAngle> if I don't know something and can't find answer I ask here and get response within 2min from elegandbeef explaining everything gg
19:46:48FromDiscord<Elegantbeef> How dare you say i'm a minority!
19:46:51FromDiscord<Phil> Module = Object, you don't do module wide variables I guess though
19:46:51FromDiscord<TryAngle> would probably still stuck at hello world
19:47:13FromDiscord<spoon> In reply to @Isofruit "I mean, so far": java but you dont have to create two different "getters" and three "parsers" to make a single rest call
19:47:15FromDiscord<Elegantbeef> You can do top level variables if you're a weirdo
19:47:16FromDiscord<Phil> (edit) "though" => "though. So in that sense nim inherently promotes better code"
19:47:17FromDiscord<spoon> true story
19:47:36FromDiscord<Phil> In reply to @Elegantbeef "You can do top": I would like to retain my sanity and only do those for exceptional usecases such as connection pooling
19:48:35FromDiscord<Phil> In reply to @spoon "java but you dont": I mean, Java introduced records (basically just a group of fields, no functions whatsoever) around 3-4 years ago... which maybe even will make its way to work in 5 years
19:49:13FromDiscord<@Legioneroff> The job market believes that both of them are not needed\: neither Nim nor Crystal. Unfortunately.
19:50:07FromDiscord<spoon> dont nim godot bindings have a semi successful mobile game from a publisher under them?
19:50:45FromDiscord<spoon> In reply to @Isofruit "I mean, Java introduced": functions without classes?
19:51:27FromDiscord<Phil> In reply to @spoon "functions without classes?": Best I can give you are lambdas. Which (utterly insane as it is) are objects in java
19:52:22FromDiscord<Phil> Like, you can define interfaces that describe the signature a specific lambda must have. As long as that interface only has one function, it'll be allowed as a "functional interface"
19:52:27FromDiscord<spoon> yeah java seems designed from the ground up to be wasteful with resources
19:53:29FromDiscord<Phil> I'm not fully convinced it is. I mean, I'm also not under the impression it's a totally sane language, but java code can run pretty fast. Not quite C/C++ levels, but up there
19:53:53FromDiscord<Phil> It just hogs memory like tomorrow will never come and imo promotes antipatterns within the language
19:54:06FromDiscord<Phil> And honestly that amount of abstraction layers are sometimes insane
19:54:28FromDiscord<Phil> (edit) "that" => "the"
19:54:28FromDiscord<leorize> as is the case with most niche languages, unfortunately. Getting to mainstream is a lot of work
19:54:52FromDiscord<willyboar> Crystal is more mature in webdev but lack of windows support hurts the gamedev imo
19:55:13FromDiscord<spoon> just needs a tool the general public can use
19:55:47FromDiscord<spoon> odin which is a language i only heard about recently has embergen, a big industry particle sim, using it in tons of production
19:55:54FromDiscord<leorize> Crystal has working openssl bindings and shared library support, unlike a certain language where they re-invent the dynamic linker for whatever reason
19:56:42FromDiscord<spoon> In reply to @Isofruit "It just hogs memory": yea, i just really dont like the java philosophy and kinda have a bias against interpreted languages
19:57:14FromDiscord<Phil> In reply to @Elegantbeef "You can do top": Wait a second! I just noticed that you threw in a dependency to your own package into that other example!
19:57:20FromDiscord<Phil> I was wondering where that colChain proc came from!
19:57:32FromDiscord<spoon> nim if the nim-lang repos had up to date bindings on everything
19:57:39FromDiscord<spoon> a lot of small languages do that
19:58:33FromDiscord<spoon> but then we wouldnt get a lot of different design philosophy choices
19:59:04FromDiscord<@Legioneroff> The webdev has been taken over by Golang. It will be hard for Crystal. 😇↵(@willyboar)
19:59:37FromDiscord<spoon> everyone i know personally in webdev is already using node
19:59:49FromDiscord<Phil> Hmm ElegantBeef? Given that slicerator is already involved, curiosity question. Would it be feasible to have it so the user doesn't have to define `:discard` ?
20:00:00FromDiscord<Phil> Webdev backend is a free for all currently in my experience
20:00:51FromDiscord<Phil> Python has multiple horses in the race, java with Spring is industry standard depending on the country, Go... exists as far as I can tell and microsoft has dot net which I also see existing occasionally
20:01:47FromDiscord<spoon> microsoft makes a lot of exclusivity deals with companies to keep them in the .net ecosystem using everything microsoft
20:01:55FromDiscord<Phil> I don't yet see Rust making any sort of sense outside of insanely high performance services that need to be that fast and can justify the maintenance cost of that language
20:01:58FromDiscord<huantian> .net isn't the worst tho
20:02:23FromDiscord<Phil> (edit) "I don't yet see Rust ... making" added "webdev"
20:02:26FromDiscord<@Legioneroff> All my friends hosts Cloud Servers hate node and other scripting languages ​​that eat their memory and there is no end to it.↵(@spoon)
20:02:55FromDiscord<Phil> Oh yeah, node is also used somewhat frequently
20:03:11FromDiscord<huantian> js is 😔
20:03:23FromDiscord<Phil> js isn't a language, it's a compilation target
20:04:01FromDiscord<Phil> There's a reason everyone and their dog is using typescript
20:04:28FromDiscord<spoon> ive had to use it to assist with discord bot dev, now imagine adding mass image processing with node, canvas took multiple seconds and pixie with nim took a fraction of a second for the same task
20:06:01FromDiscord<Phil> Node is an utterly terrible tool for computation heavy tasks. In the end, it's still JS and performs as such, so that'll always severely hamper performance.↵Doing the language swap there sounds like the right choice there.
20:06:54FromDiscord<Phil> It works fine for simpler usecases from what I can see
20:07:49FromDiscord<Phil> In reply to @huantian ".net isn't the worst": From what I can see C# can be used in .net and C# sounds like a good language
20:08:06FromDiscord<Phil> Though I may be wrong in that
20:14:42FromDiscord<konsumlamm> In reply to @TryAngle "it's literally C with": i feel like people that say that Nim literally has Rust's memory management understand neither Nim's nor Rust's memory management
20:15:32FromDiscord<konsumlamm> (not trying to insult you, but i've seen a lot of people giving uninformed comparisons to Rust and it annoys me)
20:15:44FromDiscord<tandy> why is this?
20:15:50FromDiscord<tandy> sent a code paste, see https://paste.rs/u7x
20:16:18*pro quit (Quit: pro)
20:19:14FromDiscord<TryAngle> In reply to @konsumlamm "i feel like people": I mean it's pretty similar (I mean arc)
20:20:11FromDiscord<TryAngle> I thought arc also uses "lifetimes" with destrucutres 🤔
20:21:33*flynn quit (Read error: Connection reset by peer)
20:22:38FromDiscord<konsumlamm> similar, yes
20:22:43*flynn joined #nim
20:22:50FromDiscord<konsumlamm> but still different in a lot of ways
20:23:07FromDiscord<konsumlamm> there are no explicit lifetimes in Nim, for one
20:23:38*wyrd quit (Remote host closed the connection)
20:24:23FromDiscord<konsumlamm> and you don't get a compile error if you have multiple mutable borrows
20:25:10FromDiscord<Phil> What is the beautiful version of "get last entry of array" ? I mean I could obviously infer it over len-1, but is there a nicer proc?
20:25:19FromDiscord<Phil> (edit) "array"" => "array/seq""
20:25:21FromDiscord<konsumlamm> `arr[^1]`
20:26:01FromDiscord<konsumlamm> `^i` creates a `BackwardsIndex` value which can be used to index from the back (in the collections that support it, which are most of the standard ones)
20:27:36FromDiscord<Phil> In reply to @tandy "I have these two": First things first, you have ensured that getUsers gets actually called?
20:28:56FromDiscord<Phil> After that my first question would be how you define "not available". Since IndexedDB ins't an Optional I'm fairly sure you're passing something at least
20:28:57FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3Vkv
20:28:58FromDiscord<tandy> this is the proc its getting called from
20:29:07FromDiscord<huantian> bare excepts ;pensive
20:29:20FromDiscord<tandy> sorry i mean in the browser↵(@Phil)
20:29:24FromDiscord<tandy> like incognito mode
20:29:36FromDiscord<Phil> In reply to @tandy "this is the proc": Wait, is this karax?
20:29:42FromDiscord<tandy> lool il get to that soon the try excepts werent even there before↵(@huantian)
20:29:47FromDiscord<tandy> yesir↵(@Phil)
20:29:53FromDiscord<tandy> well its js
20:29:59FromDiscord<Phil> Allow me to instantly raise a white flag
20:30:20FromDiscord<tandy> bruh
20:30:22FromDiscord<Phil> I give no guarantees for anything that is nim --> js jumping
20:31:13FromDiscord<Phil> Have you ensured with an echo or something that your proc actually gets called? I mean, an echo translates into a console.log in the browser I assune=
20:31:16FromDiscord<Phil> (edit) "assune=" => "assume?"
20:31:28FromDiscord<tandy> yep
20:31:48FromDiscord<tandy> it echos "storing users"
20:33:44FromDiscord<Phil> In reply to @tandy "sorry i mean in": Do you somehow pass "nil" as IndexedDB?
20:33:52*wyrd joined #nim
20:34:31FromDiscord<Phil> Or is this trying to access an object that should be available within the browser context but somehow isn't in your special case?↵Is the code assuming that other code has created that "IndexedDB" object?
20:41:40FromDiscord<Elegantbeef> For loop macros still require a body↵(@Phil)
20:42:26FromDiscord<Elegantbeef> I mean I could do `colChain[x] a.map(x + 2).filter(x < 6)` or something similar
20:42:45FromDiscord<leorize> have you examined the actual JS?
20:43:18FromDiscord<leorize> async for js is much less tested, so I wouldn't be surprised if it generates some code that doesn't do what you ask for at all
20:47:36FromDiscord<!Patitotective> im downloading a file in a thread and i want to display the download process somehow↵how could i achieve that? without violating memory safety 🤨
20:48:05FromDiscord<Elegantbeef> https://nim-lang.org/docs/httpclient.html#progress-reporting
20:48:20FromDiscord<!Patitotective> in a gui, sorry
20:48:42FromDiscord<leorize> pass a message back to main thread
20:48:48FromDiscord<!Patitotective> how
20:49:23FromDiscord<Elegantbeef> Yep, download thread wait's for the download, and `onProgresschanged` propogates back to the main thread either setting a global variable or using a channel
20:50:04FromDiscord<huantian> or just use async/await if you can do that
20:50:28FromDiscord<!Patitotective> doesn't async/await blocks the program?
20:50:30FromDiscord<Elegantbeef> Yep no need for a thread if it's possible to be async
20:51:36FromDiscord<leorize> it is a problem if your event loop for GUI is different from the asyncdispatch loop
20:52:43FromDiscord<!Patitotective> i dont have any asyncdispatch loop 😕 ↵im donwloading a file asynchronously
20:53:36FromDiscord<Elegantbeef> Given you use imgui and it's a update loop you can just hold onto the future and stay on that page until it fails or is completed
20:53:44FromDiscord<leorize> `waitFor`/`runForever` is asyncdispatch loop, in case you're wondering
20:54:23FromDiscord<Elegantbeef> I guess you do need a delay to allow the async proc to kick in
20:54:44FromDiscord<leorize> a simple way to do this is to use a channel and send your progress update via that, I suppose?
20:55:01FromDiscord<Elegantbeef> Yep or a global variable, though that involves manual locking
20:55:20FromDiscord<Elegantbeef> Given i assume this is a simple program the global variable isnt that terrible
20:56:18FromDiscord<!Patitotective> sooo if i was using waitFor↵now how do run it so it doesnt block the GUI
20:56:31FromDiscord<!Patitotective> In reply to @Elegantbeef "Given you use imgui": or wdym here 🤨
20:58:00FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3VkA
20:58:07FromDiscord<Elegantbeef> Something like this does work, though isnt the best of course
20:58:15FromDiscord<Elegantbeef> It's easier to spin up a thread
20:58:50FromDiscord<Elegantbeef> Also if that if statement is true the download is done
21:03:07*lumo_e quit (Ping timeout: 240 seconds)
21:05:40FromDiscord<huantian> a callback might also work?
21:06:08FromDiscord<Elegantbeef> Dont you need a break to give up your CPU somewhere?
21:06:31FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3VkI
21:06:43FromDiscord<Elegantbeef> `waitfor`
21:07:19FromDiscord<!Patitotective> but it Blocks the current thread 😕
21:07:24FromDiscord<Elegantbeef> yes
21:07:32FromDiscord<Elegantbeef> which is why you block for `5` ms or something small
21:07:52FromDiscord<Elegantbeef> To give the cpu up to the async procedures
21:08:08FromDiscord<Elegantbeef> Or use a thread and just propoagate data back
21:08:39FromDiscord<Elegantbeef> You have to give up the cpu somehow with async, so something needs to block for a small amount of time, otherwise you need threads
21:09:01FromDiscord<leorize> an I/O thread is the best way for this tbh
21:09:08FromDiscord<Elegantbeef> Yep
21:09:43FromDiscord<leorize> I believe there are better channel implementations outside of the stdlib that might be easier to use
21:10:06FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3VkJ
21:10:14FromDiscord<!Patitotective> let me try the thread thing
21:10:23FromDiscord<Elegantbeef> How the hell did you get a nil
21:10:34FromDiscord<Elegantbeef> You dont assign the future
21:10:50FromDiscord<Elegantbeef> To be fair the stdlib channel is quite easy to use
21:11:43FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3VkK
21:11:53FromDiscord<Elegantbeef> you dont check if `app != nil`
21:11:57FromDiscord<Elegantbeef> rather `future`
21:12:25FromDiscord<Elegantbeef> also nice donwload
21:12:32FromDiscord<Elegantbeef> I donwload all the stuffs from yuotbue
21:12:41FromDiscord<!Patitotective> ;-;
21:13:16FromDiscord<!Patitotective> In reply to @Elegantbeef "you dont check if": where am i doing that? 😕
21:14:44FromDiscord<Elegantbeef> you need to do that for the if statement
21:14:49FromDiscord<Elegantbeef> `if app.downloadFuture != nil and waitFor app.downloadFuture.withTimeout(5)`
21:15:19FromDiscord<Elegantbeef> Due to imgui being loop like this that waitfor is called even when the future is nil
21:15:53FromDiscord<!Patitotective> ooooooooooooooooooooooooooooooooooooooooooooooooh it works
21:15:57FromDiscord<!Patitotective> amazing
21:16:05FromDiscord<!Patitotective> thanks ❤️
21:16:12FromDiscord<Elegantbeef> Well it's going to now have a 5ms delay between draw frames
21:16:15FromDiscord<Elegantbeef> but it "works"
21:16:25FromDiscord<Elegantbeef> It's pretty much the best you can do without using threads
21:17:03FromDiscord<Elegantbeef> I'm sure leorize isinternally screaming "You can do better using CPS", but that's just his hobby i think
21:17:11FromDiscord<!Patitotective> but i can say that when its not downloading anything dont do the timeout, right?
21:17:23FromDiscord<leorize> You can do better using CPS
21:17:43FromDiscord<Elegantbeef> Well yea the timeout only happens when it's downloading
21:17:50FromDiscord<Elegantbeef> Set it to nil in the if statement
21:17:59FromDiscord<Elegantbeef> if that if statement is true it finished downloading
21:18:34FromDiscord<Elegantbeef> Hey leo i said internally screaming not externally!
21:18:36*neceve joined #nim
21:18:48FromDiscord<leorize> btw you can just `poll()` until your future finishes
21:19:03FromDiscord<Elegantbeef> Leorize this is an imgui program so not really
21:19:14FromDiscord<Elegantbeef> They want to visualize download progress
21:19:20FromDiscord<Elegantbeef> Which means they need their main loop unblocked
21:19:23FromDiscord<leorize> I mean, integrate poll into your event loop
21:19:32FromDiscord<leorize> spare it 2ms
21:19:43FromDiscord<Elegantbeef> Oh right it has a timeout
21:20:19FromDiscord<Elegantbeef> This past week or two is the most i've used async which is like once so I only pretend to know how to write it
21:20:32FromDiscord<System64 ~ Flandre Scarlet> Why it doesn't work? https://media.discordapp.net/attachments/371759389889003532/964998753033543711/unknown.png
21:20:36FromDiscord<Elegantbeef> My pr to Nimibook is fucking silly
21:20:47FromDiscord<!Patitotective> In reply to @Elegantbeef "This past week or": and i'll pretend to you know 👀
21:20:53FromDiscord<Elegantbeef> memory isa type
21:21:02FromDiscord<leorize> if frametime is scare then just spawn an IO thread tbf
21:21:06FromDiscord<Elegantbeef> `var memory: array[1024, byte]`
21:21:20*lumo_e joined #nim
21:21:24FromDiscord<Elegantbeef> Yes i highly agree with "just use a fucking thread"
21:21:39FromDiscord<!Patitotective> but
21:21:41FromDiscord<!Patitotective> :[
21:21:44FromDiscord<leorize> btw it's 0-initialized by default so you don't even have to run the loop
21:21:57FromDiscord<Elegantbeef> https://github.com/pietroppeter/nimibook/pull/53/files#diff-296b9b043ee4ab30b508d575fde250f3ef5306782e0da8e1ef7bf84011d10f5eR58-R71 yea leo i'm something an async expert myself
21:23:31FromDiscord<leorize> I'm pretty sure `withTimeout` is meant for cancellations, but cancellation doesn't exist in asyncdispatch \:P
21:23:57FromDiscord<Elegantbeef> Yea i dont know, all i know is i wanted to give the other operations some CPU time and this seemed the best
21:24:08FromDiscord<Elegantbeef> Since it also tells me when it finishes
21:24:29FromDiscord<!Patitotective> In reply to @leorize "I'm pretty sure `withTimeout`": just wait until my program crashes and ill ask you for the thread thing :p
21:24:42FromDiscord<Elegantbeef> Eitherway it does vastly speed up build times for nimibook since it multithreads the compilation/runs of the programs
21:25:00FromDiscord<Elegantbeef> Why the fuck do you need to ask anyone for the thread thing
21:25:16FromDiscord<Elegantbeef> `createThread` and a channel is all you need
21:25:36FromDiscord<Elegantbeef> https://nim-lang.org/docs/threads.html#examples https://nim-lang.org/docs/channels_builtin.html#example
21:26:24FromDiscord<!Patitotective> i dont have to ask anyone anymore 🙃
21:26:24FromDiscord<Elegantbeef> Is a cancellation in an async context stopping operation from outside?
21:26:42FromDiscord<Elegantbeef> wouldnt have even had to said anything if you went to the manual 😛
21:26:54FromDiscord<!Patitotective> i didnt know what were channels, hehe
21:27:36FromDiscord<leorize> your `all` doesn't make any sense beef
21:27:49FromDiscord<Elegantbeef> Uhh
21:28:46FromDiscord<Elegantbeef> Is there a failed callback,if so that's better
21:29:10FromDiscord<leorize> also I hate to say it, but `execProcesses` should net you the same thing
21:29:24FromDiscord<leorize> maybe not the singular `build` being async, though
21:29:55FromDiscord<Elegantbeef> Eh i just did this quickly due to seeing that it was easy to slightly modify and get it to run faster
21:30:26FromDiscord<Elegantbeef> I guess it's relatively easy to just make a group of `.nim` files
21:30:46FromDiscord<leorize> you can `addCallback` to the future to execute the reporting code on completion while you wait on `all`
21:31:00FromDiscord<leorize> the callback can be a closure, so it's pretty flexible
21:31:46FromDiscord<leorize> oh, you want chronological returns
21:32:02FromDiscord<Elegantbeef> Well with callbacks and closure chronological doesnt matter
21:32:29FromDiscord<Elegantbeef> the issue with `all` is that it wasnt chronological it was FIFO
21:32:41FromDiscord<leorize> yea, as it should be
21:32:44FromDiscord<Elegantbeef> So if one failed the error was wrong, but like i said with a callback you can just add the error to a seq then print
21:33:08FromDiscord<Elegantbeef> Yea i dont disagree just didnt even know there were callbacks when i wrote this
21:33:16FromDiscord<Elegantbeef> I've never used async in any code up to this point
21:33:54FromDiscord<Elegantbeef> So yea a closure that adds the build error to a seq on completion seems much better
21:34:07FromDiscord<Elegantbeef> then i can just call `all`
21:34:20*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
21:43:24*jjido joined #nim
21:43:49*Zectbumo joined #nim
21:47:12FromDiscord<Elegantbeef> Yep leorize callback is nicer
21:47:20FromDiscord<Elegantbeef> Though due to a change in devel need to use index iteration
22:00:17FromDiscord<willyboar> In reply to @@Legioneroff "The webdev has been": I said compared to Nim. Generally webdev still belongs to js-php and rails
22:08:56*wyrd quit (Ping timeout: 240 seconds)
22:09:08*wyrd joined #nim
22:31:15*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
22:32:14*ehmry joined #nim
22:37:12*lumo_e quit (Ping timeout: 248 seconds)
22:41:04*rockcavera quit (Remote host closed the connection)
22:43:11FromDiscord<dom96> In reply to @leorize "You can do better": the CPS circlejerk never stops eh 😛
22:45:52*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
22:47:28FromDiscord<dom96> In reply to @Elegantbeef "It's pretty much the": iirc you can also pass 0ms and have the event loop only process events that are ready, it's a trade off between IO and UI responsiveness though. Ideally your UI event loop will expose an async API that you can hook into.
22:49:04FromDiscord<!Patitotective> In reply to @Elegantbeef "Given i assume this": is there another way? i dont like global variables hehe
22:49:43*neceve quit (Ping timeout: 246 seconds)
22:50:06FromDiscord<Elegantbeef> Yes
22:50:26FromDiscord<Elegantbeef> We already told you about channels
22:50:48FromDiscord<Elegantbeef> At this point i should just scream into a void
22:51:59FromDiscord<!Patitotective> i mean, to not have the channel as a global variable
22:52:10FromDiscord<Elegantbeef> Yes
22:52:22FromDiscord<Elegantbeef> You can pass any variable that is safely scoped to another thread
22:52:22FromDiscord<dom96> You'll have the same problem with channels. You can either block read on them or check them continuously, which is almost like polling the async event loop
22:52:33FromDiscord<Elegantbeef> imagine if there was a `tryRecv`
22:52:42FromDiscord<Elegantbeef> This is an imgui looped program that problem doesnt exist with channels
22:53:52FromDiscord<Elegantbeef> Really you could pass a float and lock to the callback write the float then lock on reading it
22:54:34FromDiscord<Elegantbeef> There are a bazillion ways of doing this, aslong as the float is declared somewhere that the second thread outlves you're fine
22:54:43FromDiscord<TryAngle> is there something like an async websocket iterator that continuesly returnes a value?
22:55:17FromDiscord<Elegantbeef> continously returns a value?
22:55:23FromDiscord<dom96> In reply to @TryAngle "is there something like": what's your high-level goal?
22:56:03FromDiscord<dom96> In reply to @Elegantbeef "This is an imgui": not sure what you mean, how would you read from the channel inside the UI thread?
22:56:12FromDiscord<TryAngle> In reply to @dom96 "what's your high-level goal?": listen to a websocket on a different thread, parse those values and put them in a channel
22:56:19FromDiscord<Elegantbeef> `tryRecv`
22:56:25FromDiscord<TryAngle> wait I'm stupid I can literally just do a while loop
22:56:29FromDiscord<TryAngle> .....
22:57:14FromDiscord<dom96> not stupid, but yes you can 🙂
22:57:25FromDiscord<Elegantbeef> `while (let (hasData, newProg) = channel.tryRecv; hasData): progress = newProg`
22:57:55FromDiscord<dom96> In reply to @Elegantbeef "`while (let (hasData,": right, but that's the same as just running poll(0) on the async event loop
22:58:00FromDiscord<TryAngle> In reply to @Elegantbeef "`while (let (hasData,": 😳 ↵while let in nim ???
22:58:33FromDiscord<TryAngle> In reply to @dom96 "not stupid, but yes": 🥺
22:58:42FromDiscord<dom96> I mean, you'll have a separate thread so I guess that helps alleviate some of the load on the UI thread but it'll still be a lot of wasted work on the UI thread continuously checking the state of the channel
22:58:58FromDiscord<Elegantbeef> I mean it's imgui so it's already redoing worrk 😛
22:59:23FromDiscord<dom96> lol
22:59:35FromDiscord<TryAngle> In reply to @dom96 "I mean, you'll have": I mean isn't that the way anyways? UI (main) thread gets event from "data" thread and does something
22:59:54FromDiscord<Elegantbeef> Most proper UI solutions are event based so it's a bit less silly
23:00:22FromDiscord<TryAngle> should I not use imgui 🥲 ?
23:00:52FromDiscord<dom96> In reply to @TryAngle "I mean isn't that": I suppose it might work just fine.
23:00:56FromDiscord<dom96> Let me know how it goes 🙂
23:00:59FromDiscord<Elegantbeef> It's up to you
23:01:05FromDiscord<TryAngle> In reply to @dom96 "Let me know how": lol
23:01:11FromDiscord<Elegantbeef> dearimgui is infact not a GUI toolkit
23:01:12FromDiscord<TryAngle> is there better architecture?
23:01:27FromDiscord<TryAngle> @dom96
23:01:42FromDiscord<dom96> I always try to do everything single threaded with an async event loop
23:01:58FromDiscord<Elegantbeef> Personally async doesnt exist
23:02:17FromDiscord<!Patitotective> ~~just realized that with threads i dont need to use download async lmfao~~
23:02:38FromDiscord<TryAngle> In reply to @dom96 "I always try to": hmmmm
23:02:54FromDiscord<Elegantbeef> Dont you still need it for progress reporting
23:02:54FromDiscord<TryAngle> do u have example repo maybe?
23:03:23*Gustavo6046 quit (Read error: Connection reset by peer)
23:03:24FromDiscord<!Patitotective> In reply to @Elegantbeef "Dont you still need": ...
23:03:28FromDiscord<Elegantbeef> Man i love the docs for when objects
23:03:32FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/965024670753648640/image.png
23:05:05FromDiscord<dom96> In reply to @TryAngle "do u have example": It's quite simple, kinda what was discussed above: in your UI/Game/Event loop just call asyncdispatch.poll(5) after you draw your UI/Game/Whatever.
23:05:58FromDiscord<TryAngle> In reply to @dom96 "It's quite simple, kinda": hmm but how is this better than threaded and I call channel.recv() in UI loop ?
23:06:06FromDiscord<TryAngle> isn't it like almost the same'ish
23:06:18FromDiscord<dom96> sent a code paste, see https://play.nim-lang.org/#ix=3VkY
23:06:29FromDiscord<dom96> (edit) "https://play.nim-lang.org/#ix=3Vl0" => "https://play.nim-lang.org/#ix=3VkZ"
23:07:34FromDiscord<dom96> In reply to @TryAngle "hmm but how is": threads make everything at least an order of magnitude more complex
23:07:42FromDiscord<Elegantbeef> Probably should use `monotimes` or `cpuTime` instead of `epocTime` but mostly pedantry
23:07:47FromDiscord<dom96> it's much easier to debug code that you know runs in a single thread
23:08:17FromDiscord<dom96> In reply to @Elegantbeef "Probably should use `monotimes`": possibly 😄
23:08:32FromDiscord<Elegantbeef> In the case IO is your limiting factor you should use async/cps, if cpu is the bottleneck you use threading
23:08:42FromDiscord<Elegantbeef> There isnt much reason to use async in these cases
23:08:44FromDiscord<Elegantbeef> i mean threads
23:09:11FromDiscord<Elegantbeef> Since the bottleneck here in patito's case is just an IO operation, a poll at the end of the draw gives the cpu over to progress the download and emit any callbacks
23:09:43FromDiscord<Elegantbeef> Downloading files is a relatively cheap CPU operation of getting data from a socket and move it over to where it's supposed to go
23:09:53FromDiscord<dom96> yep
23:09:59*Gustavo6046 joined #nim
23:10:29FromDiscord<Elegantbeef> Async is of course single threaded and you have to use `waitFor` `poll` `withTimeout` and the like to give up your CPU when you're ok with it
23:10:58*Gustavo6046 quit (Remote host closed the connection)
23:11:15FromDiscord<dom96> I'd definitely recommend not using waitFor/withTimeout and instead explicitly `poll` inside your UI loop
23:11:22*Gustavo6046 joined #nim
23:11:30FromDiscord<Elegantbeef> Well waitfor doesnt make sense in this case 😛
23:11:53FromDiscord<Elegantbeef> "I want it non blocking", "yea so we're going to use waitfor here to fucking destroy your program's draw loop"
23:11:59FromDiscord<dom96> you could do waitFor sleepAsync(5) 😄
23:12:32FromDiscord<Elegantbeef> anywho point being you need to give up your cpu, whereas with threading you dont
23:12:41FromDiscord<dom96> that's just a really inefficient way to do `poll(5)`
23:12:46FromDiscord<!Patitotective> `donwloadChannel.recv()` is blocking the main thread D:
23:12:51FromDiscord<Elegantbeef> yes
23:12:54FromDiscord<Elegantbeef> `recv` blocks
23:12:55FromDiscord<Elegantbeef> RTFM
23:12:57FromDiscord<!Patitotective> DDD:
23:12:58FromDiscord<Elegantbeef> `tryRecv` doesnt
23:13:16FromDiscord<Elegantbeef> `while (let (hasData, newProg) = channel.tryRecv; hasData): progress = newProg`
23:13:26FromDiscord<Elegantbeef> That's how you do it non blocking and get the most recent update
23:16:09FromDiscord<Elegantbeef> ASync poll is likely faster than this as it unlocks and locks as many times as it has data
23:16:27FromDiscord<Elegantbeef> Though perhaps that's offset by the fact the second thread is copying the data over
23:16:50FromDiscord<Elegantbeef> Only way to know is to benchmark the difference between `poll(0)` and the above while loop
23:20:53FromDiscord<!Patitotective> it works :OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
23:20:54FromDiscord<!Patitotective> amazing
23:21:30FromDiscord<Elegantbeef> Like mentioned there is a chance this has higher latency than that of `poll` so if low latency is desired test both
23:22:18FromDiscord<!Patitotective> also beef↵how can i know when a thread finished? i dont understand this https://nim-lang.org/docs/threads.html#onThreadDestruction%2Cproc%29 where do i call it? it doesnt have a thread param
23:22:48FromDiscord<Elegantbeef> perhaps `running`
23:23:10FromDiscord<!Patitotective> but it will also return false when it haven't even started 😕
23:23:37FromDiscord<Elegantbeef> annnnd?
23:24:30FromDiscord<!Patitotective> that i want to know when the thread finished, not when is not running ;-;
23:24:59FromDiscord<Elegantbeef> Make it a `Option[Thread[T]]` then
23:25:23FromDiscord<Elegantbeef> if it's `none` it's not started if it's `some` and `not running` it finished, if it's `some` and `running` it's running
23:26:12FromDiscord<TryAngle> hmmm I forgot I have a bit different situation what I initially wrote
23:26:15FromDiscord<!Patitotective> ~~what about if its not running and `downloadProgress` is not 0, 0, 0 💀 ~~
23:26:20FromDiscord<TryAngle> I have multiple sockets of the same kind
23:26:25FromDiscord<TryAngle> I need to listen to
23:26:42FromDiscord<TryAngle> should I do one "async thread" for them?
23:26:58FromDiscord<Elegantbeef> Is it an IO issue or a CPU issue?\>
23:27:45FromDiscord<TryAngle> hmm I have the best ryzen so for me it's not an issue but I think older pcs might run into issues↵the expected sockets are 1-3 most of times
23:27:57FromDiscord<TryAngle> (edit) "issues↵the" => "issues wiht multiple threads↵the"
23:28:12FromDiscord<Elegantbeef> That doesnt change what was said
23:28:21FromDiscord<Elegantbeef> It's an IO issue so async is the solution generally
23:29:09FromDiscord<TryAngle> hmmm not sure 💀
23:29:24FromDiscord<Elegantbeef> What do you mean
23:29:49FromDiscord<Elegantbeef> You're waiting for sockets, those are IO. There is no amount of computational power that speeds up your network speed
23:30:46FromDiscord<TryAngle> so basically I want to write a "client manager for league of legends clients" that allows to manage multiple clients at once (ofc. only things that are not against Riots TOS)↵each client has a websocket to listen for events and an api, I will need to use both per launcher
23:31:12FromDiscord<TryAngle> I need to change the amounts of sockets in runtime
23:31:19FromDiscord<TryAngle> so that's IO ?
23:31:35FromDiscord<Elegantbeef> IO is input output
23:32:38FromDiscord<TryAngle> ok so the solution is to run 1 additonal thread besides main/ui and I read all clients from that and use async in that thread?
23:32:49FromDiscord<Elegantbeef> You can just use async in your main thread
23:33:09FromDiscord<Elegantbeef> Have you been reading any of the chat we've had about threads vs. async
23:33:49FromDiscord<TryAngle> In reply to @Elegantbeef "Have you been reading": only skimmed
23:33:51FromDiscord<TryAngle> I will reread
23:33:59FromDiscord<Elegantbeef> Ok good
23:34:13FromDiscord<Elegantbeef> There's alot of inforrmation there that should answer your quandary
23:34:37FromDiscord<!Patitotective> what unit does https://nim-lang.org/docs/httpclient.html#progress-reporting use for total and progress?
23:35:05FromDiscord<Elegantbeef> bytes
23:35:11*vicfred joined #nim
23:35:19FromDiscord<!Patitotective> for speed too?
23:35:19FromDiscord<Elegantbeef> you can tell cause it does `speed div 1000` to get `kb`
23:35:30FromDiscord<!Patitotective> oh, right, thanks 🙃
23:36:32FromDiscord<TryAngle> ok I reread now↵so from what I understand because my app is just ui + data reading it's only really IO bound so I should use async only.↵threading is unnacessary but works also, it just adds addition complexity?
23:36:52FromDiscord<Elegantbeef> Yes it's more complex and also makes your program needlessly use more resources
23:37:55FromDiscord<TryAngle> hmm ok 🤔
23:46:46*vicfred quit (Ping timeout: 246 seconds)
23:49:44*vicfred joined #nim
23:56:01FromDiscord<!Patitotective> can i stop a thread? 🤔
23:56:36FromDiscord<Elegantbeef> Nope
23:57:03FromDiscord<!Patitotective> and can i stop an async operation? (like downloading a file)
23:58:48FromDiscord<dom96> You should be able to by just calling `close` on the http client instance
23:59:04FromDiscord<dom96> Not sure if anyone has tested this though lol