<< 19-01-2020 >>

00:00:01*junland quit (Quit: %ZNC Disconnected%)
00:01:19*junland joined #nim
00:13:09*zedeus quit (Ping timeout: 265 seconds)
00:17:08*NimBot joined #nim
00:34:24*zedeus joined #nim
01:11:07*voltist joined #nim
01:18:25*Cthalupa joined #nim
01:18:53*lritter quit (Ping timeout: 272 seconds)
01:19:23*lritter joined #nim
01:27:59*zedeus quit (Quit: WeeChat 2.7)
01:29:49*zedeus joined #nim
01:40:46FromDiscord<treeform> I am not a fan of tupples for some reason... So I don't use that in vmath.
01:41:03*Hideki_ joined #nim
01:41:54*Hideki_ quit (Client Quit)
01:43:33*Hideki_ joined #nim
02:29:55*Tyresc quit (Quit: WeeChat 2.7-dev)
02:30:55*leorize joined #nim
02:31:54leorizeAraq: how would destructors interact with {.noreturn.} procs?
02:32:13leorizewill the resources be cleaned up or they will just be left there?
02:34:11disruptekgreat question. you can look at what happens by building the compiler with -d:toDebug="always" and saving the compiler's output.
02:36:38leorizewell the problem is that this is not in the destructors spec iirc...
02:37:24disruptekergo, code is spec.
02:40:35leorizethe answer is no: https://play.nim-lang.org/#ix=27Ni
02:41:35disruptekwhat you can do is raise.
02:42:20leorizemy only concern about this is that file descriptors will leak on `exec` calls, since they are not closed by default
02:42:45disruptekthey are closed by default.
02:43:01leorizenope, unless you mark them with O_CLOEXEC/FD_CLOEXEC
02:43:20leorizewhich currently is not done within Nim...
02:43:30disrupteki mean, they should have their destructors run by default upon leaving scope.
02:44:12disruptekthere are cases where they are lifted, but...
02:44:20leorizewell but if you have an httpclient open for instance
02:44:50leorizethen you exec, then that fd will leak
02:45:30leorizethis is also a problem if stuff are executed via fork-exec
02:45:45disruptekyeah, i mean, that's kinda the fault of the programmer, right?
02:46:31leorizewell, they would trust that "destructors" will close it for them :P
02:46:52disruptekbut who is to say what the correct behavior is?
02:47:32leorizeI guess to anticipate for destructors, we should mark every spawned destructible fds as O_CLOEXEC/FD_CLOEXEC
02:48:14leorizein the stdlib ofc :P
02:48:31disruptekhmmm.
02:49:03leorizeFDs are so easy to leak :/
02:49:26leorizeif you don't mark them with CLOEXEC ofc :P
02:50:10leorizefork creates duplicates for all of them, then exec will keep them open
02:50:42leorizeluckily in stdlib this can only happen if you do -d:useFork, which is the default for the bsds iirc
02:51:27disruptekstill, i dunno how i feel about forcing a flag.
02:51:42FromDiscord<DeltaPHC> lol. Unrelated, but I'm code-golfing the classic "99 bottles" program. Got it down to 322 chars with this monstrosity: https://play.nim-lang.org/#ix=27Nk
02:52:04disrupteki feel like it's not too ugly to be explicit and clear; it's not really the job of the language to manage the environment this way.
02:52:12leorizedisruptek: well just use it for stdlibs high-level abstraction stuff, like Socket, HttpClient, etc.
02:52:32leorizeand a big warnings in the docs that the destructors won't run on {.noreturn.}
02:52:42leorizes/a/several/
02:52:49leorizeshould be enough :P
02:53:10disruptekmaybe we should lead by example.
02:53:21disruptekcode it the longer, correct way.
02:54:03disruptekif it's really arduous, y'know, more code may yet be written.
02:58:23leorizelooks like file descriptor is the only significant thing that leak through exec
02:58:38disruptekthere's that, at least.
03:01:18leorizeFDs really are designed to leak
03:02:37leorizeI've looked at various posix documentations of process spawning, and all of them explicitly say that unless marked with O_CLOEXEC, any fd that's still open will remain open when `exec` happens
03:03:44leorizeah, someone already reported this: https://github.com/nim-lang/Nim/issues/6602
03:03:46disbotFile descripters should be non-inheritable by default.
03:04:18nisstyreAre there any XCB bindings for Nim? I need "xcb_poll_for_event" (or something like it), but the standard Xlib doesn't really support that afaict
03:05:14disrupteki think solitudesf is the one to ask.
03:05:36*Hideki__ joined #nim
03:05:51nisstyreI could just use importc for it I guess
03:05:57nisstyresince I only need that one function really
03:06:19nisstyrealthough I guess I would need the xcb event types too
03:06:29*Hideki_ quit (Read error: No route to host)
03:06:51disrupteki just don't think it's a bug, leorize.
03:06:55*Hideki__ quit (Read error: Connection reset by peer)
03:07:02*Hideki_ joined #nim
03:07:47leorizedestructors not run on {.noreturn.}?
03:08:03disruptekno, the CLOEXEC
03:09:02disrupteki don't know what the right move is for noreturn.
03:09:19leorizewell it's a problem when you start making long running processes that spawn other "maybe long running" processes
03:09:31*Hideki__ joined #nim
03:09:44disrupteki get it, but i think we have to follow convention here, too.
03:09:57*Hideki_ quit (Read error: No route to host)
03:10:25*Hideki_ joined #nim
03:10:28leorizewdym?
03:10:50disrupteki think we have to preserve the possibility that the user wants or expects their destructors not to run.
03:11:03disruptekmaybe they know more about the situation than we do.
03:11:10disruptekremember, they can always raise.
03:11:53disruptekthey can also free their stuff.
03:12:50*Hideki__ quit (Read error: Connection reset by peer)
03:13:04leorizei thought that's the not running on {.noreturn.}? :p
03:13:47disruptekright. i don't think they should run on .noreturn
03:15:57*ptdel quit (Ping timeout: 260 seconds)
03:20:02leorizedisruptek: well I guess this is how to make it run :P https://play.nim-lang.org/#ix=27Ns
03:21:37disruptekthat's not bad, is it?
03:21:50leorizeit's terrible :P
03:22:17leorizeit depends on experimental api, and I'm pretty sure it can't nest
03:22:44leorizeoh hey it can
03:22:53leorizestill depending on unstable api is never a good thing
03:24:25disrupteki'm just really wary of getting it wrong. this is exactly the sort of thing that is important you get right.
03:26:09disrupteknow i want a mock library. like, a really, really good one.
03:27:08*lritter quit (Remote host closed the connection)
03:37:09*Hideki__ joined #nim
03:37:09*Hideki_ quit (Read error: Connection reset by peer)
03:37:38*ptdel joined #nim
03:40:32*Hideki_ joined #nim
03:40:32*Hideki__ quit (Read error: Connection reset by peer)
03:51:38*logand`` joined #nim
03:52:32*nickster4 joined #nim
03:55:02*muffindrake quit (Ping timeout: 260 seconds)
03:55:38*logand` quit (Ping timeout: 268 seconds)
03:57:12*muffindrake joined #nim
03:58:45disrupteki want a way to record a stream with timestamps on when the data became readable. then i want to be able to play that stream back, modifying the time signature.
04:00:45disruptekseems pretty useful, right?
04:17:57*nickster quit (Quit: The Lounge - https://thelounge.chat)
04:17:57*nickster4 is now known as nickster
04:21:30*Hideki__ joined #nim
04:21:32*Hideki_ quit (Read error: Connection reset by peer)
04:22:05*Hideki__ quit (Read error: Connection reset by peer)
04:22:09*Hideki_ joined #nim
04:23:30*Hideki__ joined #nim
04:23:30*Hideki_ quit (Read error: Connection reset by peer)
04:32:01*Hideki_ joined #nim
04:32:01*Hideki__ quit (Read error: Connection reset by peer)
04:47:22*Hideki__ joined #nim
04:47:33*Hideki_ quit (Read error: No route to host)
04:47:51*Hideki_ joined #nim
04:47:54*Hideki__ quit (Read error: Connection reset by peer)
04:57:50*dddddd quit (Remote host closed the connection)
05:10:51*Ekho- is now known as Ekho
05:43:49*Hideki_ quit (Remote host closed the connection)
05:44:37*Hideki_ joined #nim
05:48:51*Hideki_ quit (Ping timeout: 240 seconds)
06:14:24shashlickI don't get it - even if I have a single-threaded version of my code, I'm having some gc funkiness going on - same memory location is being reused despite returning from a proc on the next invocation
06:14:30shashlickdon't see the issue with boehm
06:14:48disruptek-d:useMalloc
06:15:19shashlicknope still
06:15:30disruptekthis isn't arc, right?
06:15:36shashlicknope standard
06:15:44disruptekdamn.
06:16:02shashlicki've spent hours on this crap
06:16:21shashlickwho's messing with my memory
06:16:32disruptekdespite returning from a proc on the next invocation?
06:16:40shashlickyep
06:16:43disruptekyep
06:16:56shashlickhttps://github.com/genotrance/px2/blob/master/server.nim#L58
06:17:13*Hideki_ joined #nim
06:18:22shashlicki'm using httputils and it avoids copies and points to stuff in the middle of strings
06:18:42shashlickand then calling libcurl just throws everything off
06:18:46shashlickdeepCopy doesn't help either
06:19:10disruptekyou're running it single-threaded.
06:19:20shashlickworks the first time, then next invocation of processRequest - where everything should be brand new - still issues
06:19:25shashlicki've removed all threading and still same
06:19:34shashlickmust be some dumbass thing i've done
06:19:54*voltist quit (Quit: Leaving)
06:19:59disrupteki've only had that issue on global iteration.
06:20:19disruptekoutside a proc.
06:22:46*narimiran joined #nim
06:23:14shashlickokay now threads are optional
06:24:42disrupteki don't see the problem.
06:25:26shashlickso problem happens here - https://github.com/genotrance/px2/blob/master/curl.nim#L66
06:25:35shashlickcreating a list of headers to pass to libcurl
06:25:49shashlickwhen I print it out, it's all fine
06:25:57shashlickbut when it goes to curl, there's spurious characters in it
06:26:10disruptekthat's my least-favorite kind of character.
06:26:11shashlicknot the first time, but in subsequent calls
06:27:04disruptekwell that's bananas.
06:27:29disruptekput the concatenation into a cstring type and print that.
06:28:06disrupteki wonder if some of this stripping and shaving zevv has been doing has finally nicked an artery.
06:28:24shashlicksame issue with arc as well, had to turn threading off to get it working
06:28:43shashlickwell, fails with 1.0.4 as well
06:28:46disrupteklet's see what it looks like as a cstring.
06:29:27shashlickwell, echoing it might just switch it back to a string and work
06:29:40disruptekright, but i want to see it come out of the cstring type.
06:30:06disruptekour strings are different now.
06:30:59shashlickyou're right, i see it in my prints too
06:31:09shashlickhttp://google.com becomes http://google.com*
06:31:51disrupteksome say it's better but i say it ain't.
06:32:01disrupteki'd rather laugh with the sinners than cry with the saints.
06:32:09disruptekthe sinners are much more fun...
06:32:43shashlickthere are no sinners nor saints
06:34:01disruptekso it's realloc; aka zevv's bug.
06:34:38disruptekwhat are the chances?
06:34:47*rockcavera is now known as Guest87279
06:34:47*tiorock joined #nim
06:34:47*Guest87279 quit (Killed (weber.freenode.net (Nickname regained by services)))
06:34:47*tiorock is now known as rockcavera
06:34:57shashlickhow do you mean
06:35:00disruptekthis must have been exposed by something else.
06:35:26disruptekwe happen to discover the same dirty buffer bug independently, and twice?
06:38:15shashlickwell it is broken as far back as 0.20.2
06:38:22shashlickcannot go before that since ya
06:39:13*Hideki_ quit (Ping timeout: 260 seconds)
06:39:16disrupteki don't get it.
06:41:06*Hideki_ joined #nim
06:41:12shashlickwhat now
06:41:22disruptekthis really makes no sense.
06:41:47shashlickit is not null terminated correctly
06:41:54shashlickif i print as string, it knows how long it is
06:42:03shashlickif i print as cstring, you see extra stuff
06:42:43disruptekbut the cstring conversion should terminate it correctly.
06:43:14shashlicknope
06:43:31disruptekit never does?
06:43:42disrupteki'm using them all over the place. never had a problem.
06:44:21shashlickya there's something else
06:44:43shashlickso now I'm `(name & ": " & value & " ").strip()`
06:44:53*nsf joined #nim
06:45:08disruptekkinky.
06:45:35disrupteki'm big on objectifying strippers.
06:46:16shashlickyep that fixed it
06:46:36shashlicktwo places - with the headers iterator and uri()
06:46:52shashlicki'd like to blame https://github.com/status-im/nim-http-utils/blob/master/httputils.nim#L557
06:47:13shashlickblame status
06:47:25disruptekwell why wouldn't you use stdlib?
06:47:46disruptekgah it didn't even occur to me.
06:47:59shashlickcause it is all or nothing with httpserver
06:48:02shashlicki need more control
06:48:26shashlickplus i couldn't use asynchttpserver so good luck
06:48:40shashlickthe procs aren't written in a way where i could take over things i want
06:48:50disruptekwell, no argument here.
06:49:10shashlickthere is no plain httpserver, only async
06:49:12disrupteki didn't realize this was that project.
06:49:26Araqhi
06:49:27disrupteklike i said, it needs to be replaced.
06:49:34shashlickhey Araq
06:49:36disrupteksup
06:49:39shashlickwelcome to my grumbling
06:51:36disruptekwhy do people write code like this?
06:52:02shashlickwell, you know what - it is httputils' fault
06:52:18shashlickthey simply cast a string of bytes into a string
06:52:20shashlickhttps://github.com/status-im/nim-http-utils/blob/master/httputils.nim#L565
06:52:32disrupteki know.
06:52:56disruptekhence my question.
06:53:02leorizeWindows is weird
06:53:16leorizeso fopen() doesn't leak fds on Windows
06:53:17shashlickthe need for speed
06:53:29disruptekwho cares how efficient it might be if it's broken?
06:53:29leorizeit leaks the handle instead
06:57:28leorizeso I'm working on #6602, and now I need a name for an API to set if a FileHandle can be inherited by child processes
06:57:28disbothttps://github.com/nim-lang/Nim/issues/6602 -- 3File descripters should be non-inheritable by default.
06:57:31leorizeany ideas?
07:00:30Araqshashlick: 'cast' between strings and seqs is semi-officially supported
07:01:09shashlickthen why does converting to a cstring result in extra chars
07:02:34leorizesomeone forgot the null terminator?
07:03:05shashlickhttps://github.com/status-im/nim-http-utils/blob/master/httputils.nim#L565 <= they are casting a seq[byte] into a string
07:03:13shashlickif you then cstring that, you get extra stuff
07:03:35Araqyeah sure, seq don't have zero terminators, only strings do :-)
07:04:08shashlickwhat's amusing is that you'd expect a \r there but you get other stuff which makes no sense
07:04:27shashlicksince it is just pointing to a range within the larger buffer
07:04:40leorizethis is exactly why I always need a len() when I work with cstring
07:05:14shashlickjoys of coding `(r.uri() & " ").strip()`
07:05:52FromGitter<Varriount> I'm uncomfortable with strings being casted to a sequence
07:06:08shashlickfunny thing is that --gc:boehm is cool with this and you don't see issues
07:06:21shashlickso it's like the buffer is going out of scope or something and getting collected
07:06:33leorizewell they are internally identical
07:06:47leorizeI guess we need an official API for this instead of casting around
07:06:59shashlicki'm really not sure what's up here but at least i can proceed for now
07:07:09shashlicki'll bet it will bite me else where
07:07:22FromGitter<Varriount> leorize: While they are internally identical, strings have that null separator
07:08:27leorizeI'd advice to never rely on that
07:08:43leorizemost of the C API I have seen usually take a buflen
07:09:04shashlicktell libcurl that
07:09:46FromGitter<Varriount> leorize: Hence Why I'm uncomfortable with it
07:10:01leorizeshashlick: they don't have an api with buflen?
07:10:14shashlickhttps://curl.haxx.se/libcurl/c/curl_slist_append.html
07:10:17leorizeVarriount: I guess this is why we need an official solution :P
07:13:35leorizeshashlick: I guess this is a walkaround that you can do: setLen +1 the string, then it's safe to pass to curl
07:13:50leorizeor just copy it should do
07:16:19shashlickdeepCopy didn't really help
07:16:34leorizesetLen +1 it is then
07:23:17*ptdel quit (Ping timeout: 260 seconds)
07:24:54shashlickso be it, it isn't quite as ugly
07:32:44FromGitter<Varriount> leorize, shashlick: That's disgusting
07:55:52*solitudesf joined #nim
08:05:17*gmpreussner joined #nim
08:10:13*Jjp137 quit (Quit: Leaving)
08:10:20*Jjp137 joined #nim
08:12:12*gmpreussner quit (Ping timeout: 258 seconds)
08:34:48*narimiran quit (Quit: leaving)
08:52:23shashlicknim isn't loading any libcurl dll I'm giving it
08:52:29shashlickjust says could not load
08:52:34shashlick32-bit nor 64-bit
08:52:43shashlickany ideas?
08:53:39*jjido joined #nim
08:57:08Araqdid you get the calling conventions right?
08:57:19shashlicki'm using your libcurl wrapper
08:59:17shashlickokay got it running, but getting an overflow error
08:59:37shashlickthe headerfunction callback is getting ridiculous values for size and nmemb
09:02:53shashlickyou have to be right don't you
09:03:47Araq"my" wrapper?
09:04:04Araqwhen did I write that one, 10 years ago?
09:04:12shashlickthe callback is in my code right and I got that from choosenim which only uses curl on osx
09:04:18shashlickit didn't have {.cdecl.}
09:04:20Araqbetter c2nim it from scratch :P
09:04:39shashlickit's still working for the most part 🙂
09:04:50*luis_ joined #nim
09:10:33*tane_ joined #nim
09:14:23shashlickmy word, it works! px2 POC is a success
09:17:23*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
09:24:46shashlick390 lines of code and you get a state of the art replacement for cntlm backed by libcurl
09:25:13shashlicknow all that remains is configurability and other cosmetics
09:27:44*nsf quit (Quit: WeeChat 2.7)
09:28:25shashlickbrilliant, it was a very painful but amazing what can be accomplished over a weekend
09:31:47*Hideki_ quit (Remote host closed the connection)
09:32:24*Hideki_ joined #nim
09:32:49Zevvah it all worked out for you, sweet
09:33:07shashlickyep, phew, should sleep - 1/2 the night is over
09:33:18Zevvwho cares :)
09:33:30Zevvsleep well then!
09:33:41shashlicki've crossed the age where it didn't matter 😉
09:34:08shashlickand this is the second night in a row
09:37:12*Hideki_ quit (Ping timeout: 265 seconds)
09:37:55*Hideki_ joined #nim
09:38:35*luis_ quit (Ping timeout: 272 seconds)
09:39:00*silvernode joined #nim
09:42:38*Hideki_ quit (Ping timeout: 268 seconds)
09:43:56*Hideki_ joined #nim
09:48:41Araqhow can we tell the CIs that it's 2020 and we default to C++11 now?
09:50:22*jjido joined #nim
10:06:18FromGitter<mratsim> Vcc defaults to C++11
10:06:31leorizeAraq: pass -std=c++11 to gcc compatible compilers
10:12:54*oculux quit (Quit: blah)
10:16:00FromGitter<sheerluck> i like c++20 more
10:29:23*leorize quit (Ping timeout: 240 seconds)
10:34:16*NimBot joined #nim
10:39:24shashlickthank you!
10:42:41*luis_ joined #nim
10:53:11*nsf joined #nim
10:53:38*dom96 continues to wonder why Status is reimplementing things in the stdlib
10:59:55*Pixeli joined #nim
11:01:53stefantalpalaruIt's simple: upstreaming stdlib changes takes too damn long. If they are considered "features", they can only get into x.y.0 releases which are done twice a year.
11:02:03luis_hi all, how do I get the absolute value of a number in Nim?
11:03:12stefantalpalaruOther times, changes are simply rejected because the BDFL doesn't want to maintain them: https://github.com/nim-lang/Nim/pull/9724
11:03:13disbotunittest: opt-in test parallelisation
11:03:27dom96stefantalpalaru: see, but you're reimplementing things from scratch. I'd understand if you just fork what's there already with the possibility to upstream it later, but you're not doing that.
11:03:45stefantalpalaruSo the workaround is to fork as much of the stdlib as we need, in order to get the bug fixes or features we need.
11:04:42stefantalpalaru"Sorry, this is not something we are keen on maintaining. Unittest is already very quirky, don't want it to use multithreading. Please create a fork of unittest that provides this feature."
11:04:57dom96And yes, I did check the initial commit of the http-utils package
11:05:01stefantalpalaruIt doesn't get any more clear than that.
11:05:44stefantalpalaruUpstream is just not interested in imporoving stdlib and, when it is, it might take 6 months for it to reach an official release.
11:06:09stefantalpalaruSo the question is: why aren't you forking stdlib modules?
11:07:48dom96Are you asking me?
11:07:54stefantalpalaruYes.
11:08:25dom96Can you give me an example where I have reimplemented something?
11:08:30dom96without forking stdlib?
11:08:58stefantalpalaruThat's not how the English language works.
11:09:28lqdev[m]luis_: use math.abs
11:09:35dom96That's... what?
11:10:03solitudesflqdev[m], abs is in system
11:10:09stefantalpalaruThat's a non-sequitur. I'm asking you why you aren't forking the stdlib and you respond with gibberish. Come on, it's a simple question.
11:10:11lqdev[m]oh, right
11:10:20lqdev[m]thought it'd be in math
11:10:37lqdev[m]man, system is big
11:10:55dom96My answer is: I always fix things in the stdlib. I don't "fork" it because I have commit access to the Nim repo
11:11:04dom96But that's just semantics
11:11:21dom96The reason I asked you to show me evidence of where I have reimplemented stuff is because you are implying that I have
11:12:32stefantalpalaruASo you use Nim's devel branch in your projects?
11:12:37stefantalpalaru*So
11:13:14*luis_ quit (Ping timeout: 240 seconds)
11:14:16dom96Sometimes, if I need it.
11:15:40dom96Even if I didn't and needed some stdlib fixes it would be trivial to backport them to a stable release.
11:16:30dom96But using bleeding edge Nim works fairly well in general.
11:19:05dom96Once again I ask you, why reimplement http utilities when you could instead fork the code into a package and fix what you need, then upstream it at a later date? Surely that would take far less time and give back a lot to the Nim community
11:20:19planetis[m]how did you guys choose to respond to taking long to upstream changes, would you do something better, like discuss it more publicly, demand to change release schedule, etc? i share the same concerns with dom96 but i not familiar with the situation so i am not drawing any conclussions.
11:21:42*luis_ joined #nim
11:22:43*ikan-keli_ quit (Ping timeout: 258 seconds)
11:24:27stefantalpalarudom96, you'll have to ask cheatfate. I wasn't there when the decision was made for status-im/nim-http-utils.
11:25:29*ikan-keli_ joined #nim
11:26:10dom96Fair enough
11:27:37dom96Fun trivia: async await became a thing in Nim all the way back in 2014 https://nim-lang.org/blog/2014/04/21/version-094-released.html :O
11:28:00stefantalpalaruplanetis, there's a #nim-testers IRC channel where I complained about https://github.com/nim-lang/Nim/pull/12922 not getting into 1.0.6 because it's considered a "feature" and semver patch versions are only for bugfixes. When I couldn't convince anyone that this cherry-picking based development model where the devel branch is left stale for half a year needs to be changed, I fell back to asking for monthly x.y.0 releases.
11:28:01disbotgeneric stack trace overriding mechanism
11:28:31dom96What is the purpose of that channel?
11:28:40stefantalpalaruTesting release candidates.
11:29:13stefantalpalaruIn this case, https://github.com/nim-lang/nightlies/releases/tag/2020-01-16-version-1-0-2f557f7
11:29:20dom96These kinds of things should probably be discussed here
11:29:23FromDiscord<mratsim> @shashlick this should fix your issue, pending review: https://github.com/status-im/nim-http-utils/pull/9
11:29:24disbotNull terminate public strings
11:29:32*dadada joined #nim
11:29:38dadadahey
11:29:39FromDiscord<Rika> has anyone made a pushdown automaton on nim? i know someone made an fsm
11:29:53dadadais there a roadmap with future planned changes to the language?
11:30:08dom96mratsim: one reason why I dislike seq[byte] ;)
11:30:08stefantalpalarudom96, I tried to: https://irclogs.nim-lang.org/29-12-2019.html#15:42:05
11:30:11FromDiscord<mratsim> @Rika, a pushdown automaton is just a FSM + a stack
11:30:16FromDiscord<Rika> i do know that
11:30:20FromDiscord<Rika> but im a lazy fuck
11:30:25FromDiscord<mratsim> the json parser is a pushdown automaton
11:30:41*luis_ quit (Quit: luis_)
11:30:45FromDiscord<Rika> i'll prolly just fuck around with the fsm no?
11:30:51FromDiscord<Rika> prolly yeah
11:30:59FromDiscord<mratsim> you can also adapt synthesis , just save states to go back to in a stack
11:31:11*luis_ joined #nim
11:31:31FromDiscord<Rika> i dont even know if i should use a pushdown automaton though lmao
11:31:48FromDiscord<Rika> i'm thinking of using it for saving what ui menu i'm at for the application i'm making
11:32:00FromDiscord<Rika> does it make sense to use a pushdown automaton for that?
11:32:05FromDiscord<mratsim> THe easiest way to learn pushdown automaton is to write a brainfuck interpreter
11:32:09FromDiscord<mratsim> yes it does
11:32:21FromDiscord<mratsim> that's probably the most maintainable way as well
11:32:33FromDiscord<Rika> yeah i had a light bulb moment
11:33:06dom96stefantalpalaru, I see. Got lost in the noise I suppose. I think these kinds of problems deserve a discussion in the forum.
11:33:07FromDiscord<Rika> the issue is prolly creating the transitions because that can be a mess so i'll have to think of a good api for the pd automaton
11:33:58FromDiscord<mratsim> this is the pushdown automaton part of my brainfuck interpreter: https://github.com/mratsim/jitterland/blob/master/bfVM_v02.nim#L48-L52
11:34:30FromDiscord<mratsim> just saving and restoring the beginning of loops
11:34:44FromDiscord<Rika> @_@
11:34:50dom96btw with regards to async await, I'm putting it on the record, I think we should take inspiration from Rust and try to implement polling-based futures for zero-cost abstraction async await (for Nim 2.0)
11:35:07FromDiscord<Rika> woah discussion about nim 2.0
11:35:10planetis[m]also ime araq is not a bdfl at all, but you know, people who do all the work also get a bigger vote, this is not uncommon,
11:35:20FromDiscord<mratsim> Nim futures are not polling?
11:35:30FromDiscord<Rika> araq doesnt give a bdfl feeling
11:35:38dom96mratsim: nope
11:35:41planetis[m]in households for example...
11:35:44dom96Surprised you don't know that
11:36:15FromDiscord<mratsim> I almost didn't touch async/await
11:36:43FromDiscord<mratsim> spawn/sync (multithreading) is already quite a handful
11:36:51dom96Good that you don't know. I will definitely point this out during my FOSDEM talk then
11:37:08dom96or rather, good that you tell me that you don't know :)
11:38:39FromDiscord<Rika> what does it mean by futures being polling?
11:38:59FromDiscord<mratsim> btw, in the current design of async dispatch, how would it make sense to cooperate with a threadpool? an event loop per thread would work? I expect the OS primitives handle race conditions gracefully
11:40:42dom96mratsim: event loop per thread is how httpbeast works. You can also get pretty far by enabling `await spawn myThread()`, which we got pretty close to.
11:43:14federico3dom96: speaking of which, did you document what is not async in asyncnet and jester?
11:43:51dom96huh? everything should be async. Are you referring to asyncfile not being async?
11:44:10federico3that one and IIRC there was something else
11:45:17FromDiscord<mratsim> regarding string vs seq[byte], this would also have been an issue if the httpRequest buffer was a string. Casting a subslice of a string or seq[byte] to string will not zero-terminate it
11:46:08FromDiscord<mratsim> Also the ultimate rootcause is the design of C cstring
11:47:03dom96True, which leads me to another suggestion: we should be as vigilant about `cast` as Rust is about `unsafe` and possibly implement something similar to `cargo-geiger` but for `cast` and other "unsafe" constructs
11:48:36dadadaare there any accepted proposals for future changes to the Nim language?
11:48:42dadadaor a list of those?
11:48:54FromDiscord<mratsim> Shouldn't that be handled by nimpretty?
11:49:45FromDiscord<mratsim> @dadada: https://github.com/nim-lang/RFCs/issues https://github.com/nim-lang/RFCs/milestone/1 https://github.com/nim-lang/Nim/milestones
11:50:10dom96dadada, it's all a bit disorganised, but reading through the RFCs issues can give you some sense: https://github.com/nim-lang/rfcs
11:50:35dom96oh cool, I didn't know about that milestone
11:51:31FromDiscord<mratsim> I'm not sure why github hides the milestones
11:51:42FromDiscord<mratsim> if you don't have the direct link it's impossible to discover
11:52:14dadadamratsim: good point
11:52:18dom96I'll edit the readme to include this link
11:53:13FromDiscord<mratsim> btw, while you do maintenance, can I get contributor rights to RFCs, I can't move RFC from the Nim main tracker to the RFCs repo
11:53:52dom96Tbh I don't think we should do that
11:54:09dom96Instead we should close the issue and say "Please write up a proper RFC in the RFC repo"
11:54:27dom96Otherwise we'll get vague tiny and low-effort issues
11:54:49dadadathat list of milestones ends with 1.1 and contains only one proposal, it's not very useful that way
11:55:20dadadaat least currently, don't know how it used to look
11:58:40*dcmertens joined #nim
11:59:16FromDiscord<mratsim> mmmh, for example this one is short but I wouldn't say it's low-effort: https://github.com/nim-lang/Nim/issues/11776
11:59:17disbotException should not be Defect
12:00:10FromDiscord<mratsim> or this one, we should probably be closed? cc @Araq https://github.com/nim-lang/Nim/issues/8363
12:00:12disbotRework Nim's exception handling ; snippet at 12https://play.nim-lang.org/#ix=27OQ
12:03:47dom96mratsim: I added you as a collaborator
12:03:56dom96btw how is yglukhov, haven't seen him in some time
12:07:08*krux02 joined #nim
12:07:35FromDiscord<mratsim> he is in vacation right now. He has been fighting peer discovery for P2P for months
12:08:05dom96ahh nice
12:18:35*luis_ quit (Remote host closed the connection)
12:25:49*oculux joined #nim
12:26:31dadadahttps://github.com/nim-lang/RFCs/milestone/1 <- 4 proposals that look nice
12:26:53dadadais araq a full time nim dev?
12:30:12*krux02 quit (Remote host closed the connection)
12:31:34*krux02 joined #nim
12:32:02*krux02 quit (Remote host closed the connection)
12:34:20dadadaon the bountysource page: "Nim has never had anyone working on it full-time"
12:34:31dadadamakes Nim all the more impressive
12:34:47dom96that's pretty outdated
12:35:03dom96This was true until 2 years or so ago
12:36:16dadadadom96: then enlighten me
12:40:50FromDiscord<Rika> i think there are a few thanks to status.im
12:43:14dadadagreat
12:43:25dadadais there a nim developers conference or anything like that planned?
12:45:28*dddddd joined #nim
12:49:59FromGitter<zetashift> some talks at FOSDEM but for now no exclusively Nim conf planned
12:52:27dadadaah
12:59:07dadadadid google give any reason why Nim has so far been rejected for GSoC?
13:01:07dadadathe deadline of 2020 is: Deadline February 5, 2020
13:01:15dadadahttps://summerofcode.withgoogle.com/
13:01:29dom96Want to help us apply? :)
13:03:01dadadahave zero experience with doing that, just wanted to ensure you're aware of it
13:03:19*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:03:22dadadaall I might be able to contribute are project ideas, ...,
13:04:07dadadamay favorite idea is for a student to write wrappers for popular C++ libraries such as Qt5
13:04:32dadadaeven better would be for them to write tools for writing those wrappers quicker/easier/seamlessly
13:07:25*gangstacat quit (Quit: Ĝis!)
13:08:03*Vladar joined #nim
13:09:25*luis_ joined #nim
13:10:50dadadathe students would learn about Nim as well as the APIs and uses of those popular libraries (which is good for them), and Nim would become more popular due to those hurdles of language switching (missing your favorite APIs/libs) becoming less relevant (win-win)
13:15:44FromDiscord<Recruit_main_70007> @mratsim hello, (just to clarify, i am Albus from gitter) i really want to start ML in Nim, and since nimtorch is a bit "slept", i want to use arraymancer, but i dont know how to slove the could not load blas.dll error
13:16:35FromDiscord<mratsim> which platform are you on?
13:16:41FromDiscord<Recruit_main_70007> windows
13:17:40FromDiscord<mratsim> You need to download openblas: https://www.openblas.net/
13:18:34FromDiscord<mratsim> put it somewhere, add that folder to your PATH
13:18:48FromDiscord<mratsim> i.e. developing on windows is a huge pain 😉
13:19:17FromDiscord<Recruit_main_70007> and can i get them into a folder that is aleady in path?
13:19:58FromDiscord<mratsim> yes
13:20:13FromDiscord<mratsim> if that helps this is my CI code, I use nuget to install OpenBLAS: https://github.com/mratsim/Arraymancer/blob/master/.appveyor.yml#L30-L43
13:20:58FromDiscord<Recruit_main_70007> and do i need any special flags when compiling?
13:21:00dadadadom96: so are you applying? I have found nothing on this top "Nim Gsoc 2020"
13:21:06dadadatopic
13:21:26dadadait's understandable to me if you're not, since you keep being rejected
13:21:48dadadaon the other hand many other projects I've followed were accepted, so it's definitely possible
13:22:04FromDiscord<mratsim> if it's not called blas.dll you need to pass -d:blas=yourBLasName
13:22:39dadadafor example nuitka was accepted, and they had a student ensure that the top 20 projects on pypi work with nuitka or something to that extend
13:22:49FromDiscord<mratsim> ultimately I want to remove BLAS dependency but it's a lot of optimization work
13:23:46FromDiscord<Recruit_main_70007> thats good, do you think you could add this to the readme?
13:23:46FromDiscord<Recruit_main_70007> i found this difficult to do
13:24:25dadadaanother thing that might help is to extend the Nim organization, you could include promising Nim based projects like this one https://github.com/nimterop/nimterop in the Nim organization and make a project suggestion for it, for example the KDE organization spans dozens of different subprojects
13:25:03FromDiscord<mratsim> sure, you can also PR specific windows instruction there if you have time: https://github.com/mratsim/Arraymancer#installation
13:25:33*luis_ quit (Ping timeout: 246 seconds)
13:25:33*Pixeli quit (Read error: Connection reset by peer)
13:25:56FromDiscord<Recruit_main_70007> 👌
13:28:43FromDiscord<Recruit_main_70007> not working...
13:28:43FromDiscord<Recruit_main_70007> i have this in the path system variable,
13:28:43FromDiscord<Recruit_main_70007> "C:\Program Files\openblas\bin"
13:28:43FromDiscord<Recruit_main_70007> inside it, i have "blas.dll"
13:28:44FromDiscord<Recruit_main_70007> maybe i have to restart?
13:29:14FromDiscord<Recruit_main_70007> also PATHEXT has ".DLL"
13:30:31dadadadom96: a student could add Nim support to SWIG swig.org
13:32:51FromDiscord<Recruit_main_70007> dadada: nim is already compatible with any language that can import a C/C++ dll.
13:33:59*luis_ joined #nim
13:34:49dadadaRecruit_main_70007: there's still a lot of boiler plate coding to do before it really can interface
13:35:51dadadawhen considering a new language I'm not really looking for a theoretical compatibility, I'm looking for the convenience of being able to use the tools I like with the least amount of effort necessary
13:36:44dadadaso, since some people have already written boiler plate code for interfacing with other languages, one idea would be to piggyback on their code ... why write the same boilerplate twice/trice?
13:36:58*Hideki_ quit (Remote host closed the connection)
13:37:34*Hideki_ joined #nim
13:37:37dadadawhen I was writing "I'm" I really meant a general developer that looks for a new language
13:41:20*Hideki_ quit (Remote host closed the connection)
13:41:25*luis_ quit (Remote host closed the connection)
13:41:46*luis_ joined #nim
13:42:42*Hideki_ joined #nim
13:43:03*luis_ quit (Client Quit)
13:43:43*luis_ joined #nim
13:43:50dadada"SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages."
13:44:17dadadasee, some C/C++ projects already have the boilerplate code for SWIG
13:44:45dadadaand those can then be easily interfaced from high level langs such as D, Python, Ruby and so forth, which are supported by SWIG
13:46:31dadadanow you could ask those projects to also create special interfacing code for Nim, which would mean in the logical conclusion that making this bridging/interfacing working/boilerplate work would've to be done for each higher language separately
13:46:46dadadawhich obviously sounds like a waste of human time!
13:47:31FromDiscord<Recruit_main_70007> how do i compile an iterator to a dll?, dynlib flag fails
13:47:32dadadaOR someone writes the few thousand lines of code for Nim SWIG support ... I think it would be a nice GSoC project
13:47:58*dcmertens quit (Ping timeout: 260 seconds)
13:47:59solitudesf@Recruit_main_70007, you cant
13:48:41*luis_ quit (Quit: luis_)
13:48:50FromDiscord<Recruit_main_70007> so how would i do it, having a function and a for loop?
13:49:16*luis_ joined #nim
13:55:17*luis_ quit (Ping timeout: 260 seconds)
14:03:40lqdev[m]believe me or not but iterators do not have a runtime representation
14:03:51lqdev[m]they're sort of like templates
14:04:45lqdev[m]where each yield statement in the iterator is replaced with the body of the for loop
14:07:45*filcuc joined #nim
14:10:55*lritter joined #nim
14:17:52*silvernode quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
14:18:20*luis_ joined #nim
14:18:26FromDiscord<Rika> theyre inlined
14:20:44dom96closure iterators are different though
14:21:12FromDiscord<Recruit_main_70007> explain please
14:21:13FromDiscord<Rika> those have state
14:21:28FromDiscord<Rika> do you know python iterators?
14:21:42FromDiscord<Recruit_main_70007> for loops right?
14:21:49FromDiscord<Rika> no, python iterators
14:21:58FromDiscord<Rika> as in the iterator object
14:22:26FromDiscord<Recruit_main_70007> very little
14:36:10*Hideki_ quit (Remote host closed the connection)
14:36:48*Hideki_ joined #nim
14:39:26*filcuc quit (Ping timeout: 268 seconds)
14:42:57*Hideki_ quit (Ping timeout: 268 seconds)
14:45:45*luis_ quit (Remote host closed the connection)
14:53:56*filcuc joined #nim
14:57:07*narimiran joined #nim
14:59:34*Hideki_ joined #nim
15:04:49FromDiscord<mratsim> Python iterator just define a "next" function call, and Python iterators are just calling next() next() next() until next doesn't return anything
15:06:34FromDiscord<mratsim> I'm not sure the point @Rika wanted to make but the thing is, Nim iterators are a compile-time construct and cannot be called from C. It's just an abstraction so that "something" can be called as if it was a for loop
15:07:32FromDiscord<Recruit_main_70007> well, i found that the best solution is to get your for loop done inside a nim function and then calling it
15:08:28FromDiscord<mratsim> yes
15:09:56Zevvso, what is now the correlation between =destroy and new(..., finalizer). Do these end up to be the same thing?
15:12:26FromDiscord<Rika> @mratsim i meant that python iterators have state, which is pretty similar to closure iterators in nim
15:12:42FromDiscord<mratsim> @zevv yes
15:13:08FromDiscord<mratsim> there was a discussion about that yesterday or the day before
15:13:15Zevvah I missed that, sorry
15:13:33FromDiscord<mratsim> it's here: https://forum.nim-lang.org/t/5825
15:13:43Zevva little experiment indeed tells me the answer, if I do 'new' I can not create a =destroy for the same type
15:14:05Zevvso that makes sense. I do prefer the =destroy, as passing a type destructor to `new` feels wrong and funny
15:14:19Zevvthanks for the confirmation
15:15:54FromDiscord<mratsim> =destroy doesn't work for ref objects anyway
15:16:07Zevvit does with arc, right?
15:16:40*ng0_ joined #nim
15:16:51Zevvi now have one `=destroy` that works both with heap and stack
15:17:00FromDiscord<mratsim> AFAIk it's just that finalizers are triggered at the same time as destructors now
15:17:04FromDiscord<mratsim> ah
15:17:08FromDiscord<mratsim> well not sure
15:17:16FromDiscord<mratsim> @treeform @Araq: https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01096.html
15:17:32FromDiscord<mratsim> ^ [C++ coroutines] Initial implementation pushed to master.
15:19:53*ng0 quit (Ping timeout: 265 seconds)
15:24:31*dadada quit (Ping timeout: 265 seconds)
15:26:51*Hideki_ quit (Remote host closed the connection)
15:27:35*Hideki_ joined #nim
15:32:28*Hideki_ quit (Ping timeout: 268 seconds)
15:33:47FromGitter<zacharycarter> anyone have any experience implementing parallel pathfinding? I've found some resources on the subject - https://software.intel.com/en-us/articles/the-secrets-of-parallel-pathfinding-on-modern-computer-hardware & https://link.springer.com/chapter/10.1007/978-3-642-25090-3_25 & https://github.com/acwilton/parallel-path-finding
15:34:02FromGitter<zacharycarter> but wondering if anyone here has implemented any of these before
15:34:06FromGitter<zacharycarter> or explored the topic
15:35:31FromGitter<zacharycarter> right now in my map generation process, a* is the bottleneck
15:37:25*pbb quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
15:38:52*pbb joined #nim
15:42:34*filcuc quit (Remote host closed the connection)
15:43:01*filcuc joined #nim
15:48:32FromDiscord<mratsim> never implemented but if it's just derivate from depth-first or breadth-first search it should be easy to parallelize with Weave
15:48:43FromDiscord<mratsim> is your code public?
15:49:12FromDiscord<mratsim> I can add it as a Weave benchmark if it's relatively self-contained
15:49:17*ng0_ is now known as ng0
15:49:55AraqZevv, =destroy is bound to the object type and the finalizer to the 'ref' type
15:50:07Araqbut ultimately it's the same thing
15:50:21Araqand we map destructors to finalizers for the old GCs
15:50:31Araqand we map finalizers to destructors for --gc:arc
15:50:39Zevvthat makes sense, thanks
15:50:45Zevvmention all that in your talk :)
15:51:11Araqfinalizers have the advantage that historic Nim versions already understand them
15:51:54Araquh oh my talk
15:52:05Araqneed to prepare it...
15:52:42Zevvnah, just improvise some stand up comedy for 30 minutes, you'll be just fine
15:53:04FromDiscord<mratsim> same thing ...
15:53:35*filcuc quit (Remote host closed the connection)
15:54:11*filcuc joined #nim
15:55:18Araqmratsim: the C++ ABI seems pointer heavy
15:55:26*Hideki_ joined #nim
15:56:05Araqwhich is bad when you want to serialize the state machine to disk because you want to give your users a "save any time" feature
15:56:21Araqbut hey, what I do know about game development.
15:59:24*filcuc quit (Remote host closed the connection)
16:00:17*Hideki_ quit (Ping timeout: 265 seconds)
16:00:50*ng0 quit (Ping timeout: 268 seconds)
16:07:40*ng0 joined #nim
16:11:09*gangstacat joined #nim
16:11:24*gangstacat quit (Remote host closed the connection)
16:11:54*gangstacat joined #nim
16:20:06*dadada joined #nim
16:20:29*dadada is now known as Guest62063
16:22:10*Guest62063 left #nim (#nim)
16:32:50disruptekok, who has a version of nim that reads /etc/nim.cfg or /etc/nim/nim.cfg?
16:33:57federico3I do
16:34:02disrupteki do not.
16:34:15*jjido joined #nim
16:34:16FromGitter<zetashift> (I do not)
16:34:32disruptekwhat platform?
16:35:20FromGitter<zetashift> On my linux box
16:35:41FromGitter<deech> The stable `nimble` gives me an error when I try to `search` or `list`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5e24855d5cd79646607a3bd0]
16:35:42*Trustable joined #nim
16:35:54FromGitter<deech> I did a `nimble update` first.
16:36:06FromGitter<zetashift> huh I get the same error
16:36:39FromGitter<deech> idk if it's the cause but I don't have a file called `packages.json`, but I do see a `packages_official.json`.
16:37:20disrupteki think you might be entitled to a prize if you have the official copy.
16:38:45FromGitter<deech> I removed it and updated, poof it's back.
16:39:00disrupteksomeone really wants you to have that file.
16:41:24*Hideki_ joined #nim
16:42:47FromGitter<deech> Ok moving on, has anyone run into issues with compilation time when using the C++ backend on larger projects?
16:43:59disruptekno, but i use ccache pretty extensively.
16:47:55*nsf quit (Quit: WeeChat 2.7)
16:49:51disrupteki built rust on my palmtop (4 threads). it took >2½hrs. building nim with one thread took <8½mins.
16:50:54disruptektakes my workstation 25s, for comparison.
16:58:35FromDiscord<+[+-]> Hey there, new to nim and I've been working on a text based adventure game thing to try and get myself more acquainted with the language and I've been trying to figure out how I'd be able to actually print out individual characters at an interval of one second as an example. I know I can run stdout.write <character> but after looking at the manual, the tutorials, and even checking the forums I haven't found a way where that'd be feasible. I k
17:01:23solitudesfhttps://nim-lang.github.io/Nim/os.html#sleep%2Cint
17:01:38FromDiscord<+[+-]> You're a hero
17:01:40solitudesfhttps://nim-lang.github.io/Nim/theindex.html use this to search stdlib
17:04:27*Hideki_ quit (Ping timeout: 272 seconds)
17:11:10*oz quit (Ping timeout: 252 seconds)
17:12:03FromDiscord<treeform> @mratsim the C++ coroutines seem to be more like async/await rather then what coroutines usually are...
17:13:20FromDiscord<treeform> Fibers on Win32 are pretty interesting: https://nullprogram.com/blog/2019/03/28/ Never knew about them or how they worked.
17:13:40*oz joined #nim
17:13:42*ptdel joined #nim
17:19:08FromDiscord<treeform> Some thing I read and can't find anymore. I would like to test this: The system that use thousands of "green" threads to do IO can do IO fast in benchmarks. But as soon as they need to do any real work they blow up the CPU cache causing a ton of missed caches and make everything way slower... which approaches the legacy using real threads performance.
17:20:25FromDiscord<treeform> I would like to test the hypotheses, that doing work and not just pure IO... will make async/coroutines/fibers ... run at about the same speed as threaded code with locks.
17:20:46disrupteki think that's only true if all your fiber does is yield.
17:20:54FromDiscord<treeform> It might be a ton of extra complexity for not a huge gain....
17:21:02disrupteki've never had a problem with fibers being inefficient on the cpu.
17:22:02disruptekthey are cheaper to switch. that's the whole point.
17:22:37FromDiscord<treeform> If you want to read a file... well there is no kernel async API. So that's threads. You want to do DNS? will that's threads too... So many things in OS require blocking ... that threads escape is required from "async/coroutines/fibers" world.
17:23:47FromDiscord<treeform> "never had a problem with fibers" but what % of fibers efficacy do you gain in your app?
17:24:15disruptekyou mean, what overhead do i have?
17:24:30FromDiscord<treeform> yes I am interested in real world benchmarks
17:24:44FromDiscord<treeform> is fibers vs threads a 2% gain? 50% gain? 99% gain?
17:24:56disruptekoh, i don't know. i don't care. the win for me is in structure, design, architecture, readability, etc.
17:25:14disrupteknever noticed any performance difference.
17:25:21FromDiscord<treeform> well I am saying that maybe threads are simpler and way better supported at OS level.
17:25:32disrupteksure, but fibers have their place. they do work.
17:25:38disruptekthey can be faster than threads.
17:26:05disruptekyou're second-guessing greenlet for some reason.
17:26:07disruptekwhat's up?
17:26:15FromDiscord<treeform> not if you do a ton of DNS stuff... DNS lookups block your whole async program.
17:27:25disruptekwhy?
17:29:14FromDiscord<treeform> https://github.com/nim-lang/Nim/issues/7422#issuecomment-573602101
17:29:16disbotAsync networking and blocking host name resolving / DNS
17:29:18FromDiscord<treeform> because it requires OS stuff.
17:30:25FromDiscord<treeform> Basically the OS it build for threads. Doing Async with the OS needs some sort of synchronization ...
17:30:33FromDiscord<treeform> While threads don't.
17:30:53disruptekso sumb.
17:30:56disruptekdumb, too.
17:31:34*JustASlacker joined #nim
17:31:58disrupteki don't know if i have another resolver in me.
17:32:16FromDiscord<treeform> I am feel more ignorant about the subject of asycn/threads the more I read about them...
17:32:20disrupteki wrote dns servers in perl and python.
17:32:40FromDiscord<treeform> I want to benchmark and test hypotheses... cause I think there are myths here.
17:32:42FromDiscord<DeltaPHC> Generally speaking, the wisdom I've heard is that threads and fibers/coroutines/async-await are two different tools that are best at different things
17:33:04FromDiscord<treeform> I want to test this "wisdom"
17:33:14Zevvsure, but you dont have the choice always
17:33:33Zevvwhat if you want to use two libs, one threaded and one async?
17:33:46Zevvyou cant await on both at the same time
17:33:59disruptekbetter example is that you need to integrate with existing architecture.
17:34:47dom96treeform: benchmarking is challenging, there are so many use cases that any synthetic benchmark has no hope of capturing
17:35:18FromDiscord<DeltaPHC> Parallelism vs. concurrency. They aren't mutually exclusive. For example, Go multiplexes coroutines on multiple threads. Each thread might have more than one "goroutine" on it. It all depends on how the scheduling is implemented
17:35:39FromDiscord<treeform> dom96, yeah that's probably the main thing I worry about. Its like "unknowable" problem.
17:36:15disrupteki don't believe that.
17:36:24disrupteki believe the problem is as real as you think it is.
17:36:45disrupteknet-net, you have an issue you need to solve. it doesn't matter what the benchmarks say.
17:38:05*JustASlacker quit (Ping timeout: 268 seconds)
17:38:12FromGitter<Varriount> Who is net-net?
17:38:34disrupteki mean, when all is said and done.
17:39:05disruptekthe app is the benchmark. it's too slow.
17:49:25*dddddd quit (Ping timeout: 272 seconds)
17:50:39*JustASlacker joined #nim
17:51:06FromDiscord<treeform> I guess the route I am taking now -- for highest performance. Don't use threads or async... using a UDP packet based thingy...
17:51:45disruptekyou mean, writing your own resolver.
17:53:13dom96speaking of performance, just optimised my game's particle draws to reduce the frame time from 27ms to 1.7ms
17:53:29FromDiscord<treeform> nice! That's a huge win.
17:53:46FromDiscord<treeform> I was doing particles in my game the other day.
17:54:23dom96Thanks :) There are definitely plenty of other things that I can do, these optimisations were fairly simple and only needed to be done because I wanted to get particles on the screen ASAP
17:54:54FromDiscord<treeform> this is with SDL?
17:54:58dom96yep
17:57:50FromDiscord<treeform> I struggled with pausing the game and pausing the particles as well. And making sure the particles frame rate sync with the variable simulation rate. But I think I solved it.
17:58:02FromDiscord<Recruit_main_70007> guys, we are having a RLBot tournament, its the first appearance of a Nim bot and the second time of a Boolang, (both mine although they suck), it is very cool, we are starting in 3 minutes.
17:58:02FromDiscord<Recruit_main_70007>
17:58:03FromDiscord<Recruit_main_70007> https://www.twitch.tv/RLBotOfficial
17:58:37dom96treeform: oh? Why did you struggle with that?
17:59:00FromDiscord<treeform> I don't know... bad previous code?
17:59:58dom96Isn't it just a case of not calling your `update` procedure?
18:02:24*dddddd joined #nim
18:02:55*dadada joined #nim
18:02:56dadadahi
18:03:17dadadawhat language do yo think is most similar to Nim?
18:03:27FromDiscord<treeform> Nimrod? 🙂
18:03:27dom96Recruit_main_70007: what's the name of the NIm bot?
18:03:43FromDiscord<Recruit_main_70007> NimBot
18:03:57dadadataking into account less of the syntax and more of the feature side
18:04:13dom96hah, of course :)
18:04:43dom96this seems fun
18:05:02dadadas/do yo/do you
18:05:18FromDiscord<Recruit_main_70007> this ones are not precisely the best ones, but there are some nutty ones
18:05:53*dom96 wonders what demos are
18:05:59dom96never played rocket league :D
18:06:14FromDiscord<treeform> I think its short for demolition, or kill the other car.
18:06:23FromDiscord<Recruit_main_70007> ^
18:06:48FromDiscord<treeform> It looks like the faster car wins during collisions if its going fast enough.... not sure how that works
18:07:31*JustASlacker quit (Ping timeout: 258 seconds)
18:09:08FromDiscord<DeltaPHC> dadada: If we're talking only features, it's actually hard to say whether any one language has most of everything Nim does. Nim itself borrows a lot from other languages
18:09:20FromDiscord<treeform> maybe a proper angle is also required
18:10:26FromDiscord<DeltaPHC> I'm not sure if I've seen another language besides <insert Lisp variant here> that quite has the macro and meta-programming features of Nim
18:11:28shashlickThanks @mratsim for the fix
18:12:16FromDiscord<treeform> if you can't have lisp macros, maybe forth macros? Rebol? Red?
18:14:00dadadaDeltaPHC: I'm asking for closeness, sameness (this word should exist, even if it doesn't, agree?) of features :D
18:14:38FromDiscord<DeltaPHC> But then Nim's type system takes in features from other languages. Sum types (object variants) from functional languages, generics/constant generics similar to C++, but it also has some limited form of typeclasses, and there's also concepts which is coming to C++ though it's rather experimental
18:15:09Araqif you want Nim, you know where to find it
18:15:19FromDiscord<treeform> The indentation makes it look like python...
18:15:19AraqI don't understand the point of the question
18:15:44dadadaAraq: I agree with you
18:16:25FromDiscord<treeform> If you want python with types you can go Pyrex, Cython, Boo...
18:16:27dadadaI was just considering how much work it would be to write a Nim module for swig, swig docs suggests starting with the module for a language that has similar features / is similar
18:16:40Araqaha
18:16:44dadadacopy paste and then modify
18:16:52Araqswig used to support Modula 3 iirc
18:16:58Araquse that as the foundation ;-)
18:17:00FromDiscord<treeform> that's a a lot more contained.
18:17:09FromDiscord<treeform> constrained*
18:17:15dadadathey do support Go :D
18:17:26FromDiscord<treeform> Hmm, I never used a swig wrapper I liked.
18:17:34FromDiscord<DeltaPHC> Nearly every popular language is sort of a descendant from Algol :^)
18:17:47Araqtreeform: I wrote c2nim after having studied Swig
18:18:23dadadaafter swiftly looking over some swig code I see why
18:18:37AraqSwig uses a bastard version of C++ with dynamic typing
18:18:57Araqand it has its own non-standard C++ parser (like c2nim)
18:20:40Araqdadada, IMO the way forward is to use clang's parser inside c2nim
18:20:51Araqthat's of course easier said than done
18:21:00dadadaeverything is
18:21:09disruptekAraq: you're might be the first person i've ever met who's guilty of bikeshedding an unimplementation.
18:21:27FromDiscord<treeform> which language has the largest library of high quality software? Python2nim, Java2nim, JavaScript2nim?
18:21:38Araqdisruptek, that sounds good. does it also mean anything?
18:21:58FromDiscord<treeform> its surly not php2nim...
18:22:12disruptektelling zevv how to not-implement...
18:22:27dadadatreeform: oh my, I just want Qt5 for Nim :D
18:22:38federico3certainly not javascript either
18:22:45FromDiscord<treeform> Why Qt5?
18:22:58FromDiscord<DeltaPHC> It's a popular GUI framework
18:23:11disrupteki really like qt.
18:23:17disrupteki dunno who people hate it so much.
18:23:18dadadatreeform: because I found Qt a breeze to program in each time, I used to use Qt2, too
18:23:30disrupteks/who/why/
18:23:37FromDiscord<DeltaPHC> Main downside of Qt is that it's rather heavyweight
18:23:45*nsf joined #nim
18:23:46FromDiscord<DeltaPHC> But it's also very complete
18:23:47disruptekeven though i prefer gtk apps to run, i prefer writing qt apps.
18:23:49FromDiscord<DeltaPHC> and comprehensive
18:23:57disruptekand consistent.
18:24:09Araqdadada, krux02 started to wrap Qt via their doc generator
18:24:21FromDiscord<treeform> What is the most popular Qt powered app? I don't think I have used any.
18:24:24dadadadisruptek: it's more than a gui framework, it has tools for a lot of different tasks, you can build a httpserver, or manipulate images, it's really a giant library
18:24:34disruptekyes, i know.
18:24:38Araqnot sure if he uploaded the code though
18:24:46disrupteki've written c++ qt and also pyqt apps.
18:24:58Araqanyhow, it's an idea worth exploring, instead of producing HTML, produce a Nim wrapper out of it
18:25:05disruptekclever.
18:25:14dadadawho hates it? I've used gtk, too, like them both, does that make me odd?
18:25:45FromDiscord<DeltaPHC> That can also be seen as a "downside" of Qt. That it's basically an entire ecosystem that you have to immerse yourself into. Use its non-standard C++ extensions to make things easier. That sort of thing
18:25:47disruptekno; araq doesn't like symlinks.
18:25:51disruptekthat's "odd".
18:26:40Araqnothing odd about it, I like trees much better than more general graphs
18:26:53Araqit's odd that you bring it up in a discussion about Qt though
18:26:57dadadaAraq: while a clever trick that I used once too, making a specific tool for porting each lib is exactly the wrong approach
18:27:03disrupteksometimes a library is just a means to an end. it's not a fashion statement and it's not a political treatise and it's not a bomber's manifesto.
18:27:06dadadait's still very cool, and if it works I appreciate it!
18:27:29*JustASlacker joined #nim
18:27:46Araqdadada, ikr, hence I wrote c2nim
18:27:51FromDiscord<mratsim> Nim concepts predates C++ @DeltaPHC
18:28:08FromDiscord<DeltaPHC> Does it?
18:28:11Araqmratsim: not really
18:28:12rayman22201We also got nimterop based on tree-sitter as an attempt to modernize wrappers.
18:28:33dadadathat one looks promising :D it would be best if there were multiple such tools
18:28:38Araqthere have been C++ concept concepts and Nim's concepts were heavily inspired by them
18:28:51dadadathat way if one fails you can try the next one until one works
18:29:14AraqI massage the input code until it works with c2nim instead.
18:29:21rayman22201We already have 2 and a half, c2nim, nimgen, nimterop
18:29:31rayman22201How many do we need lol?
18:29:59disruptekno more than it takes.
18:30:05Araqone more, one that can wrap Qt
18:30:06dadadamy point is that you can't have too many, but you can have too few
18:30:30disruptekwicked insight right there.
18:30:47FromDiscord<DeltaPHC> C++ concepts were proposed for previous standards from previous years, just that it wasn't until C++20 that it was finally accepted
18:30:55Araqyup.
18:31:13Araqand then they got it wrong in C++20 still IMHO.
18:31:30Araqand so did Nim, see my RFC about it
18:31:42disruptek!rfc concepts
18:31:44disbothttps://github.com/nim-lang/RFCs/issues/168 -- 3Concepts and type-checking generics 7& 19 more...
18:31:54FromDiscord<DeltaPHC> To be fair, it's a rather complex idea and type system feature
18:31:57Araqyes, that one
18:32:26FromDiscord<mratsim> btw @Araq, do you know if this is an easy fix or not? https://github.com/nim-lang/Nim/issues/11142
18:32:26FromDiscord<mratsim>
18:32:26FromDiscord<mratsim> The crypto world is being taken by storms by zero-knowledge proofs and elliptic curve crypto and to experiment/implement them properly you need a modular bigint library.
18:32:26FromDiscord<mratsim> #11142 would really help into having a nice interface by storing all crypto constants in an object.
18:32:28disbotType mismatch on init of static[T] object with T being a static[U] ; snippet at 12https://play.nim-lang.org/#ix=27Qf
18:32:29disbothttps://github.com/nim-lang/Nim/issues/11142 -- 3Type mismatch on init of static[T] object with T being a static[U] ; snippet at 12https://play.nim-lang.org/#ix=27Qf
18:33:34Araqmratsim: I gave it a try and despaired
18:33:42FromDiscord<mratsim> ah shoot
18:33:59FromDiscord<mratsim> I'll try another way then
18:33:59Araqmaybe there is a variation
18:34:09Araqthat also doesn't work yet but is easier to fix
18:34:41FromDiscord<mratsim> I would say the alternative would be to have a "static pointer"
18:34:43Araqin theory it's not too hard, in practice it makes me wanna rewrite one or two subsystems inside the compiler...
18:35:03dadadaNim seems to have most of the features of go... it should be easy to interface with go code?
18:35:13dadadathere's a way to interface with go code from c
18:35:26FromDiscord<mratsim> it even has go GC
18:35:54FromDiscord<mratsim> but yes compile nim as a dll, call from Go
18:35:58Araqdadada, Go doesn't interface well with other natively compiled languages because of its growable stacks. IMHO
18:36:50FromGitter<zetashift> cgo it's called right? I read that it isn't a smooth interop
18:37:29dadadawell, since there are a bunch of great go libs calling go code from within Nim seems the most useful to :D
18:37:32rayman22201Araq: I would love to get your thoughts on our async leak if you have a chance. Have you seen my latest minimal repro?
18:38:05dadadazetashift: https://medium.com/@ben.mcclelland/an-adventure-into-cgo-calling-go-code-with-c-b20aa6637e75
18:39:34disruptekrayman22201: i'm not even sure the hand-written version is safe anymore.
18:39:50*dcmertens joined #nim
18:40:08rayman22201What do you mean?
18:40:37dadadathis year qt6 might get released with some c++17 rewrites, one can only hope they're working on getting rid of their metacompiler, would make interop easier
18:42:32rayman22201Or I should say. I trust the hand written one because I have a pretty deep understanding of the macro and I know how to translate back and forth. It's one of my main Nim area of expertise.
18:43:24shashlickNice link
18:43:45disrupteki don't think it's wise to pass a cursor on the future to the callback.
18:44:28Araqrayman22201, I'm listening and have a couple of hours time
18:44:34rayman22201https://play.nim-lang.org/#ix=27Hd
18:44:39rayman22201the following example leaks
18:44:43rayman22201and I don't know why
18:44:53shashlickI'm not too attached to the wrapper gen portion of nimterop
18:44:55rayman22201and I'm not even setting the callback on the future
18:45:08shashlickNimgen is dead and nimterop can use c2nim
18:45:49shashlickTomorrow if we get more tools that can wrap, they will be supported by nimterop
18:46:30rayman22201what is telling to me, getOccupiedMem, shows no leak, but valgrind shows a leak.
18:46:39rayman22201I trust valgrind more than getOccupiedMem
18:47:03AraqgetOccupiedMem is not working with -d:useMalloc
18:47:13shashlickI am reimplementing the toast backend to use the nim ast and renderer but it is a long road even for parity with what toast can do today
18:47:56*Kaivo quit (Quit: WeeChat 2.7)
18:47:56shashlickAnd too many fun projects distracting me but nothing new there for anyone
18:48:15dadadaAraq: just my 2 cents, I believe it's not preferable spending your time recreating another C/C++ parser when multiple other more generalized projects (swig, clang, probably many more, ...) have done so, clang of course is perfect in that it will always follow the C++ standards closely, but on the other hand the swig project has a close to 25 year history with new languages keep being added and new releases
18:48:18disruptekwell, we know it's a future. there are only so many code paths.
18:48:21dadadaeach year, so discounting it is a mistake in my opinion
18:49:06disruptekshashlick: long road, but a much better result.
18:49:08shashlickdadada: I'm still not convinced by clang since it is such a big dependency
18:49:20dadadaAraq: but still, skimming over the swig code I completely understand that no one wants to put in the work, it's massive headache to be sure
18:50:00shashlickArguably you could create generic wrappers which also include all preprocessor translations into Nim compile time code
18:50:23shashlickBut I'd try if we had infinite time
18:50:28dadadashashlick: QtCreator is also using clang as a runtime dependency, but with developers today regularly using 16 GB RAM and a 1TB SSD for 100 bucks there's really no point in saving in the wrong place
18:50:42shashlickI know gogolxdong is trying that
18:51:05dadadashashlick: if the final user of the code (user of app/service) doesn't suffer by a dependency it shouldn't matter too much
18:51:09rayman22201Disruptek / Araq I'm convinced the leak is related to cursors and closure iterators and not futures
18:51:09Araqdadada, sure but c2nim already exists now and back then it was the best option around
18:51:25shashlickI know tree-sitter gets no love but it is quite good at what is does
18:51:41disruptekhmm, i will look again, but i think i got it down to just 56 bytes. i got it pretty tight.
18:52:06rayman22201It's not the size that matters but the reason why
18:52:11dadadaAraq: not trying to pick on you! Indeed I'm star struck, good work! Nim is one of my favorite languages to keep track of.
18:52:43shashlickAraq - by the way, I'm using $nim to build the compiler portions into nimterop now so we should do the same for c2nim as well instead of copying source over
18:53:03shashlickIt works well all the way back to 0.20.2
18:53:06dadadashashlick: tree-sitter looks very interesting, too
18:53:21rayman22201Disruptek Notice, Your version returns the future and my version returns nil, but still leaks.
18:53:25shashlickdadada I like how portable it is
18:53:59shashlickNimterop worked seamlessly with musl as well
18:54:10shashlickSo in theory, it can work for any target
18:54:13disruptekyes, but the sum doesn't matter.
18:54:17*JustASlacker quit (Ping timeout: 265 seconds)
18:54:19FromGitter<zacharycarter> mratsim: I'll work on a weave example for the pathfinding tomorrow. Got hung up this evening with stuff
18:54:21disruptekwe have to return the future or async is not useful.
18:55:01rayman22201It's also not useful if it leaks, and I'm trying to narrow down code paths
18:55:21disruptekokay, but you fundamentally change the way arc works when you return nil.
18:55:35rayman22201No. That's straight from the macro
18:55:36disruptekso it's fundamentally changing your ability to debug.
18:55:50rayman22201It returns nil if the future completes immediately
18:56:03disruptekokay, sure.
18:56:03Araqrayman22201, so which object does it leak?
18:56:05rayman22201Look at the original macro output
18:56:16disrupteki have to switch my compiler around.
18:56:36rayman22201I didn't arbitrarily do that
18:56:37dadadaGSoC deadline is on Feb 5 , would be a great boost for the project
18:56:48disrupteki also modified async some, so i guess it's possible we're looking at different inputs.
18:57:03rayman22201Araq: good question
18:57:20rayman22201I believe it's still the future. 72 bytes
18:57:51rayman22201Somehow it's not acting like a cursor?
18:58:15Araqon the contrary, when it is a cursor, its destructor isn't called and then it leaks
18:58:24disruptekthis.
18:58:30Araqso it's "acting like a cursor too much"
18:58:42disruptekbut the other possibility is that the closure cannot supply a cursor.
18:58:52disruptekone of those two things.
18:58:55rayman22201Maybe this
18:58:57rayman22201Yeah
18:59:29disrupteki think gcc is inifinite-looping on passaux.nim
18:59:40disrupteki don't even...
19:00:20rayman22201My next step is to analyze the generated c again more closely, but I wanted some insight first.
19:02:40Araqrayman22201, I'm not sure we support .cursor for closures
19:02:59rayman22201That might be the problem?
19:03:01disruptekwell, that explains that.
19:03:16Araqnever mind, it is supported
19:03:25disruptekalso, dom96 looked at this and came to the same conclusion.
19:03:35disruptekis there a test?
19:04:28dom96the example I saw which didn't leak had the closure iterator removed
19:04:56disruptekhmm, i'm getting no leaks right now. maybe my test is broken.
19:04:57rayman22201The closure iterator is definitely the source of the leak
19:05:27dom96here is what I tried: https://gist.github.com/dom96/bd14faf86a426d9365a95ff49e74e74a
19:06:07rayman22201That still leaks iirc
19:06:21dom96yes
19:06:33rayman22201Basically the same thing I did to start
19:06:45rayman22201Then I narrowed it down to the closure iterator
19:07:41disruptekah, it's malloc.
19:07:49disruptekit leaks with useMalloc but not our alloc.
19:08:02rayman22201Fascinating!
19:08:08disruptekyeah, that explains a lot.
19:08:27disruptek🤯
19:09:05disruptekokay, i'm on head now.
19:09:42FromDiscord<Clyybber> Araq > in theory it's not too hard, in practice it makes me wanna rewrite one or two subsystems inside the compiler...
19:09:42FromDiscord<Clyybber> I mean, thats a good thing? After the work is done I mean :p
19:09:52Araqrayman22201, it leaks for me
19:09:59Araqtoo without -d:useMalloc
19:10:07Araquse -d:useMalloc + valgrind
19:10:07rayman22201Damn
19:10:21Araqor use no malloc and getOccupiedMem()
19:10:39disruptekwhich test is this?
19:10:43Araqso the good news is: I can reproduce
19:10:50rayman22201Yay
19:10:55Araqand I'm using a different OS and a different allocator
19:11:08Araqdisruptek, https://play.nim-lang.org/#ix=27Hd
19:11:09disruptekso what's different...
19:11:12Zevvdisruptek: what is your testcase?
19:11:21disrupteki will publish.
19:11:23Zevvlet me see if it is related to the stuff I touched over the last days
19:11:47disruptekhttp://ix.io/27Qt
19:11:59AraqClyybber: sure but I have "compiler rewrites" scheduled for 2021
19:12:06disruptekthis is what i use to diff the cfgs and the c output
19:12:28disruptekhttp://ix.io/27Qu/nim -- my current test.nim
19:14:48ZevvI think the malloc test is fair, the nim alloc test not
19:14:58Zevvnim allocs a huge block and just frees that on the end, or is that not so?
19:15:13disruptekpretty sure we critically must work correctly with malloc.
19:15:48disruptekbut of course we can still draw some conclusions.
19:15:49Zevv var fut = asyncProc()
19:15:55Zevvis the line leaking according to valgrind
19:15:57Zevvbut you kew that
19:17:06disruptekwell, we lift loop vars. this might not be wrong.
19:17:48disruptekno, it's wrong.
19:17:56rayman22201🤣
19:18:45Zevvdisruptek: does it make sense to minimise the test case first
19:18:54Zevvinspecting the C is no fun like this
19:19:12disruptekyou're not enjoying yourself?
19:19:25disrupteki get a real flow going.
19:19:30ZevvI've been looking through generated C code quite a bit recently
19:19:37Zevvand I so friggin' *hate* it
19:19:55rayman22201Disruptek is a masochist
19:20:06disruptekokay, so we have the full async and we have the hand-written async.
19:20:15disruptekyou want a sync version now?
19:20:22Zevv free(((void*) ((NI)((NU64)(((NI) (ptrdiff_t) (p))) - (NU64)(((NI) 8))))));
19:20:31Zevvstuff like that is so much fun
19:21:02disruptekthat's the bit i thought we were seeing in your nimmin branch.
19:21:06disruptekminnim
19:21:10disruptekwhatever it is.
19:21:34disruptekhow do you propose to reduce it?
19:21:49rayman22201"Hand Written" implies it's arbitrary. It was a carefully crafted minimal sample that very closely adheres to the same rules the macro follows.
19:22:08disrupteki know.
19:22:35disruptekso again, how do you propose to reduce it?
19:23:01rayman22201I already did?
19:23:06Araqso do you want me to understand it or not
19:23:24Zevvdisruptek: sorry, it was 80% out-whenned code, I didn't notice that yet
19:23:40Araqif so, be quiet
19:23:48Zevvyessir
19:25:58dom96just tried to compile my game with --gc:arc and received a type mismatch on `repr` taking a uint8 of all places
19:27:18dom96do we have a different implementation of repr for --gc:arc?
19:27:55Zevvno repr with arc, afaik
19:28:14dadadawhat is the best way to promote Nim? I think writing apps. This is really why I brought up Qt5... also another great idea is to target webassembly!
19:28:16disruptekis or will be replaced with $
19:28:19*JustASlacker joined #nim
19:28:38Araqdom96, indeed we do
19:28:46dom96why wouldn't we have repr with arc?
19:28:46AraqI wrote a new repr for --gc:arc, was the easiest solution
19:28:54*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:29:00dom96anyway, after fixing that: https://gist.github.com/dom96/e1d4dbe78e29450b55af59a9cf6d46ec
19:29:03Araqbecause we don't have useful RTTI
19:29:06dom96It doesn't even manage to load my config json
19:29:21Araqstrange
19:29:32AraqI personally ensure all the json tests are green
19:29:37Araqwith --gc:arc
19:29:39Araq*ensured
19:29:51dom96maybe there is a corruption somewhere
19:29:52disruptekopenapi runs with json at compile-time in arc.
19:30:25disruptekand thus, runtime.
19:32:32dadadaAraq: did you choose echo to make echo "hello" look similar to shell code, in that case why not drop the echo &"hello {var}" syntax for echo "hello ${var}" , this would make the lang an even better shell code replacement, you could use something like $$ when the dev means a literal $
19:32:47disruptekactually, nevermind. the tests are purely runtime for openapi.
19:33:00dadadasorry for weird wording of my question, hope you get what I mean
19:34:08dadadai.e. echo "hello $${var}" prints "hello ${var}" and echo "hello ${var}" prints "hello 22" (if var == 22)
19:34:23FromDiscord<Clyybber> Zevv; nice!
19:34:35FromDiscord<Clyybber> (making seqs/strings smaller)
19:34:38ZevvClyybber: ?
19:34:42Zevvoh yeah right
19:34:58Zevvthanks.
19:35:37Araqrayman22201
19:35:44Araqvar closureIter_window: typeof(asyncClosureIter) # leak gone
19:35:54Araqyou cannot make this a .cursor, it causes the leak
19:36:05Araqand in retrospect it's obvious why
19:37:02Araqcase closed, I'm allowed to watch Columbo now.
19:37:07rayman22201Lol
19:37:33rayman22201The closure environment leaks in this case
19:37:43rayman22201Hrmm
19:37:46Araqexcept that we only have one TV and my wife is watching some other crap
19:38:10rayman22201Lol. Wife always wins 😛
19:38:31disrupteki cannot repro that.
19:39:06rayman22201The wife or the cursor? Lol
19:40:19disrupteki cannot reproduce leak-free async on -d:useMalloc.
19:42:00disrupteknameIterVal doesn't need a cursor but who cares. i'm still leaking.
19:42:19*nsf quit (Quit: WeeChat 2.7)
19:43:09rayman22201Yeah... Even if it worked, it puts me back to square 0. Adding the second closure back in still leaks
19:43:33Araqfor me without the .cursor the leak is gone
19:43:49Araqso now you need to give me a bigger example program that leaks
19:44:32rayman22201yeah. confirmed, removing the cursor doesn't leak for me. Building the larger example now. stand by
19:44:45dom96can you guys post your full code?
19:45:08rayman22201actually, it's just the original: https://play.nim-lang.org/#ix=27H5
19:45:11dom96It's incredibly confusing to see you say "it doesn't leak for me" without specifying exactly what code you're using
19:45:18shashlickWe need some docs on using valgrind with Nim
19:45:32*zielmicha__ is now known as zielmicha
19:45:42shashlickAnd more formal tutorial using gdb as well
19:45:52*zielmicha is now known as zielmicha__
19:46:02*JustASlacker quit (Ping timeout: 258 seconds)
19:46:04shashlickWhen things get hard in Nim, you end up in the deep end with almost no help
19:46:04rayman22201we are posting the code Dom. We aren't going to post it with every comment
19:46:10dom96rayman22201, and that leaks?
19:46:42shashlickAnd it is sometimes hard to minimize code samples to ask people to help
19:47:22disruptekwell, i cannot reproduce this success.
19:47:40rayman22201that's strange. My valgrind shows no leaks when I take out the cursor
19:47:52rayman22201@dom96 @disruptek: here is the recap: https://play.nim-lang.org/#ix=27QF
19:48:49dom96okay, and when you apply this to the full code generated by the async macro does it still leak?
19:48:49rayman22201which brings us back to the full macro output + cursor annotations here: https://play.nim-lang.org/#ix=27H5
19:49:02rayman22201similar to what you did originally Dom
19:49:13rayman22201we came to similar conclusions independently I think
19:49:40FromDiscord<Clyybber> shashlick: For gdb theres a video tutorial by krux
19:49:49rayman22201which means, the leak is somewhere else. idk where
19:49:49FromDiscord<Clyybber> and for valgrind its just -d:useMalloc
19:50:08FromDiscord<Clyybber> ~valgrind is use -d:useMalloc
19:50:08disbotvalgrind: 11use -d:useMalloc
19:51:17shashlickYes but all these tutorials are spread out, we need a page on in our manual collating it
19:51:28shashlickDebugging or something
19:52:15rayman22201@dom96, @araq, @disruptek, here is a slight modification sot the iterator also uses the cursor Future: https://play.nim-lang.org/#ix=27QG
19:52:48rayman22201Here is the valgrind output from this https://www.irccloud.com/pastebin/DWzaoLTp/
19:53:18rayman22201The interesting part to me is this line: asyncProc__rLFS7Q9b7yfzqBp3gcbvCKw (@mbasicAsync.nim.c:816)
19:53:41rayman22201that is the closure environment for the second closure (If I understand the C correctly.)
19:54:09rayman22201specifically the closure environement for `asyncProcNimAsyncContinue_400016`
19:57:20disruptekyou're not including the closure cursor in the iterator.
19:57:50disruptekonly the future cursor matters.
19:58:11rayman22201that's not what valgrind says
19:58:56disrupteki'm looking at the playground paste.
19:59:03rayman22201I don't understand what you mean "include the closure cursor in the iterator"?
19:59:14rayman22201you should probably look at things before you make comments, as a general rule
19:59:40disruptekthat's why i'm commenting.
20:00:24rayman22201If anything, I expect the closure to not live long enough, since the callback gets a cursor to the closure.
20:01:12disruptekyou're right, i wasn't looking at the right link.
20:01:18rayman22201the only strong ref to the closure is the proc itself, which should free the closure on return, but it is apparently not doing that?
20:03:17rayman22201unless I'm missing some other strong ref somewhere?
20:03:55Araqyou do but nothing I try works either :P
20:04:37rayman22201you tease. what strong ref am I missing? :-P
20:04:54rayman22201but also, :-(
20:05:17AraqI have
20:05:18Araq var asyncProcIterOwner = asyncProcIter_400015
20:05:18Araq var nameIterVar_gensym400018 {.cursor.} = asyncProcIterOwner
20:05:39Araqand also
20:05:42Araq var closureWindow: typeof(asyncProcNimAsyncContinue_400016)
20:05:44Araq var closureWindowUnowned {.cursor.}: typeof(asyncProcNimAsyncContinue_400016)
20:05:46Araqbut no luck, the leak remains
20:06:00Araq(no need to run it a loop btw, it leaks on the first iteration)
20:06:15disruptekwell, i said that but you said it was fixed. 🙄
20:06:27rayman22201the loop was an artifact of earlier testing. ignore that. sorry
20:10:05*Vladar quit (Quit: Leaving)
20:10:57*ptdel quit (Ping timeout: 260 seconds)
20:12:03Araqwant to see my solution?
20:12:13rayman22201yes
20:12:26rayman22201but now I'm worried
20:12:32Araqbasically I removed the crap and it works :-)
20:12:56rayman22201show me the crap! :-P
20:13:12Araqhttps://play.nim-lang.org/#ix=27QO
20:13:26Araqnot sure if the macro can produce this instead but it seems do-able to me
20:14:13disruptekyes, you're two days behind me, araq. 😜
20:14:23rayman22201it looks like you just pulled out the error handling?
20:14:37Araqdoesn't matter, the error handling doesn't leak
20:15:10dom96what is the actual change to the original generated by the macro?
20:15:15rayman22201exactly
20:15:17rayman22201this?
20:15:21rayman22201I don't understand what changed
20:15:27disruptekwell, that leaks for me.
20:15:40Araqstart
20:15:42Araqhello sailor green eggs and ham
20:15:43Araqfinish
20:15:45Araqextra Mem: 0
20:15:49Araqit really doesn't
20:16:00disruptek-d:useMalloc
20:16:06dom96for reference, here is what the macro generates: https://gist.github.com/dom96/a4f8754f646e95a03985fa91b56172c3
20:16:19Araqthe most important change is that I gave the anon proc a name
20:17:11AraqI don't understand why the macro doesn't do that, it simplifies things quite a bit
20:17:31Araqand it's still a .closure so we're good
20:18:28rayman22201confirmed it does not leak for me
20:18:38Araqand once you have the named proc, all you need to do is watch out for captures
20:18:39rayman22201still trying to understand what magic you did Araq lol
20:19:05Araqand we probably need better support for a more precise control over captures
20:19:15disruptekso we can'd useMalloc with arc?
20:19:28rayman22201I tested with useMalloc
20:19:30rayman22201no leaks
20:19:32Araqdisruptek, we can and do it all the time
20:19:43disrupteki cannot repro this.
20:20:01Araqdisruptek, ok, so where does it leak for you?
20:20:02*jjido joined #nim
20:20:13rayman22201disruptek, I have a feeling your codebase may have drifted? mayb start from head again?
20:20:28disruptekholdon, let me c+p araq's stuff again.
20:21:04disruptekyep, it's fine.
20:21:06disrupteksorry.
20:21:08rayman22201the closure does have a name, "asyncProcNimAsyncContinue_400016"
20:21:17rayman22201it looks like you just changed the name to "inner"
20:22:01Araqno, it's not a 'var' anymore
20:22:09Araqplease read it carefully
20:22:26dom96Araq, can you modify the original again without removing other things?
20:22:37dom96just the changes necessary to get rid of the leak
20:23:02Araqbah, all that is missing the 'assert' logic
20:23:10Araqbut ok, let me try
20:23:41rayman22201ah. interesting. it was me that changed it to var
20:23:47rayman22201the macro doesn't do that
20:24:53rayman22201son of a bisket
20:25:04rayman22201biscuit even
20:25:23rayman22201why does that matter?
20:25:46disruptekmy closure has a first name, it's OSCURLE
20:25:53Araqrayman22201, maybe it's a bug in injectdestructors.nim
20:26:06Araqbut since it's so convoluted anyway, why not fix our macro instead?
20:26:26Araqdom96, what to base it on?
20:26:31rayman22201I agree. This is a straightforward fix the macro. but why not both? lol
20:26:33disruptekitym in addition to
20:26:33dom96my gist
20:26:40Araqhttps://play.nim-lang.org/#ix=27QG ?
20:26:50dom96https://gist.github.com/dom96/a4f8754f646e95a03985fa91b56172c3
20:27:07Araqok
20:27:56FromDiscord<itmuckel> Hey guys! How do I write a `=destroy` function for a `ref object` type?
20:28:47rayman22201@dom96 https://play.nim-lang.org/#ix=27QV
20:28:54rayman22201That's the fix
20:29:00lqdev[m]@itmuckel you don't, instead create your ref type with `new(x, proc () = discard)`
20:29:05lqdev[m]the second param is the finalizer
20:29:35FromDiscord<itmuckel> oh okay, thanks!
20:29:36lqdev[m]change the `proc () =` to `proc (x: MyRefType)`
20:29:54lqdev[m]see https://nim-lang.org/docs/system.html#new%2Cref.T%2Cproc%28ref.T%29
20:29:56rayman22201make `retFutUnown` and `nameIterVar` into cursors
20:30:28dom96https://gist.github.com/dom96/e3a9c381993aefffad3dd241d5a4b489/revisions#diff-51d3f11ded3e2aea5be62d7d3a33e651
20:31:43rayman22201yup
20:33:21dom96okay, should be fairly trivial macro change then
20:33:27Araqdom96, replied on your gist
20:34:07disruptekif nameiter isn't a cursor, we leak in malloc but not nim.
20:35:29rayman22201this. Also, I think we may need a more complicated example, because the iterator needs to be able to live longer.
20:36:01*asd joined #nim
20:36:11disruptekwe have longer tests in stdlib.
20:36:12rayman22201it works in this case because the promise completes immediately, but now we need to test a case where it takes some iterations of the async event loop to complete
20:36:29dom96easy test: use sleepAsync
20:39:10rayman22201good idea.
20:39:16rayman22201bah. I have to go. bbl
20:39:31Araqok, bye
20:39:38*asd quit (Remote host closed the connection)
20:42:31Araqdom96, about your json problem, run it via 'nim c --gc:arc --debuginfo -d:useMalloc foo.nim && valgrind ./foo'
20:42:40Araqand see what it turns up
20:42:43*narimiran quit (Ping timeout: 260 seconds)
20:46:24*JustASlacker joined #nim
21:00:52*Hideki_ joined #nim
21:05:28*Hideki_ quit (Ping timeout: 268 seconds)
21:09:30*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:21:30*logand`` quit (Ping timeout: 268 seconds)
21:32:08Zevv~.
21:32:09disbotno footnotes for `.`. 🙁
21:33:15*ronny joined #nim
21:33:33ronnyhi
21:34:18ronnyis there a siggested library/structure to use when creating commands with subcommands (similar to git + its subcommands)
21:35:43disruptek!repo cligen
21:35:44disbothttps://github.com/c-blake/cligen -- 9cligen: 11Nim library to infer/generate command-line-interfaces 15 140⭐ 11🍴 7& 1 more...
21:35:58*Trustable quit (Remote host closed the connection)
21:39:00*leorize joined #nim
21:52:00*tane_ quit (Quit: Leaving)
21:55:56ronnynimble search after nimble update complains about missing ddescription in packages.json ?
21:55:59*dadada quit (Ping timeout: 258 seconds)
22:03:39*JustASlacker quit (Ping timeout: 258 seconds)
22:06:26FromDiscord<Clyybber> !repo nimph
22:06:26disbothttps://github.com/disruptek/nimph -- 9nimph: 11Nim package hierarchy manager from the future 🧚 15 52⭐ 2🍴 7& 1 more...
22:08:43shashlickis it possible to have different proc signatures depending on a when condition
22:08:54disrupteksure.
22:08:55shashlickwant to see if async and no async can coexist in the same file
22:09:08shashlickbut same body
22:09:24disruptekmmm just use a template.
22:09:36shashlickhow
22:09:47shashlickah okay
22:09:50disruptekyeah.
22:14:46*letto quit (Ping timeout: 258 seconds)
22:20:11shashlicknope, says await only available within .async.
22:20:20disruptekwell, yeah.
22:20:47shashlickhttp://ix.io/27Rp
22:23:11*letto joined #nim
22:25:46*opal quit (Remote host closed the connection)
22:25:59*opal joined #nim
22:28:23*ptdel joined #nim
22:30:22*Hideki_ joined #nim
22:35:41*solitudesf quit (Ping timeout: 272 seconds)
22:36:03*opal quit (Ping timeout: 240 seconds)
22:36:07*dcmertens quit (Ping timeout: 268 seconds)
22:37:39shashlickfigured it out but async still doesn't work
22:38:18shashlickhave to return number of bytes written in curl's write callbacks and it doesn't get the value with Future[int]
22:38:39shashlickbasically running async code in cdecl callback
22:39:12disruptekand you cannot get a return value into your proc?
22:39:22disruptekor you cannot get it to come back out in the Future[int]?
22:39:30*opal joined #nim
22:39:41shashlickit does come back but curl probably doesn't get what i returned
22:39:49shashlicki'm returning to curl
22:40:58disruptekdoes it work if you `waitfor` the async proc?
22:41:24shashlickbut i'm not the caller, curl is
22:41:40disrupteki wouldn't expect this to work.
22:41:42shashlickbasically this proc - https://github.com/genotrance/px2/blob/master/curl.nim#L29
22:41:55shashlickheaderCb is called by curl when it has headers to write
22:42:12shashlickso I need to mark the proc as Future[int] {.async, cdecl.}
22:43:26disruptekthis is nuts. why do you have to do this?
22:44:20shashlickchanging await to waitFor in the callback and removing the async from the signature worked
22:45:07disruptekyeah, why do you need to use async?
22:46:34disruptekyou're a wild man, shashlick.
22:47:02*pbb quit (Ping timeout: 252 seconds)
22:48:39*pbb joined #nim
22:50:04dom96ronny: can you try again? I fixed the description
22:51:55*Hideki_ quit (Remote host closed the connection)
22:53:04shashlickwell, this is going to be a multi-connection proxy server so it needs to be able to do things in parallel
22:53:07dom96Araq, just did what you suggested, so far valgrind appears to be stuck.
22:53:46shashlickit is unclear if it will really work in async mode cause curl might just block on perform()
22:54:07shashlickbut now i have a single threaded, single threaded async and multi-threaded version
22:54:20shashlickneed to check if it works as expected in each mode and the benefits
22:54:22dom96Araq, yep, I'm killing it. It's using 100% CPU and not doing anything, here is the output it gave: https://gist.github.com/dom96/f5f16d962cad189dab6a788cc2593d49
22:55:44shashlickwhat's a good load testing tool that supports proxies
23:05:36*voltist joined #nim
23:24:51*ptdel quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
23:24:54*Hideki_ joined #nim
23:27:51*ptdel joined #nim
23:29:31*Hideki_ quit (Ping timeout: 258 seconds)
23:30:50*pbb quit (Ping timeout: 240 seconds)
23:46:53*Hideki_ joined #nim
23:47:50rayman22201@dom96, @disruptek, @araq, I can't stay, but I added the cursors to the correct places in the async macro
23:47:50rayman22201https://github.com/rayman22201/Nim/commit/39c1131a7d8f6d5b46d4aec78206f01a90b868f8
23:48:06rayman22201bad news. It breaks with sleepAsync :-(
23:48:40rayman22201use this test: http://ix.io/27RJ
23:49:30rayman22201weirdly, with useMalloc and valgrind it gives bad reads. With nim alloc it just leaks. bad either way
23:51:51rayman22201I believe it's the lifetime issue I spoke of earlier
23:57:03*NimBot joined #nim