<< 30-09-2018 >>

00:00:57*LeoNerd24 quit (Killed (Sigyn (Spam is off topic on freenode.)))
00:36:04*vlad1777d quit (Ping timeout: 240 seconds)
00:38:40*dddddd quit (Remote host closed the connection)
00:39:50*Robe2 joined #nim
00:46:16*Robe2 quit (Remote host closed the connection)
00:51:57FromGitter<adam-r-kowalski> What are you’re thoughts on having some sort of numeric tower defined in terms of concepts like Haskell does? Something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb01e2d2e0e027fb9947cce]
00:52:37FromGitter<adam-r-kowalski> That way we don’t have to limit ourselves to int64/int32/etc but people can make their own int types and have them work as fully first class numeric types
00:57:06*skellock quit (Quit: WeeChat 1.9.1)
01:00:04*elrood quit (Quit: Leaving)
01:03:59*Guest1907827 joined #nim
01:06:59*Guest1907827 quit (Remote host closed the connection)
01:09:14*_0ffh joined #nim
01:14:32*velix8 joined #nim
01:16:47*mpk3 joined #nim
01:17:20*_0ffh quit (Quit: leaving)
01:20:03*mpk3 quit (Remote host closed the connection)
01:25:03*velix8 quit (Ping timeout: 245 seconds)
01:42:35*EvilBill21 joined #nim
01:43:48*a_chou joined #nim
01:45:28*EvilBill21 quit (Remote host closed the connection)
01:49:12*a_chou quit (Remote host closed the connection)
01:49:29*a_chou joined #nim
01:51:19FromGitter<gogolxdong> what does bind do ?
01:55:31FromGitter<dm1try> @kayabaNerve ⏎ ⏎ > The 1st async function used to resume after the sync function called the 2nd async function and returned. ⏎ ⏎ AFAIK, it will only return if the second async function yields control somehow(ex. `await sleep_async(1)`) [https://gitter.im/nim-lang/Nim?at=5bb02d135af485306839be2b]
01:58:31FromGitter<dm1try> at least in the current implementation(though not sure about old versions of `asyncdispatch`)
02:19:10*a_chou quit (Quit: a_chou)
02:33:15*raehik joined #nim
02:39:53*raehik quit (Remote host closed the connection)
02:40:48*seppia joined #nim
02:42:34*seppia quit (Remote host closed the connection)
02:54:42FromGitter<kayabaNerve> @dm1try It works on Linux.
03:00:34FromGitter<kayabaNerve> Some async thing was changed that only changes effects on Windows and I'm trying to minimize it.
03:01:15FromGitter<kayabaNerve> My codes in multiple files so it's tricky too
03:13:23*smt quit (Read error: Connection reset by peer)
03:22:06FromGitter<kdheepak> Hi all. I'm still struggling with the ref and non ref objects in Nim.
03:22:15FromGitter<kdheepak> I wanted to ask a few questions.
03:23:00FromGitter<kdheepak> Perhaps this is just my lack of understanding, but I'm struggling to understand this from the documentation and from the resources that various people have linked here in this chat room.
03:23:35FromGitter<kdheepak> I have this very simple code base as an example to discuss. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb041b619b139275a20f07c]
03:25:53FromGitter<kdheepak> Here is my understanding so far: ⏎ ⏎ in C, after a struct is defined, it can be created using either on the stack allocation or on the heap. i.e. if it is created on the stack, it is local to the current scope and that memory should not be accessed when the scope has been terminated.
03:26:51FromGitter<kdheepak> The struct that is created on the stack can however be "returned" from a function, in which case it results in copy semantics. This can be an expensive operation for large data structures.
03:28:20FromGitter<kdheepak> In C, when a function is called, a struct that was created on the stack can be passed into the function by value or by reference (i.e. pointer).
03:29:22FromGitter<kdheepak> If the struct is passed into the function by value, it is copied into the function scope, and thus any change does not affect the struct that was allocated on the stack in the main scope.
03:29:43FromGitter<kdheepak> If the struct was passed into the function by reference / pointer, then it can be modifed.
03:30:05FromGitter<kdheepak> Hopefully all that is correct. All the above was for how things work in C.
03:30:56FromGitter<kdheepak> In Nim however, there seems to be two ways of defining a struct, two ways of creating a struct and two ways of passing a struct into a function. And this is where my confusion arises.
03:31:52FromGitter<kdheepak> ``` PersonObj = object of RootObj ⏎ name: string``` ⏎ ⏎ This is the standard syntax for defining a object in Nim, which translates to a C struct. [https://gitter.im/nim-lang/Nim?at=5bb043a7a9be136b94d1d722]
03:32:45FromGitter<kdheepak> And this code works fine, ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb043ddae7be94016dafe36]
03:33:06FromGitter<kdheepak> Based on my understanding, this creates a PersonObj struct on the stack.
03:34:36FromGitter<kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0444cef4afc4f28f6edd1]
03:34:51FromGitter<kdheepak> This results in a compile error.
03:35:27FromGitter<kdheepak> And this works. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0447f19b139275a20fd9b]
03:35:56FromGitter<kdheepak> This is when PersonObj is allocated on the stack, so things make sense.
03:41:59FromGitter<kdheepak> Now when I create a type called PersonRef i.e. ref PersonObj ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Can I get a reference to PersonObj by casting the PersonObj var p to the corresponding type? [https://gitter.im/nim-lang/Nim?at=5bb046076e5a401c2df315be]
03:42:04FromGitter<kdheepak> Does this make sense to do?
03:48:48*chemist69 quit (Ping timeout: 252 seconds)
03:50:34*chemist69 joined #nim
03:54:01FromGitter<kdheepak> I think my main source of confusion stems from the fact that the following works, and I have no clue why: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb048d95af48530683a43b7]
03:54:31FromGitter<kdheepak> Does nim not care about the number of `ref` keywords in front of PersonObj?
03:58:16FromGitter<kdheepak> I just generated the c code to compare the two cases, it seems to be largely identical. There's differences in the random variable names.
04:04:29FromGitter<kayabaNerve> You can have a pointer to a pointer. You can have a ref of a ref.
04:04:50FromGitter<kdheepak> How to make a type that's a ref of a ref?
04:08:16FromGitter<kdheepak> I get this error often and I have no idea what this means: `test.nim(12, 18) Error: object constructor needs an object type`
04:08:46FromGitter<kdheepak> I'm trying to get a ref of ref example working: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb04c4ebbdc0b2505c23ec1]
04:08:56FromGitter<kdheepak> This does not compile.
04:16:19FromGitter<kdheepak> Is there an easy way to ensure that all the seq values of a type object are initialized to empty seq?
04:16:24FromGitter<kdheepak> Or do I have to do it manually?
04:37:03FromDiscord_<demotomohiro> I think seq is always initialized to empty unless you specify initial value even if it is one of object 's field
04:37:51FromDiscord_<demotomohiro> https://wandbox.org/permlink/hMfct7t86kIYzOne
04:37:59FromGitter<kayabaNerve> Now that it's not nil
04:44:21FromGitter<kayabaNerve> @kdheepak ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb054a5271506518d94505f]
04:44:52FromGitter<kayabaNerve> Wait
04:44:53FromGitter<kayabaNerve> Typo
04:45:17FromGitter<kayabaNerve> Fixed
04:46:42FromGitter<kdheepak> Thank you!
04:46:55FromGitter<kdheepak> It looks like this also works: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0553fc08b8b3067ad2d63]
04:47:25FromGitter<kdheepak> Since `p[] = new PersonRef` creates an instance of PersonObj that is allocated on the heap.
04:48:25FromGitter<kdheepak> Thanks @demotomohiro
04:49:04FromDiscord_<demotomohiro> kdheepak: you're wellcome
04:49:40FromDiscord_<demotomohiro> In my understanding, in C, struct can be created on static, stack or heap
04:50:11FromDiscord_<demotomohiro> you can use struct to declare global variable in C
05:02:10*miran joined #nim
06:05:27*stefanos82 joined #nim
06:22:44*stefanos82 quit (Quit: Quitting for now...)
06:52:24*andrzej5 joined #nim
06:54:10*andrzej5 quit (Remote host closed the connection)
06:59:36FromGitter<kdheepak> My nim code is slower than my Python code that does almost the same thing, how do I go about debugging / optimizing my nim binary?
07:00:25FromGitter<kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb074891e23486b9366b480]
07:01:44FromGitter<kdheepak> I'm actually genuinely surprised by this. My Python code was very hacky / just a prototype, and I was expecting my naive Nim implementation to be better than that.
07:02:05FromGitter<kdheepak> I think I just have a lot more to learn about Nim!
07:07:58FromGitter<ephja> @kdheepak try this https://nim-lang.org/docs/nimprof.html
07:08:24Araqjust post your code on the forum, people will optimize it to death for you
07:09:57FromGitter<kdheepak> Thanks! I'll look at that!
07:10:44FromGitter<kdheepak> Haha @Araq that would be great! Unfortunately I have to go through the legal department at my organization before I can post it anywhere.
07:11:06FromGitter<ephja> has anyone ever stepped over code with a gdb and not have the instructions executed? I need to test it again because that's just weird. I think I was able to skip "assert(false)" and possibly other things
07:11:45FromGitter<ephja> stepping only, no jumps
07:11:53Araqkdheepak: what does the code do? json, parsing by line, ...?
07:12:07Araqdid you compile with -d:release ?
07:12:23Araqdid you put your code in a 'main' proc? (you should)
07:12:33FromGitter<kdheepak> Yes. Parses a domain specific file format to json and prints the json to the screen.
07:12:55Araqdid you try the packedJson module?
07:13:17FromGitter<kdheepak> This is how I've running it. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0778d5af48530683b35de]
07:14:26FromGitter<bung87> think you can post related parts code
07:14:57Araqfor parsing the lines iterator and 'scanf' is better than e.g. the lines proc and those terrible 'split' variants
07:15:15*jeremym10 joined #nim
07:15:30FromGitter<kdheepak> I'm building it using `-d:release`.
07:15:57FromGitter<ephja> that checks if it's the main module, but you should put most code inside some function. name it whatever you want and then call it some time after
07:16:27FromGitter<kdheepak> Yup, all my code is in separate procs, that is called from main.
07:17:26FromGitter<kdheepak> No code is being executed in the "module namespace" (Python speak), if that's what I'm being asked.
07:17:34Araqok, good
07:17:50FromGitter<kdheepak> except type definitions / a couple of const
07:17:57Araqyeah sure
07:18:03*jeremym10 quit (Remote host closed the connection)
07:18:31FromGitter<kdheepak> I can share the profile_results.
07:20:40FromGitter<kdheepak> Added a gist here (https://gist.github.com/kdheepak/fdfd779b19b2e33ab69f3e343cb4f028)
07:21:40FromGitter<kdheepak> One thing I noticed is that the profile_results is not deterministic, changes between runs.
07:22:26FromGitter<bung87> genericSeqAssign this is slow op.
07:23:09FromGitter<bung87> last time I hit performance issue , it take 50% of time.
07:24:17FromGitter<kdheepak> I changed one of my most used objects to `ref object`. New times: ⏎ ⏎ ``` 0.06s user 0.06s system 90% cpu 0.132 total``` [https://gitter.im/nim-lang/Nim?at=5bb07a20c7bf7c366292d88c]
07:24:49FromGitter<kdheepak> That's faster than Python: ⏎ ⏎ ```python test.py 0.08s user 0.04s system 50% cpu 0.253 total``` [https://gitter.im/nim-lang/Nim?at=5bb07a415331811c2e28def3]
07:25:18FromGitter<bung87> guess can be more faster
07:27:04FromGitter<kdheepak> I think so too.
07:27:24FromGitter<kdheepak> I'll be able to share this code in perhaps a couple of weeks.
07:28:24FromGitter<kdheepak> I'm also testing it on really small files at the moment. Should maybe see more difference on larger files?
07:28:25FromGitter<gogolxdong> How to build windows executable on Linux machine?
07:28:37FromGitter<bung87> you will need compare it with c or cpp program in the end.
07:29:04FromGitter<kdheepak> I will have to write c or cpp for that :P
07:29:32Araqin a couple of weeks Nim will optimize the heck out of it
07:30:02FromGitter<kdheepak> ( I've only mainly used Python, Java, MATLAB, Javascript. This is really my first foray into this low level of a language. )
07:30:26FromGitter<kdheepak> @Araq because of new features heading Nim's way?
07:30:48Araqyeah
07:31:06FromGitter<kdheepak> Ooo. Interesting. Can I ask what features?
07:32:04miran"for parsing the lines iterator and 'scanf' is better than e.g. the lines proc and those terrible 'split' variants"; Araq: what do you mean by "those terrible 'split' variants"? splitLines and splitWhitespace?
07:32:38FromGitter<bung87> I ve implemented a lib that faster than a python lib that has python c api .
07:33:30FromGitter<bung87> reduce half time costs.
07:33:36Araqkdheepak: in a way these new features taught me how to optimize high-level Nim code
07:33:43miranso what would be the recommended (fastest) way to read a multiline file?
07:34:08Araqmiran: write a lexer. use lexim, scanf, lexbase or something else
07:34:28miran...or do it at compile time? ;)
07:34:41Araqparsing with 'split' is slow and only works for toys
07:34:55FromGitter<kdheepak> Sounds too good to be true! will be watching!
07:34:57Araqfor instance, take this list of items
07:35:07Araqa b c "d e"
07:35:09FromGitter<kdheepak> My "Lexer" and "Scanner" may need optimizing too.
07:35:33*nsf joined #nim
07:36:11Araqit doesn't work with splitWhitespace(), whitespace here can also be within quotes
07:38:31FromGitter<timotheecour> > *<Araq>* in a couple of weeks Nim will optimize the heck out of it ⏎ ⏎ ya, also curious which features
07:40:58miranAraq: haven't you heard that Araq only wants bug-fixes, no new features!! :P :D
07:43:18FromGitter<bung87> guess it’s not new it’s always in araq’s mind.
07:43:24FromGitter<bung87> for optimizing
07:44:07Araqdon't take me too seriously, I'm still proud of this result: https://github.com/nim-lang/Nim/blob/devel/tests/destructor/tprevent_assign.nim
07:45:21Araqthe move optimizer is starting to work
07:46:38Araqbut moves and code specialization for genericReset/genericAssignment will solve 80% of performance problems for naively written Nim code
07:51:00FromGitter<bung87> the x:int type too simple.
07:52:42*Vladar joined #nim
07:58:22*nsf quit (Quit: WeeChat 2.2)
08:00:03FromGitter<gogolxdong> Foo is object , in allowThis, there are two assignments , b and c are two copies of Foo , yes?
08:01:38FromGitter<gogolxdong> but if changes to ref object , got `Error: signature for '=destroy' must be procT: object (x: var T)`
08:03:30*gmpreussner quit (Ping timeout: 244 seconds)
08:03:53*gmpreussner joined #nim
08:04:07FromGitter<gogolxdong> ah, overloaded ``=`` , is this the syntax works for object only, how about ref object? I see a blueprint without ref in the future, yes?
08:06:19*andjjj230 joined #nim
08:06:46*oem_ joined #nim
08:06:57FromGitter<gogolxdong> for a big object , proc `=` would be tricky.
08:10:49miranspeaking of reading input and scanf, how can i match something that is `$w-$w-$w`, and i want it to be just one match?
08:11:18Araqbung87: the 'x: int' type is irrelevant
08:13:33*andjjj230 quit (Remote host closed the connection)
08:13:58mirani've tried using `$*`, but it doesn't work as i hoped
08:14:18Araqmiran: scanf supports custom matchers
08:14:32FromGitter<bung87> just for show prevent assign? or other type of object same thing?
08:15:40FromGitter<Bennyelg> Hey, How Can I print object memory address
08:16:23miranAraq: so if i want to match "fbqijys-whqii-huiuqhsx-660[qhiwf]", i cannot do: `line.scanf("$*$i[$w]", name, sector, chSum)`, and i need to write a proc to capture the part before first digit?
08:16:46VladarBennyelg: echo object.addr ?
08:17:11Araqbung87: read the example again. *when* does it prevent assignment.
08:17:18FromGitter<Bennyelg> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0868eae7be94016dc4990]
08:17:43FromGitter<Bennyelg> need to cast ?
08:18:04Araqmiran: '$*' would be eager and needs to be replaced with a custom matcher
08:18:13FromGitter<Bennyelg> this works echo (castint (p.addr))
08:18:21VladarBennyelg: convert to string probably
08:18:28Vladaror that
08:18:33FromGitter<Bennyelg> thanks
08:19:19miranAraq: thanks. will do it. i thought i might simplify things with scanf, but i'm back to square one
08:21:15Araqhttps://nim-lang.org/docs/strscans.html#user-definable-matchers
08:21:24Araqshould still simplify your code
08:23:52miranfrom the same page it seems that both $* and $+ should work ("Matches until the token following the $+ was found") for my `$*$i[$w]` example - they should match everything until a digit. but that's not the case
08:24:13Araq$i is not a token
08:24:22Araqit's a matcher
08:24:25miranoh
08:25:12miranyup, works when there is a token. sorry for bothering
08:25:13FromGitter<gogolxdong> =destroy makes sure `otherTree` and `b` goes out of scope be destroyed, only pass c to take2 proc ,right?
08:25:17Araqit could be supported but then it would fail for custom matchers
08:31:15FromGitter<gogolxdong> Foo() allocated on stack, ref object which is usually constructed by new(Foo) allocated on heap ,right?
08:32:32FromGitter<gogolxdong> all local copies of object will be destroyed as long as they goes out of scope, but ref object remains on heap which requires GC.
08:35:09*sagax quit (Ping timeout: 252 seconds)
08:36:50FromGitter<gogolxdong> Object type with destructor becomes superior to ref object in this way.
08:37:42*saho6 joined #nim
08:39:06*saho6 quit (Killed (Sigyn (Spam is off topic on freenode.)))
08:43:37*kalii joined #nim
08:45:23FromGitter<gogolxdong> We used split a lot , need to replace with scanf. TBH, the difference is unknown if not mentioned.
08:46:05*kalii quit (Remote host closed the connection)
08:52:05FromGitter<timotheecour> @araq any chance you could take a look at https://github.com/nim-lang/Nim/pull/9116 please ? I need it for other PR
08:53:12mirannitpicking, but i expected that cases 0 and 1 would not raise "not all cases are covered" for `case i mod 2` :'(
08:55:40FromGitter<codenoid> is nim has interactive console
08:56:00Araqmiran: we did that, it sucked, here is what do use instead
08:56:35Araqtemplate staticMod(x, n): untyped = range[0..n-1](x mod n)
08:57:59mirannice, thanks
09:01:19FromGitter<mratsim> @codenoid in 6 months: https://github.com/nim-lang/Nim/issues/8927
09:03:03FromGitter<mratsim> @timotheecour Optimization in Nim is easy, just remove GenericResets ;) https://github.com/nim-lang/Nim/issues/8745
09:04:57*moei1 joined #nim
09:05:35*moei1 quit (Remote host closed the connection)
09:07:36Araqtimotheecour: Need to decide on a development model first.
09:09:52*jglick6 joined #nim
09:10:58*rogerh joined #nim
09:11:04FromGitter<timotheecour> by that u mean branch for bugfix only (19.X) vs branch for development (devel)?
09:13:17*jglick6 quit (Remote host closed the connection)
09:13:56FromGitter<gogolxdong> @shashlick , nimnuklear doesn't compile on windows10.
09:14:48FromGitter<timotheecour> my take on this: we should never stop development of new features on devel branch; we can create a new stable branch that will only accept cherry picks (or manually edited cherry picks) from devel branch corresponding to regressions, and maybe critical bug fixes.
09:15:13*rogerh quit (Remote host closed the connection)
09:16:12*xet7 quit (Quit: Leaving)
09:16:42FromGitter<timotheecour> dmd follows a similar development model: master vs stable branches; master development are never stopped
09:21:56FromGitter<gogolxdong> nuklear_sdl_gl3.nim(308, 21) Error: type mismatch: got <proc (usr: handle, text: cstring, len: cint){.cdecl, gcsafe, locks: 0.}> but expected 'plugin_copy = proc (a2: handle, a3: cstring, len: cint){.closure.}'
09:22:39*chemist69 quit (Ping timeout: 252 seconds)
09:23:05*chemist69 joined #nim
09:31:07FromGitter<kdheepak> I ran my nim parser on a larger file, and am getting much slower results than in Python.
09:31:33FromGitter<kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb097f5271506518d95a337]
09:32:13FromGitter<kdheepak> I'll just have to share the code before I'm able to make progress on this I think. I've tried everything I can think of at the moment.
09:33:14FromGitter<Bennyelg> @kdheepak can you share your code on gist ?
09:34:28FromGitter<kdheepak> Oddly the profile results don't have as many calls ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb098a4c7bf7c3662937e9c]
09:34:29FromGitter<ephja> oh so there are float ranges now
09:34:41FromGitter<kdheepak> That's the entire profile_results.txt this time.
09:36:07*Tortice joined #nim
09:36:20FromGitter<kdheepak> @Bennyelg it's not a large code base but I don't think I can put it in a gist easily ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb09914ef4afc4f28f89994]
09:36:44FromGitter<Bennyelg> no need the files
09:37:06FromGitter<Bennyelg> just the gist with your code flow both in nim and python
09:38:09*miran quit (Ping timeout: 252 seconds)
09:39:47*oem_ quit (Ping timeout: 252 seconds)
09:42:26FromGitter<kdheepak> I'll be able to share the files in a couple of weeks I think.
09:43:52*nsf joined #nim
09:51:25*geocar joined #nim
09:54:27*jjido joined #nim
09:58:17*jrcloud joined #nim
10:00:11FromGitter<gogolxdong> what's the different between sdl2 only and sdl2+nuklear?
10:02:07*jrcloud quit (Remote host closed the connection)
10:04:48FromDiscord_<Shield> pure sdl2 is just for 2d, sdl2+nuklear is using sdl2 to handle window events and sound while nuklear handles drawing things on screen, and it can do 3d, uses shaders...
10:12:01FromGitter<kdheepak> How to check if a reference pointer has been initialized or not?
10:12:23*dddddd joined #nim
10:12:32FromGitter<kdheepak> I'm getting a Illegal Storage Access error
10:12:40*lagrenouille0 joined #nim
10:15:22*tzui joined #nim
10:15:33FromGitter<kdheepak> I am using the `isNil` magic to avoid this.
10:15:42FromGitter<kdheepak> Please suggest if there's a better way.
10:16:03FromGitter<gogolxdong> clear.
10:16:31*lagrenouille0 quit (K-Lined)
10:16:55*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
10:17:39*tzui quit (Client Quit)
10:19:18*MiVo13 joined #nim
10:22:37*MiVo13 quit (Remote host closed the connection)
10:24:30FromGitter<gogolxdong> sdl2 text field events has issues , the same with a long time ago.
10:25:31FromGitter<gogolxdong> oh, it's nimx's text field
10:26:31FromGitter<gogolxdong> nimnuklear demo works well, but doesn't compile on windows.
10:28:05*tzui joined #nim
10:35:26*krux02 joined #nim
10:37:00*arecaceae quit (Remote host closed the connection)
10:37:19*arecaceae joined #nim
10:45:50*jjido joined #nim
10:50:32FromGitter<gogolxdong> http://ix.io/1nUu
10:52:01FromGitter<gogolxdong> the same problem with zachcater's nuklear-nim wrapping of nk_edit_string,but on windows.
10:53:30FromGitter<gogolxdong> want to build a graphical program for my wife :)
10:54:22FromGitter<kdheepak> Medium size files take a really long time to parse (30k lines). Like 60 seconds or more. Any suggestions on how to debug this?
10:56:08FromDiscord_<Shield> kdheepak it's better to use options when your reference can be nil
10:56:54FromDiscord_<Shield> are you parsing the file line by line? it's better to parse a chunk to a buffer then check for the lines in the buffer
10:58:41FromGitter<vivekimsit> @mratsim thanks
11:05:37*elrood joined #nim
11:07:17*workrat1 joined #nim
11:08:21*workrat1 quit (Remote host closed the connection)
11:09:07*PMunch joined #nim
11:10:34*doom25 joined #nim
11:10:40FromGitter<gogolxdong> Brilliant ! Got it work!
11:15:36*doom25 quit (Remote host closed the connection)
11:15:55FromGitter<gogolxdong> {.cdecl.} for closure as C interoperability on windows.
11:20:19*gb00s quit (Quit: The Lounge - https://thelounge.github.io)
11:22:21*efdee2 joined #nim
11:23:29FromGitter<krux02> @kdheepak what are you parsing?
11:24:42FromGitter<krux02> @kdheepak the main reason why parsing becomes is a parsing algorithm that creates a lot of intermediate objects allocated on the heap.
11:26:55*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
11:28:08*efdee2 quit (Ping timeout: 252 seconds)
11:33:45FromGitter<krux02> the main reason why a parsing algorithm becomes slow is ...
11:33:56FromGitter<krux02> someone ate a few words of my former message
11:38:09FromGitter<mratsim> yeah @kdheepak Seeing your first code examples I’m pretty sure you allocate too much
11:38:56FromGitter<mratsim> Python GC will reuse small buffers, but Nim just returns them to the OS, it’s up to you to reuse heap objects
11:45:41*xet7 joined #nim
11:48:56Torticewith httpclient, can I upload multiple files to the same key?
11:51:01FromGitter<bung87> the question is in HTTP can you upload multiple files to the same key?
11:53:38Torticein python I do this by https://stackoverflow.com/a/20769921
11:54:53FromGitter<bung87> yeah you can upload multiple files one request.
11:55:33*avieks joined #nim
11:57:37FromGitter<bung87> https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L211
11:58:26FromGitter<bung87> https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L423
12:01:32*avieks quit (Remote host closed the connection)
12:11:26*boser7 joined #nim
12:12:03*boser7 quit (Remote host closed the connection)
12:14:52*nsf quit (Quit: WeeChat 2.2)
12:15:58*xet7 quit (Remote host closed the connection)
12:23:03*SenasOzys quit (Ping timeout: 252 seconds)
12:28:20*stefanos82 joined #nim
12:30:31*PMunch quit (Remote host closed the connection)
12:36:25*sku1d8 joined #nim
12:37:19*sku1d8 quit (Killed (Sigyn (Spam is off topic on freenode.)))
12:39:32*elrood quit (Quit: Leaving)
12:40:50*Vladar quit (Remote host closed the connection)
12:41:12*Vladar joined #nim
12:42:04*SenasOzys joined #nim
12:52:02Torticewith ui, how do I use a threadpool to update the ui after a certain number of seconds? I get Error: 'spawn' takes a GC safe call expression trying to use it with sleep
12:55:23*noudle22 joined #nim
12:56:33FromGitter<bung87> `spawn yourProc()`
12:57:24TorticeI have spawn update(count, total, status)
12:57:55*noudle22 quit (Remote host closed the connection)
12:58:11Torticeand update is http://ix.io/1nVv
12:58:35Torticeactually, that's missing $1 and $2
12:59:49Torticethis is update(): http://ix.io/1nVz
13:01:06*vlad1777d joined #nim
13:02:31FromGitter<bung87> not sure you can pass `data ` to the proc
13:03:44Torticeis it not valid? https://nim-lang.org/docs/manual.html#parallel-amp-spawn-spawn-statement
13:05:08Torticedata is just httpclient.newMultiPartData()
13:05:13Torticewith some fields
13:06:19FromGitter<bung87> “We call a proc p GC safe when it doesn't access any global variable that contains GC'ed memory (string, seq, ref or a closure) either directly or indirectly through a call to a GC unsafe proc."
13:06:41FromGitter<bung87> “f must be gcsafe."
13:06:56Torticeoh, you're right - data is global
13:10:14*ToddShepard7 joined #nim
13:10:31*RoboMWM22 joined #nim
13:12:51*gangstacat joined #nim
13:14:17Torticeso here's a simple one, how to fix the type mismatch? https://ptpb.pw/LJ-c
13:14:46*RoboMWM22 quit (Remote host closed the connection)
13:19:07FromGitter<bung87> you messed up with these two index assign ? https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L441
13:19:44FromGitter<mratsim> @Tortice, threadpool are not the proper tool for a longlived UI thread
13:19:55*ToddShepard7 quit (Remote host closed the connection)
13:20:01FromGitter<mratsim> either use async or use createThread for a long-lived thread
13:20:57*w0rp22 joined #nim
13:22:13TorticeIf I messed up the index assignment, then what am I assigning? It should be data["message"], am I assigning something else?
13:24:54*xet7 joined #nim
13:27:29*w0rp22 quit (Remote host closed the connection)
13:27:48*blingrang joined #nim
13:28:32*blingrang quit (Remote host closed the connection)
13:28:51FromGitter<bung87> hmm seems matched, dont know why you got this
13:32:27*nsf joined #nim
13:44:04*smt joined #nim
13:50:00*derlafff quit (Remote host closed the connection)
14:00:00*derlafff joined #nim
14:25:52*tdc quit (Quit: WeeChat 1.5)
14:26:25*tdc joined #nim
14:29:38*Tortice quit (Read error: Connection reset by peer)
14:32:20*derlafff quit (Remote host closed the connection)
14:38:11*tefter joined #nim
14:41:59*SenasOzys quit (Remote host closed the connection)
14:42:48*SenasOzys joined #nim
14:44:01*jjido joined #nim
14:46:19*jjido quit (Client Quit)
14:48:28*jjido joined #nim
14:50:13*lilltiger2 joined #nim
14:51:48*lilltiger2 quit (Remote host closed the connection)
14:53:27*redlegion quit (Quit: Ded.)
14:53:47shashlick@gogolxdong you got it working?
14:55:12*vlad1777d quit (Ping timeout: 268 seconds)
14:59:29FromDiscord_<exelotl> one thing I've been wondering... Nim iterators look and feel a lot like coroutines. Is it possible to use them as such? (i.e. calling an iterator manually to resume it, not as part of a for loop)
14:59:46Yardanicowell, I think you can't really do that
15:00:24*sph joined #nim
15:02:17*redlegion joined #nim
15:02:18*sph quit (Remote host closed the connection)
15:02:21*redlegion quit (Changing host)
15:02:21*redlegion joined #nim
15:04:11FromDiscord_<Shield> that's exactly how asyn functions work, they're closure iterators under the hood
15:05:15FromDiscord_<Shield> the tricky part is knowing how long should a function run before yielding to let other functions get some time
15:06:41FromDiscord_<Shield> nim does have coroutines btw, try those
15:07:38*Tortice joined #nim
15:32:05FromDiscord_<exelotl> yeah, but this doesn't quite seem like what i'm after https://nim-lang.org/docs/coro.html
15:33:11FromDiscord_<exelotl> at least, the docs don't make it clear at all how these are supposed to be used
15:38:10FromDiscord_<exelotl> can you use nim coroutines like this? http://leafo.net/posts/itchio-and-coroutines.html
15:40:02*edcragg quit (Quit: ZNC - http://znc.in)
15:41:17*edcragg joined #nim
15:44:07*erratic joined #nim
15:49:21*vlad1777d joined #nim
15:52:41*SenasOzys quit (Ping timeout: 252 seconds)
15:54:43*elrood joined #nim
16:02:55*SenasOzys joined #nim
16:04:11*rimd2r12 joined #nim
16:05:05*derlafff joined #nim
16:08:25*cori joined #nim
16:11:28*rimd2r12 quit (Remote host closed the connection)
16:13:28FromGitter<Bennyelg> (https://files.gitter.im/nim-lang/Nim/jgqw/image.png)
16:14:17FromGitter<Bennyelg> Finish line.
16:14:18FromGitter<Bennyelg> (https://files.gitter.im/nim-lang/Nim/2Rz9/image.png)
16:15:19*kori joined #nim
16:15:52FromDiscord_<exelotl> nice :D
16:15:59FromGitter<Bennyelg> Oo hehe
16:17:31krux02exelotl: you can't call inline iterators like coroutines, they are in loop only.
16:19:17*kori quit (Remote host closed the connection)
16:19:23*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
16:22:54FromDiscord_<exelotl> ah ok. I have different question now, is there a way to store a struct as 'static const' and take a pointer to it?
16:25:11FromDiscord_<exelotl> I was trying to do e.g. const myVTable = EntityVTable(update: cast[EntityFn](update), draw: cast[EntityFn](draw), .....)
16:25:27*axhanul joined #nim
16:26:06FromDiscord_<exelotl> where EntityFn has nimcall convention so update and draw are just function pointers
16:26:48FromDiscord_<exelotl> but I can't get a pointer to myVTable because 'const' doesn't allow it
16:28:26*axhanul quit (Remote host closed the connection)
16:33:01*tdog joined #nim
16:33:39*tdc quit (Ping timeout: 252 seconds)
16:34:27*Jesin joined #nim
16:38:01AraqunsafeAddr ?
16:39:38FromDiscord_<exelotl> I managed to get it working with unsafeAddr but I had to use `let myVTable` instead of const
16:41:25FromGitter<bung87> why not using const now?
16:41:52FromGitter<bung87> I also tried const table, does not figure out.
16:42:02*Trustable joined #nim
16:46:38FromDiscord_<exelotl> https://gist.github.com/geckojsc/19df2068afc4b5093b8ffe32e471e147
16:50:33FromGitter<bung87> well does not work it out.
17:00:59Torticeplease forgive the spaghetti, but when I uncomment line 33 all of my memory is exhausted and the program is killed http://ix.io/1nWr - what I want to happen is have the GUI updated after 10 seconds
17:02:54*anamok joined #nim
17:04:05anamokHi. How can I format an integer to be divided by thousands? Examples: 2018 -> "2,018", or 1_234_567 -> "1,234,567".
17:04:33*miran joined #nim
17:08:59*TheLemonMan joined #nim
17:09:11TheLemonMananamok, insertSep
17:09:45anamokTheLemonMan, can you give a short example?
17:10:00Torticehttps://nim-lang.org/docs/strutils.html#insertSep%2Cstring%2CChar%2Cint
17:10:21TorticeinsertSep("1000000", digits=3)
17:10:22anamokOK, found it
17:10:25anamokthanks
17:10:40leorize!eval echo insertSep($10000, ',')
17:10:41NimBotCompile failed: in.nim(1, 6) Error: undeclared identifier: 'insertSep'
17:10:50leorize!eval import strutils; echo insertSep($10000, ',')
17:10:53NimBot10,000
17:11:02anamokawesome, this is exactly what I needed
17:12:06TheLemonManI now hate nimble's centralized registry, the package submission process should be automatized
17:18:51AraqTheLemonMan: IMO Nimble should just search github
17:19:12AraqDRY holds for package managers too.
17:19:14Araqbbl
17:20:36FromGitter<dom96> Yep. The process should be automatised.
17:21:01FromGitter<dom96> You keep suggesting this Araq, but this isn’t practical
17:21:04TheLemonManyeah, to be honest I'd just drop the search feature alltogether, google (or whatever your favourite search engine is) is much better than your hand-rolled search (or shithub one, that's terrible right now)
17:21:11FromGitter<dom96> you can’t “just search github”
17:21:34TheLemonMango approach is cool, just let the user drop a list of vcs urls and be done with it
17:21:49FromGitter<dom96> You can do that with nimble too if you want
17:22:00FromGitter<dom96> But then I won’t be using your package :p
17:23:16TheLemonManthat's the main problem
17:23:20FromGitter<dom96> But you know... I made nimble decentralised on purpose to allow anyone to create a package repo
17:23:35FromGitter<dom96> So go for it.
17:23:52Yardanicowe have a user named So in this channel :P
17:24:04TheLemonMana repo/registry makes it not so decentralized in my eyes
17:24:11FromGitter<dom96> Create an improved version or improve what we have
17:28:20FromGitter<dom96> Every decentralised system becomes centralised. Look at git and GitHub
17:28:28TheLemonManI don't think we're in dire need of another package manager
17:28:30FromGitter<dom96> We need a centralised repo for convenience
17:29:59TheLemonManconvenient for who? the end user that in 99% of the times already knows about the package he's about to install?
17:30:52FromGitter<dom96> How do you deal with conflicting names without a single repo?
17:31:32*tiorock joined #nim
17:31:33*tiorock quit (Changing host)
17:31:33*tiorock joined #nim
17:31:33*rockcavera is now known as Guest30569
17:31:33*Guest30569 quit (Killed (weber.freenode.net (Nickname regained by services)))
17:31:33*tiorock is now known as rockcavera
17:32:34TheLemonManlet the user deal with that in the unlikely case that a) two packages share the same name b) the end user needs both
17:32:50TheLemonMangotta optimize for the average case
17:33:24*Voziv1 joined #nim
17:34:11shashlickOnly need centralized for search
17:34:22shashlickCause not everyone knows about packages
17:34:53shashlickThat being said, submitting multiple packages is a pain, have to manually edit the json
17:35:07*Voziv1 quit (Remote host closed the connection)
17:35:09TheLemonMancan't you just use goog.le for that?
17:35:12shashlickSingle packages are easy with nimble publish
17:35:41shashlickGoogle doesn't necessarily mean you will find what you need
17:35:48shashlickYou don't know what you don't know
17:36:50FromGitter<dom96> Google won’t answer questions like “what’s the most popular package?”
17:36:51TheLemonManI don't get how limiting the search on the registry will help with that
17:37:33FromGitter<dom96> Plus. The fact that somebody bothered to add a package to the registry is a good signal that the package is at least somewhat reliable.
17:38:35FromGitter<kayabaNerve> Putting links directly in code like Go seems like a great way to break stuff.
17:39:55FromGitter<dom96> Oh yeah
17:40:12FromGitter<dom96> In fact, that’s number one reason why we need our own centralised registry
17:40:34FromGitter<dom96> People randomly remove their git repos
17:41:47TheLemonManyeah let's keep talking about more edge cases
17:42:04*chemist69 quit (Ping timeout: 240 seconds)
17:42:16TheLemonManthe registry is just a collection of links, if the user pulls a repo you're SOL anyway
17:42:50miransorry to interrupt, quick question: is there to replace my repeated code "for x in x1 .. x2: for y in y1 .. y2:" with some template/macro that will do that for me?
17:43:01miran*is there a way to...
17:43:23TheLemonManand now you can vendor your dependencies in go, you don't just "Put[ting] links directly in code"
17:43:24FromGitter<kayabaNerve> TheLemonMan not if the registry has the updated link or the packages itself.
17:43:53FromGitter<kayabaNerve> My comment was about package version control though.
17:44:08FromGitter<kayabaNerve> Also, good to know
17:44:26*chemist69 joined #nim
17:44:51miranok, i think i found a way with a template, that was easier than i thought
17:46:12TheLemonManmiran, an iterator yielding (int, int) maybe? but a template is also good IMO
17:46:57TheLemonManoh, hacktoberfest starts tomorrow
17:47:31shashlickWell fork every package submitted and maintain own copy then
17:48:04FromGitter<dom96> Edge cases?
17:48:18FromGitter<dom96> These are real issues that already happened to us.
17:48:37shashlickThey have happened in npm, go, etc
17:48:44shashlickPython has pip
17:48:50FromGitter<dom96> Araq has already forked tons of packages defensively. As have I.
17:48:59miranTheLemonMan: speaking of hacktoberfest — dom96, i have written a short introduction to nim-hacktober
17:49:08FromGitter<dom96> And yeah, in npm’s case that was particularly bad
17:49:24mirandom96: i can send/show it to you, to see what should be changed/added
17:49:37shashlickWell it's the standard centralized vs decentralized discussion
17:49:52FromGitter<dom96> miran: awesome. Sure, you can just create a PR on the website repo and I can review it that way if you’d like.
17:49:56shashlickAll great decentralized but quality goes to the toilet
17:50:19shashlickApple app store vs the rest
17:50:27shashlickEveryone wants control
17:50:33miran@dom96 i think this is in too early stage to create a PR. i'll upload it to gist and share the link here
17:52:13FromGitter<dom96> Okay. Whatever you prefer.
17:52:30*jjido joined #nim
17:52:51FromGitter<dom96> Btw I’m heading to meet @cabhishek
17:53:18FromGitter<dom96> In SF today. If anyone’s around, you’re welcome to join us
17:53:36miranhttps://gist.github.com/narimiran/88f2a5f80ae2beaaf549504cf37e0ec6
17:53:57miran^ @dom96
17:55:09miranit is still work in progress, so if anybody has something to add, please let me know (you can add a comment there)
17:59:19*ggbit joined #nim
17:59:27*tdog quit (Ping timeout: 252 seconds)
17:59:55FromGitter<dom96> Nice! I would add some explanation of what docs we’re looking for. How to document Nim code and generate the docs.
18:00:34FromGitter<dom96> For the last section I would mention that once the package is written it can be submitted to our packages repo, which counts as a PR :)
18:00:59miran@dom96 ok, will work on that tomorrow, now i'm too tired. good idea about PR to packages repo!
18:04:57*geocar left #nim (#nim)
18:05:20*tdog joined #nim
18:12:00*ArchDuke joined #nim
18:13:41FromGitter<Bennyelg> @narimiran cool intro
18:14:01miranthanks @Bennyelg
18:14:09*Trustable quit (Remote host closed the connection)
18:14:22*ArchDuke quit (Remote host closed the connection)
18:14:57Torticeasking again: when I uncomment line 33 all of my memory is exhausted and the program is killed http://ix.io/1nWr - what I want to happen is have the GUI updated after 10 seconds
18:14:59*ggbit quit (Quit: Page closed)
18:16:23FromGitter<cabhishek> @dom96 👍
18:17:05TheLemonManupdating the UI from a different thread is usually a big no depending on the toolkit
18:18:21*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
18:18:56TorticeI thought that was the right thing to do, but I come from python land with http://appjar.info/pythonThreads/ & http://appjar.info/pythonLoopsAndSleeps/ as reference
18:20:47TheLemonMancome on, the first link states "Threads don't always work nicely with GUIs, so your thread mustn't try to change the GUI, instead you will need to put any GUI updates in a Queue"
18:25:08anamokIn Kotlin there is a construct that I really liked: `repeat(5) { ... }` , which executes the body 5 times. I find it more elegant than `for i in 0 ..< 5`. Is there a way to replicate repeat in Nim?
18:26:12TheLemonMantemplate/macro
18:26:13mirantemplate called repeat?
18:26:57anamokproc and func is clear, but template/macro is new to me
18:27:28mirananamok: i'll show you the example, just a sec
18:28:36Torticeokay, this no longer tries to update the gui from a different thread, but it doesn't appear to wait at all http://ix.io/1nWQ
18:28:37TheLemonMananamok, https://gist.github.com/LemonBoy/f7345ddb8f7ac47534e2f989eeb4a122
18:29:01mirananamok: http://ix.io/1nWS/
18:29:45mirananamok: ok, TheLemonMan's version has a bit more things in it. take his version as he is much more experienced than me :)
18:29:46anamokThanks! It's really great that you can do that in Nim.
18:36:30anamokI'm working on a little library where I have this: `func toInt*(a: string): int = parseInt(a)` . If I replace func with template, they both work. What's the difference? Which one should it be?
18:36:52*jjido joined #nim
18:39:37miranis should be func
18:39:50FromDiscord_<Shield> a func is a normal function, you call it it works, a template however will inject its content at the place where you call it, as if you copy pasted its content there, same as inlining
18:40:35mirananamok: see the list of priorities here: https://nim-lang.org/docs/manual.html#macros-statement-macros
18:40:44FromDiscord_<exelotl> TheLemonMan: what's the purpose of static[] in that template?
18:41:21TheLemonManexelotl, force the argument to be a CT one
18:42:55FromGitter<bung87> https://github.com/bung87/cpp_nim_interop/blob/master/src/cpp_nim_interop/std/vector.nim how to make it work cpp vector <=> seq ?
18:44:11FromGitter<bung87> I hit stackoverflow sometime and can not get representation when call `echo toVector( @[1, 2])`
18:45:21Torticeso I'm guessing I shouldn't be using spawn, but rather createThread? http://ix.io/1nWQ
18:49:16FromDiscord_<Shield> what are you trying to do?
18:50:32TorticeI want to loop over each chunk in the sequence, wait a certain number of seconds, update the gui, then continue
18:51:18FromGitter<vivekimsit> Hi, I want to buy the nim in action book, is there any promo or discount available ;p
18:52:54FromDiscord_<Shield> i don't think i understood your code, why are you spawning a wait(seconds) in a separate thread?
18:53:00*piro_14 joined #nim
18:55:09*skellock joined #nim
18:57:21*piro_14 quit (Remote host closed the connection)
18:58:13Torticebecause the ui blocks with sleep in the same thread
18:59:03*lewd24 joined #nim
19:00:29FromDiscord_<Shield> spawning sleep in another thread will create a thread and make it sleep, then it ends, the main thread isn't affected whatsoever
19:01:33Torticethen what's the solution if I'm not supposed to update the gui from a seperate thread?
19:02:26*lewd24 quit (Read error: Connection reset by peer)
19:02:58FromDiscord_<Shield> you want to call dump() itself in another thread and use normal sleeping, you use channels to make the second thread send data about its state, while the main thread will try to read from that channel to know the state of the thread
19:05:50FromDiscord_<exelotl> it's a shame you can't define a macro that allows this config MyConfig: x, y: int
19:06:08FromDiscord_<exelotl> it has to be like this config MyConfig: x:int y:int
19:06:53FromDiscord_<exelotl> if I omit the comma then it's valid nim syntax config MyConfig: x y: int
19:07:08FromDiscord_<exelotl> but that seems unconventional. :s
19:09:07*nsf quit (Quit: WeeChat 2.2)
19:12:21*krux02 quit (Remote host closed the connection)
19:13:49Torticewhere should I spawn the thread from if I can't do it from the button press proc?
19:14:47*mirv_ joined #nim
19:17:56*mirv_ quit (Remote host closed the connection)
19:24:10FromGitter<vivekimsit> For some reasons I think `nimble test` is not running my tests
19:24:27FromGitter<vivekimsit> it just says `Success: All tests passed`
19:24:39FromGitter<vivekimsit> even if I change my tests to fail
19:25:40stefanos82dom96: are you available for a second?
19:27:33stefanos82dom96: the latest nim dev version fails to compile your NimbleExample/math you demonstrated in your book.
19:27:55stefanos82is says now "Error: undeclared identifier: 'math'"
19:28:01stefanos82it used to work before
19:28:09stefanos82yes, the package is installed
19:32:31stefanos82Araq: did you break multiline comments #[ ... ]# by mistake in nim version 407ede3aaefc94bc79c0edba158e4403ccfbb401?
19:32:36stefanos82it does not work
19:33:26stefanos82this is the error it throws: "Error: end of multiline comment expected"
19:36:43stefanos82OK, I closed it and reopened it and now works >:|
19:37:17FromGitter<vivekimsit> my tests are not working too
19:37:51stefanos82interesting
19:38:01stefanos82did you check your generated log file?
19:38:40FromGitter<vivekimsit> its just says all tests passed
19:39:07FromGitter<vivekimsit> how to select older version by choosenim?
19:40:39*tdog quit (Ping timeout: 252 seconds)
19:41:33*riidom quit (Remote host closed the connection)
19:43:20stefanos82I have no idea; what does choosenim --help say?
19:44:37Torticevivekimsit, just type the version
19:44:42Tortice$ choosenim 0.18.0
19:44:50stefanos82cool
19:45:13Torticehelp with type mismatch? http://ix.io/1nXb
19:46:14stefanos82what line does it say it's the mismatch
19:46:22Tortice101
19:46:56FromGitter<vivekimsit> ok, can confirm now. Switching back to version `0.18.0` runs my tests again
19:49:40FromGitter<kdheepak> @mratsim @krux02 Interesting. Thanks for the comments. My initial impression was that even if I allocate a lot of objects on the heap, it should just consume more memory and shouldn't effect speed as much. Nim's gc should take care of the memory allocations eventually.
19:50:48FromGitter<kdheepak> Your comments seem to indicate that I should allocate on the heap. Should I reuse existing allocations or call the GC?
19:50:49FromDiscord_<Shield> @torice read the docs for createThread, that's not how you use it, you need to pass a thread variable to store the thread, it's not like spawn, check some threading examples
19:52:00FromGitter<kdheepak> People are going to have such a laugh when I share my code, because it's probably so poorly optimized.
19:52:08FromGitter<kdheepak> I just coded the way I would in Python.
19:52:42stefanos82why choosenim cannot be found with nimble search command?
19:53:07FromGitter<kdheepak> I'm still not sure why creating a large number of objects on the heap and storing them in a seq would be slow though.
19:53:31stefanos82ah I see to run a script first -_-
19:54:27*ExEs47 joined #nim
19:54:28FromGitter<vivekimsit> Can someone please check if they are able to run their tests after switching to 0.19.0?
19:54:45Yardanicowhat's the error you're getting?
19:56:07FromGitter<vivekimsit> no error, it just says `Success: All tests passed`
19:56:19FromGitter<vivekimsit> even for failing tests
19:56:35FromGitter<vivekimsit> switching back to older version works as expected
19:59:48*ExEs47 quit (Remote host closed the connection)
20:00:34stefanos82how can I uninstall choosenim if I want to? there's no information anywhere on the project's page
20:02:40FromGitter<vivekimsit> yes, I just sent a PR to update the usage section
20:03:26FromGitter<vivekimsit> lol, changing readme changed the Travis test
20:03:35FromGitter<vivekimsit> broke*
20:03:58*arthurnn28 joined #nim
20:07:11*bodie_7 joined #nim
20:07:23Torticeshould be createThread(Thread, dump(url, seconds, dir, status)?
20:09:09*arthurnn28 quit (Remote host closed the connection)
20:11:49FromGitter<kdheepak> @vivekimsit I'm able to run my tests in 0.19.0
20:11:59stefanos82@vivekimsit: when you decide to install a different version along with the existing one, where will it place it inside $HOME/.nimble/bin/ ?
20:16:43*bodie_7 quit (Ping timeout: 245 seconds)
20:20:18*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:28:07*Tortice quit (Remote host closed the connection)
20:34:10FromGitter<mratsim> @kdheepak on a local PC (i.e. without networking) memory allocation is the most costly thing.
20:34:38FromGitter<mratsim> that’s why most games use a memory pool for example, to reuse memory already allocated.
20:35:30FromGitter<mratsim> Since dynamicc language work so often with strings, both JS and Python will optimize a lot small memory allocations and reuse them from a pool
20:36:06FromGitter<mratsim> but Nim (and C, C++, Rust, …) will not give you easy tool that are hard to go around when there not sufficient
20:36:13*miran quit (Ping timeout: 268 seconds)
20:36:51FromGitter<mratsim> Have a look into this blog post to write a fast parser: https://nim-lang.org/blog/2017/05/25/faster-command-line-tools-in-nim.html the example is with CSV
20:42:07*nsf joined #nim
20:53:26*TheLemonMan quit (Quit: "It's now safe to turn off your computer.")
20:54:12*nsf quit (Quit: WeeChat 2.2)
21:02:20*skellock quit (Quit: WeeChat 1.9.1)
21:05:25*Vladar quit (Remote host closed the connection)
21:09:00*gangstacat quit (Quit: Ĝis!)
21:34:53*druonysus quit (Read error: Connection reset by peer)
21:56:20*nitram27 joined #nim
21:58:30*nitram27 quit (K-Lined)
21:59:13FromGitter<kdheepak> Thanks for the comment @mratsim!
21:59:31FromGitter<kdheepak> I refactored my code base to use less allocations on the heap.
22:00:40*tzui quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
22:00:58FromGitter<kdheepak> Initially I was using a object for each character: I had something like the following ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ This made it easy to [https://gitter.im/nim-lang/Nim?at=5bb14799bbdc0b2505c7b603]
22:01:28FromGitter<kdheepak> This made it easy to print out the exact position of the error when I wasn't able to parse the file.
22:02:07FromGitter<kdheepak> I've now refactored the codebase to no longer use Character, and store the line_index and column_index in the token. Can probably optimize it more.
22:02:39*darithorn joined #nim
22:03:05FromGitter<kdheepak> But good news! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb14819c7bf7c3662977e9f]
22:03:14FromGitter<kdheepak> Nim is about 8 times faster now.
22:03:52FromGitter<alehander42> what is source_text? the token text/the line/the whole text?
22:04:13FromGitter<kdheepak> Yes. ( bad idea? )
22:04:16*TViernion26 joined #nim
22:04:30FromGitter<alehander42> but which one of them? :D
22:04:33*krux02 joined #nim
22:05:00FromGitter<kdheepak> Haha omg sorry I didn't read, it was the whole text
22:06:06*darithorn_ joined #nim
22:06:29*darithorn_ quit (Client Quit)
22:06:37FromGitter<alehander42> I just thought that the code that generates the error, knows about the text anyway, so it doesn't need to be pointed to from each character? (but maybe it can be somehow ambigious)
22:06:46FromGitter<alehander42> each token*
22:06:55FromGitter<alehander42> ah that's the old code anyway
22:06:56FromGitter<alehander42> nvm
22:06:58FromGitter<ephja> doesn't that make it one copy of the whole string for every processed character?
22:07:25FromGitter<gogolxdong> yes
22:07:38*TViernion26 quit (Remote host closed the connection)
22:08:04*MoaMoaK21 joined #nim
22:09:38*darithorn quit (Ping timeout: 272 seconds)
22:11:52*wildlander quit (Quit: Konversation terminated!)
22:12:50*MoaMoaK21 quit (Remote host closed the connection)
22:13:55FromGitter<kdheepak> That would explain why things were so very slow.
22:14:07*ChrisWi9 joined #nim
22:18:00*ChrisWi9 quit (Remote host closed the connection)
22:23:29*gangstacat joined #nim
22:24:20*elrood quit (Quit: Leaving)
22:35:21anamokHaving a unicode string, how to get its last character? Ex.: "helló"[^1] doesn't give back the ó character.
22:36:12FromGitter<kdheepak> Might have to use `Rune`?
22:36:34FromGitter<mratsim> ^
22:36:37*Tortice joined #nim
22:36:54FromGitter<mratsim> yes see here: https://nim-lang.org/docs/unicode.html#runeLen%2Cstring
22:37:24FromGitter<kdheepak> The last character in that string is what you get. What you want is the last Unicode character. You can't use normal indexing for that unfortunately.
22:37:27FromGitter<mratsim> I think we need a seq[Rune] or type UtfString = distinct string to avoid issues
22:38:12FromGitter<kdheepak> Python has spoiled me here. I'm so used to not even thinking about the somewhat low level details.
22:42:03anamok`echo toSeq("helló".runes)[^1]` works
22:45:36*darkoneko joined #nim
22:45:53Torticehttp://ix.io/1nXU cannot instantiate Thread got: <int literal(0)> expected: <TArg>
22:48:26krux02kdheepak: when you use [^1] on a string you get the last byte of a string
22:48:58krux02while what anamok says is true it is extremely inefficient.
22:49:42krux02it converts the entire string into a new seq object that is around 4 times bigger than the original string just to get the last rune
22:50:07krux02kdheepak: never index by rune, that never works
22:52:19krux02kdheepak: just look at how multibyte sequentces in unicode are composed, then you can find out a very fast and reliable way to get the last rune.
22:53:07*darkoneko quit (Ping timeout: 268 seconds)
22:54:53*r0kc4t joined #nim
22:55:07*r0kc4t quit (Remote host closed the connection)
23:01:27anamokHow to get the unicode codepoint of "ó"? I tried `ord('ó')` but got an error: missing closing ' for character literal.
23:02:57krux02anamok, that one is a multibyte rune, character literals can only hold single byte characters.
23:03:17krux02or in other words "bytes"
23:03:31krux02maybe "char" is the wrong word
23:04:53krux02anamok: manybe there are unicode functions to help you, but first of all you really need to know how multibyte utf8 works
23:05:11FromGitter<bung87> anamok you need unicode module
23:05:32krux02then you will know how to get the unicode codepoint, but you might look for a helper, if you don't find one, you will be able to write it.
23:05:51FromGitter<bung87> no it’s in std
23:06:31krux02bung87: my point is, just because there is a module for it, it doesn't mean you can spare yourself from understanding the basics.
23:07:40FromGitter<bung87> yeah I agree
23:09:43krux02btw my PR on nim-mode got merged
23:09:58krux02code highlighting is now fast
23:10:47*kali-chewy joined #nim
23:10:59krux02says a lot about emacs that you can screp up syntax highlighting to be slow, but yea for Nim it's fast, until somebody breaks it.
23:11:12krux02I go to bed now.
23:11:28*kali-chewy quit (Killed (Sigyn (Spam is off topic on freenode.)))
23:11:29FromGitter<bung87> do you have document about epc ?
23:11:40krux02no
23:11:53krux02epc is a real complexity monster in my eyes
23:12:18krux02and the reason to use epc was async
23:12:29krux02the problem of nimsuggest, it isn't async
23:12:30FromGitter<bung87> so what is using in transport layer.
23:12:34krux02it blocks the input
23:13:11krux02theri is epc in use, but that part is not what I understand
23:13:28krux02I am happy I understand the fontification process now, kind of.
23:13:34FromGitter<bung87> guess that’s the reason why vscode-nim using one process per file.
23:13:42krux02at least well enough to make it fast.
23:13:57krux02ouch, one process per file
23:14:16krux02processes are not cheap.
23:14:42FromGitter<bung87> yeah I tried remain one process per workspace but does not work.
23:15:13krux02emacs does not have a concept of a workspace
23:15:26krux02I really needed to get used to that
23:16:06anamokthanks, bye
23:16:22*anamok quit (Remote host closed the connection)
23:16:30krux02I think vscode is a complexity monster as well. It just uses more popular web tech
23:16:32FromGitter<bung87> I impelemented a nim version switch at vscode status bar can change it for current workspace.
23:17:07krux02switch what version?
23:17:28FromGitter<bung87> but for a nim language server ,must first implemented language protocol.
23:17:35FromGitter<bung87> nimsuggest version
23:18:28krux02I now understand what is so broken about LSP
23:19:20*lbt10 joined #nim
23:19:36krux02at least I think
23:19:54FromGitter<bung87> MS implemented js version and C# version
23:20:04krux02It uses this high overhead network protocol and it has no support for low level features, such as syntax highlighting.
23:20:48krux02I don't use vscode for one very simple reason.
23:21:30FromGitter<bung87> vscode is still cool, no more configuration, the default behaviour fine to me
23:21:52krux02I think the whole web technology stack is technology cancer. It grows complexety and eats all resources available to the computer for nothing more than a little bit of styling and interactivity. It should die sooner rather than later.
23:22:16krux02I can't fight it anymore when it also grows in my development stack
23:23:18krux02bung87, yes I agree. I want to change nim-mode, so that it also works without configuration.
23:23:31krux02a lot of things work fine in vscode
23:23:44krux02other are just horrible
23:24:03FromGitter<bung87> speak of cancer , the node package come to my head
23:24:28*lbt10 quit (Killed (Sigyn (Spam is off topic on freenode.)))
23:24:43krux02I know node, and I don't even program javascript at all.
23:24:53krux02not even as a compilation target
23:25:05FromGitter<bung87> so much developers can get involved
23:26:36krux02somebody showed me how node package manager automatically wanted to check out something that was a combanation of a git hash and a version number
23:26:41krux02total nonsense
23:26:53krux02but yea, nimble is broken, too.
23:27:14krux02I never had a reproducable build in nimble
23:27:28krux02whenever I compiled on another computer, it didn't work.
23:27:54krux02nimble isn't helping at all to manage dependencies reliably.
23:28:17krux02but yea, I go to sleep for now.
23:29:00FromGitter<bung87> good night
23:29:24*krux02 quit (Remote host closed the connection)
23:31:48TorticeI clearly don't get threads cannot instantiate Thread got: <int literal(0)> expected: <TArg>