00:25:03 | FromDiscord | <Matt> I'm continuing to work on a simple lsm tree kv store |
00:25:19 | FromDiscord | <Matt> I currently have a function that does a compaction / merge of the on disk files |
00:25:26 | FromDiscord | <Elegantbeef> Chaining together words together does not make it true |
00:25:35 | FromDiscord | <Matt> Huh |
00:25:54 | FromDiscord | <Matt> I wanted to introduce a background thread that would invoke that compaction on a set interval |
00:26:19 | FromDiscord | <Matt> Would it make sense form my LSM type to have a thread property that gets set upon instantiation or is that asking for trouble |
00:28:32 | FromDiscord | <elegantbeef> Ah there was a follow up message, the bridge ate it. It's up to you |
00:28:42 | FromDiscord | <Matt> All g |
00:28:48 | FromDiscord | <Matt> Just some bad timing |
00:28:55 | FromDiscord | <Matt> So on second thought I'm not sure I can |
00:29:31 | FromDiscord | <Matt> sent a code paste, see https://play.nim-lang.org/#ix=4D7G |
00:29:37 | FromDiscord | <Matt> That's what my code looks like for the lsm |
00:29:53 | FromDiscord | <Matt> Sorry in advance if it doesn't render in your irc client, I can pastebin / gist it |
00:30:21 | FromDiscord | <Elegantbeef> I use matrix so it renders |
00:30:30 | FromDiscord | <Matt> sent a code paste, see https://play.nim-lang.org/#ix=4D7H |
00:30:36 | FromDiscord | <Matt> And here's what I tried as my type def |
00:30:47 | FromDiscord | <Matt> problem is that this is an illegal circular reference |
00:31:01 | FromDiscord | <Matt> So I guess my question is |
00:31:03 | FromDiscord | <Elegantbeef> Where? |
00:31:18 | FromDiscord | <Matt> nim_lsm.nim(21, 6) Error: illegal recursion in type 'LSM' |
00:31:38 | FromDiscord | <Matt> Upon introducing that tuple |
00:32:02 | FromDiscord | <Elegantbeef> Ah it stores the arg internally |
00:32:18 | FromDiscord | <Matt> So my general question is how can I instantiate a background thread for a LSM object that does the compaction, so that it is also managed by the object's lifetime |
00:32:33 | FromDiscord | <Elegantbeef> Seperate the LSM from the thread through a data type |
00:32:35 | FromDiscord | <Matt> i.e. I don't delete my LSM object later, say in a library, and then the thread wreaks haboc |
00:32:45 | FromDiscord | <Matt> 👀 I'm listening |
00:32:49 | FromDiscord | <odexine> The code you have as is right now will copy the LSM type as you pass it into the thread |
00:32:51 | FromDiscord | <odexine> Is that intended |
00:32:54 | FromDiscord | <Matt> No |
00:33:00 | FromDiscord | <Matt> Maybe it should be ref |
00:33:01 | FromDiscord | <Matt> ? |
00:33:14 | FromDiscord | <odexine> If you’re feeling lucky you can use a pointer |
00:33:38 | FromDiscord | <Matt> Is there a cleaner way to do it? |
00:33:46 | FromDiscord | <Matt> In reply to @odexine "If you’re feeling lucky": Not out of the question |
00:33:49 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/GHRsj |
00:34:06 | FromDiscord | <Matt> sent a code paste, see https://play.nim-lang.org/#ix=4D7J |
00:34:17 | FromDiscord | <odexine> Locks don’t play well when put into references from what I recall |
00:34:31 | FromDiscord | <Elegantbeef> OtherLSMThing should have a `lsm: LSM` field if unclear |
00:34:33 | FromDiscord | <Matt> Oh lovely |
00:34:44 | FromDiscord | <Matt> In reply to @Elegantbeef "OtherLSMThing should have a": Why is that |
00:34:57 | FromDiscord | <Matt> I'm not sure I fully grok the ownership / threading model |
00:35:04 | FromDiscord | <Elegantbeef> Cause that object holds teh lsm and the thread |
00:36:05 | FromDiscord | <Elegantbeef> I don't see why you could not use a ref with locks, the issue is more destructors are going to get called if you do not disarm the destructor properly |
00:36:26 | FromDiscord | <Matt> > more destructors are going to get called if you do not disarm the destructor properly↵? |
00:37:19 | FromDiscord | <Elegantbeef> Welcome to Nim threading without atomic ref counting |
00:37:48 | FromDiscord | <Elegantbeef> Sharing is hard to do safely you need to know when to use `wasMoved` to stop the GC from attempting to free resources |
00:38:57 | FromDiscord | <Matt> Ok |
00:39:08 | FromDiscord | <Matt> So without knowing much about nim's gc model right now |
00:39:29 | FromDiscord | <Matt> Is this doable? I'm not following from your suggestion |
00:40:09 | FromDiscord | <Elegantbeef> Nim's GC model is quite simple now, it calls destructors at end of scope, if you share a reference to a thread you need one thread to not destroy it so you need to call `wasMoved` on one side |
00:40:54 | FromDiscord | <Matt> I see |
00:41:26 | FromDiscord | <Matt> Is there something like "weakref" in Nim that does this |
00:41:40 | FromDiscord | <Elegantbeef> There is a `{.cursor.}` annotation, but it's not a weak ref |
00:42:19 | FromDiscord | <Matt> I see |
00:42:52 | FromDiscord | <Matt> > But please notice that this is not C++'s weak_ptr, it means the right field is not involved in the reference counting, it is a raw pointer without runtime checks.↵↵So it's just a compiler hint but doesnt come with any safety guarantees |
00:43:02 | FromDiscord | <Elegantbeef> Right |
00:43:57 | FromDiscord | <litlighilit> using `ord` is safer↵(@heysokam) |
00:44:08 | FromDiscord | <Elegantbeef> `ord` doesnt work on sets |
00:44:44 | FromDiscord | <heysokam> In reply to @litlighilit "using `ord` is safer": ord is for single enums. i want the underlying value of a set of enums |
00:44:48 | FromDiscord | <Matt> So if I do use cursor, how would I check if the object is deallocated inside my background thread so that I can exit when the object is wiped |
00:45:22 | FromDiscord | <Elegantbeef> I mean you wouldnt use cursor |
00:45:55 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4D7K |
00:46:15 | FromDiscord | <Elegantbeef> There is no items for your hashset you did not do `import std/sets` |
00:46:44 | FromDiscord | <heysokam> i did add it, though |
00:46:57 | FromDiscord | <heysokam> or you mean that the set is empty? |
00:46:57 | FromDiscord | <Elegantbeef> In the consuming module? |
00:47:12 | FromDiscord | <Elegantbeef> Why would the set being empty give a compile time error |
00:47:50 | FromDiscord | <heysokam> In reply to @Elegantbeef "In the consuming module?": its a func, shouldn't the consuming module be the same as the one that contains the func itself? 🤔 |
00:48:15 | FromDiscord | <heysokam> (edit) "its" => "the union call is inside" |
00:48:18 | FromDiscord | <Elegantbeef> The issue is the `sets` module |
00:48:26 | FromDiscord | <Elegantbeef> `for item in other.items` |
00:48:41 | FromDiscord | <Elegantbeef> `for x in y` does not properly look up symbols |
00:48:42 | FromDiscord | <heysokam> yeah, but i don't know why that is failing there |
00:48:50 | FromDiscord | <Elegantbeef> It's a bug with implicit items |
00:49:14 | FromDiscord | <heysokam> a bug in the lang or in my app? |
00:49:38 | FromDiscord | <Elegantbeef> You really like being silly, your app is not "implicit items" is it 😛 |
00:50:23 | FromDiscord | <Elegantbeef> Inside generics `for x in y` does not look up the proper `items` |
00:50:25 | FromDiscord | <heysokam> i don't understand what that means |
00:50:49 | FromDiscord | <Elegantbeef> In nim for loops `for x in y` implicitly calls `for x in y.items` |
00:50:56 | FromDiscord | <Elegantbeef> The look up is broken inside generic procedures |
00:51:24 | FromDiscord | <Elegantbeef> The bug is in the language, if it's still unclear |
00:51:43 | FromDiscord | <Matt> @ elegantbeef. Sorry, not following- so as it currently stands if I create a thread object within my LSM type and run a proc on it, deallocating the LSM will stop the thread, right?↵↵However, I can't do what I want because the compiler complains about a circular reference. You suggested a second type and mentioned cursor but I'm not 100% clear on how you suggest using them |
00:52:03 | FromDiscord | <Elegantbeef> Deallocating the LSM will not stop the thread |
00:52:10 | FromDiscord | <Elegantbeef> I didnt suggest a cursor 😄 |
00:52:59 | FromDiscord | <heysokam> In reply to @Elegantbeef "The bug is in": shoot, well thats a probl i guess 😔↵any ideas how I could do the same in the meantime? |
00:53:26 | FromDiscord | <Matt> In reply to @Elegantbeef "Deallocating the LSM will": Interesting. Do you know if that could be done? |
00:53:29 | FromDiscord | <Elegantbeef> Copy the procedure into your own module and put `items` |
00:54:16 | FromDiscord | <Matt> wdym |
00:54:49 | FromDiscord | <Elegantbeef> Seriously is it this hard to have multiple conversations at once |
00:54:49 | FromDiscord | <Elegantbeef> That was for skam |
00:54:50 | FromDiscord | <Elegantbeef> sokam even |
00:55:36 | FromDiscord | <Matt> I filtered out what they were writing honestly |
00:55:55 | FromDiscord | <Elegantbeef> Rude |
00:56:53 | FromDiscord | <Matt> Not really |
00:57:02 | FromDiscord | <Matt> IM ux is heavy |
00:57:12 | FromDiscord | <Matt> especially for multiple technical conversations |
00:57:15 | FromDiscord | <Elegantbeef> Ok that was clearly satire |
00:57:29 | FromDiscord | <Matt> Guess today's not my day |
00:58:15 | FromDiscord | <Elegantbeef> I for the life of me cannot remember how to properly disarm a GC hook |
01:01:31 | FromDiscord | <heysokam> sent a code paste, see https://paste.rs/S3Ngb |
01:01:50 | FromDiscord | <Elegantbeef> Are you sure you have `sets` in this module? |
01:01:54 | FromDiscord | <heysokam> yes i do |
01:01:58 | FromDiscord | <heysokam> checked like 5 times |
01:02:09 | FromDiscord | <Elegantbeef> did you call `.items` explicitly? |
01:02:11 | FromDiscord | <heysokam> now its failing with the `toSeq` implementation |
01:02:28 | FromDiscord | <heysokam> (edit) "now its failing with the `toSeq` implementation ... " added "from sequtils" |
01:03:50 | FromDiscord | <litlighilit> What if to use `ptr` instead?↵(@Matt) |
01:06:13 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4D7P |
01:07:03 | FromDiscord | <Elegantbeef> I said what I thought it was |
01:07:06 | FromDiscord | <Matt> In reply to @litlighilit "What if to use": looking into it as well |
01:07:08 | FromDiscord | <Elegantbeef> Anyway I do not thread so I should not try helping anymore |
01:07:36 | FromDiscord | <Elegantbeef> You should be able to use `ref` instead of ptr as long as you ensure you only destroy it from one thread, but that's a complicated matter I guess |
01:08:09 | FromDiscord | <Matt> I'll follow up tomorrow - think I've hit the wall for today |
01:08:10 | FromDiscord | <Matt> Thank you |
01:19:39 | FromDiscord | <litlighilit> Is there a show-case? |
01:19:52 | FromDiscord | <Elegantbeef> No we have not got a reproduction |
01:21:14 | FromDiscord | <litlighilit> Does it come from an empty set literal? |
01:21:39 | FromDiscord | <Elegantbeef> Hashsets do not have a literal |
01:24:34 | FromDiscord | <Matt> sent a long message, see http://ix.io/4D7S |
01:24:52 | FromDiscord | <Matt> Unexpected markdown, disregard |
01:24:57 | FromDiscord | <Matt> open to suggestions from all |
01:26:49 | FromDiscord | <Matt> + if anyone knows anything about protect/dispose |
01:31:43 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4D7U |
01:32:22 | FromDiscord | <Matt> I also found this: 6-7 years old,t hough |
01:32:23 | FromDiscord | <Matt> https://github.com/zielmicha/collections.nim/blob/master/collections/weakref.nim |
01:32:44 | FromDiscord | <arathanis> also can you specify the source file in the task without just using `exec "nim c ..."`? |
01:32:56 | FromDiscord | <litlighilit> nimble tasks |
01:33:09 | FromDiscord | <Elegantbeef> they're not using nimble |
01:33:19 | FromDiscord | <Elegantbeef> They're using nim's nimscript tasks |
01:33:22 | FromDiscord | <Elegantbeef> I do not know if there's a way to list them arath |
01:33:42 | FromDiscord | <arathanis> i was afraid of that, ill keep looking |
01:33:55 | FromDiscord | <arathanis> hopefully there is a way but i guess there is always "look at the config.nims file" lmao |
01:34:06 | FromDiscord | <Elegantbeef> Oh the docs say make `nim help` print commands |
01:34:33 | FromDiscord | <arathanis> god, did i just miss it completely? checking... |
01:34:55 | FromDiscord | <Elegantbeef> Yea it does |
01:35:17 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/nims.html#nimscript-as-a-build-tool documented here |
01:35:59 | * | sneekyfoxx joined #nim |
01:36:03 | FromDiscord | <arathanis> ok i figured it out |
01:36:13 | FromDiscord | <arathanis> it show up with `nim help` but not `nim --help` |
01:36:27 | sneekyfoxx | quit |
01:36:28 | FromDiscord | <arathanis> also its missing a space, the formatting drives me insane |
01:36:34 | * | sneekyfoxx quit (Client Quit) |
01:36:39 | FromDiscord | <Elegantbeef> No |
01:36:40 | FromDiscord | <Elegantbeef> You're here now |
01:37:03 | FromDiscord | <Elegantbeef> What's missing a space? |
01:37:07 | FromDiscord | <arathanis> sent a long message, see http://ix.io/4D7V |
01:38:17 | FromDiscord | <arathanis> In reply to @Elegantbeef "What's missing a space?": oh wait nvm my terminal was jacked up |
01:38:30 | FromDiscord | <arathanis> when i did `nim help` |
01:38:33 | FromDiscord | <arathanis> it printed the help as |
01:38:37 | FromDiscord | <arathanis> `nimbuild build the program` |
01:38:44 | FromDiscord | <arathanis> but now its not doing that |
01:39:14 | FromDiscord | <arathanis> Beef, is there a way to specify the source file beyond just using `exec "nim c <src>"` in a task? |
01:39:35 | FromDiscord | <Elegantbeef> No clue |
01:39:50 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4D7W |
01:40:40 | FromDiscord | <Elegantbeef> Certainly not now that I think about it |
01:41:04 | FromDiscord | <Elegantbeef> PS use `selfExec` |
01:46:11 | FromDiscord | <litlighilit> When it comes to ownership, there is `owned` type in nim↵(@Matt) |
01:49:42 | FromDiscord | <Elegantbeef> No there isnt |
02:03:09 | FromDiscord | <arathanis> In reply to @Elegantbeef "PS use `selfExec`": so I can invoke `selfExec` to invoke the rest of the command? |
02:03:38 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4D80 |
02:04:01 | FromDiscord | <Elegantbeef> No clue |
02:09:44 | FromDiscord | <litlighilit> if `-d:nimOwnedEnabled` |
02:09:52 | FromDiscord | <Elegantbeef> Right and that means nothing |
02:10:20 | FromDiscord | <Elegantbeef> `std/isolation` exists and `sink`/`lent` exist |
02:11:13 | FromDiscord | <Elegantbeef> owned will be removed eventually |
03:16:54 | FromDiscord | <terrygillis> sent a long message, see http://ix.io/4D8f |
03:17:22 | FromDiscord | <terrygillis> (edit) "http://ix.io/4D8f" => "http://ix.io/4D8g" |
03:19:16 | FromDiscord | <Elegantbeef> This is cause `c` is a `var T` and to make a closure of that `Counter` it needs to be a place that is guaranteed to outlive `later` |
03:19:40 | FromDiscord | <Elegantbeef> Nim does not have a borrow checker so this means `c` needs to be `c: ref Counter` |
03:21:28 | FromDiscord | <terrygillis> why in this case does inner() not outlive later()? |
03:22:28 | FromDiscord | <Elegantbeef> Nim doesnt have a smart checker, it literally just says "this is a closure it cannot capture `var T`" |
03:23:12 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4D8h |
03:23:17 | FromDiscord | <Elegantbeef> gets around the checker in this case |
03:23:23 | FromDiscord | <Elegantbeef> Don't use it unless you know it's safe to |
03:23:37 | FromDiscord | <terrygillis> Ah I see, so effectively capturing stack allocated reference is banned from Nim right? |
03:25:00 | FromDiscord | <Elegantbeef> Yes cause it has no way to ensure it safely |
03:25:21 | FromDiscord | <Elegantbeef> It will get a borrow checker eventually, but does not have a non experimental one presently |
03:25:45 | FromDiscord | <terrygillis> but why is it compiling here: https://play.nim-lang.org/#ix=4D8i? |
03:26:17 | FromDiscord | <terrygillis> (edit) "https://play.nim-lang.org/#ix=4D8i?" => "https://play.nim-lang.org/#ix=4D8i ?" |
03:26:38 | FromDiscord | <Elegantbeef> It's copying the variable |
03:28:21 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4D8k |
03:31:28 | FromDiscord | <terrygillis> that's a bit confusing, like why if I pass a `var T` in a proc then that proc cannot capture it in a closure, but if I declare as a `var` in a proc directly then it would be captured and actually modifiable? |
03:32:40 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4D8m |
03:33:02 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=nbd |
03:34:20 | FromDiscord | <terrygillis> (edit) "https://play.nim-lang.org/#ix=4D8m" => "https://play.nim-lang.org/#ix=4D8n" |
03:34:35 | FromDiscord | <terrygillis> (edit) "https://play.nim-lang.org/#ix=4D8n" => "https://play.nim-lang.org/#ix=4D8o" |
03:35:37 | FromDiscord | <terrygillis> sorry for constantly editing the message if anyone is bothered |
03:36:58 | FromDiscord | <Elegantbeef> I don't know what to say it clearly copies https://play.nim-lang.org/#ix=4D8q |
03:42:42 | * | disso-peach joined #nim |
03:43:01 | FromDiscord | <terrygillis> In reply to @Elegantbeef "I don't know what": Ok, to clarify, do you mean copy in the sense "copy the reference to that variable" or "copy the value of that variable", because in both the code you sent and my code above, `inner` is clearly capturing the reference to `var counter` and increasing `counter.start` every time it gets called? |
03:43:37 | FromDiscord | <Elegantbeef> It's capturing a copied version that is not stack allocated |
03:48:05 | FromDiscord | <terrygillis> sent a code paste, see https://paste.rs/ZbhuL |
03:48:27 | FromDiscord | <Elegantbeef> Ah this is simple |
03:48:28 | FromDiscord | <Elegantbeef> Whenever a procedure creates a closure the variables that are captured are aliase to the scope |
03:48:45 | FromDiscord | <Elegantbeef> > Any captured variables are stored in a hidden additional argument to the closure (its environment) and they are accessed by reference by both the closure and its enclosing scope (i.e. any modifications made to them are visible in both places). |
03:48:48 | FromDiscord | <Elegantbeef> From the manual |
03:49:14 | NimEventer | New thread by isaiah: What is the best way to learn nim for someone who is fluent with python, see https://forum.nim-lang.org/t/10394 |
03:49:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4D8t |
03:49:49 | FromDiscord | <Elegantbeef> Which gives you a nice ergonomic api that just works |
03:50:53 | FromDiscord | <Elegantbeef> This is why `for x in 0..3: let z = (proc(): int = x)` doesnt work as expected |
03:56:09 | FromDiscord | <Elegantbeef> Well that does but when you store that into a proc that outlives the for loop |
03:57:14 | FromDiscord | <terrygillis> I thought as the for loop ends, its scope which includes proc z is dropped entirely? |
03:59:00 | FromDiscord | <Elegantbeef> Well like i said it should outlive the for loop |
03:59:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4D8u |
03:59:37 | FromDiscord | <Elegantbeef> now if you call those procs you get a nice unexpected behaviour |
03:59:40 | FromDiscord | <terrygillis> ah that one I see |
04:01:02 | FromDiscord | <terrygillis> but back to the previous: "it actually aliases counter to inner.env.counter internally" is a bit muddy to me (sorry I'm still a novice). Can you clarify a bit more? |
04:01:36 | FromDiscord | <Elegantbeef> closure procedures store an environment with the data they capture |
04:02:13 | FromDiscord | <Elegantbeef> when you declare a closure inside of a procedure that captures a variable it aliases that variable to a global environment |
04:02:37 | FromDiscord | <terrygillis> a so it is passed in a reference to `var counter` everytime it gets called, right? |
04:02:47 | FromDiscord | <terrygillis> (edit) "a" => "ah" |
04:02:54 | FromDiscord | <terrygillis> (edit) removed "in" |
04:03:06 | FromDiscord | <Elegantbeef> Hidden away from you yes |
04:08:04 | FromDiscord | <odexine> Doesn’t Nim have that closure capture proc to fix this |
04:08:12 | FromDiscord | <odexine> I didn’t read the whole chat I just got here |
04:12:35 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4D8x |
04:13:59 | FromDiscord | <Elegantbeef> `var Counter` is a might be on a reference or the stack and there is no way to propagate that it's now owned by a closure, there's also no back propagation |
04:14:44 | FromDiscord | <Elegantbeef> back propagation to change where it's pointing |
04:15:32 | FromDiscord | <Elegantbeef> regardless `var T` cannot be captured cause it's not safe to do such as you need to ensure the resource stays alive as long as the closure exists, in this case it's fine but Nim just applies a wide brush on disallowing it |
04:18:11 | FromDiscord | <terrygillis> In reply to @Elegantbeef "regardless `var T` cannot": ah so it's just that the compiler is not smart enough to guarantee that counter will outlive inner so it just ban it for safety concern. |
04:19:19 | FromDiscord | <Elegantbeef> Well it requires following the life time of the closure and seeing whether `inner` escapes the scope, so you need a borrow checker |
04:19:19 | FromDiscord | <Elegantbeef> we do have `views` but it's experimental |
04:20:44 | FromDiscord | <terrygillis> In reply to @Elegantbeef "`var Counter` is a": but I don't understand this really, I thought `var Counter` is kinda a reference to a Counter object on the stack, and googling back propagation gives me some machine learning mouthful. |
04:21:14 | FromDiscord | <jakraes> Is there a way to give a value to attributes inherited from a parent object? |
04:21:48 | FromDiscord | <jakraes> Like, a game entity has an attribute called HP, and I want the player, which inherits from game entity to have 20 hp by default |
04:21:52 | FromDiscord | <Elegantbeef> `var Counter` is a pointer to a `Counter` anywhere |
04:22:07 | FromDiscord | <Elegantbeef> It can be in a `seq` a `ref object` a `ref Counter` it can be anywhere |
04:22:43 | FromDiscord | <Elegantbeef> back propagation in that there is no way of saying "This now points here" since you do not own the resource that you're making a closure of, you can do it inside of proc cause you own that resource |
04:24:23 | FromDiscord | <terrygillis> In reply to @Elegantbeef "It can be in": wait what, so `c: var Counter` will accept a `ref Counter` as an argument? |
04:24:41 | FromDiscord | <Elegantbeef> No it'll accept a `Counter` that is from a ref |
04:25:13 | FromDiscord | <Elegantbeef> Completely valid code |
04:25:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4D8y |
04:28:04 | FromDiscord | <terrygillis> ah, so is there a way for a proc to actually demand that the argument passed in must be allocated on the stack? (just a curious question) |
04:28:24 | FromDiscord | <Elegantbeef> Not without concepts and macros |
04:30:40 | FromDiscord | <terrygillis> Thank you very much. Well, for the first time while trying out nim, I encounter something that is as hairy as fighting the rust borrow checker 😭 |
04:31:14 | FromDiscord | <Elegantbeef> It's not that hairy |
04:31:48 | FromDiscord | <Elegantbeef> if you know it's safe to reference you do `let myCounter = counter.addr` if it's not safe and you do not care that it points to the original you do `var counter = counter` |
04:34:13 | FromDiscord | <terrygillis> btw does manually dereferencing a ref type with `[]` classify as an unsafe or safe operation? |
04:44:33 | FromDiscord | <odexine> Depends if you think dereferencing nil is safe or not |
05:05:26 | * | rockcavera quit (Remote host closed the connection) |
05:27:37 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=4D8G |
05:29:06 | * | advesperacit joined #nim |
05:29:30 | FromDiscord | <Elegantbeef> `rss: (Channel,)` 😄 |
05:29:36 | FromDiscord | <Elegantbeef> But yea there is no inline object |
05:30:44 | FromDiscord | <ajusa> no macros that do anything similar which you are aware of beef? |
05:31:11 | FromDiscord | <Elegantbeef> I personally have the view that anonymous objects defeat the purpose of objects, so if there I do not know of it |
05:33:05 | FromDiscord | <Elegantbeef> Also `Channel` might be wrong it's a generic type |
05:33:32 | FromDiscord | <ajusa> ah no this is my own channel type, I'm not importing threads |
05:36:05 | * | advesperacit quit (Read error: Connection reset by peer) |
05:36:53 | FromDiscord | <Elegantbeef> If anyone has anon objects it'd be metagn, they do cool shit |
05:37:37 | * | advesperacit joined #nim |
06:22:46 | FromDiscord | <ringabout> Indeed 🤣 |
06:24:08 | NimEventer | New Nimble package! mapster - A library to quickly generate functions converting instances of type A to B, see https://github.com/PhilippMDoerner/mapster |
06:25:39 | * | ntat joined #nim |
06:25:40 | FromDiscord | <Elegantbeef> @Phil\: you forgot to mention which module to import in your examples |
06:25:47 | FromDiscord | <Elegantbeef> Literally unusable |
06:26:22 | FromDiscord | <Phil> Tfw you realize on the way to work that you left in the dummy tests in the package itself |
06:26:24 | FromDiscord | <Elegantbeef> "Oh i'll import 'mapster'.... wait why is my program printing inane shit" |
06:27:01 | FromDiscord | <Elegantbeef> And you want mocked procedures, the only mocking we do around here is personal |
06:27:24 | FromDiscord | <Phil> Eh, I'll fix it when I'm back, not like my packages actually grow that much of a user base.↵Majority of the time I'm my own user and I have patience |
06:27:53 | FromDiscord | <Elegantbeef> Yea I just noticed it so thought I'd annoy you here instead of making an issue |
06:28:04 | FromDiscord | <Phil> Fair |
06:28:42 | FromDiscord | <Phil> In reply to @Elegantbeef "And you want mocked": If I ever figure out how to deal with generics we shall have those! |
06:29:27 | FromDiscord | <Elegantbeef> Such wasted effort 😄 |
06:29:49 | FromDiscord | <Phil> Eh, agree to disagree |
06:53:38 | * | azimut quit (Ping timeout: 240 seconds) |
07:08:51 | * | junaid_ joined #nim |
07:17:02 | * | junaid_ quit (Remote host closed the connection) |
09:06:39 | FromDiscord | <heysokam> is there a way to get a string `"name"` from `name :untyped` input in a template? 🤔 |
09:07:24 | FromDiscord | <Elegantbeef> Nope |
09:07:40 | FromDiscord | <Elegantbeef> `astToStr(name)` will be turned into `astToStr(whatever passed here)` |
09:08:20 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4D9u |
09:09:09 | FromDiscord | <heysokam> only the examples depend on vmath and other things, but there are like 15+ so writing `taskRequires` for all of them and all of the libraries gets tiresome quick |
09:11:51 | FromDiscord | <heysokam> In reply to @Elegantbeef "Nope": is it possible to do the opposite, and get a string into an untyped word instead? 🤔 |
09:22:37 | FromDiscord | <Elegantbeef> Make a macro that converts it to an ident |
09:24:30 | FromDiscord | <litlighilit> This works if passed a arg from template |
09:24:47 | FromDiscord | <System64 ~ Flandre Scarlet> I try to parse an xml file, is it possible to query elements? https://media.discordapp.net/attachments/371759389889003532/1139489576277245952/image.png |
09:28:35 | FromDiscord | <litlighilit> sent a code paste, see https://play.nim-lang.org/#ix=4D9x |
09:39:09 | FromDiscord | <heysokam> is there a way to revert the effects of a `{.dirty.}` template, but just for one specific symbol? |
09:39:22 | FromDiscord | <heysokam> aka the opposite of `.inject.` |
09:40:35 | FromDiscord | <litlighilit> {.genSym.} |
09:41:51 | FromDiscord | <heysokam> taskRequires doesn't seem to be solving the dependency anyway... so not like the template I made is that useful anyway 😔 |
09:42:02 | FromDiscord | <heysokam> (edit) "dependency anyway..." => "dependency..." |
09:42:33 | * | junaid_ joined #nim |
09:42:59 | FromDiscord | <litlighilit> Opp, I find in above example, {.inject.} can be omitted, as the template is {.dirty.} |
09:44:58 | FromDiscord | <litlighilit> ? details |
09:45:52 | FromDiscord | <heysokam> In reply to @litlighilit "Opp, I find in": yeah i noticed that the template doesn't need to be dirty at all |
09:47:33 | FromDiscord | <litlighilit> Also, if you don't use strformat for name, there is no need to inject a temporary symbol like `name_str` |
09:48:29 | FromDiscord | <litlighilit> sent a code paste, see https://play.nim-lang.org/#ix=4D9B |
09:50:34 | FromDiscord | <Hamid_Bluri> In reply to @sys64 "I try to parse": not sure but this might help you https://nimble.directory/pkg/q |
09:52:06 | FromDiscord | <Hamid_Bluri> In reply to @sys64 "I try to parse": this too https://nimble.directory/pkg/nimpath |
09:55:36 | FromDiscord | <System64 ~ Flandre Scarlet> the seconds sounds more complex to use |
09:56:08 | FromDiscord | <System64 ~ Flandre Scarlet> https://nim-lang.org/docs/xmltree.html#XmlNode↵I use that but seems it's not as easy to use as the JSON one |
09:56:20 | FromDiscord | <System64 ~ Flandre Scarlet> https://nim-lang.org/docs/xmlparser.html↵Well that, sorry |
09:57:52 | FromDiscord | <Hamid_Bluri> In reply to @sys64 "https://nim-lang.org/docs/xmltree.html#XmlNode I us": why is not easy? |
09:58:24 | FromDiscord | <Hamid_Bluri> https://nimble.directory/pkg/nimquery |
09:59:14 | FromDiscord | <Hamid_Bluri> sure XML does not have `int`, `float` ,... types but that's not way hard |
10:15:44 | NimEventer | New thread by radekm: Nim 2 and need for try-finally?, see https://forum.nim-lang.org/t/10395 |
10:16:40 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4D9I |
10:16:58 | FromDiscord | <System64 ~ Flandre Scarlet> It's very easy to navigate through the tree with JSON |
10:38:03 | FromDiscord | <terrygillis> sent a code paste, see https://paste.rs/wJXf7 |
10:39:25 | FromDiscord | <terrygillis> (edit) "https://play.nim-lang.org/#ix=4D9K" => "https://play.nim-lang.org/#ix=4D9L" |
10:39:39 | FromDiscord | <terrygillis> (edit) "https://play.nim-lang.org/#ix=4D9L" => "https://play.nim-lang.org/#ix=4D9N" |
10:44:34 | * | junaid_ quit (Remote host closed the connection) |
10:49:10 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4D9P |
10:56:56 | FromDiscord | <System64 ~ Flandre Scarlet> Alright so I start to understand how to parse XML |
11:05:16 | FromDiscord | <Hamid_Bluri> In reply to @sys64 "Alright so I start": the problem is XML entries can be repeateed unlike JSON object keys |
11:05:25 | FromDiscord | <Hamid_Bluri> (edit) "In reply to @sys64 "Alright so I start": the problem is ... XML" added "that" |
11:07:21 | FromDiscord | <demotomohiro> In reply to @terrygillis "hi, I'm trying out": `addT`'s first parameter is `TType` but you calls `addT` without `TType` argument. |
11:08:22 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @hamidb80 "the problem is that": XML is like poor HTML |
11:09:16 | FromDiscord | <System64 ~ Flandre Scarlet> but it's great for GUIs (XAML and FXML are things) |
11:24:32 | FromDiscord | <terrygillis> In reply to @terrygillis "hi, I'm trying out": oops sorry I mistranslated from my code. Here’s my problematic code: https://play.nim-lang.org/#ix=4D9X |
11:25:52 | FromDiscord | <terrygillis> The error message from the compiler only shows ‘type mismatch: got 'string' for 'text' but expected 'float'’ but the vscode extension would show the reverse for the code below too, where I pass in the number |
11:52:44 | FromDiscord | <litlighilit> use when |
12:01:28 | FromDiscord | <litlighilit> Nim is static-typed, one symbol must only has one type.↵↵When nim compiles your code, both `t.floatField = a` and `t.stringField = a` are solved and nimc complains `a` can't be both `float` and `string`↵(@terrygillis) |
12:05:02 | FromDiscord | <double_spiral> You probably shouldnt be doing stuff like that in python either, can make your code confusing and hard to keep track of |
12:07:12 | FromDiscord | <litlighilit> One small point\:↵↵In addtion, better to use `elif` or `case` (if there're more cases) instead of double `if` or `when` (as they're mutually exclusive. |
12:07:44 | PMunch | litlighilit, case doesn't have a compile-time equivalent unfortunately |
12:07:47 | FromDiscord | <litlighilit> Also, maybe using generics or overload would be simpler. |
12:09:41 | FromDiscord | <litlighilit> All right, that would requires macros. |
12:11:23 | FromDiscord | <litlighilit> I myself came to forget this😅 |
12:15:45 | * | PMunch_ joined #nim |
12:18:21 | FromDiscord | <nervecenter> In reply to @terrygillis "oops sorry I mistranslated": You can use an object variant for this:↵https://nim-lang.github.io/Nim/manual.html#types-object-variants |
12:19:02 | * | PMunch quit (Ping timeout: 252 seconds) |
12:19:52 | FromDiscord | <terrygillis> In reply to @nervecenter "You can use an": I thought I’m already using object variant? |
12:19:55 | * | PMunch_ is now known as PMunch |
12:20:18 | FromDiscord | <terrygillis> or am I mistaking something? |
12:20:40 | FromDiscord | <nervecenter> Look at the documentation, it must be contained in a `ref` |
12:29:00 | FromDiscord | <terrygillis> In reply to @nervecenter "Look at the documentation,": The documentation doesn’t seem to stress specifically that it should be a ref type, and when I’m using it as stack allocated type it does not error. What is the catch here? |
12:30:36 | FromDiscord | <odexine> Object variants do not need to be references |
12:31:05 | FromDiscord | <odexine> The reason it uses a reference in the example is because the object contains itself |
12:34:26 | FromDiscord | <terrygillis> So it’s not that I’m mistaking right? |
12:35:23 | * | PMunch quit (Quit: Leaving) |
12:39:30 | FromDiscord | <odexine> The mistake is as lit says |
12:41:33 | FromDiscord | <terrygillis> In reply to @odexine "The mistake is as": Ah yes, that’s a different one. Also, what is the scope of things in template, as I thought it’s just code substitution |
12:42:19 | FromDiscord | <terrygillis> I mean: |
12:43:44 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4Dab |
12:44:33 | FromDiscord | <terrygillis> this thing does not compile, so it's not just substitution |
12:44:50 | FromDiscord | <terrygillis> what is at play in templates? |
12:51:52 | FromDiscord | <odexine> Templates do not introduce a new scope but it does sanitise variable names |
12:52:03 | * | rockcavera joined #nim |
12:54:18 | FromDiscord | <terrygillis> so any variables declared inside template would not be accessible from outside, right? |
13:10:53 | FromDiscord | <juan_carlos> sent a code paste, see https://play.nim-lang.org/#ix=4Dai |
13:17:10 | FromDiscord | <terrygillis> sent a code paste, see https://paste.rs/B3isw |
13:19:45 | FromDiscord | <demotomohiro> identifier 'x' in template body is replaced with the identifier in call site. |
13:21:01 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates |
13:26:41 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4Dal |
13:44:56 | FromDiscord | <terrygillis> why is this not working as a template? |
13:45:07 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4Dat |
13:45:23 | FromDiscord | <terrygillis> `Error: expression 'true' is of type 'bool' and has to be used (or discarded)` |
13:46:23 | FromDiscord | <odexine> No return type on the template |
13:47:36 | FromDiscord | <terrygillis> I thought it's just substitution. return type is required like proc too? |
13:48:50 | * | lucasta joined #nim |
13:50:17 | FromDiscord | <terrygillis> in the manual every example returns `untyped` |
14:07:16 | FromDiscord | <litlighilit> By default, template's return type is typed |
14:08:43 | FromDiscord | <litlighilit> which means that its body can't have a value |
14:11:17 | FromDiscord | <litlighilit> here `untyped` tells nim not to check the value, i.e. whether have a value, so `void`(no value) or any other type is valid↵(@terrygillis) |
14:14:23 | FromDiscord | <litlighilit> True and recommended if this improve readability, compared with `untyped`↵(@terrygillis) |
14:16:08 | FromDiscord | <litlighilit> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1139561678489534464): here `untyped` tells nim not to check the value, i.e. whether has a value, so `void`(no value) or any other type is valid |
14:33:04 | * | azimut joined #nim |
14:59:09 | FromDiscord | <Phil> Alrighty, mapster package cleaned up |
15:11:26 | FromDiscord | <terrygillis> why does nim float lose decimal precision at 60 while in c it's 31? |
15:11:47 | qwr | imho its corresponds to C double |
15:11:55 | FromDiscord | <odexine> Float in Nim is always 64 bits |
15:12:11 | FromDiscord | <odexine> No matter the platform |
15:12:37 | FromDiscord | <odexine> If you want single size floats use float32 |
15:15:06 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4DaX |
15:16:53 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4DaY |
15:17:25 | FromDiscord | <terrygillis> somewhere it says float can range from 1.175494351 E - 38 to 3.402823466 E + 38 |
15:17:50 | FromDiscord | <terrygillis> which I don't know how relates to this precision cut-off |
15:19:31 | NimEventer | New thread by Isofruit: Mapster - Because life is too short to map A to B, see https://forum.nim-lang.org/t/10396 |
15:53:47 | FromDiscord | <litlighilit> It's just due to binary system, ↵like when we use decimal system, we cannot represent 1/3 accurately |
15:56:59 | FromDiscord | <litlighilit> If you're comparing with other language like Python, you may wanna say Python can represent 64.1 internally. But it's not true.↵(@terrygillis) |
15:59:12 | FromDiscord | <terrygillis> so 64 is not really the floating point precision cut off? |
15:59:21 | FromDiscord | <litlighilit> As long as one lang use IEE794, it cannot store some floats as small as 0.1 (in fact it doesn't matter whether it's small) |
16:00:05 | FromDiscord | <terrygillis> but the code prints 63.1 as it is while 64.1 gets distorted |
16:00:20 | FromDiscord | <terrygillis> why is that? |
16:00:26 | FromDiscord | <litlighilit> Round |
16:01:40 | FromDiscord | <litlighilit> There is a mechanism inside `represent a float`\: rounding |
16:02:22 | FromDiscord | <litlighilit> try `0.4-0.1` |
16:02:56 | FromDiscord | <litlighilit> Or `0.4-0.1 == 0.3` |
16:07:47 | FromDiscord | <litlighilit> sent a long message, see http://ix.io/4Dba |
16:09:24 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Dbb |
16:10:10 | FromDiscord | <litlighilit> For details, refer to IEE-794. |
16:10:29 | FromDiscord | <System64 ~ Flandre Scarlet> Is there a library to load PNGs? Especially color-indexed PNGs |
16:11:03 | FromDiscord | <ieltan> pixie ? |
16:11:07 | FromDiscord | <arathanis> daaaang. `selfExec` doesn't seem to inherit the command and switches you set |
16:11:12 | FromDiscord | <ieltan> In reply to @sys64 "Is there a library": https://github.com/treeform/pixie |
16:12:03 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @ieltan "https://github.com/treeform/pixie": Ah yeah, I have this↵Will read the docs to find out about Color-Indexed PNGs |
16:12:54 | FromDiscord | <ieltan> ah, not sure if it support color indexes |
16:15:06 | FromDiscord | <System64 ~ Flandre Scarlet> @treeform Does Pixie supports PNGs that use a Palette? |
16:17:17 | FromDiscord | <ieltan> Reading pixie source code it seems like it actually implements file formats in pure Nim ? That's so cool ! |
16:25:47 | FromDiscord | <System64 ~ Flandre Scarlet> would be nice to be able to get a PNG's palette |
16:26:07 | FromDiscord | <System64 ~ Flandre Scarlet> but looks like I'll have to use LibPNG or something |
16:35:59 | NimEventer | New thread by mildred: IPv6 compatibility (dual-stack AF_UNSPEC), see https://forum.nim-lang.org/t/10397 |
16:36:40 | FromDiscord | <exelotl> In reply to @sys64 "would be nice to": NimPNG exists which can do this, and is probably easier than libpng |
16:36:48 | FromDiscord | <exelotl> <https://github.com/jangko/nimPNG> |
16:37:04 | * | lucasta quit (Quit: Leaving) |
16:38:18 | FromDiscord | <exelotl> example where I use it: https://github.com/exelotl/trick/blob/master/src/trick/gfxconvert.nim#L259-L262 |
16:38:42 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @exelotl "NimPNG exists which can": Just found thit, will give it a try |
17:05:45 | FromDiscord | <treeform> In reply to @sys64 "<@107140179025735680> Does Pixie supports": I don't think so, they are very rare? Try it I don't remember... |
17:06:01 | FromDiscord | <treeform> In reply to @ieltan "Reading pixie source code": Yes it does, that's why we wanted pure nim. |
17:06:19 | FromDiscord | <odexine> In reply to @treeform "Yes it does, that's": What do you mean wanted pure Nim |
17:06:26 | FromDiscord | <odexine> Wanted it for what? |
17:08:14 | FromDiscord | <ieltan> Think it's better to have a pure implementation than c bindings |
17:25:50 | FromDiscord | <treeform> Yes pure Nim is better then C bindings. Once we get pure Nim version we can optimize it faster then any C code. And we did we have one of the fastest PNG readers, because we have one of the fastests zip implemeantions. Its all really cool to us. |
17:26:59 | * | qwr . o O ( technically not true, nim compiles to C code... ) |
17:27:48 | FromDiscord | <ieltan> Only real flaw is that it's super hard to contribute anything new to the library, you need to have skills™ and reading a spec and implementing it is something most programmers have never done before |
17:29:16 | FromDiscord | <treeform> In reply to @qwr ". o O (": We have proven again and again that we can write faster Nim code that people can write C code. Once you have a compiled langage the speed of the code is in smart algorithms > memory allocations > pointer indirection > branch prediction. |
17:31:42 | FromDiscord | <treeform> zlib is used by pretty much all software. Its been around for like 30 years. But guzba was just pretty smart about it and wrote zlib in nim that is x1.5 - x2.0 faster. |
17:31:47 | * | genr8eofl joined #nim |
17:31:52 | FromDiscord | <treeform> https://github.com/guzba/zippy |
17:32:24 | FromDiscord | <treeform> Technically the C people can write code just like Nim compiler does. But why don't they? |
17:32:37 | FromDiscord | <treeform> We both use C in the end? |
17:32:48 | FromDiscord | <treeform> I think large projects are just hard in C so getting anything working at all is a big win. |
17:33:06 | FromDiscord | <treeform> While large projects in Nim are much easier, and you can focus your time in hotspots. |
17:33:42 | qwr | pretty believable you can beat code hand-written to be more likely to work despite the shoot-your-foot traps in C |
17:34:18 | qwr | but technically you still have then machine generated fast C code :) |
17:34:58 | FromDiscord | <treeform> yeah the zlib people could just take our Nim to C output and just copy paste that into their project to be faster... |
17:35:11 | FromDiscord | <treeform> (edit) "faster..." => "as fast..." |
17:35:35 | qwr | and why - the handwritten C tends to use lot of pointer indirection and OO-like encapsulation thats probably is evaded by nim |
17:35:43 | FromDiscord | <treeform> yes |
17:35:49 | FromDiscord | <TheUnderName> Hi |
17:35:54 | FromDiscord | <treeform> Because stuff is hard in C they try to write it the easy way |
17:36:09 | FromDiscord | <ieltan> In reply to @treeform "yeah the zlib people": Might as well just rewrite the actual project in Nim and expose a C API |
17:36:27 | FromDiscord | <treeform> Thats why we wrote https://github.com/treeform/genny |
17:36:36 | FromDiscord | <treeform> to expose the coolness of Nim to other langs easy |
17:37:34 | FromDiscord | <TheUnderName> Nim translates to C? |
17:37:57 | FromDiscord | <ieltan> Wow! |
17:38:34 | qwr | C is stable interface to multiple compiler backends |
17:39:40 | FromDiscord | <treeform> In reply to @TheUnderName "Nim translates to C?": Not always, but most likely when you compile Nim it produces a C file that the C compiler then compiles. |
17:39:42 | qwr | though, Nim also compiles to C++ and javascript |
17:40:45 | FromDiscord | <TheUnderName> In reply to @treeform "Not always, but most": What do you mean by "not always"? |
17:42:41 | FromDiscord | <treeform> Some times you compile to JavaScript or even more rare run Nim as a script. |
17:42:53 | FromDiscord | <treeform> And some times C++, but usually its same compiler... |
17:44:12 | FromDiscord | <TheUnderName> Great, but how is Nim different from other languages? Haxe does the same. |
17:47:57 | qwr | treeform: fyi, genny README seems to have typo (its usually called kebab-case, not kabob-case :)) |
17:48:42 | FromDiscord | <ieltan> In reply to @TheUnderName "Great, but how is": You would need someone who is both fluent in Nim and Haxe to answer that question |
17:51:25 | FromDiscord | <TheUnderName> In reply to @ieltan "You would need someone": I have worked a little, especially in managing buffers and reading them |
17:53:16 | FromDiscord | <TheUnderName> was a pain in the ass |
17:53:37 | * | qwr is not fluent, but read about haxe some time ago, and it is a bit similar in generating code for existing compilers, but haxe seems to be more about "write once, run/integrate into different runtimes/VMs" - it has lot of targets: https://haxe.org/documentation/introduction/compiler-targets.html |
17:55:40 | qwr | also, haxe is pretty big, and imho don't fit at all nims lightweight, systems programming niche |
17:56:11 | FromDiscord | <jos7388> In reply to @qwr "C is stable interface": I’m convinced C is the new ASM |
17:58:41 | FromDiscord | <jos7388> have you seen Beef? |
18:00:08 | FromDiscord | <TheUnderName> In reply to @jos7388 "I’m convinced C is": I? |
18:02:54 | FromDiscord | <Phil> In reply to @jos7388 "I’m convinced C is": insert link to famous article that C is not a language, it's a compilation target |
18:03:33 | FromDiscord | <Phil> https://faultlore.com/blah/c-isnt-a-language/ |
18:06:10 | FromDiscord | <TheUnderName> In reply to @isofruit "*insert link to famous": Then cpp is not a language xD |
18:07:05 | FromDiscord | <Phil> Eh, the article arguments since everbody has to be able to talk to C and everybody talks to each other via C, that C is a protocol (and compilation target) more than a lang |
18:07:34 | FromDiscord | <Phil> Can't say the same for C++, nobody sane would want to have 2 separate languages implement ways to talk to each other in C++ specific terms |
18:08:53 | FromDiscord | <TheUnderName> In reply to @isofruit "Eh, the article arguments": Let's accept that C is obsolete and people choose Rust instead |
18:09:49 | FromDiscord | <Phil> Depends, but I mean from where I stand everything is better than C, even if Rust is a bit harsh on the eyes |
18:10:16 | FromDiscord | <Phil> But that is, disclaimer, from the perspective of somebody that rarely, if ever, actually has to deal with memory management |
18:11:04 | FromDiscord | <Phil> As my field is web/webdev and perfecting memory moves/copies is not going to be anywhere near as impactful as having decent strategies for optimizing DB useage |
18:11:13 | FromDiscord | <odexine> I mean what does it mean for something to be better |
18:11:32 | FromDiscord | <odexine> When it comes to these languages we have it’s so reliant on what the user needs |
18:11:55 | FromDiscord | <odexine> Is rust better than C when you’re running on an exotic computer? |
18:16:42 | FromDiscord | <TheUnderName> sent a code paste, see https://play.nim-lang.org/#ix=4DbA |
18:19:06 | FromDiscord | <jos7388> i think rust is kind of ass |
18:19:28 | FromDiscord | <jos7388> it's good for procedural stuff |
18:19:44 | FromDiscord | <jos7388> but anything where you have loads of retained state flying around or need dynamic linking, it massively overcomplicates stuff |
18:20:03 | FromDiscord | <jos7388> that's why UI is in such a rough place in rust |
18:21:52 | FromDiscord | <TheUnderName> Each language has its advantages and disadvantages, and it is still difficult and expensive to replace millions of codes with Rust. |
18:23:56 | FromDiscord | <TheUnderName> However, C and C++ are much better languages than Rust's ugly syntax:) |
18:29:21 | FromDiscord | <jos7388> rust is literally the only language pretending to be a general purpose language where aliasing is impossible |
18:29:39 | FromDiscord | <jos7388> that's why i think of it in a separate class |
18:32:31 | FromDiscord | <nervecenter> Rust's biggest problem is more than other statically typed languages, and definitely more than Nim, you need to have your spec pre-arranged and your ducks in a row or else refactoring becomes a bit of a nightmare. Between its abstractions, types, and syntax, a lot of work goes into a change to the spec, similar to C++. |
18:32:40 | FromDiscord | <nervecenter> I guess they're competing with each other so that's to be expected |
18:32:53 | FromDiscord | <nervecenter> Nim is probably the most frictionless static language I've ever used |
18:32:57 | FromDiscord | <jos7388> i think the issue is lack of aliasing personally |
18:33:15 | FromDiscord | <jos7388> u can't have deep call stacks, because you're locking a shitload of memory via the borrow checker as u make it deeper |
18:33:25 | FromDiscord | <jos7388> so anything OOP-like will just never, ever work |
18:33:29 | FromDiscord | <jos7388> that's why ECS exists |
18:33:37 | FromDiscord | <jos7388> u get row polymorphism |
18:33:42 | FromDiscord | <jos7388> to simulate OOP-style polymorphism |
18:33:51 | FromDiscord | <jos7388> and ur call stacks don't get deep, instead you work only on dependencies you know upfront |
18:33:57 | FromDiscord | <jos7388> (edit) "exists" => "is so popular in Rust" |
18:34:09 | FromDiscord | <jos7388> and u pass it off to another "system" which also has a shallow call stack |
18:34:24 | FromDiscord | <jos7388> i think there is a way to supplement all of rust's shortcomings by building a framework with those things in mind |
18:34:36 | FromDiscord | <jos7388> but i don't know how to do it and nobody seems to have done it yet |
18:35:18 | FromDiscord | <ieltan> If you've read the blogpost from Rust ex-BDFL venting about how lifetimes were supposed to be inferred and not explicit, I immediately thought "I think he'd like Nim for this" |
18:35:31 | FromDiscord | <nervecenter> Oh wow |
18:35:37 | FromDiscord | <nervecenter> That's...a MAJOR fuckup |
18:35:48 | FromDiscord | <nervecenter> That would completely change the language |
18:35:49 | FromDiscord | <ieltan> Of course if only view types worked lol... |
18:36:22 | FromDiscord | <jos7388> why would that change it much though, you still can't violate aliasing rules either way |
18:36:28 | FromDiscord | <jos7388> you would still have the same fundamental limitations on what you can and can't write |
18:36:42 | FromDiscord | <ieltan> In reply to @nervecenter "That's...a MAJOR fuckup": I don't know, yes it'd change the language, but I don't know if it would have "killed" it's future |
18:37:02 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @treeform "I don't think so,": Oh, woops |
18:37:25 | FromDiscord | <ieltan> He was BDFL but even back then it seemed to be very committee'ish |
18:37:42 | FromDiscord | <nervecenter> In reply to @ieltan "I don't know, yes": I'm not saying it would've killed it, I'm saying it probably would've been an incredibly nice feature and losing control over the language was a major fuckup |
18:37:52 | FromDiscord | <nervecenter> I've seen him complain that it was design by committee from very early on |
18:37:59 | FromDiscord | <nervecenter> and how ti changed into something unrecognizable from his concept |
18:38:04 | FromDiscord | <nervecenter> (edit) "ti" => "it" |
18:38:20 | FromDiscord | <jos7388> it's necessary |
18:39:00 | FromDiscord | <jos7388> the language does infer lifetimes already |
18:39:09 | FromDiscord | <jos7388> so like, it does what he's saying |
18:39:17 | FromDiscord | <nervecenter> He almost wanted it to compete with Haskell or Java/.NET with a near-native but still abstracted runtime, and a bunch of C++ devs seemed to steal the project from him and turn it into a hyper low-level project |
18:44:43 | FromDiscord | <ieltan> sent a code paste, see https://paste.rs/VgiHX |
18:45:52 | FromDiscord | <TheUnderName> I prefer Nim to Rust :):nim1: |
18:46:30 | FromDiscord | <TheUnderName> (edit) ":):nim1:" => "🙂 :nim1:" |
18:46:50 | FromDiscord | <jos7388> In reply to @ieltan "I think he really": so basically like inout parameters or something |
18:46:53 | FromDiscord | <jos7388> u can't store them in structs |
18:46:57 | FromDiscord | <jos7388> its a temp borrow that can't outlive the function |
18:47:07 | FromDiscord | <jos7388> or just refs in C++ |
18:48:14 | FromDiscord | <Phil> Yeah you guys are way deeper in that than I am, I'm barely following |
18:48:29 | FromDiscord | <Phil> (edit) "following" => "following... like 30% of that" |
18:48:36 | FromDiscord | <ieltan> Well, I'm not in his head but when Nim stabilize view types you should be able to have `lent` part of an object type |
18:49:54 | FromDiscord | <ieltan> In reply to @jos7388 "its a temp borrow": Yeah :p |
18:50:12 | FromDiscord | <jos7388> whats a view type in nim |
18:50:35 | FromDiscord | <Phil> Sounds like the concept orients itself on relational database views |
18:51:04 | FromDiscord | <ieltan> https://nim-lang.org/docs/manual_experimental.html#view-types |
18:51:56 | FromDiscord | <ieltan> dont use it, it's broken |
18:52:02 | FromDiscord | <ieltan> but that's basically the idea |
18:53:13 | FromDiscord | <jos7388> i haven't used lent yet, but putting them in structs sounds a lot like borrows in rust no |
18:53:14 | FromDiscord | <jos7388> (edit) "no" => "no?" |
18:53:23 | FromDiscord | <jos7388> i guess they only have a simple lexical lifetime though, right |
18:54:40 | FromDiscord | <ieltan> Yup, but the point I am making is that implicit lifetimes are already there in Nim anyways, just annotate `sink` and `lent` in your procs where it make sense |
18:55:33 | FromDiscord | <jos7388> ye i agree |
18:55:37 | FromDiscord | <jos7388> i like how in nim it's an optimization though |
18:55:42 | FromDiscord | <jos7388> i think rust got it backwards |
18:56:05 | FromDiscord | <jos7388> in nim you start with ORC, and then you can optimize it away with other patterns |
18:56:12 | FromDiscord | <jos7388> in rust u start with the hardest shit |
18:56:20 | FromDiscord | <jos7388> not to mention least flexible |
18:56:33 | FromDiscord | <jos7388> it's literally premature optimization imo |
18:57:54 | FromDiscord | <Phil> Same conclusion I came to, I just formulate it as nim being very strongly based around opt in for various features |
18:58:33 | FromDiscord | <Phil> Like you can use macros, you don't have to.↵You can optimize memory moves/copies etc., you don't have to.↵You can give a hoot about circular data structures, or you stick with ORC and you don't have to |
18:58:58 | FromDiscord | <jos7388> yup |
18:59:08 | FromDiscord | <jos7388> the one thing i will say is that rust's approach is really good when u apply it at scale |
18:59:15 | FromDiscord | <jos7388> like, sure, it's annoying to write certain kinds of programs in rust |
18:59:25 | FromDiscord | <jos7388> but when i pick up a rust binary, i know it's going to be a certain way |
18:59:35 | FromDiscord | <jos7388> low memory usage, not a lot of memory moving around at all |
18:59:48 | FromDiscord | <jos7388> i think it's nice a language like that exists |
19:00:02 | FromDiscord | <jos7388> i am just surprised it's so popular? and people are trying to use it for problems that are very hard to solve in that way? |
19:02:04 | FromDiscord | <Phil> You'd know more about that than I do, I'm barely wrapping my head around when I see rust stuff as it is |
19:02:30 | FromDiscord | <jos7388> i've written a ton of rust, i was very pro-rust for gamedev for a while |
19:02:39 | FromDiscord | <jos7388> i had my own 3d engine and a bunch of other stuff |
19:02:48 | FromDiscord | <jos7388> but i really value hot reloading, dynamic linking-- things like that |
19:02:59 | FromDiscord | <jos7388> rust is very very bad at those things, so i dropped it |
19:03:07 | FromDiscord | <jos7388> so now im trying nim.. again |
19:03:21 | FromDiscord | <jos7388> my biggest problem with nim was that it wasn't "production ready", was getting tons of internal compiler issues, stuff like that |
19:03:24 | FromDiscord | <jos7388> but it's improved so much since then |
19:05:13 | FromDiscord | <Phil> I recall the nim survey back when I started and it was focussing on stability and the like, seems like that happened (?)↵There are some limitations I run into, but those are more for new features.↵Stuff like default types for DateTime distinct aliases not working well |
19:05:25 | FromDiscord | <Phil> At least that was an issue a couple months back, haven't checked since |
19:05:57 | FromDiscord | <Phil> (edit) "types" => "values" | "valuesfor ... DateTimealias" added "fields with" | "aliases" => "alias types" |
19:07:32 | FromDiscord | <jos7388> nim has insanely cool features, but kind of sucks at the basics |
19:07:39 | FromDiscord | <Festive> How can I take a screenshot in nim? |
19:07:45 | FromDiscord | <odexine> In reply to @jos7388 "i am just surprised": Marketing |
19:07:51 | FromDiscord | <jos7388> ur right about that.. rust marketing is insane |
19:07:53 | FromDiscord | <odexine> Nim doesn’t have that good marketing |
19:08:47 | FromDiscord | <Festive> https://github.com/Senketsu/nsu nvm |
19:10:52 | FromDiscord | <ieltan> I think it's a strange and ironic world. People don't question why Rust's "exist", you will be told something like:↵"well, considering that PLs exist to solve a niche, Rust can do memory management without GC, that's a big deal for embedded!"↵But then, you see Rust being used in web application where that feature becomes a weakness, or how Rust relies on LLVM, a poor target for embedded hence the irony. |
19:11:48 | FromDiscord | <ieltan> But it's true that I like Rust when I don't have to use it, I think it's an especially great language to make tooling in. |
19:12:23 | FromDiscord | <jos7388> so true |
19:12:35 | FromDiscord | <jos7388> rust is the best shell scripting language of all time |
19:12:37 | FromDiscord | <odexine> Unfortunately for me I consider syntax as critical or as significant dealbreakers so rust is pretty much out as something I’d use |
19:12:44 | FromDiscord | <jos7388> i actually really like rust syntax |
19:12:49 | FromDiscord | <jos7388> but i guess if u grew up on python and friends u would hate it |
19:12:59 | FromDiscord | <jos7388> syntax is holding nim back from wider adoption IMO |
19:13:13 | FromDiscord | <jos7388> at least from the intended target audience-- people who like nim-like languages probably want c-like syntax |
19:13:31 | FromDiscord | <odexine> If ever that happens consider me gone |
19:13:38 | FromDiscord | <odexine> The reason I like Nim is because it is not c like |
19:13:54 | FromDiscord | <ieltan> Nim has an hard time because it tries to be "the language to rule them all", I think it does that great which is an exploit. But people want to solve their niche and Nim does have enough material covering how it solve those "niches" (because it's not incapable in the least) |
19:14:08 | FromDiscord | <ieltan> (edit) "does" => "doesnt" |
19:14:25 | FromDiscord | <odexine> Honestly I don’t think languages should change syntax just for popularity sake |
19:14:50 | FromDiscord | <odexine> Or not change necessarily, even when picking it shouldn’t |
19:15:12 | FromDiscord | <odexine> please note that I might be incoherent because I’m pretty sleep deprived right now sorry |
19:15:20 | FromDiscord | <jos7388> i remember reading a post from the nim author who was like "there will be syntax views on nim, so you can just like use any syntax you want" |
19:15:24 | FromDiscord | <Phil> In reply to @jos7388 "at least from the": wow if that's the case I'm super weird |
19:15:36 | FromDiscord | <odexine> In reply to @jos7388 "i remember reading a": It used to exist yes |
19:15:43 | FromDiscord | <odexine> Removed because of disuse and maintenance cost |
19:15:51 | FromDiscord | <jos7388> it sounds kind of interesting.. |
19:15:58 | FromDiscord | <jos7388> but it does sound insane |
19:16:07 | FromDiscord | <odexine> Nim really did have a braces syntax skin |
19:16:12 | FromDiscord | <odexine> No one used it though |
19:16:16 | FromDiscord | <odexine> Ironic |
19:16:22 | FromDiscord | <jos7388> In reply to @isofruit "**wow** if that's the": well its just my opinion, but i think every systems lang has brackets at least |
19:16:40 | FromDiscord | <odexine> In reply to @jos7388 "well its just my": Correlation causation thing I bet you that |
19:16:52 | FromDiscord | <odexine> Maybe I’m not thinking properly right now |
19:16:54 | FromDiscord | <jos7388> well people are like you-- they also throw out languages because of syntax |
19:16:59 | FromDiscord | <jos7388> and systems devs use brackets |
19:17:15 | FromDiscord | <jos7388> so i would guess, that systems lang devs would avoid nim because it's not what they're used to syntactically |
19:17:25 | FromDiscord | <jos7388> tbh when i first saw nim i thought it was a scripting language because of the syntax |
19:17:44 | FromDiscord | <jos7388> but i actually love the syntax now |
19:17:55 | FromDiscord | <odexine> Okay here maybe this is a coherent and sensible thought |
19:17:59 | FromDiscord | <Phil> In reply to @jos7388 "well its just my": TBH I never understood the need for those once I realized that every lang has a linter and that'll lead you to unified indentation for code-blocks anyway |
19:18:08 | FromDiscord | <ieltan> In reply to @jos7388 "at least from the": I think defining an audience for Nim is hard because Nim "does it all". I often just think saying that Nim is a statically typed python that's a fast as C is a good start. There is an audience for a faster python, look at all these effort made in their community to have more typing (mypy) and have more speed (Mojo) |
19:18:17 | FromDiscord | <odexine> Does Nim have to be that popular as to change syntax for the sake of it |
19:18:34 | FromDiscord | <odexine> Nim does benefit from being popular yes |
19:18:38 | FromDiscord | <ieltan> It should start somewhere |
19:18:43 | FromDiscord | <odexine> But is it worth it to switch |
19:18:52 | FromDiscord | <ieltan> Rust definitely did not intend to please web developer at the beginning |
19:19:06 | FromDiscord | <ieltan> Programming languages eventually evolve and cover more use-cases |
19:19:31 | FromDiscord | <jos7388> i think it's worth personally, for gamedev crowd |
19:19:33 | FromDiscord | <Phil> Unless the learning material for webdev has significantly improved or the frameworks have made leaps in the meantime in featureset and how simply they provide it, I'd claim it still doesn't |
19:19:36 | FromDiscord | <odexine> Yes but how many languages do you see out there switching their block delimitation |
19:19:46 | FromDiscord | <jos7388> it's impossible at this point ye |
19:19:46 | FromDiscord | <ieltan> In reply to @odexine "Does Nim have to": Imo it's not worth the risk |
19:19:49 | FromDiscord | <jos7388> would have to be a dialect or something |
19:20:02 | FromDiscord | <odexine> May as well be a whole different language at that point |
19:20:05 | FromDiscord | <jos7388> isn't there a nim fork? that's trying to do that? |
19:20:23 | FromDiscord | <odexine> There is but they are not abandoning indentation IIRC |
19:20:30 | FromDiscord | <odexine> At least no plans to as of now |
19:20:40 | FromDiscord | <odexine> Their plans are only right now to improve the compiler backend |
19:20:43 | FromDiscord | <ieltan> I have a wishlist of features for Nim that are probably impossible to realize, doesn't mean I must fork it |
19:20:51 | FromDiscord | <ieltan> I just do with what I have :p |
19:21:53 | FromDiscord | <ieltan> For example, I kinda wish Nim used result/either types for error handling. I know a lot of ink has been spilled over this and it's basically a matter of taste |
19:22:15 | FromDiscord | <jos7388> that's something rust nailed IMO |
19:22:32 | FromDiscord | <ieltan> In it's ideal form, Nim would do something like how Swift does |
19:22:35 | FromDiscord | <requiresupport> `let port_int = cast[int](port)` any idea why I can't do this when I'm getting the port from command line?↵↵`Error: expression cannot be cast to 'int'` |
19:23:21 | * | Phytolizer joined #nim |
19:23:28 | FromDiscord | <odexine> In reply to @requiresupport "`let port_int = cast[int](port)`": I don’t think that’s the whole snippet, can you provide the code with no changes, or at least minimal changes |
19:24:03 | FromDiscord | <that_dude.> Is `port` a string? I'm assuming so because you said it's from the command line. Check out https://nim-lang.org/docs/parseutils.html#parseInt%2CopenArray%5Bchar%5D%2Cint . It's probably what yo uwant |
19:24:07 | FromDiscord | <that_dude.> (edit) "yo uwant" => "you want" |
19:24:30 | FromDiscord | <odexine> In reply to @ieltan "For example, I kinda": I think there should be a mechanism where one can switch between exceptions and result types as seamlessly as possible |
19:24:39 | Phytolizer | is `disarm` still useful for anything? its docs mention --newruntime which sent me on a wild goose chase just to discover it is deprecated (https://nim-lang.org/docs/system.html#disarm.t%2Ctyped) |
19:24:57 | FromDiscord | <odexine> Why restrict one to a choice if both can be accommodated for |
19:25:05 | FromDiscord | <odexine> In reply to @Phytolizer "is `disarm` still useful": Unlikely |
19:25:27 | Phytolizer | thx for the quick answer, maybe i will stop getting distracted by random stuff in system lol |
19:26:29 | * | ntat quit (Quit: leaving) |
19:28:46 | FromDiscord | <requiresupport> In reply to @that_dude. "Is `port` a string?": Thanks kind soul, works! |
19:31:55 | FromDiscord | <ieltan> In reply to @odexine "I think there should": I don't think it's possible Because the semantics are different, in Nim `raise` unwind the stack and exits the program with an error message, in Swift `throw` actually just return an error value. |
19:32:15 | FromDiscord | <ieltan> Hope I got that right |
19:33:11 | FromDiscord | <jos7388> like it short-circuits the function when u call throw? |
19:33:14 | FromDiscord | <jos7388> to just return the error variant |
19:33:23 | FromDiscord | <jos7388> does the function have to return a Result<T> type? |
19:33:25 | FromDiscord | <ieltan> It returns the error variant |
19:33:28 | FromDiscord | <ieltan> No |
19:33:32 | FromDiscord | <jos7388> hmm interesting |
19:33:38 | FromDiscord | <jos7388> so does it like |
19:33:53 | FromDiscord | <jos7388> that sounds cool.. |
19:35:07 | FromDiscord | <ieltan> Ye it's like exceptions but... it's not |
19:36:10 | FromDiscord | <ieltan> You have a `try!` keyword that allow you to mimic unchecked exceptions |
19:37:18 | FromDiscord | <ieltan> So if a function returns a error value it will crash |
19:37:54 | FromDiscord | <ieltan> There's no stack unwinding |
19:38:42 | FromDiscord | <jos7388> it does look pretty cool, i looked it up |
19:38:48 | FromDiscord | <jos7388> looks a lot easier to work with than rust's approach |
19:38:57 | FromDiscord | <Elegantbeef> You can convert between results and exceptions "seemlessly" it's just not free |
19:39:33 | FromDiscord | <ieltan> The biggest win in Swift error handling is that you don't have to wrap your type in a `Result<T>` imo |
19:39:57 | FromDiscord | <ieltan> So it doesn't pollute the type of the actual return value that you care about |
19:40:43 | FromDiscord | <ieltan> And if you don't care about errors (because you know it won't throw or you're writing one-offs) , you use `try!` |
19:40:47 | FromDiscord | <ieltan> It just make so much sense |
19:40:55 | FromDiscord | <ieltan> I WANT IT IN NIM |
19:40:59 | FromDiscord | <ieltan> 😢 |
19:42:25 | FromDiscord | <ieltan> I don't know how the `throws` thingy would look like in Nim syntax though |
19:43:16 | Phytolizer | like an annotation or what is that in swift? |
19:43:28 | Phytolizer | nim has the {.raises: [IOError, ...].} pragma |
19:44:08 | FromDiscord | <Elegantbeef> It'd look the same |
19:44:23 | FromDiscord | <Elegantbeef> You can write macros to get swift style errors |
19:44:40 | FromDiscord | <ieltan> It simply means "this function can throw" |
19:44:46 | FromDiscord | <ieltan> Without it, it cannot |
19:44:51 | FromDiscord | <ieltan> Simple |
19:45:08 | FromDiscord | <Elegantbeef> `proc doThing: int {.throw.}` boom we did it |
19:45:17 | FromDiscord | <Elegantbeef> any procedure marked `throw` gets an injected `throw` template |
19:46:48 | FromDiscord | <Elegantbeef> How does swift even make an error type or is it a fully runtime polymorphic type? |
19:46:52 | FromDiscord | <ieltan> I'll try to make something like that when I get good at macros |
19:47:36 | FromDiscord | <Phil> Is there a way to check if 2 symbols count as equal in nim's sense of the word (so `is_potato` and `isPotato` count as equal) ? |
19:48:06 | FromDiscord | <Elegantbeef> `eqIdent` |
19:48:49 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4DbN |
19:49:23 | FromDiscord | <Phil> so instead of sourceName == targetName which I think is only true for "isPotato" == "isPotato" |
19:49:35 | FromDiscord | <Phil> One sec, checking the proc |
19:50:50 | FromDiscord | <Phil> Sweet, that does work! |
19:54:25 | FromDiscord | <Phil> In reply to @Elegantbeef "`eqIdent`": mapster comes out, same day I'm already 2 patch versions deep |
20:17:15 | FromDiscord | <Elegantbeef> But are you using graffiti @Phil ? 😄 |
20:18:27 | FromDiscord | <Phil> I'm too tired to actually get that reference |
20:18:38 | FromDiscord | <Elegantbeef> https://github.com/beef331/graffiti |
20:18:41 | FromDiscord | <Elegantbeef> My git tagger |
20:19:59 | FromDiscord | <Phil> Ah so basically instead of doing a version bump commit and then doing git tag vX.X.X and git push --tags, I do a version bump commit and grafiti <path-to-nimble> and git push --tags? |
20:20:41 | FromDiscord | <Elegantbeef> You don't even need to push tags |
20:20:59 | FromDiscord | <Phil> Can it do the version bump commit for me by me specifying minor/major/patch? |
20:21:03 | FromDiscord | <Elegantbeef> It does it all, it even tags if you didnt create tags for a specific nimble version tick |
20:21:20 | FromDiscord | <Elegantbeef> Nah, that's one thing I wanted to add though |
20:21:28 | FromDiscord | <Phil> That would be siiiiiick |
20:22:12 | FromDiscord | <Elegantbeef> Thos where I jokingly say "it's like 50 loc, PRs welcome" 😄 |
20:22:14 | FromDiscord | <Elegantbeef> this even |
20:23:48 | FromDiscord | <Phil> If that can be done in 50 loc I'll be impressed |
20:24:05 | FromDiscord | <Phil> That includes arg parsing as well as writing to a nimble file |
20:24:36 | FromDiscord | <Elegantbeef> I mean it's a single earg |
20:24:38 | FromDiscord | <Elegantbeef> arg\ |
20:25:03 | FromDiscord | <Elegantbeef> I already go over all the git history and create tags for each commit inside a nimble file |
20:28:43 | FromDiscord | <Phil> That is a fascinating prospect.↵I shall contemplate that as I drift into snoozin time |
20:32:22 | * | nmz joined #nim |
20:44:26 | FromDiscord | <jordan4ibanez> I'm feeling very.... Enterprise® |
20:44:33 | FromDiscord | <jordan4ibanez> Is there a spell check for nim comments? |
20:46:16 | FromDiscord | <jordan4ibanez> In naylib is ``Rectangle()`` putting the rectangle on the heap? |
20:46:39 | FromDiscord | <jordan4ibanez> I just have so many questions today for no reason |
20:47:12 | FromDiscord | <jos7388> will nim ever get support for cyclic imports? |
20:47:22 | FromDiscord | <jos7388> i feel like it makes some of the metaprogramming impossible |
20:47:28 | FromDiscord | <jos7388> from a compiler design perspective |
20:47:51 | FromDiscord | <Elegantbeef> It's intended to be in 2.x |
20:47:57 | FromDiscord | <jos7388> like u can't just do a pre-pass and collect all the types, because those types could be generated using comptime code?? idk |
20:47:57 | FromDiscord | <Elegantbeef> Unlikely jordan |
20:48:07 | FromDiscord | <jordan4ibanez> I don't mean to brag, but, I just drew a rectangle |
20:48:12 | Phytolizer | :O |
20:48:29 | FromDiscord | <jordan4ibanez> In reply to @Elegantbeef "Unlikely jordan": How do we do this, I tried creating a new rectangle but it says "nah" |
20:48:41 | FromDiscord | <Elegantbeef> What? |
20:48:54 | FromDiscord | <jordan4ibanez> I want to dump my garbage onto the heap |
20:49:20 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4DbZ |
20:50:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Dc0 |
20:50:59 | FromDiscord | <jordan4ibanez> Ohhh, so I have to create a wrapper type perhaps? Hmm |
20:51:03 | Phytolizer | you can |
20:51:20 | FromDiscord | <TheUnderName> <a:emoji_3:1137632478807474226> |
20:51:23 | Phytolizer | e.g. `type RectangleRef = ref Rectangle` and then when you use RectangleRef it will allocate |
20:51:44 | Phytolizer | or just `let x = (ref Rectangle)(x: ...)` |
20:53:18 | FromDiscord | <Elegantbeef> Yea I was being daft |
20:53:29 | FromDiscord | <Elegantbeef> Was thinking about Nim primitives |
20:54:28 | FromDiscord | <jordan4ibanez> Oh oh oh I think we can also use that auto translation converter feature!! |
20:54:38 | FromDiscord | <TheUnderName> Bot to Bot:trollface: |
20:54:50 | Phytolizer | on different platforms no less :) |
20:55:04 | FromDiscord | <Elegantbeef> Matric |
20:55:18 | FromDiscord | <Elegantbeef> matirc whoops |
20:55:20 | FromDiscord | <jordan4ibanez> O my god it works |
20:55:25 | FromDiscord | <Elegantbeef> My urge for correctness ruined that |
20:55:31 | Phytolizer | lol |
20:55:40 | FromDiscord | <TheUnderName> :thinkinghard: |
20:56:03 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4Dc1 |
20:56:13 | FromDiscord | <jordan4ibanez> That's amazing |
20:56:56 | FromDiscord | <jordan4ibanez> I don't even understand how it's automatically able to infer and deduce and then insert all this metacode but that's downright impressive |
20:57:28 | FromDiscord | <Elegantbeef> No you do not cast |
20:57:31 | Phytolizer | ive not seen converters, i guess that is like c++ operator OtherType() |
20:57:35 | FromDiscord | <Elegantbeef> Can we just remove cast |
20:57:56 | Phytolizer | yeah casting doesn't seem like the right option there |
20:57:59 | FromDiscord | <jordan4ibanez> How do I turn it into a Rectangle without a cast? |
20:58:09 | Phytolizer | postfix [] will dereference |
20:58:14 | FromDiscord | <jordan4ibanez> Noice |
20:58:16 | FromDiscord | <Elegantbeef> `myRef[]` to dereference |
20:58:26 | FromDiscord | <Elegantbeef> Never use cast unless you know what you're doing |
20:58:31 | FromDiscord | <Elegantbeef> And I can assure you, you do not know what you're doing |
20:59:01 | Phytolizer | can't remember the last time i used cast myself |
20:59:23 | FromDiscord | <jordan4ibanez> Now how do I convert the Rectangle into RectangleRef? |
20:59:31 | Phytolizer | https://play.nim-lang.org/#ix=4Dc2 |
20:59:36 | FromDiscord | <Elegantbeef> You need to allocate |
20:59:59 | Phytolizer | i removed imports and stuff so itd work on the playground |
21:00:42 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4Dc4 |
21:00:58 | Phytolizer | yeah that works too |
21:01:16 | FromDiscord | <Elegantbeef> that works or what phyto shared |
21:03:13 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4Dc6 |
21:04:29 | Phytolizer | cast is probably okay there because it is the exact same type with a different name |
21:04:36 | FromDiscord | <Elegantbeef> You must not |
21:04:51 | FromDiscord | <Elegantbeef> It's probably fine but there is very little reason |
21:05:05 | FromDiscord | <Elegantbeef> `Vector2f(x: x.x, y: y.y)` is simple as |
21:05:54 | Phytolizer | would love for cast to be renamed as bitCast or something that makes more clear how dangerous it is |
21:06:17 | FromDiscord | <jordan4ibanez> Mhmmm |
21:06:21 | FromDiscord | <Elegantbeef> I'd prefer `neverUseThisUnlessYouKnowWhatYou'reDoing` |
21:06:35 | FromDiscord | <Elegantbeef> The amount of times people use cast instead of type conversion is too damn high |
21:06:36 | Phytolizer | oh haskell has one of those lol |
21:06:44 | Phytolizer | accursedUnutterablePerformIO |
21:07:33 | FromDiscord | <toma400> In reply to @Elegantbeef "It's intended to be": Dang, that sounds sick! Will required predefinition of procedures get resolved in the same time? So we can use arbitrary order of procedure declaration? |
21:07:49 | FromDiscord | <Elegantbeef> Obviously that'd be a requirement |
21:07:54 | Phytolizer | i believe there's already an experimental version of proc order independence |
21:08:05 | FromDiscord | <toma400> Heck, that makes me so happy ❤️ |
21:08:33 | Phytolizer | actually my only contribution so far to the nim compiler was fixing some tooling around the reorder feature lol |
21:08:48 | FromDiscord | <Elegantbeef> That code reordering is really lazy |
21:08:58 | FromDiscord | <Elegantbeef> Forward declaration is just too easy to use that feature imo |
21:09:03 | FromDiscord | <Elegantbeef> It's more clear aswell |
21:09:19 | Phytolizer | yeah i only discovered it because i think nimterop translated a c header and injected that pragma |
21:12:41 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4Dc7 |
21:13:28 | Phytolizer | it's certainly less likely to result in problems |
21:13:33 | Phytolizer | `result =` is redundant here btw |
21:13:50 | FromDiscord | <Elegantbeef> `cast` is saying "Compiler I know best" |
21:14:05 | FromDiscord | <Elegantbeef> You rarely know best so avoid it unless you actually do |
21:15:04 | FromDiscord | <jordan4ibanez> https://tenor.com/view/adventure-time-jake-finn-time-to-learn-learn-gif-4458347 |
21:18:36 | FromDiscord | <Elegantbeef> PS if that sounds like 'superiority' it's not. I also avoid `cast` 😄 |
21:19:39 | FromDiscord | <jordan4ibanez> No, no, don't worry, I'm not at all offended or feeling down etc. This happens with learning every lang, I'm just very appreciative that you guys are basically like "HOLD ON THERE PARTNER" because this could have gone very badly |
21:21:13 | FromDiscord | <jordan4ibanez> I think these heap elements could be easily bolted into naylib, but the only problem is if raylib goes crazy and then there's a Z component for a rectangle for no reason |
21:23:59 | Phytolizer | i certainly used cast in very questionable ways when i was starting out with nim :P |
21:26:15 | FromDiscord | <jordan4ibanez> Exactly! I've been programming in java for the last few months so all this little detail when it gets transpiled into C is very important |
21:27:26 | FromDiscord | <jordan4ibanez> Unfortunately when I go back into java I already know I'm going to be like "why do I have to write all this?" |
21:33:21 | FromDiscord | <Elegantbeef> @.elcritch\: we're cooking with gas now |
21:33:23 | FromDiscord | <Elegantbeef> simplescreenrecorder-2023-08-11\_15.31.55.mp4 https://media.discordapp.net/attachments/371759389889003532/1139672940326162602/simplescreenrecorder-2023-08-11_15.31.55.mp4 |
21:33:46 | FromDiscord | <Elegantbeef> Using nimcall procs across the VM bridge, it's actually pretty sensible |
21:34:07 | FromDiscord | <Elegantbeef> And cause I'm using a real `.nim` file for `nicoscript` nimlsp works |
21:39:48 | * | advesperacit quit () |
21:40:12 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4Dcb |
21:40:34 | FromDiscord | <Elegantbeef> `tuple[palette: Pallete, data: seq[byte], ble, meh: int]` |
21:41:16 | FromDiscord | <System64 ~ Flandre Scarlet> Oh, it's array notation, thanks! |
21:41:24 | FromDiscord | <Elegantbeef> It's not array notation 😄 |
21:41:41 | FromDiscord | <System64 ~ Flandre Scarlet> well I meant↵Between [] like arrays |
21:47:38 | FromDiscord | <Elegantbeef> Damn this is even more cool |
21:47:41 | FromDiscord | <Elegantbeef> simplescreenrecorder-2023-08-11\_15.46.02.mp4 https://media.discordapp.net/attachments/371759389889003532/1139676536887320676/simplescreenrecorder-2023-08-11_15.46.02.mp4 |
21:47:48 | FromDiscord | <Elegantbeef> First instance is nimscript, the second instance is a compiled version |
21:50:44 | FromDiscord | <jos7388> nice! |
21:50:49 | FromDiscord | <jos7388> did you ever get that wasm thing working? |
21:51:12 | FromDiscord | <jos7388> after looking into my own wasm stuff i think it's not a good idea |
21:51:25 | FromDiscord | <jos7388> mostly because i want hot reload |
21:51:29 | FromDiscord | <jos7388> is nimscript good enough? |
21:51:30 | FromDiscord | <Elegantbeef> I mean yea I got wasm working |
21:51:50 | FromDiscord | <Elegantbeef> Who knows if it's good enough |
21:51:59 | FromDiscord | <Elegantbeef> Wasm based plugins gives you HCR |
21:52:05 | FromDiscord | <Elegantbeef> Just use nlvm to do it |
21:52:35 | FromDiscord | <jos7388> i want to retain state though, and stuff like struct layouts changing, etc seems really problematic with wasm |
21:52:54 | FromDiscord | <Elegantbeef> It's the same thing with using system libraries |
21:53:02 | FromDiscord | <Elegantbeef> It's an implicit issue with HCR |
21:53:03 | FromDiscord | <jos7388> wdym |
21:53:11 | FromDiscord | <Elegantbeef> You cannot change the data you can only change the logic |
21:53:17 | FromDiscord | <Elegantbeef> Changing the data in anyway can corrupt state |
21:53:20 | FromDiscord | <jos7388> ye |
21:53:25 | FromDiscord | <jos7388> but with a scripting lang it's not so much an issue |
21:53:34 | FromDiscord | <jos7388> since you aren't invalidating struct layouts and stuff |
21:53:39 | FromDiscord | <jos7388> so i figure nimscript might be a better target |
21:53:40 | FromDiscord | <Elegantbeef> Right, but that's not HCR that's scripting |
21:54:02 | FromDiscord | <jos7388> if HCR means hot code reload, i don't see why it wouldn't apply to scripting too |
21:54:17 | FromDiscord | <jos7388> you know what i mean? |
21:54:27 | FromDiscord | <jos7388> i'm actually working on a scripting lang now that i plan on adding really robust HCR support to |
21:54:41 | FromDiscord | <jos7388> as like the main feature |
21:57:21 | FromDiscord | <Elegantbeef> Yea the way I'm doing Nimscripts save state is quite questionable |
21:57:53 | FromDiscord | <Elegantbeef> Changing global state is generally going to be a challenge unless you use a table based data type like lua |
22:02:35 | FromDiscord | <jmgomez> In NUE you can update the global state via NimScript or DLLs, it doesnt care. It just works 😛 |
22:03:45 | FromDiscord | <Elegantbeef> Right but the global state is not just a struct it's likely a pointer to a RTTI type no? |
22:03:58 | FromDiscord | <System64 ~ Flandre Scarlet> https://github.com/jangko/nimBMP↵Oh, it also supports BMP! |
22:04:17 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4Dcj |
22:04:24 | FromDiscord | <Elegantbeef> Yes |
22:04:29 | FromDiscord | <jordan4ibanez> I'm relearning thank goodness |
22:04:32 | FromDiscord | <Elegantbeef> Why would you want a heap based vector2 though |
22:04:34 | FromDiscord | <jordan4ibanez> Thank ya |
22:04:46 | FromDiscord | <jordan4ibanez> Long term storage, I've run into stack overflows before with my crazy projects |
22:05:07 | FromDiscord | <Elegantbeef> Well maybe rewrite your code to not have recursive allocations |
22:05:27 | FromDiscord | <jordan4ibanez> Not recursive, tens of thousands of entities |
22:05:41 | FromDiscord | <Elegantbeef> How does stack relate then |
22:05:43 | FromDiscord | <Elegantbeef> Make a `seq[T]` and there you go |
22:05:45 | FromDiscord | <jmgomez> In reply to @Elegantbeef "Right but the global": Yeah, well Im cheating because Im leveraging on the infra that Unreal already has. Although I have to say that Nim feels better integrated that C++ in what has to do with HR. C++ HR crashes a lot |
22:05:59 | FromDiscord | <Elegantbeef> Why would you make your vectors likely the most allocated type a reference |
22:06:07 | FromDiscord | <Elegantbeef> This is why Minecraft runs at .2fps |
22:06:31 | FromDiscord | <jordan4ibanez> If I put the stack based Vector into a ref object, does that ref object's position point to the stack? Or is it a component of the ref object on the heap? |
22:06:48 | FromDiscord | <Elegantbeef> the vector is heap allocated |
22:06:54 | FromDiscord | <jordan4ibanez> NOICE |
22:06:56 | FromDiscord | <Elegantbeef> Types are not ever concretely stack or heap allocated |
22:07:11 | FromDiscord | <Elegantbeef> A reference that contains a value object makes that value object allocated on the heap |
22:07:25 | FromDiscord | <Elegantbeef> It's just contiguous in the block of allocated memory |
22:07:33 | FromDiscord | <jordan4ibanez> I had this problem in D so I wanted to double check |
22:08:03 | FromDiscord | <Elegantbeef> Well that just means you do not understand heap allocations |
22:08:11 | FromDiscord | <Elegantbeef> Even in C# a struct inside a class is heap allocated |
22:08:39 | FromDiscord | <jordan4ibanez> You'd think that, but it happened |
22:08:43 | FromDiscord | <Elegantbeef> When someone says "Is this heap or stack allocated" they generally mean "When used inside of a normal procedure where will the data be" |
22:08:54 | FromDiscord | <Elegantbeef> I mean you clearly do not understand heap allocations |
22:09:21 | FromDiscord | <Elegantbeef> > If I put the stack based Vector into a ref object, does that ref object's position point to the stack? Or is it a component of the ref object on the heap?↵Is quite clear you do not understand how heap allocated types work |
22:09:39 | FromDiscord | <Elegantbeef> It implies all value types are stack allocated and refs must point to them |
22:09:53 | FromDiscord | <Elegantbeef> I cannot think of a language where that's true |
22:10:41 | FromDiscord | <jordan4ibanez> In D, just like destructors do not work properly in D, I've already went through this when translating JOML (https://github.com/jordan4ibanez/doml) and wanted to ensure the same was not true |
22:11:23 | FromDiscord | <jordan4ibanez> Maybe I'm misremembering, it's been a while |
22:11:53 | FromDiscord | <Elegantbeef> D is based on C++ and I know in C++ `new T` does not make a struct or classes value fields point to the stack |
22:12:12 | Phytolizer | I don't believe that's true in D either |
22:12:15 | FromDiscord | <Elegantbeef> They're contiguous allocated to where the pointer points |
22:12:29 | FromDiscord | <Elegantbeef> It's clearly not cause it makes no sense |
22:13:03 | FromDiscord | <Elegantbeef> There is 0 reason for your heap to point to your stack, it adds pointer indirect, is unsafe, and makes it so you now have an extra word taken up |
22:13:13 | Phytolizer | a value type can live anywhere, fundamentally speaking. stack or heap |
22:13:23 | FromDiscord | <Elegantbeef> Even in static memory 😛 |
22:13:30 | Phytolizer | yeah |
22:13:56 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Elegantbeef "This is why Minecraft": Minecraft runs at 2 FPS because Java goofy ahh |
22:14:01 | FromDiscord | <Elegantbeef> Well just to highlight how silly that would be, it means any time you heap allocate you could not reverse your stack |
22:14:15 | FromDiscord | <Elegantbeef> Which means your stack can only grow |
22:16:09 | * | Phytolizer quit (Quit: Client closed) |
22:16:59 | FromDiscord | <jordan4ibanez> Oh yeah it's me misremembering! Then I don't even remember which lang that was an issue in? Hmm |
22:18:24 | FromDiscord | <jordan4ibanez> How does one make a parameter mutable? If it's not heap allocated, do we have to allocate? |
22:18:39 | FromDiscord | <Elegantbeef> `var T` |
22:24:11 | FromDiscord | <jordan4ibanez> Thank ya |
23:02:54 | * | jmdaemon joined #nim |
23:07:34 | * | jmdaemon quit (Ping timeout: 246 seconds) |
23:09:18 | qwr | in C++ (and probably D) its fine for pointers to refer into stack. Nim imho generally just doesn't allow making ref out of non-ref value. |
23:10:46 | FromDiscord | <Elegantbeef> I mean it's fine in Nim aswell, the thing isnt heap referring to stack as much as forcing all value types on the stack |
23:10:46 | FromDiscord | <Elegantbeef> It doesnt make sense to do that |
23:12:21 | qwr | not that it makes sense, but how would you even make ref object out of non-ref object without coping in the nim? |
23:12:47 | FromDiscord | <Elegantbeef> The question is wrong |
23:13:00 | FromDiscord | <Elegantbeef> you just do `.addr` to get a pointer |
23:13:12 | FromDiscord | <Elegantbeef> You cannot make a non ref a ref since a ref is a distinct type of pointer that is automatically managed |
23:13:19 | FromDiscord | <Elegantbeef> You need to allocated and move |
23:13:51 | FromDiscord | <Elegantbeef> Technically if you use `sink` you can remove copying |
23:13:52 | FromDiscord | <demotomohiro> Nim's raw pointer types like `ptr int` can points to stack. C++'s smart pointer like `shared_ptr` or `unique_ptr` can refer only heap as far as I know. |
23:15:20 | qwr | ok, yes, you still have non-safe pointers also. maybe D also has both, but C has only non-safe ones and in C++ you can build shared_ptr out of classes with constructors/destructors |
23:16:14 | FromDiscord | <demotomohiro> You cannot make ref object out of non-ref object without copying in Nim because how stack is managed is different from heap. |
23:16:36 | qwr | in nim you normally just won't use the bare pointer unless really needed for interfacing something else (foreign library, hardware etc) |
23:16:39 | FromDiscord | <Elegantbeef> Well like I said you can remove any large copying with sink |
23:16:53 | FromDiscord | <Elegantbeef> The scary copying happens in `seq[T]` or `string` |
23:17:18 | FromDiscord | <Elegantbeef> Yes it still copies arrays and other value types |
23:19:34 | FromDiscord | <demotomohiro> Heap memory can be allocated/deallocated at any time but stacks are allocated when a proc is called and deallocatdd when leaving a proc. |
23:23:07 | FromDiscord | <Elegantbeef> Anywho view types soon |
23:23:18 | FromDiscord | <Elegantbeef> In the year 2034 I guarantee it! |
23:25:08 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/manual_experimental.html#view-types |
23:25:27 | FromDiscord | <Elegantbeef> Yea, but it's very broken and unusable presently |
23:43:10 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://paste.rs/IirTT |
23:43:42 | FromDiscord | <Elegantbeef> `bmp.convert[: YourT](bitsPerPixel)` or `convert[T](bmp, bitsPerPixel)` |
23:44:07 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright, thanks |