00:04:45 | FromDiscord | <Elegantbeef> Anonymous files? |
00:05:50 | FromDiscord | <spotlightkid> Probably you mean some kind of file upload service? |
00:06:34 | FromDiscord | <spotlightkid> If they don't have a published API, you have to resort to reverse engineering. |
00:06:55 | FromDiscord | <spotlightkid> If they do, use any Nim http client library. |
00:07:53 | * | pbsds quit (Quit: The Lounge - https://thelounge.chat) |
00:08:31 | * | pbsds joined #nim |
00:11:47 | FromDiscord | <demotomohiro> Anonymous files? Are there file systems that allow creating files without name? |
00:14:07 | FromDiscord | <Andreas> prbl. hidden-files ? |
00:14:39 | FromDiscord | <Elegantbeef> Who knows until they actually respond |
00:14:52 | FromDiscord | <Elegantbeef> We can be here all day throwing darts at the board |
00:15:05 | FromDiscord | <Andreas> lets do that.. |
00:19:17 | FromDiscord | <jakraes> sent a code paste, see https://play.nim-lang.org/#ix=4CiN |
00:19:59 | FromDiscord | <Elegantbeef> Nim doesnt have the concept of virtual, so that's fine |
00:20:17 | FromDiscord | <nixfreak> hmm , does anyone have atlas in their nimble path ? |
00:20:17 | FromDiscord | <Elegantbeef> Ideally you wouldnt use dynamic dispatch but it's easier to pickup and reason than the alternative |
00:20:40 | FromDiscord | <nixfreak> all the tools come up accept for atlas |
00:20:45 | FromDiscord | <Elegantbeef> From my understanding choosenim doesnt move atlas to where it's supposed to be |
00:20:55 | FromDiscord | <nixfreak> (edit) "accept for" => "except" |
00:21:06 | FromDiscord | <nixfreak> ahh ok |
00:21:21 | FromDiscord | <nixfreak> so just create a symlink I guess |
00:21:29 | FromDiscord | <Elegantbeef> Yea |
00:22:15 | FromDiscord | <jakraes> In reply to @Elegantbeef "Ideally you wouldnt use": Are there any downsides on that? I'm going to use inheritance so I thought it made sense to use the method keyword instead of proc |
00:22:47 | FromDiscord | <Elegantbeef> Well dynamic dispatch has overhead, so that's pretty much it |
00:23:29 | FromDiscord | <jakraes> Hmmm, yeah that makes sense |
00:24:15 | FromDiscord | <jakraes> What I'm doing isn't going to be very resource heavy so it's not a worry for now |
00:24:23 | FromDiscord | <jakraes> But I'll keep that in min |
00:24:26 | FromDiscord | <jakraes> (edit) "min" => "mind" |
00:29:46 | FromDiscord | <pastor0102> sent a code paste, see https://play.nim-lang.org/#ix=4CiR |
00:30:17 | FromDiscord | <Elegantbeef> You want `proc` not method |
00:30:21 | FromDiscord | <Elegantbeef> `method` is for dynamic dispatch and inheritance |
00:30:33 | FromDiscord | <Elegantbeef> `proc` is statically dispatched and what you want 90% of the time |
00:31:39 | FromDiscord | <pastor0102> But this should be a method for the `Property`. |
00:31:57 | FromDiscord | <Elegantbeef> Nim doesnt have concept of procedures attached to types |
00:32:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/kUAMP |
00:33:43 | FromDiscord | <nixfreak> nm the atlas dir ~/.choosenim/toolschains/nim2.0.0/tools/atlas is empty |
00:34:07 | FromDiscord | <pastor0102> so what is the difference between `proc` and `method` |
00:34:16 | FromDiscord | <Elegantbeef> Methods are dynamically dispatched |
00:35:32 | FromDiscord | <demotomohiro> Method is something like virtual member function in C++. |
00:36:55 | FromDiscord | <pastor0102> Can you give me some examples to let me know when and how to use `method`? |
00:37:34 | FromDiscord | <Andreas> `method` when you want Inheritance. Otherwise `proc` |
00:38:03 | FromDiscord | <demotomohiro> In reply to @pastor0102 "Can you give me": https://nim-lang.org/docs/manual.html#methods |
00:38:18 | FromDiscord | <pastor0102> |
00:38:33 | FromDiscord | <Andreas> (edit) "`method` when you want Inheritance. Otherwise `proc` ... " added "or `func`." |
00:38:41 | FromDiscord | <Elegantbeef> There you go |
00:38:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/EDNek |
00:39:04 | FromDiscord | <huantian> woah |
00:39:15 | FromDiscord | <huantian> is that drug in the family friendly nim discord |
00:40:30 | FromDiscord | <Elegantbeef> Your name is almost an anagram for Marihuana |
00:44:59 | FromDiscord | <nixfreak> what does base pragma actually do |
00:45:05 | FromDiscord | <nixfreak> is it needed ? |
00:47:25 | FromDiscord | <Elegantbeef> It tells nim this is the first implementation of the method and to only consider children of this type for dispatch here |
00:47:52 | FromDiscord | <Elegantbeef> It also gives a signature for the rest to follow |
00:48:09 | FromDiscord | <Elegantbeef> So you can do `method myBase(...){.gcSafe, raises:[], ...}` |
00:51:53 | * | lumo_e quit (Quit: Quit) |
01:00:34 | FromDiscord | <pastor0102> sent a code paste, see https://play.nim-lang.org/#ix=4CiY |
01:03:10 | FromDiscord | <Elegantbeef> It converts it into `A` inside `[]` |
01:05:10 | FromDiscord | <Elegantbeef> This is the same sort of logic as `List<object>` in C# or Java if you know those |
01:07:59 | FromDiscord | <nixfreak> What scenario would you want to use dynamic dispatch rather then static? Methods in nim are runtime right? |
01:08:14 | FromDiscord | <Elegantbeef> Yes |
01:09:02 | FromDiscord | <nixfreak> So when would you actually have to use methods if you already know the type? |
01:09:27 | FromDiscord | <Elegantbeef> You wouldnt use it unless you want dynamic dispatch |
01:10:55 | FromDiscord | <nixfreak> So really no reason to use methods on nim? |
01:11:08 | FromDiscord | <nixfreak> (edit) "on" => "in" |
01:11:45 | FromDiscord | <Elegantbeef> If you need them |
01:12:34 | FromDiscord | <nixfreak> Yeah I’m trying to find a scenario where you would. |
01:12:50 | FromDiscord | <jakraes> Inheritance and abstraction I'd say |
01:12:54 | FromDiscord | <Elegantbeef> GUI |
01:12:55 | FromDiscord | <Elegantbeef> Games |
01:12:55 | FromDiscord | <jakraes> That's what I'm using it for at least |
01:13:01 | FromDiscord | <Elegantbeef> Places where you have some form of 'type erasure' |
01:13:13 | FromDiscord | <Elegantbeef> Eh you can use procs with inheritance if you do not need homogenous collections |
01:13:34 | FromDiscord | <Elegantbeef> The issue is mostly homogenous collections |
01:13:44 | FromDiscord | <jakraes> Yeah that's true |
01:13:57 | FromDiscord | <nixfreak> As in ref objects |
01:14:04 | * | lucasta joined #nim |
01:14:05 | FromDiscord | <jakraes> I personally enjoy storing almost everything I can in the same seq |
01:14:23 | FromDiscord | <jakraes> Instead of spreading it out across multiple seqs |
01:14:35 | FromDiscord | <Elegantbeef> Object variants! |
01:15:38 | FromDiscord | <jakraes> I might look into that |
01:15:40 | FromDiscord | <jakraes> Seems interesting |
01:15:58 | FromDiscord | <jakraes> Might find it useful for my current object |
01:22:50 | FromDiscord | <nixfreak> So are all object variants runtime objects? |
01:28:00 | FromDiscord | <michaelb.eth> In reply to @nixfreak "So are all object": no, e.g. you can have a `const` that's an instance of an object variant |
01:30:11 | FromDiscord | <nixfreak> https://nim-lang.org/docs/manual.html#restrictions-on-compileminustime-execution |
01:30:41 | FromDiscord | <michaelb.eth> sure, but that doesn't exclude object variants |
01:31:09 | FromDiscord | <nixfreak> yeah I know nothing about object varients I need to read up on them |
01:31:37 | FromDiscord | <michaelb.eth> object variants have a field (or more than one) that is used to express `case..of` |
01:31:59 | FromDiscord | <michaelb.eth> In reply to @nixfreak "yeah I know nothing": https://nim-lang.org/docs/manual.html#types-object-variants |
01:39:50 | FromDiscord | <nixfreak> So would you turn a ref object into an object? |
01:40:02 | FromDiscord | <nixfreak> (edit) "So ... would" added "why" |
01:42:43 | FromDiscord | <Chronos [She/Her]> In reply to @nixfreak "So why would you": Objects can be constants, refs can't, there's some minor overhead with ref objects but that doesn't really matter tbh, data associated with ref objects are always mutable, unlike objects which are only mutable if the actual object is stored in a variable |
01:45:09 | FromDiscord | <xtrayambak> I love abusing object variants. |
01:45:24 | FromDiscord | <Chronos [She/Her]> I mean you're using them for their intended purpose so, lol |
01:45:26 | FromDiscord | <demotomohiro> In reply to @nixfreak "So why would you": https://internet-of-tomohiro.netlify.app/nim/faq.en.html#type-when-to-use-ref-object-vs-plain-object-qmark |
01:45:27 | FromDiscord | <Elegantbeef> There isnt really any abusing them |
01:46:06 | FromDiscord | <michaelb.eth> if one believes in "shared mutable state is the root of all evil", `ref` and `var` should only be used when there's no other practical choice |
01:51:25 | FromDiscord | <Elegantbeef> Such a nice thing you can say that and not have to use `var` for pass by reference |
01:56:33 | FromDiscord | <michaelb.eth> hint on the subtle point you're making? 😄 |
01:59:08 | FromDiscord | <Elegantbeef> Odin, Zig, C, require passing by reference manually so side from the `const` in C the pointer is mutable |
01:59:09 | FromDiscord | <Elegantbeef> Actually I'm wrong with Zig |
01:59:11 | FromDiscord | <Elegantbeef> It does the same thing as Nim where it decides how to pass |
02:02:57 | FromDiscord | <Elegantbeef> The point being made is that if it wasnt for that implicit pass by reference one would need to use `var` more often to reduce copies. That should clear that up |
02:04:04 | NimEventer | New thread by elcritch: CBOR?, see https://forum.nim-lang.org/t/10372 |
02:16:32 | FromDiscord | <.matrixagent> does this look like gtk https://media.discordapp.net/attachments/371759389889003532/1136845088950075402/image.png |
02:17:08 | FromDiscord | <.matrixagent> looks no different from gtk https://media.discordapp.net/attachments/371759389889003532/1136845242755186829/image.png |
02:17:23 | FromDiscord | <.matrixagent> wonder if java swing is actually calling native widgets or mocking them like qt |
02:19:11 | FromDiscord | <Elegantbeef> > Unlike AWT components, Swing components are not implemented by platform-specific code. Instead, they are written entirely in Java and therefore are platform-independent. |
02:19:46 | FromDiscord | <.matrixagent> so they just mock native |
02:19:57 | FromDiscord | <.matrixagent> amazing how they can make it look identical like native |
02:19:58 | FromDiscord | <Elegantbeef> Seems it might have a theming api and use your gtk theme |
02:20:10 | FromDiscord | <.matrixagent> let me try to change some ui colors |
02:21:36 | FromDiscord | <.matrixagent> yeah they do change with my ui change |
02:22:06 | FromDiscord | <.matrixagent> java swing is truly one of the best ui toolkits created |
02:22:10 | FromDiscord | <nixfreak> https://internet-of-tomohiro.netlify.app/nim/faq.en.html#procedures-how-to-define-constructorqmark |
02:22:15 | FromDiscord | <.matrixagent> qt is unparalleled ofc |
02:23:12 | FromDiscord | <nixfreak> So is Foo compiled time and Bar is runtime? |
02:23:49 | FromDiscord | <Elegantbeef> No |
02:23:56 | FromDiscord | <Elegantbeef> Foo is stack allocated Bar is heap allocated |
02:24:38 | FromDiscord | <nixfreak> Heap allocated because of ref pointer |
02:32:18 | FromDiscord | <michaelb.eth> In reply to @.matrixagent "so they just mock": isn't JavaFX the current hotness for UI with Java? you can even style it with CSS |
02:32:37 | FromDiscord | <nixfreak> JavaFX is old |
02:33:08 | FromDiscord | <michaelb.eth> the original implementation was apparently pretty yucky, but then it was almost completely redone, iirc |
02:33:09 | FromDiscord | <nixfreak> Can do the same thing with Qt |
02:33:23 | FromDiscord | <michaelb.eth> though maybe the initial impression doomed it |
02:33:33 | FromDiscord | <nixfreak> That could be |
02:34:27 | FromDiscord | <nixfreak> Is there a compiler option to show if code is executed at runtime or compile time? |
02:35:16 | FromDiscord | <nixfreak> -x? |
02:35:39 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4Cja |
02:35:57 | FromDiscord | <nixfreak> I like nuklear |
02:36:45 | FromDiscord | <Elegantbeef> If code is statically executable it's done statically |
02:37:02 | FromDiscord | <Elegantbeef> If it has a side effect or requires the host runtime it's done at runtime |
02:37:16 | FromDiscord | <michaelb.eth> (edit) "http://ix.io/4Cja" => "http://ix.io/4Cjb" |
02:37:20 | FromDiscord | <nixfreak> Just curious if you could actually see it. |
02:37:25 | FromDiscord | <Elegantbeef> Nope |
02:38:03 | FromDiscord | <demotomohiro> In reply to @nixfreak "Is there a compiler": I don't know such option. Nim generates assembly code with `--asm` so that you can see what is executed at runtime. |
02:38:25 | FromDiscord | <Elegantbeef> But not for the entire project |
02:38:29 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Cjc |
02:38:50 | FromDiscord | <Elegantbeef> It wouldnt be too hard to modify the compiler to see there's even a nice little `foldconstants` or similar |
02:40:01 | FromDiscord | <michaelb.eth> would be cool if Nim's compiler had a global option for dumping out what is transformed at compile-time and what those transform evaluated to at compile-time |
02:40:33 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/devel/compiler/semfold.nim#L575 putting an echo inside of here would suffice |
02:40:52 | FromDiscord | <Elegantbeef> it'd be so much noise |
02:41:51 | FromDiscord | <michaelb.eth> maybe filter-able by module? |
02:41:59 | FromDiscord | <michaelb.eth> to reduce the noise, I mean |
02:45:37 | FromDiscord | <elegantbeef> Bridge is really silly |
02:45:44 | FromDiscord | <elegantbeef> Anyway typical "PRs welcome" 😄 |
02:50:07 | FromDiscord | <nixfreak> Are there language’s that methods are compiled? Or are all methods executed at runtime |
02:50:15 | FromDiscord | <nixfreak> (edit) "runtime" => "runtime?" |
02:51:00 | FromDiscord | <Elegantbeef> Someone is asking questions with information they don't understand 😄 |
02:51:19 | FromDiscord | <michaelb.eth> if the decision-making based on the inputs happens re: data supplied at runtime, then how could the dispatch happen at other than runtime? |
02:51:42 | FromDiscord | <Elegantbeef> Methods in Nim are dynamically dispatched, which means the runtime type information is used to call the underling procedures. Methods really are just procedures with a fancy dispatch logic |
02:52:34 | FromDiscord | <demotomohiro> If some compiler's optimizer found function/procedure's output can be calculated at compile time, it might do so. |
02:52:55 | FromDiscord | <nixfreak> Ok that is where I am getting confused |
02:53:39 | FromDiscord | <nixfreak> Cause I polymorphism during compile time checks objects which invokes a method. |
02:53:58 | FromDiscord | <nixfreak> (edit) "I" => "with" |
02:54:07 | FromDiscord | <Elegantbeef> I really hate the term polymorphism as it's ambiguous what you mean |
02:54:11 | FromDiscord | <Elegantbeef> There are multiple forms of it |
02:55:49 | FromDiscord | <nixfreak> Ok so at compile time the code understands and checks for the object which invokes a method. |
02:56:28 | FromDiscord | <Elegantbeef> At compile time the onlything the compiler knows is "We're invoking a method, use the dispatch table to actually call it" |
02:56:57 | FromDiscord | <JJ> the term "method" is usually used to refer to runtime-dispatched functions |
02:57:17 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/Uel1v |
02:57:31 | FromDiscord | <Elegantbeef> The only reason you need methods is for runtime polymorphism |
02:57:44 | FromDiscord | <nixfreak> Ok , sorry for the confusion, I’m not a professional programmer so I was just curious. |
02:57:46 | FromDiscord | <Elegantbeef> Where you can have `[A(), B(), C()]` |
02:57:55 | FromDiscord | <Elegantbeef> I'm not a professional programmer either, so that's unexcusable |
02:57:59 | FromDiscord | <Elegantbeef> 😛 |
02:58:45 | FromDiscord | <nixfreak> Ok seasoned programmer then. I just write scripts and break things. |
02:59:04 | FromDiscord | <Elegantbeef> Where is my favourite point Dexter to say "It's actually inexcusable" |
02:59:52 | FromDiscord | <nixfreak> Ok,ok point taken |
03:01:52 | FromDiscord | <michaelb.eth> just remembered, was wanting to ask Beef: the work on CPS seems like there was a lot of promise behind it, so was there a melt down due to technical problems, or it was related to some personality conflicts, or a mix of both? |
03:02:10 | FromDiscord | <Elegantbeef> Mixture of both afaik |
03:02:18 | FromDiscord | <michaelb.eth> I see |
03:02:18 | FromDiscord | <Elegantbeef> It works well but there is no way of doing generic continuations |
03:02:32 | FromDiscord | <Elegantbeef> Or the last I heard there wasnt |
03:02:57 | FromDiscord | <michaelb.eth> generic in the sense of the payload... or...? |
03:03:21 | FromDiscord | <Elegantbeef> `proc doThing[T](): Continuation[T]` or w/e the syntax is |
03:03:46 | * | kedin joined #nim |
03:03:47 | FromDiscord | <Elegantbeef> Due to how Nim's generics are that doesnt work since the macro evaluates on declaration instead of instantiation |
03:04:05 | FromDiscord | <Elegantbeef> So they cannot generate the appropriate code |
03:04:32 | FromDiscord | <Elegantbeef> They do want to integrate it into cyo/nimskall/denim or whatever they want to call it |
03:04:41 | FromDiscord | <Elegantbeef> But as a language feature instead of a macro of course |
03:05:45 | FromDiscord | <Elegantbeef> Dis is now using janet though, so any of his Nim packages are likely to bitrot |
03:06:03 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4Cje |
03:07:02 | FromDiscord | <Elegantbeef> CPS is still more than usable I think termer was using it to some success for their web shite |
03:07:20 | FromDiscord | <Elegantbeef> Was it termer, might've been someone else I don't know without proper PFPs names are lost on me |
03:07:32 | termer | who |
03:07:34 | FromDiscord | <demotomohiro> It should be `var foo: BaseType = if runtimeFunc(): A() else B()`. |
03:07:43 | FromDiscord | <Elegantbeef> Exactly |
03:07:45 | termer | I livestreamed working with it |
03:07:57 | FromDiscord | <Elegantbeef> Right that was you |
03:08:09 | termer | I want to livestream trying to work with that stdio module made for CPS |
03:08:22 | FromDiscord | <Elegantbeef> Nim-sys? |
03:08:25 | termer | yeah |
03:08:32 | termer | I've been doing soul searching and wondering why I'm even using Nim but I did find myself upgrading one of my projects to 2.0.0 this morning |
03:08:49 | FromDiscord | <Elegantbeef> There's nothing like it is what I've come to |
03:09:14 | kedin | i,m sorry to interrupt |
03:09:14 | kedin | i install the nimx package to try it out.. |
03:09:15 | kedin | non of the example code compiled (that,s not the problem) |
03:09:15 | kedin | i tried to uninstall it out using nimble but it returns [Error: Package not found] |
03:09:25 | kedin | it list it just fine tho |
03:10:25 | termer | I wanna redo KommandKit with CPS |
03:11:05 | FromDiscord | <Elegantbeef> Odd that it's not uninstalling |
03:11:44 | FromDiscord | <Elegantbeef> I dumbly am getting the urge to write a fantasy console, too much toying with nimscript |
03:11:55 | termer | that'd be fun |
03:12:45 | FromDiscord | <Elegantbeef> Already have nico as the graphics/input, and I've done similar before with my snake example even runs in browser |
03:13:25 | FromDiscord | <Elegantbeef> Try a `nimble refresh` followed by a `nimble uninstall nimx` I guess kedin |
03:14:13 | kedin | still no luck |
03:14:31 | FromDiscord | <Elegantbeef> Odd, Nimble is just broken it seems 😄 |
03:14:40 | kedin | why tho? |
03:14:50 | FromDiscord | <Elegantbeef> No clue |
03:15:00 | FromDiscord | <Elegantbeef> I could uninstall a library overhere |
03:15:19 | kedin | can i remove it with it,s package and reinstall? |
03:15:29 | kedin | *packages |
03:16:24 | FromDiscord | <Elegantbeef> You should be able to manually delete it inside `.nimble/pkgs2` |
03:17:21 | FromDiscord | <.matrixagent> is there any O(1) search algo? |
03:17:50 | kedin | wait... |
03:17:51 | kedin | i search the directory and it seems that nimx is not install... |
03:18:11 | kedin | however it,s dependences are |
03:18:18 | FromDiscord | <.matrixagent> for example if i have a huge list of sorted elements alphabetically from A to Z and i want to find Banana in the list is there a way to do this in an O(1) fashion? |
03:18:32 | FromDiscord | <Elegantbeef> insert adam savage saying "well there's your problem" here |
03:18:48 | FromDiscord | <Elegantbeef> You're describing a hashtable 😄 |
03:19:15 | FromDiscord | <.matrixagent> i really have to learn more data structures lol |
03:19:20 | kedin | how....... why didn,t it install? |
03:19:26 | FromDiscord | <Elegantbeef> `std/tables` |
03:19:35 | FromDiscord | <Elegantbeef> I don't know I'm not the nimble binary |
03:19:39 | FromDiscord | <.matrixagent> hashtable is O(1)? |
03:19:44 | FromDiscord | <.matrixagent> in search sorted array |
03:19:45 | FromDiscord | <Elegantbeef> yes |
03:20:02 | FromDiscord | <Elegantbeef> hashtable is O(1) regardless if sorted |
03:20:25 | FromDiscord | <odexine> In reply to @Elegantbeef "Where is my favourite": sorry i was busy |
03:20:46 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "hashtable is O(1) regardless": thanks |
03:21:25 | FromDiscord | <odexine> btw O(1) doesnt always mean faster than O(log n) |
03:22:02 | FromDiscord | <.matrixagent> sure but its constant |
03:22:15 | FromDiscord | <.matrixagent> i'd argue a for loop would work if it was unsorted |
03:22:20 | FromDiscord | <Elegantbeef> Time complexity really means little |
03:22:45 | FromDiscord | <Elegantbeef> Binary search would be even better |
03:22:53 | FromDiscord | <odexine> In reply to @.matrixagent "sure but its constant": could be constantly slow, you know |
03:23:14 | FromDiscord | <odexine> O(1) just guarantees that the speed will be the same regardless of input size |
03:23:14 | FromDiscord | <.matrixagent> In reply to @odexine "could be constantly slow,": still constant |
03:23:24 | FromDiscord | <Elegantbeef> lol |
03:23:36 | FromDiscord | <.matrixagent> if its a huge list i'd take constant |
03:23:36 | FromDiscord | <Elegantbeef> "I use a table instead of an array cause both are constant time" |
03:23:43 | FromDiscord | <odexine> and that point where constant is better than logn could be in the millions, way outside the practical range |
03:23:55 | FromDiscord | <odexine> In reply to @.matrixagent "if its a huge": huge list could mean millions, as ive said |
03:24:00 | FromDiscord | <odexine> and you may never reach that point |
03:24:10 | FromDiscord | <monark.chan> How can I include a file in a macro |
03:24:48 | FromDiscord | <.matrixagent> In reply to @odexine "huge list could mean": i mean i had an idea of if its sorted i could just start at the index of the char i want |
03:25:30 | FromDiscord | <.matrixagent> wouldnt work probably |
03:25:40 | FromDiscord | <Elegantbeef> `nnkIncludeStmt.newTree(infix("std", "/", "strutils"))`↵(@monark.chan) |
03:26:02 | FromDiscord | <Elegantbeef> If it's sorted you just use binary search and call it a day |
03:26:14 | FromDiscord | <monark.chan> Ok ty |
03:30:11 | FromDiscord | <user2m> How would I go about calling a python function from my nim code? Nimpy and Nimporter seem to be for calling Nim code in python |
03:31:44 | FromDiscord | <.kanaxa> In reply to @user2m "How would I go": Nimpy does allow you to call Python from Nim |
03:31:49 | FromDiscord | <odexine> In reply to @.matrixagent "i mean i had": okay so how would you know the index of the first of the character you want |
03:31:51 | FromDiscord | <.kanaxa> The bridge works the other way around |
03:32:24 | * | kedin quit (Quit: Connection closed) |
03:32:33 | FromDiscord | <.matrixagent> In reply to @odexine "okay so how would": nested array |
03:32:57 | FromDiscord | <user2m> In reply to @.kanaxa "The bridge works the": Ahh yes u are correct! Just checked out the tests. At first I thought nimpy only allowed u to call built-ins |
03:36:51 | FromDiscord | <.matrixagent> In reply to @.matrixagent "nested array": or nested dictionary probably |
03:37:37 | FromDiscord | <demotomohiro> HashTable is actually not O(1) as cache memory affects performance. |
03:38:20 | FromDiscord | <Elegantbeef> It's O(1) |
03:38:21 | FromDiscord | <.matrixagent> the probability that a 100 mb array is in the cache is probably 0 |
03:38:37 | FromDiscord | <.matrixagent> since no cache has that amount |
03:38:41 | FromDiscord | <Elegantbeef> Cache effecting speed does not change time complexity |
03:38:55 | FromDiscord | <leorize> it never have to cache the entire thing anyways |
03:38:59 | FromDiscord | <Elegantbeef> Time complexity describes the effect length has on the algorithim |
03:39:20 | FromDiscord | <Elegantbeef> The length of the table has 0 effect on the complexity of the look up |
03:39:41 | FromDiscord | <Elegantbeef> Affect should be somewhere here I think |
03:40:18 | FromDiscord | <demotomohiro> If table size was small, most of contents can be placed on 1st cache memory and less likey cache miss happen. |
03:40:35 | FromDiscord | <Elegantbeef> Sure but that is not what time complexity is in regards to |
03:40:51 | FromDiscord | <Elegantbeef> It's not about actual speed it's about the algorithms theoretical complexity |
03:48:03 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4Cjn |
03:48:23 | * | lucasta quit (Quit: Leaving) |
03:48:23 | FromDiscord | <.matrixagent> i bet the number is just hardcoded in the assembly |
03:48:34 | * | ajunior quit (Ping timeout: 260 seconds) |
03:49:17 | FromDiscord | <Elegantbeef> 1 million isnt a large set of numbers |
03:49:32 | FromDiscord | <leorize> turns out if you have a computer with 4Ghz CPU, it can churn through instructions real fast |
03:49:37 | FromDiscord | <demotomohiro> https://godbolt.org/↵It might help you to find out. |
03:49:57 | FromDiscord | <Elegantbeef> Especially when it's just anding two integers together 😄 |
03:50:05 | FromDiscord | <.matrixagent> In reply to @leorize "turns out if you": wow 1 million iterations in near instantly |
03:50:14 | FromDiscord | <.matrixagent> or nearly 1 million iterations |
03:51:44 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "1 million isnt a": i have a better idea |
03:51:49 | FromDiscord | <Elegantbeef> and 1 million allocations |
03:51:59 | FromDiscord | <Elegantbeef> Ok not that many, but a lot of them |
03:52:07 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "and 1 million allocations": how is it 1 million allocations |
03:52:20 | FromDiscord | <.matrixagent> just once for the seq no? |
03:52:31 | FromDiscord | <Elegantbeef> you call `.add` |
03:52:41 | FromDiscord | <leorize> probably not 1mil |
03:52:45 | FromDiscord | <leorize> it does have a growth factor of 1.5 |
03:52:47 | FromDiscord | <Elegantbeef> Yea it's not 1 mil |
03:52:52 | FromDiscord | <Elegantbeef> it's not 1.5 😄 |
03:52:57 | * | ajunior joined #nim |
03:52:59 | FromDiscord | <Elegantbeef> its `len 2 div 3` |
03:53:09 | FromDiscord | <.matrixagent> computers are fast |
03:53:16 | FromDiscord | <.matrixagent> i wonder how they got electron to work this slow |
03:53:36 | FromDiscord | <Elegantbeef> leroize yes that is practically 1.5 times, but it's integer math so it's not exact! |
03:56:38 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4Cjs |
03:56:39 | FromDiscord | <.matrixagent> its done instantly |
03:56:52 | FromDiscord | <.matrixagent> would 1 billion elements make a dent? |
04:00:13 | FromDiscord | <.matrixagent> 20 gb of memory just to search from 1 to 1000000000 https://media.discordapp.net/attachments/371759389889003532/1136871185313976381/image.png |
04:00:43 | FromDiscord | <leorize> it's just the growth metric of the array |
04:00:49 | FromDiscord | <leorize> (and also the allocator used by nim sucks) |
04:01:10 | FromDiscord | <.matrixagent> In reply to @leorize "(and also the allocator": damn was just told that the nim allocator is constant |
04:01:17 | FromDiscord | <.matrixagent> (edit) "In reply to @leorize "(and also the allocator": damn was just told that the nim allocator is constant ... " added "time complexity" |
04:01:45 | FromDiscord | <Elegantbeef> Who said that? |
04:01:46 | FromDiscord | <leorize> it's the space-time tradeoff |
04:02:02 | FromDiscord | <leorize> and also the algorithm is just really, really old by now |
04:02:13 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Who said that?": you or phil probably |
04:02:14 | FromDiscord | <leorize> it didn't see a lot of innovation during it's lifetime |
04:02:26 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Nim's allocator is TLSF": this |
04:02:41 | FromDiscord | <leorize> and Nim is like the only project using TSLF-based allocators afaict |
04:03:30 | FromDiscord | <.matrixagent> its constant tho |
04:03:33 | FromDiscord | <Elegantbeef> I did say inspired |
04:03:54 | FromDiscord | <.matrixagent> so wtf is its time complexity |
04:04:02 | FromDiscord | <leorize> it's pretty much the exact algo I think |
04:04:09 | FromDiscord | <leorize> with a global lock for threading |
04:04:28 | FromDiscord | <.matrixagent> why doesnt nim just give every thread its own GC |
04:04:30 | FromDiscord | <Elegantbeef> It's modified leo |
04:04:41 | FromDiscord | <leorize> it used to |
04:04:41 | FromDiscord | <Elegantbeef> Global heap is nicer |
04:04:49 | FromDiscord | <leorize> people didn't like it |
04:04:59 | FromDiscord | <.matrixagent> so now i can just use threads with the typical worries? |
04:05:25 | FromDiscord | <.matrixagent> data races and deadlocks worries without worring about the gc messing anything up? |
04:06:28 | FromDiscord | <Elegantbeef> Well sharing data across threads is a chore in that world |
04:06:28 | FromDiscord | <Elegantbeef> The present Nim allocator has inspiration from mimalloc and tslf afaik |
04:06:28 | FromDiscord | <leorize> it's not like it's less of a chore today \:P |
04:06:29 | FromDiscord | <Elegantbeef> It is |
04:06:29 | FromDiscord | <Elegantbeef> You can pass data using isolate or directly if you disarm the destructor |
04:06:34 | FromDiscord | <leorize> isolate works now? |
04:06:41 | FromDiscord | <Elegantbeef> That's what I've been told |
04:06:57 | FromDiscord | <Elegantbeef> I do not use multi threading so it's all hearsay for me |
04:07:26 | FromDiscord | <.matrixagent> and also why does the allocator lock when i try to allocate something twice at the same time for example one on the main thread and one on the child thread |
04:07:33 | FromDiscord | <.matrixagent> or worker thread whatever you wanna call it |
04:08:00 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Well sharing data across": copy |
04:08:07 | FromDiscord | <.matrixagent> easy |
04:08:10 | FromDiscord | <leorize> turns out it wasn't that well designed \:P |
04:08:18 | FromDiscord | <.matrixagent> they say i can replace it |
04:08:22 | FromDiscord | <.matrixagent> any suggestions? |
04:08:36 | FromDiscord | <leorize> `-d:useMalloc` for a real allocator |
04:08:41 | FromDiscord | <leorize> more secure, too |
04:08:55 | FromDiscord | <Elegantbeef> mimalloc is probably better |
04:08:56 | FromDiscord | <.matrixagent> would it cause problems? |
04:08:57 | FromDiscord | <Elegantbeef> malloc is slow leo |
04:09:23 | FromDiscord | <leorize> the nice thing about malloc is that you get to replace the implementation |
04:09:42 | FromDiscord | <leorize> and every allocator library have a replacement you can link |
04:09:43 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "malloc is slow leo": how is malloc slow |
04:10:09 | FromDiscord | <Elegantbeef> I think malloc is even slower than stock Nim's |
04:10:13 | FromDiscord | <.matrixagent> https://github.com/microsoft/mimalloc |
04:10:15 | FromDiscord | <leorize> but if malloc works for you then just use it |
04:10:22 | FromDiscord | <.matrixagent> wow unreal even uses it? |
04:10:38 | FromDiscord | <.matrixagent> how do i even use it |
04:10:46 | FromDiscord | <leorize> it's battle-tested, and usually is hardened against attacks |
04:11:44 | FromDiscord | <.matrixagent> In reply to @leorize "but if malloc works": also malloc isnt really slow |
04:11:46 | FromDiscord | <.matrixagent> at all |
04:13:44 | FromDiscord | <Elegantbeef> Depends on OS, but it can be quite slow |
04:13:55 | FromDiscord | <gamedroit> Yea I agree malloc is slow, you are forcing memory to be allocated to a size and this introduces the need to manage that memory directly. |
04:13:56 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Depends on OS, but": in any modern OS malloc is not slow |
04:14:07 | FromDiscord | <.matrixagent> this is C |
04:14:14 | FromDiscord | <.matrixagent> if its slow it wouldnt have been implemented |
04:14:20 | FromDiscord | <Elegantbeef> What? |
04:14:27 | FromDiscord | <leorize> you jest |
04:14:27 | FromDiscord | <.matrixagent> yes |
04:14:46 | FromDiscord | <.matrixagent> simply memory allocation isnt slow anymore |
04:15:10 | FromDiscord | <leorize> it's still very slow |
04:15:22 | FromDiscord | <Elegantbeef> Malloc is slower than other allocators |
04:15:22 | FromDiscord | <leorize> gamedevs don't flock to mimalloc for fun, y'know |
04:15:39 | FromDiscord | <leorize> malloc is a little too generic tbf |
04:15:55 | FromDiscord | <Elegantbeef> It's also very very eager to return memory afaik |
04:15:55 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4Cjx |
04:15:56 | FromDiscord | <Elegantbeef> Which is one of the biggest bottlenecks |
04:15:56 | FromDiscord | <leorize> glibc's malloc is ok for most usages |
04:16:03 | FromDiscord | <.matrixagent> this allocates memory 1000 times in a row and it finishes instantly |
04:16:09 | FromDiscord | <Elegantbeef> Ok cool |
04:16:22 | FromDiscord | <guzba8> In reply to @.matrixagent "this allocates memory 1000": 🤣 "finishes instantly is not a benchmark |
04:16:25 | FromDiscord | <Elegantbeef> Now make a real program with a bunch of allocations then switch to mimalloc |
04:16:28 | FromDiscord | <guzba8> (edit) "instantly" => "instantly"" |
04:16:29 | FromDiscord | <leorize> you do know that a page is 4MiB, right?↵(@.matrixagent) |
04:16:32 | FromDiscord | <gamedroit> 😂 |
04:16:45 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Now make a real": sure where is it |
04:16:49 | FromDiscord | <.matrixagent> how can i get it |
04:16:56 | FromDiscord | <Elegantbeef> I give up |
04:17:05 | FromDiscord | <gamedroit> Have you ever tried to create an entire large project in C using just malloc? |
04:17:18 | FromDiscord | <.matrixagent> millions of projects that are performant use malloc |
04:17:29 | FromDiscord | <.matrixagent> from real time apps and everything |
04:17:35 | FromDiscord | <Elegantbeef> some people's children |
04:17:44 | FromDiscord | <leorize> if you want to benchmark, you really gotta learn how to do it |
04:17:57 | FromDiscord | <.matrixagent> you really cannot say malloc is slow when it literally runs the entire infrastructure you see |
04:18:07 | FromDiscord | <Elegantbeef> The hell is this argument |
04:18:23 | FromDiscord | <Elegantbeef> Good programs hardly allocate so malloc isnt as much of an issue |
04:18:31 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "The hell is this": simply if malloc was slow it wouldnt have been in any stdlibs |
04:18:41 | FromDiscord | <Elegantbeef> The issue is when programs need to allocate, they need to fetch that memory, and that low time to memory is important |
04:18:56 | FromDiscord | <leorize> may I introduce you to Windows |
04:19:03 | FromDiscord | <Chronos [She/Her]> Poor code is in stdlibs for basically anything |
04:19:05 | FromDiscord | <leorize> where there's a custom malloc in most apps |
04:19:08 | FromDiscord | <Elegantbeef> Why would so many people use mimalloc if it wasnt so impactful |
04:19:28 | FromDiscord | <Elegantbeef> As leo said glibc malloc is actually very good |
04:19:29 | FromDiscord | <leorize> jemalloc is in Chrome, Firefox, Edge |
04:19:32 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "Why would so many": optimized for their usage |
04:19:33 | FromDiscord | <gamedroit> In reply to @yu.vitaqua.fer.chronos "Poor code is in": There are a lot of things which were also only kept to maintain compatibility |
04:19:36 | FromDiscord | <leorize> MS Office doesn't use native malloc either |
04:20:05 | FromDiscord | <.matrixagent> the least you can say about malloc is its good enough |
04:20:06 | FromDiscord | <Elegantbeef> Yea windows malloc vs. linux malloc is night and day |
04:20:17 | FromDiscord | <Elegantbeef> It's an allocator it'd be hard to not be good enough |
04:20:27 | FromDiscord | <Elegantbeef> The point is it's slower than other allocators |
04:20:34 | FromDiscord | <.matrixagent> and also whos gonna tell them that the operating system gives you memory near instantly 😄 |
04:20:40 | FromDiscord | <.matrixagent> modern ones at least |
04:20:48 | FromDiscord | <Elegantbeef> They don't |
04:20:51 | FromDiscord | <.matrixagent> they do |
04:20:55 | FromDiscord | <leorize> you can allocate more than your RAM in Linux |
04:20:57 | FromDiscord | <Elegantbeef> That's why allocators do not instantly give memory back and sit on it |
04:21:00 | FromDiscord | <gamedroit> Just because malloc runs "instantly" doesn't mean it isn't slow compared to the rest, benchmark it and you'll see |
04:21:22 | FromDiscord | <Elegantbeef> Requesting memory from the OS is one of the slowest operations you can do |
04:21:25 | FromDiscord | <leorize> also, your benchmark is wholly flawed |
04:21:32 | FromDiscord | <.matrixagent> In reply to @gamedroit "Just because malloc runs": alright, i hope my benchmark didnt just remove all my code since im not doing anything with it lol |
04:21:34 | FromDiscord | <leorize> you don't account how allocators actually allocate |
04:21:37 | FromDiscord | <.matrixagent> or anything meaningful |
04:21:58 | FromDiscord | <leorize> allocators don't actually allocate the exact amount you told it to |
04:22:00 | FromDiscord | <Elegantbeef> Benchmarking an allocator requires a program that realistically allocates like a program would |
04:22:07 | FromDiscord | <leorize> they usually allocate in memory pages |
04:22:36 | FromDiscord | <Elegantbeef> This does a multitude of things, it gets the pages built, it also sees the behaviour in a place where you have many different size blocks and freeing blocks where memory is returned to the OS |
04:22:48 | FromDiscord | <.matrixagent> In reply to @leorize "they usually allocate in": let me just turn off paging |
04:22:59 | FromDiscord | <Elegantbeef> They're a troll |
04:23:00 | FromDiscord | <leorize> it has nothing to do with paging |
04:23:17 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "They're a troll": how am i even trolling my dude |
04:23:29 | FromDiscord | <.matrixagent> you cant call somone with a valid opinion a troll |
04:23:31 | FromDiscord | <leorize> I think you need to study how computer memory management is done |
04:23:43 | FromDiscord | <.matrixagent> i think you need to as well my brother |
04:23:52 | FromDiscord | <.matrixagent> OS'es cache memory if you didnt know |
04:24:11 | FromDiscord | <.matrixagent> if a program requests it it gets one from the cache memory unless your allocating more than what is cached |
04:24:23 | FromDiscord | <.matrixagent> cache as in the os cache not cpu cache |
04:24:24 | FromDiscord | <leorize> I think I'm done with this thread |
04:24:33 | FromDiscord | <.matrixagent> sure |
04:24:39 | FromDiscord | <Elegantbeef> Did I summon you into this leo, if so sorry |
04:25:09 | FromDiscord | <leorize> nah, I like discussions about hardware and OS |
04:25:51 | FromDiscord | <gamedroit> I give up, if you really want to understand why malloc is slow read this thread:↵↵https://www.linuxquestions.org/questions/programming-9/is-c-malloc-slow-703979/ |
04:26:36 | FromDiscord | <.matrixagent> i literally just called malloc 1000000 times with a size of 1000 and it finished in 300 ms |
04:27:06 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4CjA |
04:27:14 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4CjB |
04:27:22 | FromDiscord | <leorize> I think you gotta learn about scales |
04:27:26 | FromDiscord | <Elegantbeef> Nice, what a realistic benchmark |
04:27:28 | FromDiscord | <gamedroit> Cool but this is not a benchmark |
04:27:34 | FromDiscord | <.matrixagent> how is it not |
04:27:44 | FromDiscord | <.matrixagent> i saw the memory rocket in front of my eyes |
04:27:50 | FromDiscord | <.matrixagent> it did call malloc im sure of it |
04:28:20 | FromDiscord | <Elegantbeef> It's not a benchmark cause all you did was allocate a bunch of data, there is no realworld approximation |
04:28:26 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "It's not a benchmark": so> |
04:28:28 | FromDiscord | <.matrixagent> (edit) "so>" => "so?" |
04:28:34 | FromDiscord | <Chronos [She/Her]> Because you're not actually doing anything with the memory you're claiming |
04:28:35 | FromDiscord | <.matrixagent> we benchmarking malloc here right |
04:28:37 | FromDiscord | <Chronos [She/Her]> It's sitting there |
04:28:42 | FromDiscord | <Chronos [She/Her]> Doing nothing |
04:28:45 | FromDiscord | <.matrixagent> In reply to @yu.vitaqua.fer.chronos "It's sitting there": whats the problem with that |
04:28:49 | FromDiscord | <.matrixagent> i did get the memory at the end |
04:28:54 | FromDiscord | <Elegantbeef> You're allocating the exact same size over and over again |
04:29:06 | FromDiscord | <Chronos [She/Her]> In reply to @.matrixagent "i did get the": A real world scenario wouldn't just do nothing with the memory? |
04:29:12 | FromDiscord | <Elegantbeef> You are not allocating different sizes, and forcing the allocator to do any work like would in real life |
04:29:19 | FromDiscord | <Elegantbeef> You havent freed any memory |
04:29:30 | FromDiscord | <Elegantbeef> You've benchmarked the speed of sequential benchmarks of a fixed size |
04:29:30 | FromDiscord | <Elegantbeef> Congrats |
04:29:38 | FromDiscord | <Elegantbeef> The most useless allocation profile has been generated |
04:29:38 | FromDiscord | <.matrixagent> In reply to @Elegantbeef "You've benchmarked the speed": mhm |
04:29:38 | FromDiscord | <gamedroit> Can someone write a simple bench online and send it to him? I'm busy |
04:30:29 | FromDiscord | <.matrixagent> so basically what your saying is "i cant believe malloc isnt slow i must prove this guy wrong with no proof" |
04:30:49 | FromDiscord | <.matrixagent> unless minmalloc will do the same in 10ms |
04:30:52 | FromDiscord | <gamedroit> Btw using your own hardware for comparison is not the best option, the result on your computer and mine may be totally different. |
04:30:59 | FromDiscord | <.matrixagent> In reply to @gamedroit "Btw using your own": exactly |
04:31:11 | FromDiscord | <.matrixagent> therefore you should also run the same benchmarks when comparing |
04:31:34 | FromDiscord | <.matrixagent> im going to try minmalloc with the same benchmark |
04:31:40 | FromDiscord | <Chronos [She/Her]> https://github.com/daanx/mimalloc-bench |
04:31:45 | FromDiscord | <Chronos [She/Her]> Run benchmarks from here |
04:32:00 | FromDiscord | <.matrixagent> In reply to @yu.vitaqua.fer.chronos "Run benchmarks from here": Ok |
04:32:02 | FromDiscord | <Chronos [She/Her]> Specifically `sys` and then `mi` |
04:32:51 | FromDiscord | <.matrixagent> sent a code paste, see https://play.nim-lang.org/#ix=4CjE |
04:32:52 | FromDiscord | <.matrixagent> gotta fix the errors first |
04:33:14 | FromDiscord | <Elegantbeef> https://stackoverflow.com/a/2560863/15200657 |
04:33:15 | FromDiscord | <Elegantbeef> Allocators like anything have performance characteristics, you've benchmarked in my opinion the least important one |
04:33:27 | FromDiscord | <Elegantbeef> You can even write your benchmarks then compare directly to mimalloc |
04:33:32 | FromDiscord | <Elegantbeef> Without recompiling |
04:33:51 | FromDiscord | <.matrixagent> sure i just wanna see if malloc is truly slow or not |
04:34:02 | FromDiscord | <leorize> sent a long message, see http://ix.io/4CjG |
04:34:14 | FromDiscord | <.matrixagent> my understanding of C it should be as performant as possible so i dont think they would put a slow memory allocator in the stdlbi |
04:34:17 | FromDiscord | <.matrixagent> (edit) "stdlbi" => "stdlib" |
04:34:19 | FromDiscord | <leorize> some are code, some are descriptions in a design paper |
04:34:34 | FromDiscord | <leorize> that's not how C works |
04:34:41 | FromDiscord | <leorize> it's never a goal to be performant |
04:34:46 | FromDiscord | <leorize> it's performant because of what it is |
04:35:29 | FromDiscord | <Elegantbeef> You can have a Nim program faster than C if the C author wrote less intelligent code than the Nim programmer |
04:35:39 | FromDiscord | <gamedroit> Since the early days of C, performance has never been the thing they cared about. |
04:36:00 | FromDiscord | <Elegantbeef> It's all about writing a slightly higher level asm |
04:36:29 | FromDiscord | <leorize> if you ask some die hard gamedevs, they would say they rather write it in ASM to squeeze all the juice out |
04:36:49 | FromDiscord | <leorize> luckily compilers aren't so bad anymore and computers are much faster now |
04:36:55 | FromDiscord | <leorize> so we can afford some creature comfort |
04:37:02 | FromDiscord | <Elegantbeef> I mean I know a dev that is still making sega genesis games using asm 😄 |
04:37:19 | FromDiscord | <.matrixagent> i mean hand written asm beats C |
04:37:27 | FromDiscord | <.matrixagent> if you used the same code |
04:37:30 | FromDiscord | <leorize> not neccesarily |
04:37:36 | FromDiscord | <.matrixagent> In reply to @leorize "not neccesarily": it does |
04:37:44 | FromDiscord | <.matrixagent> assuming you can write performant assembly |
04:37:48 | FromDiscord | <Elegantbeef> It depends on the C compiler |
04:37:50 | FromDiscord | <gamedroit> In reply to @Elegantbeef "I mean I know": Damn, i'm sorry for him. ASM is a pain just as it must have been back in the day when they used punch cards, the early days of bits. |
04:38:02 | FromDiscord | <leorize> that's a big assumption |
04:38:04 | FromDiscord | <.matrixagent> and im trying to setup minmalloc |
04:38:13 | FromDiscord | <Elegantbeef> He likes making the games using asm |
04:38:19 | FromDiscord | <leorize> the knowledge base for "performant" assembly is insane |
04:38:48 | FromDiscord | <leorize> you have to understand microarchitectural scheduling and how it reacts so certain memory layout |
04:38:58 | FromDiscord | <gamedroit> C code can perform better than assembly if the programmer is good enough. |
04:39:00 | FromDiscord | <leorize> as well as how many cycles is performed for a given sequence |
04:39:45 | FromDiscord | <leorize> whether pipelined sequence are faster than this simple instructions |
04:39:54 | FromDiscord | <leorize> it's a mess |
04:41:05 | FromDiscord | <.matrixagent> and also how is one supposed to use minmalloc in ubuntu based distro 😄 |
04:41:15 | FromDiscord | <leorize> have you installed it? |
04:41:15 | FromDiscord | <.matrixagent> i installed the libmimalloc2.0 |
04:41:19 | FromDiscord | <.matrixagent> via apt |
04:41:29 | FromDiscord | <jakraes> Is the noreturn pragma implicit if I do not specify a return type? |
04:41:30 | FromDiscord | <leorize> https://github.com/microsoft/mimalloc#dynamic-override-on-linux-bsd |
04:41:37 | FromDiscord | <leorize> no |
04:41:45 | FromDiscord | <leorize> and it doesn't mean what you think it does |
04:42:10 | FromDiscord | <jakraes> If you're saying that then I think you're right xd |
04:42:20 | FromDiscord | <jakraes> I assume it just tells the compiler that the proc returns nothing? |
04:42:32 | FromDiscord | <leorize> it tells the compiler that the proc doesn't return |
04:42:37 | FromDiscord | <.matrixagent> In reply to @leorize "https://github.com/microsoft/mimalloc#dynamic-overr": oh so i can run the same code without recompiling? |
04:42:39 | FromDiscord | <.matrixagent> let me try |
04:42:55 | FromDiscord | <leorize> like, you get in and never get out |
04:43:06 | FromDiscord | <jakraes> Ooooh |
04:43:14 | FromDiscord | <leorize> typically used for `exit()` or `quit()` |
04:43:26 | FromDiscord | <jakraes> Yup that makes sense, I get what it means now |
04:43:30 | FromDiscord | <jakraes> Thank you |
04:43:34 | FromDiscord | <.matrixagent> `libmimalloc2.0 is already the newest version (2.0.5+ds-2).`↵`ERROR: ld.so: object '/usr/lib/libmimalloc.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.`↵😄 |
04:43:47 | FromDiscord | <.matrixagent> i think i need the 2.0 prefix right |
04:43:55 | FromDiscord | <.matrixagent> nope |
04:44:00 | FromDiscord | <leorize> ls `/usr/lib64/libmimalloc` |
04:44:06 | FromDiscord | <leorize> see which file comes up |
04:44:19 | FromDiscord | <.matrixagent> sure |
04:44:30 | FromDiscord | <.matrixagent> cannot find file |
04:45:05 | FromDiscord | <.kanaxa> Shoutout to the Nim docs for being wonderfully concise with its `system` module https://media.discordapp.net/attachments/371759389889003532/1136882476745232405/image.png |
04:45:31 | FromDiscord | <leorize> the file is\: /usr/lib/x86\_64-linux-gnu/libmimalloc.so.2↵(@.matrixagent) |
04:45:37 | FromDiscord | <leorize> from\: https://packages.ubuntu.com/kinetic/amd64/libmimalloc2.0/filelist |
04:45:46 | FromDiscord | <.matrixagent> In reply to @leorize "the file is\: /usr/lib/x86\_64-linux-gnu/libmimallo": alright |
04:46:02 | FromDiscord | <.matrixagent> now it compiles |
04:46:08 | FromDiscord | <.matrixagent> the moment of truth everyone |
04:46:29 | FromDiscord | <.matrixagent> sent a code paste, see https://paste.rs/2Jzbu |
04:46:36 | FromDiscord | <.matrixagent> the same benchmark |
04:46:43 | FromDiscord | <.matrixagent> i shall try their offical one |
04:47:20 | FromDiscord | <leorize> I can write an allocator that's 100x faster if you use your benchmark lol |
04:47:38 | FromDiscord | <.matrixagent> what would a fair benchmark look like then |
04:47:50 | FromDiscord | <leorize> I linked a bunch earlier |
04:47:59 | FromDiscord | <.matrixagent> yep none of them would run |
04:48:16 | FromDiscord | <.matrixagent> its probably due to the stupid clang error i keep getting thats why i use gcc |
04:48:24 | FromDiscord | <leorize> then you have to figure out what have you done wrong \:P |
04:48:48 | FromDiscord | <.matrixagent> the error is pretty much either unfixable or very hard to fix |
04:48:57 | FromDiscord | <.matrixagent> been trying for days until i removed clang |
04:49:03 | * | ajunior quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
04:49:17 | FromDiscord | <leorize> it's likely you did something wrong, sorry |
04:49:30 | FromDiscord | <.matrixagent> probably |
04:49:31 | FromDiscord | <leorize> clang compiles 99.9999% of code these days |
05:06:03 | FromDiscord | <jordan4ibanez> Hello |
05:07:44 | FromDiscord | <demotomohiro> Hello |
05:07:59 | FromDiscord | <jordan4ibanez> Ahem |
05:08:03 | FromDiscord | <jordan4ibanez> THIS IS AMAZING |
05:08:34 | FromDiscord | <jordan4ibanez> Lisp python static typing modula GC and etc all wrapped into one? amazing |
05:09:52 | FromDiscord | <.matrixagent> In reply to @jordan4ibanez "Lisp python static typing": agreed im using it in production and its been great |
05:10:26 | FromDiscord | <Phil> What kind of operations can you actually do on an import?↵Like if I do `import std/strformat` I can do dot expressions on it to access procs, can I pass `strformat` to a template to check if it defines a given set of procs? |
05:10:44 | FromDiscord | <Phil> (edit) "procs, can" => "procs.↵Can" |
05:11:09 | FromDiscord | <Phil> (edit) "What kind of operations can you actually do on an import?↵Like if I do `import std/strformat` I can do dot expressions on it to access procs.↵Can I pass `strformat` to" => "sent" | "template to check if it defines a given set of procs?" => "code paste, see https://play.nim-lang.org/#ix=4CjM" |
05:11:34 | FromDiscord | <Elegantbeef> You can pass it to a template and check using the when stuff I showed yesterday |
05:11:36 | FromDiscord | <Phil> Wait, that should definitely be doable since templates are copy-paste... can namespaces be passed to procs as well? |
05:11:55 | FromDiscord | <Elegantbeef> modules can only be used in ambiguity |
05:12:01 | FromDiscord | <gamedroit> https://github.com/nim-lang/ui↵↵So, why is this dead since 2021? Not even support for windows was introduced, sad. Is it the contributors' lack of time or was it really abandoned? |
05:12:16 | FromDiscord | <Phil> In reply to @Elegantbeef "You *can* pass it": I just woke up, I essentially erased my memory from yesterday, could you give me key words for discord search? |
05:12:34 | FromDiscord | <jordan4ibanez> As they say in rust "reached ideal stability, not dead or abandoned" |
05:12:45 | FromDiscord | <Elegantbeef> uring exists now if you're interested in libui stuffs |
05:12:45 | FromDiscord | <Elegantbeef> `{.error.}` |
05:12:47 | FromDiscord | <.matrixagent> In reply to @gamedroit "https://github.com/nim-lang/ui So, why": araq is pretty mad 😄 https://github.com/nim-lang/ui/issues/43 |
05:13:29 | FromDiscord | <elegantbeef> https://discord.com/channels/371759389889003530/371759389889003532/1136364785169092618 save you a search phil |
05:13:40 | FromDiscord | <.matrixagent> @gamedroit https://github.com/neroist/uing this is an updated fork |
05:15:30 | FromDiscord | <gamedroit> Native UI so, hm... I think it's cool but incredibly weird at the same time, I would prefer a consistent interface in all systems. Sometimes a change can make the layout messy. |
05:15:46 | FromDiscord | <.matrixagent> In reply to @gamedroit "Native UI so, hm...": just use qt |
05:20:35 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4CjR |
05:21:06 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4CjR" => "https://paste.rs/RuH2l" |
05:21:18 | FromDiscord | <Elegantbeef> That is a type conversion |
05:21:41 | FromDiscord | <Elegantbeef> We can do something cleaner in hindsight |
05:21:54 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/Gyh0lVhtHQkbXWJB hopefully that works |
05:21:58 | FromDiscord | <Elegantbeef> I know many people have issue with wandbox links |
05:22:37 | FromDiscord | <Phil> Ohhh never seen that with procs before. And since it should be the same proc type that type conversion should essentially do nothing and work and thus confirm that that identifier is of that type |
05:23:28 | FromDiscord | <Elegantbeef> Yea that's how you disambiguate an overload |
05:24:04 | FromDiscord | <Elegantbeef> The wandbox is better though |
05:24:05 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4CjT |
05:24:40 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/og5r77y7QWZDYX6i as this shows it even works for global variables |
05:27:55 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4CjY |
05:28:54 | FromDiscord | <Elegantbeef> `value: SomeFloat` |
05:29:08 | FromDiscord | <Phil> Oh fffff it doesn't like generics I take it |
05:29:19 | FromDiscord | <Phil> since generics are a lie |
05:30:25 | FromDiscord | <Phil> generics not being real truly leads to the meanest limitations |
05:31:34 | FromDiscord | <Elegantbeef> Eh easier to just ensure a bunch of statement compiles like concepts do |
05:38:10 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Ck3 |
05:39:15 | FromDiscord | <Phil> It would also be a dream if you could just check if 2 modules fully implement the same procs but for that you'd need to be able to iterate over namespaces which I don't think is feasible |
05:39:36 | FromDiscord | <Phil> (edit) "implement" => "provide" | "procs" => "symbols" |
05:45:13 | FromDiscord | <Elegantbeef> Araq seems generally opposed to module based programming |
05:45:19 | FromDiscord | <Elegantbeef> So best cry about that one |
05:54:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Ck8 |
05:57:05 | NimEventer | New thread by JohnLuck: Any way to produce Arm64 binaries for MacOS from choosenim versions of nim?, see https://forum.nim-lang.org/t/10373 |
06:01:16 | FromDiscord | <Phil> In reply to @Elegantbeef "Araq seems generally opposed": I think I can see why, it kinda leads down the path of OO which ultimately will get you very fucking annoyed how somebody built 3 tiny frameworks of highly coupled modules |
06:01:25 | FromDiscord | <Phil> (edit) "In reply to @Elegantbeef "Araq seems generally opposed": I think I can see why, it kinda leads down the path of OO which ultimately will get you very fucking annoyed how somebody built 3 tiny frameworks of highly coupled modules ... " added "into your project and now you need to understand those" |
06:01:53 | FromDiscord | <Elegantbeef> Eh module based programming results in more reusable code |
06:02:02 | * | rockcavera quit (Remote host closed the connection) |
06:02:15 | FromDiscord | <Elegantbeef> Want to use a graphics library but use your vectors instead `import gwapiks[TheirVec2: YourVec2]` |
06:07:45 | FromDiscord | <Phil> In reply to @Elegantbeef "Here you go phil": Shit, got to head to work, I'll bookmark that link and ask you later |
06:12:38 | * | azimut quit (Ping timeout: 240 seconds) |
06:21:05 | * | mal`` quit (Quit: Leaving) |
06:37:39 | * | ntat joined #nim |
06:44:01 | * | mal`` joined #nim |
06:53:00 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4Ckp |
06:53:11 | FromDiscord | <.kanaxa> (edit) "https://play.nim-lang.org/#ix=4Ckp" => "https://play.nim-lang.org/#ix=4Ckq" |
06:53:17 | FromDiscord | <.kanaxa> (edit) "https://play.nim-lang.org/#ix=4Ckq" => "https://play.nim-lang.org/#ix=4Ckr" |
06:54:14 | FromDiscord | <Elegantbeef> `(x, y) = (y, res)` |
06:54:21 | FromDiscord | <Elegantbeef> Better yet just `swap(x, y)` |
06:59:09 | FromDiscord | <Elegantbeef> On second thought that's not just swap |
07:00:59 | FromDiscord | <Elegantbeef> @.elcritch\: how goes your fidgetty rewrite? |
07:01:34 | FromDiscord | <.kanaxa> In reply to @Elegantbeef "`(x, y) = (y,": Ah I see, missed the parentheses, thank you! |
07:02:01 | FromDiscord | <.kanaxa> In reply to @Elegantbeef "Better yet just `swap(x,": Oh man, a swap in-built function, that's sexy |
07:08:37 | FromDiscord | <Festive> Any way to execute a .net executable in memory? |
07:10:17 | FromDiscord | <.elcritch> In reply to @Elegantbeef "<@703717429230174229>\: how goes your": Itsa going! Just finished splitting up renderer and widget modules. I also got them running on separate threads. They share nodes types, but hoping to split those up next |
07:11:29 | FromDiscord | <Elegantbeef> Nice, I've been mostly rewriting the setup code for nimscript interop, calling Nimscript from C and Nim in a single API is interesting |
07:13:59 | FromDiscord | <Elegantbeef> In theory I should still have automatic memory management with the Nim interface, but it presently has low level operations(like using cstrings everywhere). Do not like the premise of sharing Nim GC'd types across the DLL barrier |
07:16:00 | FromDiscord | <Elegantbeef> Just need to make some macros to generate the VM procs and extract vmargs, and it's in a state one could probably use for the GUI stuff |
07:20:34 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4Ckv |
07:21:17 | FromDiscord | <Elegantbeef> `var (x, y) = (0, 1)` |
07:22:12 | FromDiscord | <.kanaxa> Eh? So the type declaration is unnecessary |
07:22:19 | FromDiscord | <.kanaxa> (edit) "Eh? So the type declaration is unnecessary ... " added "with the unpacking?" |
07:22:24 | FromDiscord | <.kanaxa> Can it still be done? |
07:22:34 | FromDiscord | <Elegantbeef> It's always unnecessary 😄 |
07:22:39 | FromDiscord | <.kanaxa> Oh wait! Oh yeah |
07:22:44 | FromDiscord | <.kanaxa> 0 and 1 are already known types |
07:22:45 | FromDiscord | <.kanaxa> Hahahaha |
07:23:03 | FromDiscord | <.kanaxa> This is the problem when you're learning new syntax, you forget the basics |
07:33:11 | FromDiscord | <.kanaxa> Is there a walrus operator equivalent in Nim? |
07:33:31 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Ckx |
07:33:33 | FromDiscord | <Elegantbeef> `if (let x = y; x) < x == bleh` |
07:35:07 | FromDiscord | <.kanaxa> I'm not sure how to read that line after the `;` semicolon |
07:35:14 | FromDiscord | <.kanaxa> Let x =y, ... and what is x then doing? |
07:35:26 | FromDiscord | <Elegantbeef> you returning x |
07:35:26 | FromDiscord | <.kanaxa> (edit) "x =y," => "`x =y`," |
07:35:30 | FromDiscord | <emanresu3> it's returning x |
07:35:30 | FromDiscord | <.kanaxa> Oh! |
07:35:32 | FromDiscord | <.kanaxa> I see |
07:35:33 | FromDiscord | <Elegantbeef> Nim is expression ful |
07:35:40 | FromDiscord | <Elegantbeef> expressionful even |
07:35:57 | FromDiscord | <.kanaxa> Implicit returns |
07:35:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/k7skk |
07:36:04 | FromDiscord | <Elegantbeef> No expressionful |
07:36:14 | FromDiscord | <Phil> You learned about `result` yet? |
07:36:24 | FromDiscord | <.kanaxa> In reply to @isofruit "You learned about `result`": Yeah I think it's quite brilliant |
07:36:25 | FromDiscord | <emanresu3> sent a code paste, see https://paste.rs/7LWxQ |
07:36:36 | FromDiscord | <.kanaxa> In reply to @Elegantbeef "expressionful even": Never heard of the term 'expressionful' before, learned something today |
07:36:59 | FromDiscord | <emanresu3> but it's not exactly like python's walrus |
07:37:11 | FromDiscord | <.kanaxa> In reply to @Elegantbeef "`if (let x =": Apparently Araq's also addressed on the walrus operator before: https://forum.nim-lang.org/t/4637#28963 |
07:37:16 | FromDiscord | <Phil> In reply to @.kanaxa "Yeah I think it's": Some may disagree, just a good idea to keep in mind that an implicitly instantiated `result` variable exists |
07:37:19 | FromDiscord | <.kanaxa> (edit) "In reply to @Elegantbeef "`if (let x =": Apparently Araq's also addressed on the walrus operator ... before:" added "Nim equivalent" |
07:38:05 | FromDiscord | <demotomohiro> In reply to @.kanaxa "I'm not sure how": https://nim-lang.org/docs/manual.html#statements-and-expressions-statement-list-expression |
07:38:06 | FromDiscord | <.kanaxa> Except for strictly procedural functions most of the time you want to compute something from a function anyways, I like the idea of a 'result' variable although I can see how some people might not like it |
07:43:18 | FromDiscord | <.kanaxa> Thanks so much guys, appreciate the help |
07:47:06 | * | xet7 quit (Remote host closed the connection) |
07:49:15 | FromDiscord | <emanresu3> keep in mind that this `x` is only on the `if` scope, not on the `else` unlike python |
07:53:14 | * | ntat quit (Quit: leaving) |
07:56:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4CkG |
07:56:24 | FromDiscord | <Elegantbeef> `type A = range[1..3] | range[6..8]` |
07:56:31 | FromDiscord | <Elegantbeef> It's a limitation of the `..` shorthand |
07:57:25 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4CkH |
07:57:36 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4CkH" => "https://play.nim-lang.org/#ix=4CkI" |
07:57:38 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4CkI" => "https://play.nim-lang.org/#ix=4CkJ" |
07:57:47 | FromDiscord | <Elegantbeef> Nope |
07:58:00 | FromDiscord | <Phil> Then I'm missing something here |
07:58:19 | FromDiscord | <Elegantbeef> Generic constraints are not meant for variables or returns |
07:58:26 | FromDiscord | <Elegantbeef> Araq's own words |
07:58:54 | FromDiscord | <jordan4ibanez> So nim 2.0 automatically can discard cases which do not cover all cases huh? That's pretty neat |
07:59:58 | FromDiscord | <Phil> Well at least it narrows down the type to int |
08:00:04 | FromDiscord | <Elegantbeef> "discard cases" |
08:00:34 | FromDiscord | <jordan4ibanez> Oh that's pretty neat, but it's only working for string switches hmm |
08:02:25 | FromDiscord | <Elegantbeef> Don't even know what you mean |
08:02:59 | FromDiscord | <jordan4ibanez> sent a code paste, see https://play.nim-lang.org/#ix=4CkL |
08:03:19 | FromDiscord | <jordan4ibanez> now let's be....frank here and observe the no discard on the first one :P |
08:03:37 | FromDiscord | <Elegantbeef> Sure, string cases are not exhaustive |
08:03:48 | FromDiscord | <Elegantbeef> Cause it's technologically impossible to be exhaustive |
08:04:46 | FromDiscord | <jordan4ibanez> Hmmm, perhaps since this is compiled to C intermediately this could be optional to need to discard, an automatic discard? I dunno just throwing out ideas |
08:05:08 | FromDiscord | <jordan4ibanez> "Automatic exhaustion by default" |
08:05:17 | FromDiscord | <Elegantbeef> Ordinal case statements are exhaustive for good reason |
08:05:24 | FromDiscord | <jordan4ibanez> Kind of like the final switch statement in D |
08:05:48 | FromDiscord | <Elegantbeef> You don't even need to discard |
08:05:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4CkM |
08:06:02 | FromDiscord | <Elegantbeef> Literally any ast inside else works |
08:06:44 | FromDiscord | <jordan4ibanez> I'm not trying to fight about it, just seems like a little thing |
08:07:44 | FromDiscord | <Phil> I am, fite me!↵Use an enum instead! |
08:07:53 | FromDiscord | <jordan4ibanez> Hmm |
08:10:17 | FromDiscord | <Phil> There are usecases for switch over string if in general you want to be able to handle all strings ever but a clearly defined subset of those trigger something special on the side |
08:10:52 | FromDiscord | <Phil> But generally I'd say an enum transformation somewhere is necessary |
08:11:06 | FromDiscord | <jordan4ibanez> That's true |
08:11:27 | FromDiscord | <jordan4ibanez> Quite interesting so far, not used to indentation as scope, but getting there |
08:18:08 | FromDiscord | <jordan4ibanez> It's...very strangely readable, I like it |
08:22:57 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4CkP |
08:23:19 | FromDiscord | <.kanaxa> (edit) "https://play.nim-lang.org/#ix=4CkP" => "https://play.nim-lang.org/#ix=4CkQ" |
08:23:53 | FromDiscord | <griffith1deadly> In reply to @.kanaxa "I'm attempting to benchmark": use monotime for benchmarking |
08:27:00 | FromDiscord | <Phil> In reply to @.kanaxa "I'm attempting to benchmark": For simple benchmarking, use benchy |
08:27:02 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=4CkR |
08:27:15 | FromDiscord | <Phil> You can call python code from within nim via nimpy |
08:27:56 | FromDiscord | <Phil> Oh wait, I need to read better, bit difficult while mid meeting |
08:35:19 | FromDiscord | <Phil> Anyway, here's the benchy package:↵https://github.com/treeform/benchy |
08:50:01 | FromDiscord | <Festive> How do I ask for input in nim |
08:55:33 | FromDiscord | <Festive> How do I use ansi color does? |
08:56:00 | Amun-Ra | std/terminal |
09:00:53 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4CkZ |
09:01:02 | FromDiscord | <.kanaxa> But why is a template used here over a function? Any serious benefits? |
09:01:18 | FromDiscord | <.kanaxa> (edit) "https://play.nim-lang.org/#ix=4CkZ" => "https://play.nim-lang.org/#ix=4Cl0" |
09:01:33 | FromDiscord | <enthus1ast> about atlas, when you use choosenim, it should be (copied?) to the nimble path or ? |
09:01:33 | FromDiscord | <.kanaxa> In reply to @isofruit "For simple benchmarking, use": Thanks for the recommendation! Will look to try it now |
09:01:56 | FromDiscord | <enthus1ast> this is how choosenim seems to operate or? |
09:02:09 | FromDiscord | <enthus1ast> at least it does so for the compiler |
09:03:06 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=4Cl1 |
09:06:16 | FromDiscord | <enthus1ast> i've created a symlink for now |
09:11:06 | FromDiscord | <ringabout> In reply to @enthus1ast "i've created a symlink": Yeah, choosenim needs a patch. |
09:16:25 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4Cl6 |
09:17:29 | FromDiscord | <.kanaxa> sent a code paste, see https://play.nim-lang.org/#ix=4Cl7 |
09:18:54 | FromDiscord | <enthus1ast> mhh, it seems that atlas also has no concept of develop projects, it clones them and puts the cloned path in the nim.cfg, BUT one can add the packages manually on the nim path |
09:34:40 | FromDiscord | <Phil> In reply to @.kanaxa "Might ask a few": "untyped" basically means that you can put entire code-blocks into that template. Those require untyped. |
09:35:17 | FromDiscord | <Phil> You could of course also have accepted a closure that executes the given functions and then you execute that closure in the loop, but that might bring other limitations with it. |
09:35:53 | * | FromDiscord quit (Remote host closed the connection) |
09:36:06 | * | FromDiscord joined #nim |
09:36:23 | FromDiscord | <Phil> Notably the template approach is just way nicer to read |
09:38:04 | NimEventer | New thread by nealie: Trouble Porting to FreeBSD, see https://forum.nim-lang.org/t/10374 |
09:57:02 | * | ntat joined #nim |
10:31:23 | FromDiscord | <.kanaxa> In reply to @isofruit "You could of course": Ahh I see! Thank you |
10:31:27 | FromDiscord | <.kanaxa> A bit clearer now |
10:32:17 | FromDiscord | <Phil> In reply to @.kanaxa "Ahh I see! Thank": You might know something like context managers in python |
10:32:25 | FromDiscord | <Phil> Templates make writing your own types of context managers completely trivial |
10:32:56 | FromDiscord | <Phil> Just accept an untyped body parameter, add whatever code you want to execute before/after said body, then write "body", done |
10:42:40 | FromDiscord | <jordan4ibanez> Wow, I actually managed to do the tutorial, it's an actual miracle. BEHOLD, my garbage https://pastecode.io/s/rcqw3ggq |
10:43:52 | FromDiscord | <jordan4ibanez> I have no idea what to do with it, bleh |
10:48:44 | FromDiscord | <.kanaxa> In reply to @isofruit "Templates make writing your": My understanding of context managers was principally for handling scope, and making setup/teardown simpler |
10:48:57 | FromDiscord | <jordan4ibanez> I'm not even done yet though, I'll have to have a quick look out the mirror, dramatically, before I continue |
10:48:57 | FromDiscord | <.kanaxa> Didn't quite see it from that angle, I thought templates were copy-pasted by the compiler |
10:50:14 | FromDiscord | <Phil> In reply to @.kanaxa "Didn't quite see it": They are, that's why they're great for creating context managers and more |
10:51:02 | FromDiscord | <Phil> sent a long message, see http://ix.io/4Cli |
10:52:07 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Clk |
10:52:21 | FromDiscord | <Phil> Connection is fetched from and automatically returned to the pool |
10:52:34 | FromDiscord | <.kanaxa> Hmmm.... interestinggg |
10:52:49 | FromDiscord | <.kanaxa> But wouldn't a function here do essentially the same thing? |
10:52:50 | FromDiscord | <Phil> Templates have far more usecases of course, but this is just one where they really shine |
10:53:01 | FromDiscord | <Phil> Only if you desperately want to deal with closures and I for one do not |
10:53:07 | FromDiscord | <.kanaxa> I can see how it's used |
10:53:09 | FromDiscord | <.kanaxa> Ah I see |
10:53:12 | FromDiscord | <.kanaxa> To avoid closures |
10:53:15 | FromDiscord | <.kanaxa> I see, I see |
10:53:31 | FromDiscord | <.kanaxa> Why do you like passing closures? |
10:53:35 | FromDiscord | <.kanaxa> (edit) "like" => "dislike" |
10:53:53 | FromDiscord | <.kanaxa> Am curious |
10:54:01 | FromDiscord | <.kanaxa> I don't think it adds too much complexity |
10:54:15 | FromDiscord | <Phil> Because a closure is not just a callback function, it is also the environment that the callback function captures.↵And that can make things messy in terms of dealing with anything when you do more compile time and meta-programm-y stuff |
10:54:20 | FromDiscord | <Phil> At least for the way I do it |
10:54:30 | FromDiscord | <.kanaxa> Mmm, I see - I haven't dealt with any serious metaprogramming yet |
10:54:44 | FromDiscord | <.kanaxa> (edit) "Mmm, I see - I haven't dealt with any serious metaprogramming ... yet" added "yet, so I'm not too wise on the drawbacks" |
10:55:09 | FromDiscord | <Phil> It's not that closures are horrible or anything, it's just that templates are in my opinion far easier on the eyes and the mental model of "copy paste this thing in here" is not hard to deal with |
10:55:30 | FromDiscord | <.kanaxa> I'm with you on that one, anything that easens my mental model is a winner |
10:55:43 | FromDiscord | <.kanaxa> I just need to do more exercises on the templates stuff first to get a hang of it |
10:56:11 | FromDiscord | <Phil> completely fair |
10:56:25 | FromDiscord | <Phil> Though for reference, generics are stripped down templates in a sense, because just like templates, they aren't real |
10:56:36 | FromDiscord | <Phil> They generate code where you call them, but they are not code themselves |
10:57:16 | FromDiscord | <Phil> If you call a generic with 3 different types, what you'll end up having is the same proc defined 3 times for those 3 types |
10:59:25 | FromDiscord | <Phil> ~~They are like cake in that regard: Filthy liars that make doing any kind of mocking with them nigh impossible~~ |
11:15:44 | FromDiscord | <frobnicate> Do you guys have nim v2 in your docker image? I can't seem to get it to work |
11:16:01 | * | jmd_ quit (Ping timeout: 260 seconds) |
11:17:48 | FromDiscord | <Phil> Not yet, haven't done any deployments since nimv2 came out.↵Could ask @moigagoo |
11:18:09 | FromDiscord | <frobnicate> That makes more sense then. I thought I was being stupid again |
11:26:44 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4Clu |
11:34:41 | FromDiscord | <frobnicate> Is there any way I can help with the tooling? |
11:39:31 | FromDiscord | <frobnicate> I use Nim mostly for the easier workflow than something like C++ so I wouldn't mind helping with the tools |
11:45:21 | FromDiscord | <.kanaxa> In reply to @isofruit "~~They are like cake": How DARE you accuse cakse |
11:45:23 | FromDiscord | <.kanaxa> (edit) "cakse" => "cakes" |
11:45:28 | FromDiscord | <.kanaxa> The cake is not a lie |
11:45:45 | FromDiscord | <Phil> In reply to @.kanaxa "The cake is *not*": You say that, yet I don't see you with a cake in hand |
11:46:16 | FromDiscord | <.kanaxa> This was a triumph. I'm making a note here: HUGE SUCCESS |
11:46:40 | FromDiscord | <.kanaxa> Gotta quickly stop before I go offtopic haha |
11:50:24 | FromDiscord | <enthus1ast> @frobnicate maybe have a look how the old nimble develop used to work and why nimble develop -g does not work the same |
11:50:50 | FromDiscord | <frobnicate> thanks |
11:51:00 | FromDiscord | <enthus1ast> if i have some time i'll also look at it |
12:00:02 | FromDiscord | <jordan4ibanez> So when is nim 3 coming? |
12:00:07 | FromDiscord | <jordan4ibanez> Nah I'm just kidding |
12:14:05 | * | lucasta joined #nim |
12:23:58 | * | disso-peach joined #nim |
12:26:13 | FromDiscord | <Phil> In reply to @jordan4ibanez "So when is nim": Next week right after my workplace realizes that STOMP is not a sensible messaging protocol to build a chat application around |
12:36:55 | FromDiscord | <jordan4ibanez> So next year? |
12:39:01 | FromDiscord | <Phil> God damn you're even more optimistic than your profile picture lead me to believe |
13:11:53 | FromDiscord | <terrygillis> how does `ref` types behave in the js backend? how does nim stack objects get translated to js? |
13:14:03 | FromDiscord | <Phil> In reply to @Elegantbeef "Here you go phil": Ah so basically you don't check if a symbol with a given type is present, you check if a symbol can be executed that would deliver the desired results. aka whether that compiles |
13:14:18 | FromDiscord | <bung8954> In reply to @terrygillis "how does `ref` types": refers to an array element |
13:17:04 | FromDiscord | <terrygillis> if stack object would be translated to array, then what would `ref object` be translated to? |
13:23:49 | FromDiscord | <Chronos [She/Her]> In reply to @terrygillis "if stack object would": Array and index of value in array |
13:24:17 | * | ntat quit (Quit: leaving) |
13:32:41 | * | ajunior joined #nim |
13:47:09 | FromDiscord | <Phil> Were the docs for the macro module always this good?↵https://nim-lang.org/docs/macros.html#callsslashexpressions-command-call |
13:47:32 | FromDiscord | <Phil> Like having examples of the AST for each kind of expression etc.? |
13:50:33 | * | azimut joined #nim |
13:52:06 | FromDiscord | <Phil> Turns out it was and I was just an imbecile |
14:02:34 | FromDiscord | <frobnicate> In reply to @isofruit "Turns out it was": That's me daily |
14:03:30 | FromDiscord | <Phil> You can't do a varargs with typedesc's right? |
14:03:48 | FromDiscord | <Phil> Like I want to have a proc that the User can give various different types as parameters |
14:03:58 | FromDiscord | <Phil> And I kinda don't want to care about the number of types |
14:04:44 | FromDiscord | <Phil> Like I'd want to handle ↵`proc x(FirstType, SecondType)`↵via the same proc as ↵`proc x(FirstType, SecondType, ThirdType, FourthType)` |
14:21:15 | FromDiscord | <frobnicate> You can't coerce them into a parent type and then back to the inherited one based on a type field? In case you want to have different types but the same definition |
14:21:32 | FromDiscord | <frobnicate> Or am I misunderstanding |
14:21:46 | FromDiscord | <Phil> Nah, pretty much, I'd want to have a list of types in either a proc, a template or a macro |
14:21:55 | FromDiscord | <Phil> And I keep forgetting that I can't have that |
14:23:09 | FromDiscord | <frobnicate> Types are compile time, right? |
14:23:35 | FromDiscord | <Phil> compile-time only |
14:23:58 | FromDiscord | <frobnicate> So you'd need an alias or key for each type |
14:24:05 | FromDiscord | <frobnicate> And look them up in a table |
14:25:44 | FromDiscord | <frobnicate> I'm not sure what the practical solution is there, but that seems like the most straightforward solution |
14:26:57 | FromDiscord | <Phil> It's basically I myself don't really care all that much about the types, I just need them to generate a proc definition that has variables with those types in order |
14:27:17 | FromDiscord | <Phil> The actual "obj.field.innerField" expressions etc. I generate via macros from strings |
14:27:23 | FromDiscord | <Phil> (edit) "strings" => "strings, no types needed" |
14:27:41 | FromDiscord | <frobnicate> You lost me. Sounds smart. Good luck |
14:27:50 | FromDiscord | <Phil> Ever used MapStruct? |
14:28:02 | FromDiscord | <frobnicate> Like a map in general? Yeah |
14:28:20 | FromDiscord | <Phil> Nah, not a map, something that generates you mapping functions to map an instance of type A to type B |
14:28:27 | FromDiscord | <Phil> So that you don't have to type all of the tedious crap out by hand |
14:28:27 | FromDiscord | <frobnicate> Oh |
14:28:34 | FromDiscord | <frobnicate> Yeah I've used that, unfortunately |
14:28:52 | FromDiscord | <frobnicate> They are a nightmare to maintain |
14:29:00 | FromDiscord | <Phil> Hmmm |
14:29:34 | FromDiscord | <Phil> But writing map procs to transform↵`User` to `UserDTO` to get rid of the fields you don't want to expose to the outside is so annoying =/ |
14:30:31 | FromDiscord | <frobnicate> I mean mapping objects to each other in general is annoying. It's just most of my job is maintaining code and fixing bugs and mappers aren't always that reader friendly |
14:34:08 | * | disso-peach quit (Quit: Leaving) |
14:40:51 | FromDiscord | <ieltan> How tf do I await a template that returns a Future[T] ? I got it working before but now it somehow blows up |
14:42:53 | FromDiscord | <ieltan> ughhh it litteraly worked an hour ago how does it magically stop working now |
14:46:13 | FromDiscord | <ieltan> 😸 nvm i got it working again |
14:54:33 | FromDiscord | <ieltan> Await error msgs are the most unhelpful thing, it took me ages to realize I had forgot an `await` and I get the most confusing message "await expects Future[T], got void", coming from `asyncmacro` a module that I didn't even know existed and didn't even import |
14:54:56 | FromDiscord | <ieltan> Hope CPS or whatever will replace current async will make this better |
15:05:01 | * | smallfoot- joined #nim |
15:05:09 | smallfoot- | What is the difference between: |
15:05:26 | smallfoot- | type Foo* = float |
15:05:27 | smallfoot- | and |
15:05:29 | smallfoot- | type Foo = float |
15:07:31 | FromDiscord | <spotlightkid> The asterisk exports symbols to be available outside of the module they are in. |
15:08:40 | smallfoot- | oh okay, so its like "pub type Foo" instead of "private type Foo" in another language? |
15:09:57 | FromDiscord | <neroist.> uhm, sure |
15:10:40 | FromDiscord | <neroist.> marks it public, same with vars and procs |
15:10:59 | FromDiscord | <neroist.> (edit) "" => "``" |
15:11:49 | FromDiscord | <spotlightkid> https://nim-lang.org/docs/manual.html#modules |
15:12:17 | smallfoot- | oh, that is very confusing and non-intuitive |
15:12:53 | FromDiscord | <nervecenter> Not really. When you import another module, the things that are available are anything in that module with a |
15:12:55 | FromDiscord | <nervecenter> pretty simple |
15:13:59 | smallfoot- | * could as well be ? or ^ or _ or [, it really says nothing |
15:14:05 | smallfoot- | would make much more sense to have "pub" or "public" |
15:14:46 | FromDiscord | <spotlightkid> But its meaning is not "public". It's "this is exported". |
15:15:18 | FromDiscord | <spotlightkid> Sort of like the opposite of the leading underscore in Python. |
15:17:43 | smallfoot- | but public and exported are the same thing? |
15:20:45 | * | ntat joined #nim |
15:20:52 | FromDiscord | <nervecenter> public and private are holdovers of oop and can have other meanings, "export" is much more explicit |
15:20:56 | FromDiscord | <odexine> i mean you can say that for a lot of operators, the only thing justifying other operators being popularity |
15:21:09 | FromDiscord | <spotlightkid> No, public has additional meaning and implications in e.g. C++. Using this term would only lead to confusion. |
15:21:19 | FromDiscord | <odexine> that oh theres no reason for the indexing operator to be `a[i]` and not `a indexed by i` |
15:21:39 | FromDiscord | <spotlightkid> brevity? |
15:21:53 | FromDiscord | <nervecenter> is brief |
15:22:00 | FromDiscord | <nervecenter> (edit) "" => "``" |
15:24:15 | smallfoot- | yeah but popularity is valid, then user have their expectations |
15:24:30 | smallfoot- | sounds like "export" would make much more sense than asterisk * |
15:24:55 | FromDiscord | <spotlightkid> but wrong expectations, like in the case of "public" can be a problem too. |
15:26:24 | FromDiscord | <odexine> In reply to @smallfoot- "yeah but popularity is": how else would certain strange operators become popular if not for use in a language that then becomes popular |
15:26:32 | FromDiscord | <odexine> example: `::<>` |
15:26:35 | FromDiscord | <odexine> x d |
15:26:51 | FromDiscord | <spotlightkid> otoh, you could always, like, just read the documentation. |
15:26:52 | FromDiscord | <odexine> arguable that it is a derivative of `<>` from C |
15:26:54 | FromDiscord | <odexine> (edit) "C" => "C++" |
15:28:16 | FromDiscord | <nervecenter> In reply to @smallfoot- "sounds like "export" would": You'd have an aneurysm if you ever tried a Lisp |
15:28:39 | FromDiscord | <odexine> lol |
15:29:20 | FromDiscord | <ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4CmO |
15:29:23 | smallfoot- | yeah, I would, Lisp, ugly |
15:29:52 | FromDiscord | <nervecenter> Welp. |
15:30:27 | FromDiscord | <ieltan> Syntax is the least important aspect of a programming language, or so they say |
15:31:28 | FromDiscord | <ieltan> I kinda stick with Nim because I like the syntax compared to Python and it can be as fast as C and it's strongly, statically typed |
15:32:04 | FromDiscord | <nervecenter> In reply to @ieltan "Syntax is the least": I like to say that syntax is important, because it can enable certain paradigms and modeling styles, but that bikeshedding syntax is a waste of time. For example disliking Lisp because "ugly" and "parens" is closing yourself off to such a powerful programming paradigm that there is a threshold of ability you will never ever cross, because of dumb aesthetic concerns. |
15:32:30 | FromDiscord | <ieltan> I really, really, really freaking hate the `thingy` |
15:32:37 | FromDiscord | <ieltan> In python |
15:32:59 | FromDiscord | <nervecenter> (edit) "example" => "example," | "ability" => "skill, ability, and understanding" |
15:35:26 | FromDiscord | <ieltan> In reply to @nervecenter "I like to say": That's true, I even just said that I like Nim better than Python because of the syntax, and a lot of language features will influence the syntax that people will use so it kinds of contradicts this famous proverb 😅 |
15:36:02 | FromDiscord | <ieltan> At the end ymmv |
15:45:53 | * | rockcavera joined #nim |
15:46:27 | FromDiscord | <.kanaxa> In reply to @ieltan "I really, really, really": Really? I quite like the appearance of Python's 'magic' methods |
15:46:36 | FromDiscord | <.kanaxa> (edit) "methods" => "methods, haha" |
15:53:34 | FromDiscord | <_gumbercules> The asterisk for export is a holdover from Oberon |
15:55:34 | FromDiscord | <_gumbercules> And fwiw I much prefer having to type `` next to an object field than something like `pub` , `public`, `extern` or `export`. |
16:01:10 | FromDiscord | <bung8954> `var b: array['a', int]` does this make sense ? |
16:05:42 | FromDiscord | <_gumbercules> In reply to @bung8954 "`var b: array['a', int]`": Yes https://play.nim-lang.org/#ix=4Cn5 |
16:06:53 | FromDiscord | <_gumbercules> I'm not sure how it's arriving at 256 for the length though - probably because it's casting it to an `int8` or something |
16:07:00 | FromDiscord | <bung8954> if you try `var b: array['a', int] = [1]` you get `Error: type mismatch: got <array[0..0, int]> but expected 'array[char, int]'` |
16:07:13 | FromDiscord | <_gumbercules> oh weird |
16:07:24 | FromDiscord | <_gumbercules> (edit) removed "- probably because it's casting it to an `int8` or something" |
16:07:37 | FromDiscord | <_gumbercules> oh well that makes a bit of sense |
16:07:50 | FromDiscord | <_gumbercules> because `var b: array['a', int] ` is going to be an array with a lenght of 256 apparently |
16:07:56 | FromDiscord | <_gumbercules> but the error message makes no sense |
16:08:03 | FromDiscord | <_gumbercules> sounds like a bug |
16:08:03 | FromDiscord | <bung8954> looks like it accept many invalid |
16:08:50 | FromDiscord | <bung8954> no it will not have 256 length, it should be char or 'a' ..'z' if use char as index |
16:09:13 | FromDiscord | <_gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4Cn6 |
16:09:15 | FromDiscord | <_gumbercules> compiles fine |
16:09:20 | FromDiscord | <_gumbercules> I think I get what's going on |
16:09:30 | FromDiscord | <_gumbercules> char is 0-255 |
16:09:43 | FromDiscord | <_gumbercules> that's why the length of `b` is `256` |
16:10:23 | FromDiscord | <_gumbercules> arrays can have an index of different types - it doesn't necessarily have to be an `int` - I'm not sure what all the supported types are but apparently `char` is supported |
16:13:40 | FromDiscord | <arathanis> anyone got some tips for compiling Nim to a static lib and linking it to C++ compiled under visual studio? linker complaining about undefined symbols, works fine w/ g++ |
16:17:01 | FromDiscord | <spotlightkid> then you probably got the linker flags wrong in VC |
16:18:11 | FromDiscord | <arathanis> are there special linker flags needed? When using g++ and an example application there is no problem. Just need the flags for linking the library. |
16:19:50 | FromDiscord | <bung8954> In reply to @_gumbercules "arrays can have an": it could be easier for compile that reject these literals as index. |
16:22:15 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Cna |
16:23:27 | FromDiscord | <Phil> It should be noted that the value `fieldName` I will get from iterating over a type at compiletime via `fieldPairs` iterator and `sourceDotExpression` is a static string provided by the user |
16:26:50 | * | smallfoot- quit (Quit: Leaving) |
16:31:08 | * | lucasta quit (Quit: Leaving) |
16:36:27 | Amun-Ra | the topic needs a slight update (Latest version) |
16:48:12 | * | mIRC-rockcavera joined #nim |
16:48:37 | * | mIRC-rockcavera left #nim (#nim) |
16:52:28 | FromDiscord | <srmordred> sent a code paste, see https://play.nim-lang.org/#ix=4Cnh |
16:52:47 | FromDiscord | <srmordred> (edit) "https://play.nim-lang.org/#ix=4Cnh" => "https://play.nim-lang.org/#ix=4Cni" |
16:55:57 | FromDiscord | <_gumbercules> In reply to @bung8954 "it could be easier": might be... I can't think of many places it'd be useful over just using numerical indices but 🤷 maybe there's a reason it works this way |
16:56:07 | FromDiscord | <_gumbercules> probably a good question for #internals |
16:59:10 | * | jmdaemon joined #nim |
17:10:46 | FromDiscord | <odexine> In reply to @srmordred "the `*` vs `pub`": honestly i can see how someone would be super confused seeing that |
17:10:57 | FromDiscord | <odexine> and also field order is important in nim |
17:11:01 | FromDiscord | <odexine> memory layout |
17:19:40 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4Cnq |
17:21:30 | FromDiscord | <Phil> ?!, I thought int by default was 64 bit, how are those numbers coming about?↵Should that be↵8 + 1 + 8 + 1 = 18 in both cases? |
17:21:40 | FromDiscord | <Phil> (edit) "?!, I thought int ... by" added "and float were" | removed "was" |
17:22:01 | FromDiscord | <Phil> (edit) "?!, I thought int and float were by default 64 bit, how are those numbers coming about?↵Should that be↵8 ... +Byte" added "Byte" | "Byte+ 1 ... +Byte" added "Byte" | "+ 1Byte+ 8 ... +Byte" added "Byte" | "+ 1Byte+ 8Byte+ 1 ... =Byte" added "Byte" | "+ 1Byte+ 8Byte+ 1Byte= 18 ... in" added "Byte" |
17:22:51 | FromDiscord | <nervecenter> In reply to @odexine "and also field order": Wouldn't the Nim compiler optimize this anyways though? |
17:22:57 | FromDiscord | <odexine> ? |
17:23:03 | FromDiscord | <odexine> the nim compiler does not reorganise fields |
17:23:11 | FromDiscord | <Phil> Ohh wait it might be allocating in fixed increments or sth and thus there may be some dead bytes in there |
17:23:22 | FromDiscord | <nervecenter> That seems like an easy performance win left on the table |
17:23:37 | FromDiscord | <odexine> no, because memory order can be important |
17:23:59 | FromDiscord | <odexine> it would prolly be a win if you mark the object or the fields as reorganisable sure ig |
17:24:12 | FromDiscord | <nervecenter> In specific scenarios, at which point order and alignment should probably be explicitly specified |
17:24:23 | FromDiscord | <nervecenter> But automatic regorg of field seems like it'd be a good default |
17:24:32 | FromDiscord | <nervecenter> (edit) "field" => "fields" |
17:26:00 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4Cns |
17:26:49 | FromDiscord | <odexine> i dont recall what the details of padding are but iirc its related to time-performance |
17:26:56 | FromDiscord | <odexine> time-space tradeoff thing |
17:27:37 | FromDiscord | <odexine> accessing a misaligned 64-bit field is expensive compared to masking 8-bit fields |
17:29:14 | FromDiscord | <demotomohiro> https://en.wikipedia.org/wiki/Data_structure_alignment |
17:31:58 | FromDiscord | <demotomohiro> When you wrap C libraries, order of fields in object type must match to corresponding C structure type. |
17:38:53 | FromDiscord | <srmordred> sent a code paste, see https://play.nim-lang.org/#ix=4Cnx |
17:40:18 | FromDiscord | <odexine> that's not what i mean |
17:40:34 | FromDiscord | <odexine> i mean that it would be more ergonomic to have instead of public because of that |
17:41:13 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#ix=4Cnz |
17:41:39 | FromDiscord | <odexine> because they have to keep the memory layout the same for the start or break ABI |
17:42:01 | FromDiscord | <odexine> also why they have reserved fields sometimes |
17:42:11 | * | ajunior quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
17:43:08 | FromDiscord | <odexine> i do wonder though, it isn't a bad idea |
17:43:24 | FromDiscord | <odexine> i'm just thinking maybe theres a better way \to implement this |
17:43:27 | FromDiscord | <odexine> (edit) "\to" => "to" |
17:43:40 | FromDiscord | <srmordred> sent a code paste, see https://play.nim-lang.org/#ix=4CnA |
17:46:35 | FromDiscord | <juan_carlos> `include` the file and everything is like public. |
17:47:10 | FromDiscord | <odexine> or use importutils |
17:47:17 | FromDiscord | <odexine> but thats janky |
17:47:38 | FromDiscord | <juan_carlos> Macro that generates `export foo, bar, baz` |
17:48:01 | FromDiscord | <srmordred> In reply to @juan_carlos "`include` the file and": oh, I completely forgot about this. ↵this may be enough ^^ |
17:56:01 | FromDiscord | <odexine> there are caveats to that |
18:00:49 | * | attah quit (Quit: ZNC 1.7.5+deb4 - https://znc.in) |
18:05:36 | * | attah joined #nim |
18:20:16 | FromDiscord | <Phil> I'm looking at micros and it looks nice, but are there any docs beyond the readme of what is all in there? |
18:20:26 | FromDiscord | <Phil> Wait, this is a beef lib, what am I expecting |
18:23:06 | FromDiscord | <bostonboston> Can Nim import from a .lib |
18:27:34 | * | ntat quit (Quit: leaving) |
18:30:03 | FromDiscord | <demotomohiro> Importing C functions from .lib is almost same to importing from .c. |
18:30:46 | * | ajunior joined #nim |
18:37:25 | FromDiscord | <Phil> Okay when a macro auto-converts all the input parameter into Nimnode, how do I get the actual contents of them back?↵I pass one of my macros a `seq[MyType]` and I would like to flipping access the contents |
18:37:53 | FromDiscord | <Phil> Which is a smidgeon hard when the compiler just goes "Well that's a NimNode, you can't access your type's field on that" |
18:43:02 | FromDiscord | <demotomohiro> You can pass values to a macro like `macro foo(x: static[string])` but the argument must be const. |
18:43:42 | FromDiscord | <Phil> That's perfectly fine |
18:53:26 | FromDiscord | <Phil> Is there some kind of way where I can define a bunch of nim-code and have it all turned into a large nim-node?↵What I'd essentially like to do is have like roughly 40 lines of Nim code turned into a NimNode so that I can attach that to generated proc definitions |
18:55:48 | FromDiscord | <auxym> In reply to @isofruit "Is there some kind": parseExpr if your code is a string. But also check out genAst |
18:56:18 | FromDiscord | <auxym> https://nim-lang.org/docs/macros.html#parseExpr%2Cstring%2Cstring |
18:56:37 | FromDiscord | <auxym> https://nim-lang.org/docs/genasts.html |
18:56:37 | FromDiscord | <demotomohiro> In reply to @isofruit "Is there some kind": https://nim-lang.org/docs/manual.html#templates-passing-a-code-block-to-a-template↵I think this is what you want. |
18:57:02 | FromDiscord | <Phil> Yeah but I want to use that body in a macro, so I use a template in which I call a macro to generate a proc? |
18:57:15 | FromDiscord | <Phil> Or can I create NimNodes in a template as well? |
18:57:25 | FromDiscord | <demotomohiro> You can pass code block in the same to macro. |
18:57:38 | FromDiscord | <Phil> Oh it follows the same syntax? Sweet! |
18:58:23 | FromDiscord | <auxym> oh yeah, you can pass a code block as the last arg with the colon syntax with a macro, too |
19:00:03 | FromDiscord | <bostonboston> In reply to @demotomohiro "Importing C functions from": Could you give me an example |
19:02:05 | FromDiscord | <demotomohiro> In reply to @bostonboston "Could you give me": https://internet-of-tomohiro.netlify.app/nim/clibrary.en#c-library-tutorial-for-nimmer-use-c-static-library-from-nim |
19:14:10 | * | junaid__ joined #nim |
19:45:44 | FromDiscord | <bostonboston> Thank you, also fortunately I don't need to use this thanks a lot silabs |
19:47:24 | * | junaid__ quit (Remote host closed the connection) |
20:03:00 | FromDiscord | <Phil> Okay once you learn some of the macro ground rules, writing them becomes a lot more fun |
20:08:28 | FromDiscord | <monark.chan> How can I check if a variable hasn't been written to yet |
20:10:42 | FromDiscord | <Phil> You can't really.↵If it's a ref-type it is nil, but nobody can guarantee you if that was nil because it was just initialized or because some codee earlier set the thing to nil.↵Similarly value types get default values and maybe if you encounter a 0 it's from default initialization, maybe it's an actual legit value, nobody knows. |
20:10:53 | FromDiscord | <Phil> (edit) "codee" => "code" |
20:11:04 | FromDiscord | <monark.chan> Oh |
20:12:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4CnZ |
20:13:06 | FromDiscord | <Phil> If you want to express that something can be "nothing" or not, I can only say to try and use optionals |
20:13:31 | FromDiscord | <Phil> Other than that it's typically good design to only initialize complete datasets from the get go, and not first initialize and then assign valid values |
20:13:44 | FromDiscord | <Phil> (edit) "Other than that it's typically good design to only initialize complete datasets from the get go, and not first initialize and then assign valid values ... " added "(like you would with setters in java which is an antipattern in and of itself)" |
20:26:52 | FromDiscord | <.kanaxa> https://github.com/neroist/uing |
20:27:10 | FromDiscord | <.kanaxa> Oh man, I'm in love with uing right now, the examples all compiled with no issues on Linux and Windows |
20:27:17 | FromDiscord | <.kanaxa> Why is this not the default GUI library yet? |
20:27:23 | FromDiscord | <.kanaxa> (edit) "yet?" => "yet for Nim" |
20:33:54 | * | ajunior quit (Remote host closed the connection) |
20:39:39 | * | ajunior joined #nim |
20:51:23 | FromDiscord | <Phil> Never tried it, thus 🤷 ↵I would claim that also for becoming a default of sorts it'd need better docs ^^ |
20:51:44 | FromDiscord | <Phil> If you want I can show you the ways of nimibook (which allows for writing docs with compiled examples) and you can contribute ^^ |
20:54:10 | FromDiscord | <Phil> And for becoming any sort of default it will need to provide some basic aminities, including lifecycle hooks for widgets as well as enabling writing your own widgets that extend the basic provided ones |
21:05:15 | FromDiscord | <Elegantbeef> @Phil\: the flame about micros was unwarranted, most of my packages are documented |
21:06:13 | FromDiscord | <Phil> In reply to @Elegantbeef "<@180601887916163073>\: the flame about": Apologies, combatting your way through the various ways macros can blow up on you is currently proving strenuous |
21:07:08 | FromDiscord | <Phil> rereading it, at the time it was meant a bit more jokingly than it reads tbh |
21:07:23 | FromDiscord | <Elegantbeef> Eh I know it was jokingly |
21:09:05 | FromDiscord | <Phil> What is the magic incantation to get the stringified version of a type from a macro as a "static string" of sorts that can be passed to another macro that would eat a static string ? |
21:09:31 | FromDiscord | <Elegantbeef> `repr myType` |
21:12:00 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Co6 |
21:12:01 | FromDiscord | <michaelb.eth> hmm, trying out `uing` on macOS, but can't get the examples to build |
21:12:09 | FromDiscord | <Phil> Compiler blows up for me every time before that can happen |
21:12:16 | FromDiscord | <Elegantbeef> well yea `repr(t)` will never be static |
21:12:34 | FromDiscord | <michaelb.eth> the readme says↵> This library installs the C sources for libui-ng and statically compiles them into your application.↵↵but maybe I'm misunderstanding something |
21:12:50 | FromDiscord | <Phil> But I need this stuff to be static to pass it onto another macro without it getting auto converted into a NimNode I thought |
21:13:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/E6Wz6 |
21:14:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Co7 |
21:15:07 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Co8 |
21:15:42 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4Co8" => "https://play.nim-lang.org/#ix=4Co9" |
21:17:42 | FromDiscord | <Phil> Does that execute the call? So if bla returns a NimNode I can also return that? |
21:20:07 | FromDiscord | <Elegantbeef> I mean the macro is expanded in place |
21:20:21 | FromDiscord | <Elegantbeef> If you're calling a macro it's called within the macro scope and with the macro arguments |
21:22:13 | FromDiscord | <Phil> can newcall eat a "body" of nim-code the same way templates and macros do? |
21:22:17 | FromDiscord | <Elegantbeef> If you want things resolved you have to pass them along and to let Nim evaluate them outside of the macro scope |
21:30:41 | FromDiscord | <ieltan> In reply to @auxym "parseExpr if your": I don't know if you have the knowledge but why is `genasts` it's own module? |
21:31:03 | FromDiscord | <ieltan> Can't it just be included inside `macros` |
21:31:59 | FromDiscord | <ieltan> `std/with` too |
21:32:26 | FromDiscord | <ieltan> Why couldn't it just be in `std/sugar`? |
21:32:40 | FromDiscord | <Elegantbeef> Cause including everything inside a single module is not the wisest |
21:33:07 | FromDiscord | <ieltan> I'm not talking about `include` of course |
21:33:20 | FromDiscord | <Elegantbeef> Who said you were |
21:33:21 | FromDiscord | <ieltan> Just write it inside a module that already exist |
21:33:42 | FromDiscord | <ieltan> What could possibly go wrong |
21:35:26 | FromDiscord | <Elegantbeef> Ambiguities |
21:35:51 | FromDiscord | <Elegantbeef> Slows down compile times |
21:37:49 | FromDiscord | <Phil> Seems like newCall can not accept a body the same way templates and macros do, gnaa↵Ugh I give up for today |
21:38:00 | FromDiscord | <Elegantbeef> `newStmtList(myCode)` |
21:38:05 | FromDiscord | <ieltan> In reply to @Elegantbeef "Ambiguities": I see, thanks for answering 🙂 |
21:54:56 | FromDiscord | <jakraes> Is there a way to import every single file in a folder? |
21:55:11 | FromDiscord | <Andreas> nope |
21:55:22 | FromDiscord | <jakraes> Daaaamn |
21:56:09 | FromDiscord | <jakraes> Well, that's unfortunate |
21:56:50 | FromDiscord | <Elegantbeef> You can write a macro, or more reasonably a script to generate a `import export` chain for all the modules |
21:58:25 | FromDiscord | <Elegantbeef> The script is slightly more reasonable in my view as it doesnt have to iterate a folder every single compilation |
21:58:26 | FromDiscord | <jakraes> Isn't export and the same thing? |
21:58:32 | FromDiscord | <_gumbercules> No |
21:58:34 | FromDiscord | <Andreas> we had this conversation a couple of days before - one can write a macro, thus extending the language. Thats requires advanced knowledge of nims `templates/macros`. Since nobody from the expert-users ever had the need to do so - maybe you explain why you need such ? |
21:58:45 | FromDiscord | <Elegantbeef> No cause you cannot `import std/strutils` |
21:59:06 | FromDiscord | <_gumbercules> Also in what programming language can you import every file / module in a folder? |
21:59:14 | FromDiscord | <Elegantbeef> I mean I've had the need 😄↵(@Andreas) |
21:59:31 | FromDiscord | <jakraes> Damn, I'm completely confused now, I'll need to look into it then |
21:59:43 | FromDiscord | <Elegantbeef> Doesnt java have wildcard imports |
22:00:02 | FromDiscord | <jakraes> In reply to @_gumbercules "Also in what programming": I'm unsure, but Nim could be an exception haha |
22:00:04 | FromDiscord | <_gumbercules> Yes but everything is stil structured into a package in Java which you have to declare at the top |
22:00:24 | FromDiscord | <_gumbercules> In reply to @jakraes "I'm unsure, but Nim": I just don't see the appeal - generally in Nim the idiomatic thing to do is have one module that exports all the other modules |
22:00:37 | FromDiscord | <_gumbercules> so you'd have like an `api.nim` which imports all of your other `.nim` files and then exports them |
22:00:44 | FromDiscord | <_gumbercules> that way everything just imports `api.nim` |
22:00:44 | FromDiscord | <jakraes> Oh, so it's like a header file? |
22:01:03 | FromDiscord | <_gumbercules> Can be - yeah in Nim there's no distincton between where a declaration is made and an implementation is provided |
22:01:06 | FromDiscord | <jakraes> Wait, wouldn't circular imports be an issue there? |
22:01:08 | FromDiscord | <_gumbercules> but you can certainly use modules like header files |
22:01:22 | FromDiscord | <_gumbercules> In reply to @jakraes "Wait, wouldn't circular imports": yes they can be - and that's why in larger NIm projects you'll generally find some sort of `types.nim` file |
22:01:34 | FromDiscord | <_gumbercules> it sucks but tmk the compiler still can't handle circular imports |
22:01:40 | FromDiscord | <_gumbercules> unless that was resolved in 2.0 |
22:01:51 | FromDiscord | <Elegantbeef> Well it can handle circular imports but only with delayed imports |
22:01:58 | FromDiscord | <Elegantbeef> So tightly cyclical graphs fail |
22:02:04 | FromDiscord | <Elegantbeef> But loosely cyclical graphs succeed |
22:02:31 | FromDiscord | <jakraes> Yeah I remember I had a lot of issues when trying to mimic a header file in Nim last year or so, I'll to check that out though |
22:02:34 | FromDiscord | <jakraes> Maybe it'll work this time |
22:02:46 | FromDiscord | <Elegantbeef> No it will not |
22:02:53 | FromDiscord | <Elegantbeef> Cyclical imports still require thought |
22:02:56 | FromDiscord | <Elegantbeef> They do not magically work |
22:03:00 | FromDiscord | <jakraes> Ah damn |
22:03:13 | FromDiscord | <jakraes> Well I need to look into this whole situation then |
22:03:25 | FromDiscord | <jakraes> It'll save me a lot of work in the future |
22:04:01 | FromDiscord | <_gumbercules> btw the difference between `export` and `` is that `` is used to mark a symbol as available outside of the module |
22:04:21 | FromDiscord | <_gumbercules> so it's like omitting `static` from a declaration in C |
22:04:35 | FromDiscord | <jviega> I've recently dealt with a cyclical issue that "extern" would have easily fixed but would have required refactoring that obfuscated the code by declaring both sides to the other as if they were in C and just forcing the calling convention on both 🙂 |
22:04:36 | FromDiscord | <Andreas> In reply to @Elegantbeef "Cyclical imports still require": and some additional work on the compiler - i tried "module-package-types ?" and found it brittle and failing on generics.. |
22:04:36 | FromDiscord | <_gumbercules> `export` is generally used when you want to export a symbol from a module you've imported |
22:05:01 | FromDiscord | <_gumbercules> so module `a` imports `b` and wants to make `b` available to anything that imports `a` |
22:05:14 | FromDiscord | <Elegantbeef> Nah andreas that's a different issue |
22:05:17 | FromDiscord | <_gumbercules> you'd upse `export b` inside module `a` |
22:05:23 | FromDiscord | <jakraes> Ooooh |
22:05:31 | FromDiscord | <jakraes> Yeah that'll be super useful |
22:05:39 | FromDiscord | <jakraes> I was wondering if there was a way to do that, guess there is |
22:05:43 | FromDiscord | <jakraes> Thank you :D |
22:05:58 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/QWoxQtBAXoiHhLuw for an example of how delayed imports allow cyclical imports |
22:06:09 | FromDiscord | <jakraes> That answers my question |
22:06:36 | FromDiscord | <jakraes> I asked my initial question because imports weren't working like they do in C |
22:06:46 | FromDiscord | <jakraes> Guess I just needed the export |
22:06:52 | FromDiscord | <jakraes> Pretty damn cool |
22:07:24 | FromDiscord | <Elegantbeef> `include` is like C's include, `import` is a proper system and what you should use 99% of the time |
22:07:31 | FromDiscord | <Andreas> In reply to @Elegantbeef "https://wandbox.org/permlink/QWoxQtBAXoiHhLuw for a": nice trick.. |
22:07:44 | FromDiscord | <jakraes> In reply to @Elegantbeef "`include` is like C's": Yeah I'll still be using import |
22:08:20 | FromDiscord | <Elegantbeef> It's not much of a trick really, it's just how Nim's imports work |
22:08:29 | FromDiscord | <Elegantbeef> Loosely cyclical graphs are fine, it's the tightly cyclical that are not |
22:08:57 | FromDiscord | <jakraes> In C I always had problems with passing down some undesired includes |
22:09:07 | FromDiscord | <jakraes> Import and export fixes my issue with C lul |
22:09:17 | FromDiscord | <jakraes> One of the issues, I mean |
22:09:46 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/VBtPjED9cAtqjWMR this slight modification to above shows a tight graph causing the issue |
22:11:09 | FromDiscord | <Elegantbeef> main -\> a -\> import b -\> declare type -\> import a -\> import b -\> declare type -\> import a -\> .... |
22:11:33 | FromDiscord | <Prestige> oh nice we're getting some youtube coverage on nim 2.0 |
22:12:37 | FromDiscord | <Andreas> In reply to @avahe "oh nice we're getting": nice, you got a link ? |
22:12:44 | FromDiscord | <Prestige> https://www.youtube.com/watch?v=nFPm48nANCY |
22:12:56 | FromDiscord | <Prestige> just started watching |
22:23:41 | FromDiscord | <nicolterra> I am having an issue with installing the nim ls on neovim. my lucky guess is my bash rc is not set up correctly? https://media.discordapp.net/attachments/371759389889003532/1137148881898057879/Screenshot_from_2023-08-04_16-22-12.png |
22:26:14 | FromDiscord | <Elegantbeef> Hard to say without a full error message |
22:29:08 | FromDiscord | <Elegantbeef> Prestige if only they had anything of substance to add 😄 |
22:30:10 | FromDiscord | <Prestige> The video? Yeah he doesn't know anything about Nim yet. He has a huge audience though, hopefully this will be some sort of gateway into him trying Nim and making videos about it |
22:30:45 | FromDiscord | <Elegantbeef> Eh given what he's said about Nim before, doubtful |
22:31:00 | FromDiscord | <Elegantbeef> But I could be wrong |
22:31:32 | FromDiscord | <Prestige> fingers crossed |
22:31:39 | FromDiscord | <Prestige> I think he'd enjoy the language if he tried it |
22:32:45 | FromDiscord | <Prestige> Well, I take that back, he'd probably drop it because of editor support |
22:35:58 | FromDiscord | <ricky> is ther a nix pkg for nim2 yet fellas |
22:36:02 | FromDiscord | <ricky> im hungry bad |
22:36:24 | FromDiscord | <Andreas> seems he is currently is in a love-affair with OCaml 🙂 |
22:36:49 | FromDiscord | <nicolterra> In reply to @avahe "just started watching": ive been listening trying to fix my lsp issue lol |
22:37:07 | FromDiscord | <Andreas> (edit) removed "is" |
22:37:59 | FromDiscord | <ricky> In reply to @Andreas "seems he is currently": cursed lang |
22:40:11 | FromDiscord | <Prestige> He's been _really_ into rust for a while and trying out other languages on the side |
22:43:16 | FromDiscord | <Andreas> In reply to @avahe "He's been _really_ into": ik, but presenting nim without any noticable preparation is , well weak.. |
22:44:00 | FromDiscord | <Prestige> Yeah that was pretty lame |
22:44:11 | FromDiscord | <nicolterra> last ping on this, sorry, but this is the full error https://media.discordapp.net/attachments/371759389889003532/1137154042229968926/Screenshot_from_2023-08-04_16-43-40.png |
22:44:17 | FromDiscord | <nicolterra> i am still somewhat new to nvim |
22:45:02 | FromDiscord | <Prestige> Looks like it can't find nimble |
22:45:52 | FromDiscord | <nicolterra> i just ran which nimble so it is installed, i think |
22:46:36 | FromDiscord | <nicolterra> huh, my bashrc crashed and has a backup |
22:48:17 | FromDiscord | <nicolterra> sorry if i need to be babied during config, i do however have nim 2.0 and nimble |
22:48:30 | FromDiscord | <nicolterra> on debian/pop os |
22:49:17 | FromDiscord | <nicolterra> my bashrc is where my environment path is set up right? |
22:49:38 | FromDiscord | <Elegantbeef> If that's the shell you're using and you didnt setup your path elsewhere |
22:53:34 | FromDiscord | <Elegantbeef> Do think I had similar issues with fish and astronvim |
22:54:10 | FromDiscord | <nicolterra> astrovim is my starting config--- |
23:21:55 | NimEventer | New thread by user2m: Nim Autome / Win32 API, see https://forum.nim-lang.org/t/10375 |
23:27:23 | FromDiscord | <ieltan> In reply to @avahe "https://www.youtube.com/watch?v=nFPm48nANCY": Big brain fart at the 12:25 mark lol |
23:29:02 | FromDiscord | <ieltan> To be fair to him, the article probably shouldn't have put the C++ and the Nim code in the same block, it make it look like you can directly write C++ inside Nim (I mean, you can with emit but the article is not using it) |
23:33:45 | FromDiscord | <Prestige> Yeah agreed |
23:40:44 | FromDiscord | <bostonboston> video hurt me in some spots |