00:01:10 | * | Serenitor joined #nim |
00:03:35 | * | Jesin joined #nim |
00:09:20 | * | Notkea quit (Remote host closed the connection) |
00:15:28 | * | Serenitor quit (Quit: Leaving) |
00:15:53 | * | leaf__ quit (Quit: Page closed) |
01:00:33 | * | noonien quit (Quit: Connection closed for inactivity) |
01:07:51 | * | Yardanico quit (Ping timeout: 252 seconds) |
01:21:54 | * | Yardanico joined #nim |
01:25:13 | * | Yardanico quit (Client Quit) |
01:28:49 | * | ryanhowe joined #nim |
01:39:57 | * | ryanhowe quit (Read error: Connection reset by peer) |
01:49:07 | FromGitter | <gogolxdong> Does NEP-1 apply to nimsuggest or nimpretty? |
01:54:01 | FromGitter | <gogolxdong> How to keep lines no longer than 80 characters? How to change them if they are rather than manual edit? |
02:11:13 | * | abm quit (Read error: Connection reset by peer) |
02:19:11 | FromDiscord | <treeform> sagax, % and c %, can be confusing when dealing with negative numbers. if you run into issues use this: https://gist.github.com/treeform/51db7a31b1bb64daf5bdb662a9b8e6c8 |
02:19:47 | FromDiscord | <treeform> https://stackoverflow.com/questions/1907565/c-and-python-different-behaviour-of-the-modulo-operation |
02:19:56 | FromDiscord | <treeform> https://www.rapitasystems.com/blog/ada-c-rem-and-mod |
02:22:51 | * | Yardanico joined #nim |
02:24:45 | FromDiscord | <emekoi> is the nim `mod` a mathematical mod or is it the remainder? |
02:25:37 | FromDiscord | <treeform> I think nim's mod is the engineering mod while python's mod is the mathematical mod. |
02:25:52 | FromDiscord | <treeform> but they are both called mod and rem in different languages... |
02:26:05 | FromDiscord | <treeform> It really depends on number system you have to deal with |
02:38:45 | * | endragor joined #nim |
02:43:21 | * | endragor quit (Ping timeout: 252 seconds) |
02:57:15 | * | endragor joined #nim |
02:58:34 | * | dddddd quit (Read error: Connection reset by peer) |
03:05:16 | zachcarter | is there a way to get the value of a const inside a macro? |
03:05:46 | zachcarter | from within an untyped block? |
03:05:51 | zachcarter | I just have the ident |
03:14:36 | * | Yardanico quit (Ping timeout: 252 seconds) |
03:20:10 | Tanger | zachcarter, Would the typeVal procs work? ie floatVal, boolVal etc? |
03:21:52 | zachcarter | I think I figured it out |
03:27:39 | Tanger | What was the deal? |
03:29:35 | FromGitter | <gogolxdong> compiler set MaxLineLen = 80, codes write by macro implements the rule No.1 of NEP-1 ,but doesn't go further along with it. Like alignment of tuple, proc definition and call of Conventions for multi-line statements and expressions. |
03:30:40 | zachcarter | Tanger: still working on it :/ |
03:36:44 | FromGitter | <gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b90a0cce5b40332ab4fa4c5] |
03:41:33 | FromGitter | <gogolxdong> there are two lines longer than 80 characters ,have no idea why it can even though written by compiler, alignment of seq is not clear , the alignment of tuple shows alignment right at the first character in the same seq. |
03:42:44 | FromGitter | <gogolxdong> in the same bracket. |
03:50:07 | * | Yardanico joined #nim |
03:55:19 | * | cspar joined #nim |
05:01:47 | FromDiscord | <emekoi> if your object has a destructor and you create a `ref` to it, is the destructor run when your `ref`'s ref count reaches 0? |
05:36:19 | * | nsf joined #nim |
06:05:33 | * | leorize quit (Quit: WeeChat 2.2) |
06:12:08 | FromGitter | <codem4ster> there is an example in streams module; ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but there is no readLine proc in streams. How can I read a file line by line without getting all the file to the memory? [https://gitter.im/nim-lang/Nim?at=5b90c538c9500b4bab8cbb32] |
06:21:25 | FromGitter | <codem4ster> I made it with open(), discard my question. But `fs.readLine(line)` is not working on this example. May be we can consider correct the example. |
06:25:41 | sagax | wow |
06:25:49 | sagax | % it's like as "mod" |
06:25:52 | sagax | % it's like as "mod" |
06:25:55 | sagax | "%" it's like as "mod" |
06:26:02 | sagax | hm |
06:26:08 | sagax | i type % twice |
06:26:20 | sagax | but see only one % |
06:26:38 | sagax | ok, twice % it like as "mod" |
06:48:03 | FromGitter | <narimiran> sagax: it is not the same |
06:48:18 | FromGitter | <narimiran> try `-3 mod 4` and `-3 %% 4` |
06:49:32 | FromGitter | <kayabaNerve> !eval echo (-3 mod 4) |
06:49:35 | NimBot | -3 |
06:49:47 | FromGitter | <kayabaNerve> !eval echo (-3 %% 4) |
06:49:50 | NimBot | 1 |
06:49:55 | FromGitter | <kayabaNerve> ABS value? |
07:10:20 | FromGitter | <narimiran> i have two `var` HashSets, let's call them `a` and `b`. i cannot do `(a - b).pop()`. the error says `'a - b' is immutable`. is this the intended behaviour? (cc @Araq) |
07:16:38 | * | leorize joined #nim |
07:17:05 | * | Senketsu quit (Quit: WeeChat 2.2) |
07:20:02 | * | Senketsu joined #nim |
07:30:13 | * | Vladar joined #nim |
07:35:25 | * | PMunch joined #nim |
07:35:57 | * | Senketsu quit (Quit: WeeChat 2.2) |
07:40:15 | * | Senketsu joined #nim |
07:41:43 | * | Senketsu quit (Client Quit) |
07:45:01 | * | Senketsu joined #nim |
07:50:47 | FromGitter | <mratsim> because `a - b` gives you a new HashSet |
07:51:24 | FromGitter | <mratsim> you would need to do something like `a -= b; a.pop()` |
07:52:55 | FromGitter | <mratsim> `a - b` expression is a rvalue: a temporary that needs to be assigned or passed to a proc for further computation. (Rvalue because it lives on the right side of the assignment). |
07:54:06 | * | Senketsu quit (Quit: WeeChat 2.2) |
07:58:18 | FromGitter | <codem4ster> how can I add a string to a global seq in a thread? I tried like this without luck; ⏎ part of the code like this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b90de1ac2bd5d117a2854ef] |
07:58:28 | * | Senketsu joined #nim |
07:59:04 | FromGitter | <codem4ster> I want to add a word to foundWords in a thread |
08:00:05 | FromGitter | <codem4ster> but it gives `wordGenerator.nim(18, 6) Error: 'hasTdkWord' is not GC-safe as it accesses 'foundWords' which is a global using GC'ed memory` in compile time |
08:02:12 | FromGitter | <codem4ster> and I tried this with threadpool before but spawn with a parallel never created a new thread they're working just linear. |
08:03:04 | * | gmpreussner quit (Ping timeout: 240 seconds) |
08:03:53 | * | gmpreussner joined #nim |
08:06:40 | zachcarter | codem4ster - use channels or shared heap |
08:06:51 | FromGitter | <mratsim> @dom96 Should I delete spam account or keep them as spammer or banned on the forum? |
08:07:20 | FromGitter | <mratsim> It’s for hongwei284h |
08:07:45 | FromGitter | <narimiran> thanks @mratsim |
08:08:24 | FromGitter | <mratsim> @codem4ster Use ptr to the seq. |
08:22:05 | FromGitter | <codem4ster> @zacharycarter how can I turn this pointer into a seq for adding data into it |
08:22:59 | FromGitter | <codem4ster> @zacharycarter is there an example? |
08:24:21 | FromGitter | <mratsim> use `ptr seq` and dereference |
08:24:39 | FromGitter | <mratsim> but you might have GC conflicts. |
08:25:13 | FromGitter | <narimiran> !eval echo (-10 mod 5), (-10 %% 5) |
08:25:15 | NimBot | 01 |
08:25:27 | FromGitter | <mratsim> For shared data structure it’s much safer to preallocate and never use `add` |
08:25:48 | FromGitter | <mratsim> because if you go over the reserved space, the GC will move everything |
08:26:03 | FromGitter | <mratsim> and your pointer will point to garbage |
08:26:04 | * | xet7 joined #nim |
08:26:33 | FromGitter | <mratsim> (that’s exactly what Rust means by fearless concurrency) |
08:26:59 | FromGitter | <codem4ster> will locking prevent these situations? |
08:27:05 | FromGitter | <mratsim> no |
08:27:47 | FromGitter | <mratsim> you would need to keep the pointer on each thread in sync with the real seq location |
08:28:03 | FromGitter | <codem4ster> and I already make prt seq, but I cannot use pointer as seq. I need to convert it to seq again, but I dont't know how to do that |
08:28:23 | FromGitter | <mratsim> `a[]` <— that’s the dereference operator |
08:29:05 | FromGitter | <codem4ster> > you would need to keep the pointer on each thread in sync with the real seq location ⏎ how can I do this? |
08:31:39 | FromGitter | <codem4ster> if so, what is the purpose of this; https://rosettacode.org/wiki/Mutex#Nim |
08:32:48 | PMunch | Locks are only to assure only one thread accesses shared variables at the same time |
08:35:42 | PMunch | The issue here is that a sequence in Nim is just a malloced piece of memory. When you add something and it doesn't have room for it it will realloc the entire thing, possibly moving the entire seq somewhere else in memory. In Nim each thread has it's own thread-local GC and so it can't access memory managed by another threads GC. So if you start a thread and want to add something to a sequence you essentially try to add the string (which is GC'ed by the |
08:35:42 | PMunch | thread) to a sequence GC'ed by the main thread. This would cause all kinds of complexity. The best option is probably to use a channel and have the main thread listen on that channel and add everything that comes along on it to the sequence. |
08:37:21 | PMunch | Another option is to have a shared pointer to the sequence, but every time you want to add something on the sequence you must ensure that this pointer is updated (and I'm not sure how that would handle strings, if it would handle them at all). |
08:39:07 | FromGitter | <mratsim> @codem4ster I’m pretty sure that’s PhD thesis research material and why Araq choose to go with thread local GC |
08:39:27 | FromGitter | <mratsim> Global GC are probably much more complex beasts with lots of corner cases |
08:40:23 | * | stefanos82 joined #nim |
08:40:49 | FromGitter | <mratsim> and also those kind of bookkeeping are why GCs are slow in other languages. |
08:41:46 | FromGitter | <mratsim> so I see 3 solutions: ⏎ ⏎ 1) Channels ⏎ 2) thread local seq that you merge at the end ⏎ 3) Preallocating [https://gitter.im/nim-lang/Nim?at=5b90e84a1d3a5711b6f0f5d6] |
08:41:59 | PMunch | There are ways around the string problem by the way, for example: https://gist.github.com/aboisvert/0791b53e492ebc4020c4e1cc049d539d |
08:42:22 | PMunch | mratsim, how does preallocating work with strings? |
08:42:36 | PMunch | Can a thread add a string to let's say an array? |
08:43:29 | FromGitter | <mratsim> I don’t like strings, my libraries don’t use strings at all ;). Problem solved. |
08:43:59 | PMunch | Huh, there even is a sharedstring implementation built in: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/sharedstrings.nim |
08:44:20 | PMunch | And a shared list for that matter: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/sharedlist.nim |
08:45:31 | PMunch | I wish there was a way to have read-only access to a static shared resource in threads |
08:45:45 | FromGitter | <codem4ster> oh, very much thanks for lot of information. :) You are great. I will look at channels then. I think this shared memory things are a bit much for me. |
08:46:04 | PMunch | E.g. build a table of data, spawn threads that read from table. |
08:46:27 | PMunch | codem4ster, I've been thinking of writing something about concurrency in Nim |
08:46:35 | PMunch | But I'm hardly an expert on the subject myself |
08:47:32 | PMunch | Well I guess there is this: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/sharedtables.nim |
08:47:56 | FromGitter | <mratsim> @PMunch that’s parallelism here ;) |
08:48:42 | PMunch | Yeah I've given up on those terms. Think I asked the professor about three times about what the difference was and he couldn't give me a good answer.. |
08:49:14 | FromGitter | <mratsim> https://cdn-images-1.medium.com/max/409/1*_4B2PKsJn9pUz3jbTnBnYw.png |
08:50:35 | PMunch | Ah, that makes it a bit clearer |
08:50:38 | FromGitter | <mratsim> concurrency is about interleaving on the same hardware thread. Parallelism is about distributing on the same hardware thread |
08:51:05 | * | leorize quit (Quit: WeeChat 2.2) |
08:51:07 | FromGitter | <codem4ster> @mratsim is there any simple example with channels? Cannot found a proper one :( |
08:51:08 | FromGitter | <mratsim> Concurrency is very useful for IO, because the CPU is idle when waiting for IO |
08:51:45 | FromGitter | <codem4ster> that's why nodejs is faster than java in IO operations :) |
08:52:34 | FromGitter | <mratsim> tbh, I’m not a channel expert (or a concurrency expert) I understand the challenges but that’s all :/ |
08:53:10 | FromGitter | <mratsim> this is relevant but it’s more about someone struggling in 2015: https://forum.nim-lang.org/t/959 |
08:53:24 | FromGitter | <mratsim> maybe scouring gists/github |
08:54:16 | * | seni joined #nim |
08:54:40 | FromGitter | <mratsim> and check what this beginner is doing, he recently asked about channels and seems like he unstuck himself: https://github.com/nais314/stui/blob/b9c44615929e6bbd3c428fdae5a46901cde2fbac/mainloop.inc.nim |
08:54:48 | PMunch | codem4ster, it's pretty simple. Create a globally scoped Channel type variable (with T being the type you want to send over it), then in your thread use "mychannel.send(<data>)". And in the main thread do "myChannel.open(<max number of units before waiting>); spawn threads; read from channel |
08:57:15 | FromDiscord | <2vg> concurrency is fun x) |
08:58:20 | FromGitter | <Bennyelg> Where can I see how much threads nim opened ? |
09:00:43 | FromGitter | <codem4ster> In Nim you must create your threads into an Thread[T]. And you will probably need to attach them to an array. You can count running threads in this array. |
09:09:41 | PMunch | codem4ster, here is an example of threads for you: http://ix.io/1m5b/Nim |
09:10:28 | PMunch | (By the way if you want to copy from ix.io without line numbers simply remove the "/Nim" part of the link: http://ix.io/1m5b |
09:10:31 | PMunch | ) |
09:15:30 | * | rockcavera quit (Ping timeout: 252 seconds) |
09:16:55 | FromGitter | <Bennyelg> (https://files.gitter.im/nim-lang/Nim/2upM/image.png) |
09:16:57 | FromGitter | <Bennyelg> presto in action |
09:26:42 | PMunch | @codem4ster ^ |
09:26:54 | PMunch | Does the irc bot translate highlights properly? |
09:27:07 | PMunch | Or do you still have to use @ when talking to people on Gitter? |
09:28:25 | FromGitter | <mratsim> need @ |
09:29:59 | PMunch | Aight |
09:30:38 | PMunch | That's the most annoying thing on the IRC->Gitter bot. You can't tab complete user names, and highlighting doesn't work properly.. |
09:35:45 | PMunch | Could the IRC bot theoretically create a new user per user on Gitter? |
09:59:15 | * | abm joined #nim |
10:08:00 | FromGitter | <codem4ster> @PMunch thanks for the code I was at lunch. gitter complete user names if you start typing with @ |
10:09:25 | PMunch | Yeah I know Gitter does it, but I can't complete your Gitter name on IRC |
10:09:32 | PMunch | Because all of you are named FromGitter :P |
10:10:14 | PMunch | I remember at some point a guy on Gitter thought that someone on IRC was a bot :P |
10:16:25 | livcd | nim-forum feels slower on ff nightly |
10:28:48 | * | zachcarter quit (Ping timeout: 272 seconds) |
10:30:47 | FromGitter | <Bennyelg> reuse of jobs which done their job is done |
10:31:35 | sagax | help me understand this http://susepaste.org/77910319 |
10:32:01 | sagax | where i can read about % vs mod |
10:32:04 | sagax | ? |
10:32:15 | sagax | double % vs mod |
10:36:54 | * | dddddd joined #nim |
10:36:58 | * | xet7 quit (Quit: Leaving) |
10:37:03 | FromGitter | <narimiran> sagax: `%%` treats numbers as unsigned, and this produces 'confusing' results |
10:37:26 | FromGitter | <narimiran> if you want python-like behaviour, i use `a % b + b` |
10:37:36 | FromGitter | <narimiran> oops, i meant `a mod b + b` |
10:38:49 | FromGitter | <narimiran> this is for negative numbers, where you want/expect `-10 % 3 == 2` |
10:43:53 | sagax | thanks |
10:44:11 | sagax | we have iterator with syntax .. example 0..10 |
10:44:31 | sagax | but with this syntax we have 11 number |
10:44:49 | sagax | we have syntax like as ... example 0...10 ? |
10:45:00 | FromGitter | <narimiran> use `0 ..< 10` if you want to exclude higher limit |
10:45:12 | sagax | yes, exclude |
10:48:36 | * | xet7 joined #nim |
10:55:59 | FromGitter | <codem4ster> @PMunch channels works great thanks for your helps :) |
11:01:42 | PMunch | @codem4ster, no problem :) |
11:18:04 | * | kapil___ joined #nim |
11:26:52 | * | rockcavera joined #nim |
11:53:42 | * | noonien joined #nim |
11:56:46 | FromGitter | <alehander42> man sympy is huge |
11:57:20 | FromGitter | <alehander42> I hoped to port the most important stuff in it |
11:57:54 | FromGitter | <alehander42> but it has so many additional modules |
11:58:06 | stefanos82 | you mean simpy |
11:58:31 | FromGitter | <alehander42> No, sympy |
11:59:08 | stefanos82 | you mean the actual sympy.org? |
11:59:42 | stefanos82 | lol I have confused it with nimpy @alehander42 |
12:00:07 | FromGitter | <alehander42> ha I didn't know about simpy |
12:00:14 | FromGitter | <alehander42> Well it's not my domain haha |
12:00:20 | FromGitter | <alehander42> Problem domain |
12:00:39 | FromGitter | <alehander42> Oh yeah nimpy is its own beast |
12:01:10 | stefanos82 | so you are dealing with math? |
12:03:09 | FromGitter | <alehander42> well I have a bit more experience with it compared to signal processing |
12:05:19 | stefanos82 | signal processing is an amazing topic to invest time in it |
12:05:30 | stefanos82 | especially video processing |
12:09:43 | FromGitter | <alehander42> it sounds intriguing |
12:10:06 | FromGitter | <alehander42> why is it so fascinating |
12:18:03 | stefanos82 | because it's a category that can open so many doors for job opportunities and advanced research topics |
12:18:20 | stefanos82 | audio processing, image / video processing |
12:18:29 | stefanos82 | there are so many things you could do with it |
12:19:41 | stefanos82 | from medical research to NASA sophisticated projects |
12:20:09 | FromGitter | <alehander42> I see |
12:20:32 | FromGitter | <Aaron-JM> hey |
12:20:38 | FromGitter | <alehander42> I have to read more about it, no idea what do they use |
12:20:41 | * | leorize joined #nim |
12:20:47 | FromGitter | <alehander42> Hello Aaron |
12:21:02 | stefanos82 | @alehander42: ffmpeg is one of such projects |
12:21:26 | stefanos82 | mplayer, mpv, VideoLAN as well |
12:37:51 | * | regtools_ quit (Quit: leaving) |
12:38:02 | * | regtools joined #nim |
12:43:35 | * | leorize quit (Quit: WeeChat 2.2) |
13:08:31 | * | endragor quit (Remote host closed the connection) |
13:20:56 | FromGitter | <Grabli66> Hi! Is there a procedure for finding max for seq[int] ? I don't see any. Only for openarray in module system |
13:23:00 | FromGitter | <Vindaar> Hey @Grabli66! `openArray` is just a combined type of `seq` and `array` basically. So any proc taking `openArray` also takes `seq` |
13:23:55 | FromGitter | <Grabli66> Ok. It works :) |
13:26:45 | * | endragor joined #nim |
13:30:47 | * | endragor quit (Ping timeout: 240 seconds) |
13:44:45 | * | endragor joined #nim |
13:54:11 | * | craigger_ quit (Quit: bye) |
13:54:28 | * | craigger joined #nim |
14:11:09 | * | Perkol joined #nim |
14:17:36 | FromGitter | <Araq> hmm I hope you guys don't mind yet another compiler API breakage... |
14:18:13 | FromGitter | <Araq> I'm adding distinct strings for AbsoluteFile, RelativeDir etc. I'm tired of getting the compiler's path handling wrong all the time... |
14:18:42 | FromGitter | <Clyybber> What would it be? |
14:19:35 | FromGitter | <Clyybber> @Araq What would it be? |
14:20:08 | FromGitter | <Araq> as I said, path handling is becoming typesafe |
14:27:17 | FromGitter | <Clyybber> I don't think anyone would have a problem with that... |
14:33:50 | FromGitter | <Araq> I might break Nimble and all other clients of the compiler API |
14:33:53 | FromGitter | <Araq> but we'll see |
14:34:27 | FromGitter | <Araq> the clarity is worth it, stringly-based code is so bad |
14:39:09 | * | PMunch quit (Quit: Leaving) |
14:43:07 | euantor | I quite like Rust's Path and pathBuf for a similar reason: https://doc.rust-lang.org/std/path/struct.Path.html |
14:43:34 | euantor | Though it still uses strings, having a little bit of safety on top is nice |
14:47:09 | * | kapil___ quit (Quit: Connection closed for inactivity) |
14:47:25 | FromDiscord | <treeform> I have no issues with paths... i think it will just introduce extra typing? |
14:48:39 | FromGitter | <Araq> well only the compiler is affected for now. but if the experiment is successful I'll push for a stdlib addition |
14:49:47 | FromGitter | <Araq> good that you mention Rust's Path. for now I consider it illdesigned |
14:50:00 | FromGitter | <Araq> I'm adding 4 different distinct string types |
14:50:23 | FromGitter | <Araq> as absoluteDir / absoluteFile makes no sense it shouldn't even compile |
14:51:25 | FromGitter | <Clyybber> How does it not make sense? I thought you want to add AbsoluteFile, AbsoluteDir (and RelativeFile, RelativeDir)? |
14:56:39 | * | leorize joined #nim |
15:08:54 | * | kapil___ joined #nim |
15:09:44 | * | tribly quit (Quit: WeeChat 2.2) |
15:10:04 | * | TheLemonMan joined #nim |
15:12:02 | * | tribly joined #nim |
15:24:47 | FromDiscord | <treeform> Has there been a change with now `new` works? I think before it required `new` before creating a `ref object` and now it does not? |
15:26:16 | FromGitter | <mratsim> it does |
15:26:38 | FromGitter | <mratsim> either you use new or you use RefObject(field1: foo, field2: bar) |
15:27:47 | FromDiscord | <treeform> I think I did not know about the RefObject(field1: foo, field2: bar) case |
15:56:11 | * | nsf quit (Quit: WeeChat 2.2) |
16:06:33 | FromGitter | <Alan-FGR> hey guys, the basic math links are broken here: https://nim-lang.org/docs/lib.html#pure-libraries-math-libraries |
16:07:37 | FromGitter | <Alan-FGR> btw did the state of editors change in the past couple of years? last i checked editors weren't great, no refactor and such |
16:07:55 | FromGitter | <mratsim> @Alan-FGR, it works for me. |
16:08:53 | FromGitter | <mratsim> Regarding editors what do you expect them to do when refactoring? I like VScode. works great even when refactoring big codebases |
16:10:24 | FromGitter | <Alan-FGR> do these links work for you: https://nim-lang.org/docs/basic2d.html https://nim-lang.org/docs/basic3d.html ? |
16:10:28 | FromGitter | <Alan-FGR> I get server error here |
16:11:20 | FromGitter | <Alan-FGR> @mratsim well, maybe i should give it a try, is vscode the best nim editor currentl? |
16:11:43 | FromGitter | <mratsim> Arguably it’s that and Vim/Emacs |
16:14:08 | FromGitter | <Alan-FGR> also, when you do say `SomeCppObj = {.importcpp: "someClass"} = object` does that declare a nim object that holds and underlying cpp object? if so how is memory managed? fully manually? |
16:19:54 | FromGitter | <mratsim> no, you reuse the C++ struct |
16:20:00 | FromGitter | <mratsim> there is no holder object |
16:21:32 | FromGitter | <mratsim> If the C++ struct declaration includes destructor those will apply |
16:23:55 | FromGitter | <Alan-FGR> nice. thanks. |
16:26:33 | FromGitter | <mratsim> In terms of memory management: ⏎ ⏎ `type Foo = object` ==> Stack allocation, automatically managed ⏎ `type Foo = ref object` ==> Heap alloc, GC-managed ⏎ `type Foo = ptr object` ==> view, manually managed. You need to allocate the buffer manually. [https://gitter.im/nim-lang/Nim?at=5b915539ac25fd11b5edd1e1] |
16:27:30 | FromGitter | <Alan-FGR> wow, it's great that you have the option to manage memory manually! |
16:27:45 | FromGitter | <mratsim> and @Alan-FGR basic2D was deprecated in devel which may explain why it doesn’t get generated or something |
16:28:07 | FromGitter | <Alan-FGR> @mratsim so the link is broken for you too? |
16:29:47 | FromGitter | <mratsim> You can even choose the GC implementation: ⏎ ⏎ 1) default: ref counting ⏎ 2) markAndSweep: Java like mark and sweep GC (except that it doesn’t reserve 100+MB memory before running) ⏎ 3) boehm: Boehm GC ... [https://gitter.im/nim-lang/Nim?at=5b9155fbac25fd11b5edd549] |
16:30:13 | FromGitter | <mratsim> and ye the link is broken |
16:30:17 | FromGitter | <mratsim> yes* |
16:32:11 | FromGitter | <Alan-FGR> i'll make sure to give nim another try, thanks :) |
16:32:26 | FromGitter | <mratsim> @Alan-FGR https://nim-lang.org/blog/2018/03/01/version-0180-released.html ⏎ ⏎ Documentation bug |
16:32:45 | FromGitter | <mratsim> you should probably use GLM: https://github.com/stavenko/nim-glm |
16:35:58 | FromGitter | <Alan-FGR> oh boi :( |
16:39:17 | * | Trustable joined #nim |
16:42:04 | * | noonien quit (Quit: Connection closed for inactivity) |
16:43:13 | FromGitter | <mratsim> In short basic2D and basic3d were really too basic and people had to use GLM (for physics/graphics) or Neo/Arraymancer (for matrix/science) anyway. |
16:43:36 | FromGitter | <mratsim> you can still get those here: https://github.com/nim-lang/basic2d |
16:43:47 | FromGitter | <mratsim> https://github.com/nim-lang/basic3d |
16:56:22 | * | endragor quit (Ping timeout: 246 seconds) |
17:10:58 | * | erratic quit (Ping timeout: 272 seconds) |
17:13:24 | * | Perkol quit (Quit: Leaving) |
17:17:11 | * | kapil___ quit (Quit: Connection closed for inactivity) |
17:37:51 | * | Jesin quit (Quit: Leaving) |
17:41:46 | * | Jesin joined #nim |
18:07:15 | * | rockcavera quit (Remote host closed the connection) |
18:10:51 | * | PMunch joined #nim |
18:11:49 | livcd | I want to thank everyone in this small community for all the hard work and libs you guys create |
18:11:57 | livcd | Just realized how painful would it be without you |
18:12:17 | PMunch | Haha, yeah we often take libs for granted |
18:13:02 | TheLemonMan | hey PMunch, did you finish your cocktail thingie? |
18:13:28 | livcd | PMunch: yeah |
18:13:55 | livcd | PMunch: i am not very good at reinventing the necessary pkgs. I would end up with barely working crap if I would do everything by myself |
18:14:22 | PMunch | TheLemonMan, well kind of |
18:14:36 | PMunch | It works as I wanted, but it doesn't have any kind of interface |
18:15:29 | TheLemonMan | that's all that matters, interfaces are boring :P |
18:15:37 | PMunch | Currently you just type into the script itself what you have and which categories you are interested in and how many ingredients you want to get and it will spit out lists of drinks you can make, list of drinks you can make if you by a list of ingredients, etc. |
18:19:31 | * | Notkea joined #nim |
18:19:32 | * | Notkea quit (Remote host closed the connection) |
18:22:26 | livcd | hmm do we have a way to read/write to boltdb ? :O |
18:25:01 | FromGitter | <mratsim> BoltDB is in go, so … if they provide a C API you can use c2nim or Nimgen |
18:25:14 | FromGitter | <mratsim> otherwise just use RocksDB |
18:25:36 | livcd | I dont think they do |
18:25:47 | livcd | I thought about rw existing boltdb files |
18:36:48 | FromGitter | <codem4ster> my threads leaking memory :( |
18:37:15 | FromGitter | <kayabaNerve> @codem4ster What's the app? |
18:37:17 | FromGitter | <codem4ster> VIRT memory is always increasing |
18:37:49 | FromGitter | <codem4ster> and it gives out of memory and shut down |
18:37:58 | FromGitter | <kayabaNerve> If it's a video game, just spawn an unkillable boss when the memory gets out of hand. ez |
18:38:39 | FromGitter | <codem4ster> it is a script which connects to a site and get multiple page content at the same time |
18:38:49 | FromGitter | <codem4ster> I have 8 active threads all the time |
18:39:11 | FromGitter | <kayabaNerve> Just erase the internet drivers when memory gets out of hand. |
18:39:11 | FromGitter | <kayabaNerve> ez |
18:39:36 | FromGitter | <codem4ster> hmm, so funny yes |
18:40:28 | FromGitter | <kayabaNerve> I thought so *shrugs* |
18:41:28 | FromGitter | <mratsim> do you only use seq and strings? |
18:41:50 | FromGitter | <mratsim> I suppose something keeps a reference to those even though they should be collected |
18:42:57 | * | stefanos82 quit (Quit: Quitting for now...) |
18:46:05 | FromGitter | <codem4ster> this is my thread: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b9175edc9500b4bab911244] |
18:46:18 | * | Jesin quit (Quit: Leaving) |
18:47:02 | FromGitter | <codem4ster> it connects to a url make a check and if its true it sends data to a channel. If connection lost then it tries (at most 3 times). |
18:47:34 | FromGitter | <mratsim> your client.close() should be in a try finally or a defer: statement |
18:47:36 | FromGitter | <codem4ster> and this is the thread caller; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b91764894f8164c17e9912e] |
18:49:14 | * | Jesin joined #nim |
18:49:29 | FromGitter | <codem4ster> @mratsim but the code reaches the client.close() |
18:49:50 | FromGitter | <codem4ster> always |
18:50:57 | FromGitter | <mratsim> regarding the leak, unfortunately I’m not that familiar with threads/httpclient. but you can print the GC statistics |
18:51:47 | FromGitter | <codem4ster> how can I print that |
18:52:25 | * | erratic joined #nim |
19:00:54 | * | Jesin quit (Quit: Leaving) |
19:01:30 | FromGitter | <tim-st> livcd: boltdb was inspired by lmdb and lmdb is available for nim and only has advantages over boltdb |
19:04:15 | * | Jesin joined #nim |
19:17:50 | FromGitter | <Araq> don't do this `for thread in threads:` |
19:18:33 | FromGitter | <codem4ster> how can I use a threadpool then |
19:18:52 | FromGitter | <codem4ster> a real threadpool not like Nim's :D |
19:19:03 | FromGitter | <Araq> Nim's threadpool is real. |
19:19:16 | FromGitter | <Araq> check how it iterates over the threads, at least. |
19:19:22 | FromGitter | <codem4ster> spawn do nothing for me :( |
19:19:42 | FromGitter | <Araq> `setMinPoolSize`, jezz |
19:20:09 | FromGitter | <codem4ster> really :( I want to cry now |
19:20:49 | FromGitter | <Araq> either use dead simple code with `createThread` and watch out for all its problems, or use threadpool.nim |
19:21:05 | FromGitter | <Araq> and it's all terrible :P |
19:21:12 | FromGitter | <Araq> but your code seems much worse |
19:21:38 | FromGitter | <codem4ster> :) I'm very new to Nim, you know |
19:21:54 | FromGitter | <Araq> somebody needs to revive Yuriy's PR ... |
19:25:25 | FromGitter | <Araq> @codem4ster yeah, it's not your fault. in order to get threads sane we need `=sink`() {.error.} |
19:25:58 | FromGitter | <codem4ster> @Araq how can I understand all spawned procs ended their job? |
19:27:40 | FromGitter | <codem4ster> sync() is not an option, I will break a loop if they all finished |
19:28:20 | FromGitter | <Araq> make them return something and wait for all |
19:30:25 | FromGitter | <codem4ster> but spawn is async, and I don't know the count of the spawns, they're dynamic |
19:30:53 | FromGitter | <codem4ster> I will spawn about 90000 of them |
19:31:25 | TheLemonMan | slightly over nine thousand, I like it |
19:31:49 | FromGitter | <codem4ster> 90_000 |
19:32:02 | FromGitter | <codem4ster> :D |
19:32:38 | FromGitter | <codem4ster> I will spawn them in a 8 threads pool |
19:33:28 | FromDiscord | <Gilgamish> Good day! I have two questions that I'd apprecaite if anyone could answer. |
19:33:28 | FromDiscord | <Gilgamish> |
19:33:29 | FromDiscord | <Gilgamish> 1. Does Nim have any system for union types/algebraic data types or polymorphism? |
19:33:29 | FromDiscord | <Gilgamish> 2. I'd like to build a tokenizer/lexer: I did something similar in Java where I used regex Is nims regex library mature enough or should I just process the string instead? |
19:35:23 | PMunch | 1. Yes, look at this: https://github.com/nim-lang/Nim/blob/master/lib/pure/json.nim#L606 |
19:35:36 | PMunch | That's a very basic example of a union type in Nim |
19:36:38 | PMunch | 2. There are multiple regex libraries, one is a simple wrapper around a C library, which obviously is very stable. And there are some that are pure Nim, not 100% sure on the status of those though |
19:37:14 | * | rockcavera joined #nim |
19:37:58 | FromDiscord | <Gilgamish> Thanks man |
19:38:06 | FromDiscord | <Gilgamish> Any documentation on the union types? |
19:38:55 | PMunch | https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants |
19:39:47 | PMunch | Not sure if there is more.. |
19:39:57 | PMunch | But they're pretty simple to get a grasp on |
19:40:21 | FromDiscord | <Gilgamish> That's actually quite nice |
19:40:39 | FromDiscord | <Gilgamish> No need for inheritance, thanks! |
19:42:42 | PMunch | Well inheritance solves another kind of problem |
19:42:48 | PMunch | And you can use that as well :) |
19:43:12 | PMunch | But yeah, often you wouldn't need it |
19:43:52 | FromGitter | <Araq> don't build lexers with regexes, unless it's a specialized lexer generator like lexim, flex etc |
19:47:21 | FromGitter | <mratsim> @codem4ster there are 2 unfortunately named spawned. One for async and one for threadpools. |
19:48:42 | FromGitter | <mratsim> anyway if you want to spawn 90000 threads you are looking for a M-N threading (i.e. M lightweight threads over N hardware threads) similar to Erlang Beam VM or goroutines. Unfortunately you can’t do that in Nim, that’s very complex. |
19:49:26 | FromDiscord | <Gilgamish> Thanks for the input, Araq |
19:50:01 | FromGitter | <mratsim> @Gilgamish, the main use case for inheritance in Nim is to allow a library to be extensible by user-derived types. |
19:50:29 | FromGitter | <mratsim> don’t use it to write a parser, you would have hundreds of allocations otherwise |
19:50:36 | FromGitter | <mratsim> and that would be your bottleneck |
19:51:08 | FromGitter | <mratsim> A state machine would be the fastest. |
19:51:35 | FromGitter | <mratsim> with states in enum |
19:56:32 | FromDiscord | <Gilgamish> I'm not really looking for performance |
19:57:08 | FromGitter | <codem4ster> I did it @mratsim threadpool doing that :) |
19:57:34 | FromDiscord | <Gilgamish> I wanted to build a programming language (it's my goto toy project when learning a language) and some union type works well in that case |
19:57:43 | FromGitter | <codem4ster> now I'm looking to the non-leaking flowing data from my terminal :) ⏎ ahh, that's the life... :D |
19:57:54 | FromDiscord | <Gilgamish> You know, for grouping statements, or variables |
20:00:28 | FromGitter | <Araq> @mratsim: it's actually not that hard to do with a trick... (famous last words) |
20:02:09 | FromGitter | <mratsim> @codem4ster congrats =), now you can write a blog post :P |
20:03:05 | FromGitter | <mratsim> @Gilgamish, I see, then you can check this as example: https://github.com/gokr/spryvm |
20:04:04 | * | nsf joined #nim |
20:04:06 | FromGitter | <mratsim> and check this as well for some example code of interpreters in Nim: https://github.com/status-im/nimbus/wiki/Interpreter-optimization-resources#nim-implementation-benchmark |
20:05:39 | TheLemonMan | did I just hear the "benchmark" word? :D |
20:05:44 | FromGitter | <mratsim> You have 5 examples: ⏎ ⏎ 1) Switch dispatch ⏎ 2) function table ⏎ 3) inheritance ... [https://gitter.im/nim-lang/Nim?at=5b918898c2bd5d117a2c8f22] |
20:06:00 | FromGitter | <unreadable> hey |
20:06:18 | FromGitter | <unreadable> How safe is Nim to use? :) |
20:06:30 | FromGitter | <mratsim> @TheLemonMan, beware this wiki link is a time blackhole |
20:06:56 | FromGitter | <mratsim> @unreadable, I would say “with great power comes great responsibility" |
20:06:58 | TheLemonMan | unreadable, quite to very |
20:07:43 | FromGitter | <mratsim> Nim comes with several tools from Ada that can makes very robust programs, or you can the C way with raw pointers |
20:07:46 | FromGitter | <unreadable> well, the fact that compiles to C made me wonder it |
20:08:15 | FromGitter | <mratsim> well assembly can be safe or unsafe, it’s not the language |
20:08:27 | FromDiscord | <Gilgamish> Thanks a lot @mratsim I genuinly could not ask for any more help! 😃 |
20:09:46 | FromGitter | <mratsim> @Gilgamish, here is another one a CPU interpreter: https://github.com/mratsim/chirp8/blob/master/src/cpu.nim |
20:10:10 | FromGitter | <unreadable> thanks, I'll deep into nim to see what is has to offer |
20:10:12 | FromGitter | <mratsim> if you have doubt on object variant you should see how to use them |
20:10:34 | FromGitter | <mratsim> you have both tagged and untagged union even |
20:11:46 | * | Notkea joined #nim |
20:13:29 | * | Trustable quit (Remote host closed the connection) |
20:22:09 | * | endragor joined #nim |
20:26:30 | * | endragor quit (Ping timeout: 252 seconds) |
20:35:25 | * | PMunch quit (Remote host closed the connection) |
20:40:55 | * | skelett1 quit (Quit: WeeChat 2.1) |
20:41:23 | * | skelett joined #nim |
20:46:46 | FromDiscord | <treeform> Does any one know if nim's strings in JS mode, are arrays of utf-8s or unicode chars? There seems to be a bug that comes up with `toJSStr` and I am trying to figure out what it should be. |
20:48:27 | * | skelett quit (Quit: WeeChat 2.1) |
20:48:44 | * | skelett joined #nim |
21:02:32 | * | erratic quit (Quit: this server has gone to sleep) |
21:02:42 | * | sz0 quit (Ping timeout: 252 seconds) |
21:04:09 | * | sz0 joined #nim |
21:04:38 | FromGitter | <Araq> arrays of unicode chars |
21:05:26 | FromGitter | <Araq> @mratsim: the better example is "illegal instruction". asm has it, C lacks it. but oh why? C compiles to asm... the big riddle. |
21:09:01 | * | leaf__ joined #nim |
21:10:07 | * | erratic joined #nim |
21:17:11 | dom96 | no? |
21:24:23 | * | nsf quit (Quit: WeeChat 2.2) |
21:31:24 | * | Notkea quit (Ping timeout: 252 seconds) |
21:32:44 | * | Notkea joined #nim |
21:47:58 | * | TheLemonMan quit (Quit: "It's now safe to turn off your computer.") |
21:57:57 | * | leaf__ quit (Ping timeout: 252 seconds) |
22:03:52 | FromDiscord | <emekoi> i think i broke nim |
22:04:18 | FromDiscord | <emekoi> the compiler dies silently and returns error code -1073741571 |
22:05:41 | AlexMax | So I notice that when I use nimble build to build my binaries, the binaries end up in the root directory and nimcache ends up in src/ |
22:06:03 | AlexMax | But I now want a nims build task as well, so it doesn't look up dependencies every build |
22:06:35 | AlexMax | To get the exact same beavhior, I use switch("nimcache", "src/nimcache"); setCommand("c", "src/rocked"); switch("out", "rocked") |
22:06:39 | ldlework | emekoi hehe |
22:07:29 | AlexMax | Is there a single switch that I can use instead - or rather, does nimble just use one switch to get the behavior I describe? |
22:07:49 | AlexMax | I mean, it works well enough for me |
22:11:47 | FromDiscord | <emekoi> AlexMan, in the nimble file you can set `binDir` to the desired binary directory. |
22:24:12 | * | a_b_m joined #nim |
22:24:51 | FromDiscord | <emekoi> does nim do ci tests for mac, linux, and windows (32 and 64 bit)? |
22:24:56 | * | zachcarter joined #nim |
22:25:30 | FromGitter | <mratsim> @emekoi yes, check our repo https://github.com/status-im/nimbus |
22:27:30 | * | abm quit (Ping timeout: 252 seconds) |
22:27:47 | * | Vladar quit (Remote host closed the connection) |
22:30:51 | FromDiscord | <emekoi> okay, so would it be feasible for the binaries from those ci tests to be uploaded/deployed/etc. to some sort of "server" if the test succeds and then choosenim downloads those binaries, instead of building locally? |
22:31:20 | FromGitter | <mratsim> yes search for Travis:Appveyor build artifacts |
22:34:21 | FromDiscord | <emekoi> then why doesn't choosenim do this? is there some advantage to building locally instead of downloading a binary? |
22:35:13 | FromGitter | <mratsim> the stable version are downloaded |
22:35:55 | FromGitter | <mratsim> there are no nightlies because no one set it up but dom96 said 2 days ago that he welcomes any PR in that direction |
22:36:25 | FromDiscord | <emekoi> oh boy add one more to my todo list 😉 |
22:42:17 | * | xet7 quit (Quit: Leaving) |
23:03:42 | * | gangstacat quit (Ping timeout: 252 seconds) |
23:14:11 | * | seni quit (Quit: Leaving) |
23:16:16 | * | gangstacat joined #nim |
23:19:12 | * | sagax quit (Ping timeout: 244 seconds) |
23:30:01 | * | sagax joined #nim |
23:36:08 | * | a__b__m joined #nim |
23:39:55 | * | a_b_m quit (Ping timeout: 246 seconds) |
23:44:07 | * | sagax quit (Quit: Konversation terminated!) |