00:17:40 | FromDiscord | <jtv> Is there a way to pass a pointer to a function directly, or do I have to assign it to a variable first? Have tried casting and a bunch of other crap |
00:18:00 | FromDiscord | <jtv> Not that big a deal, just would be nice |
00:18:51 | FromDiscord | <jtv> Particularly, have some data type that takes an Option[SomeFuncPtrType] and having to go through a dummy variable to call some() on it feels ugly |
00:19:01 | FromDiscord | <Elegantbeef> you can just do `myProc(myOtherProc)` |
00:19:31 | FromDiscord | <jtv> I'm trying to do myProc(some(myOtherProc)) |
00:20:11 | FromDiscord | <jtv> And if I don't stick myotherProc in a variable first, it gives me an obtuse error about two types being different, when they both are the same, ones just the alias that's the formal |
00:20:25 | FromDiscord | <jtv> But if I do x = myOtherProc; myProc(some(x)) it's fine |
00:24:03 | FromDiscord | <Elegantbeef> Uncertain what you're doing |
00:24:40 | FromDiscord | <Elegantbeef> is `myOtherProc` an overload? |
00:25:23 | FromDiscord | <Elegantbeef> Without the actual code it's quite hard to say what's what |
00:28:23 | FromDiscord | <jtv> 1 sec |
00:28:34 | FromDiscord | <jtv> https://play.nim-lang.org/#ix=4kBH |
00:29:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kBI |
00:29:54 | FromDiscord | <Elegantbeef> `Option[proc{.nimcall.}]` cannot convert to `Option[proc{.closure.}]` |
00:30:16 | FromDiscord | <Elegantbeef> As such you need to explicitly state `TestType` is a closure |
00:30:20 | FromDiscord | <Elegantbeef> I mean nimcall |
00:32:36 | FromDiscord | <jtv> I see, I suppose {.nimcall.} is just the standard calling convention, yes? But I don't understand why it infers that it's a closure in one context, but a nimcall in the other. |
00:32:49 | FromDiscord | <Elegantbeef> You could also do `some(proc(i: int){.closure.}(addFive))` |
00:32:56 | FromDiscord | <Elegantbeef> Well Nim's default type for procedures is closures |
00:33:04 | FromDiscord | <Elegantbeef> Aside from declarations |
00:33:26 | FromDiscord | <jtv> Got it |
00:33:28 | FromDiscord | <jtv> Thank you |
00:33:30 | FromDiscord | <Elegantbeef> So `proc doThing(p: proc())` expects `closure` as this allows both `nimCall`(through conversion) and also `closure` of course |
00:34:59 | FromDiscord | <Elegantbeef> I do have a PR that thunks all procedures to closures, but it's pretty much dead on arriaval by my lack of knowledge in code generators |
00:36:08 | FromDiscord | <Elegantbeef> But in theory there is no reason why nimcall -\> closure is special and Nim couldnt convert any procedure into a nimcall or closure |
00:36:51 | FromDiscord | <jtv> Yup got it. If your PR works, what's the issue with it really? Too kludgy?? |
00:36:59 | FromDiscord | <Elegantbeef> It doesnt work |
00:37:04 | FromDiscord | <jtv> Ahhhhhh |
00:37:21 | FromDiscord | <Elegantbeef> There is an issue with the code generator and I dont know what to do |
00:37:32 | FromDiscord | <jtv> That sucks :/ |
00:37:45 | FromDiscord | <Elegantbeef> It's really not that complicated of a change, just I only have ever touched semantic analysis |
00:38:40 | FromDiscord | <jtv> Still, code generation is usually the messiest part of a compiler. I can imagine that's the case here too :/ |
00:39:20 | FromDiscord | <Elegantbeef> Eh it's not even code gen i need to change |
00:39:26 | FromDiscord | <Elegantbeef> It's just a useless error message inside codegen 😄 |
00:40:52 | FromDiscord | <jtv> 90% of the error messages in nim are close to useless 🙂 |
00:41:34 | FromDiscord | <jtv> BTW, doThing(TestType(addFive)) worked, which is cool and feels elegant and obvious enough |
00:41:48 | FromDiscord | <jtv> Erm, dothing(some(TestType(addFilve))) |
00:42:32 | FromDiscord | <Elegantbeef> Meh i find them ok mostly |
00:45:09 | FromDiscord | <Elegantbeef> But that's likely stockholm calling |
00:45:39 | FromDiscord | <jtv> Yeah, I guess that's not even really true, it's the optimization that's the worst... just that tends to be the peephole optimizations that are often baked into the code generation phase |
00:45:57 | FromDiscord | <rlipsc> sent a code paste, see https://paste.rs/Dvi |
00:47:13 | FromDiscord | <Elegantbeef> That should work |
00:47:17 | FromDiscord | <Elegantbeef> Symbols dont care about scope |
00:47:38 | FromDiscord | <rlipsc> oh... today I learned... |
00:47:59 | FromDiscord | <rlipsc> that's not what I expected 😅 though does explain some stuff |
00:48:06 | FromDiscord | <Elegantbeef> Hell you can copy a procedure that's exported and copy it calling all symbols internally |
00:48:54 | FromDiscord | <rlipsc> how have I been using the language for so long and not known this... 😆 |
00:49:05 | FromDiscord | <Elegantbeef> That is the entire point of a symbol after all to be an identifer that is typed and bound to an implementation |
00:49:43 | FromDiscord | <rlipsc> Makes sense, but then again, I still expected scope to work as it's not 'visible', but apparently not. |
00:50:13 | FromDiscord | <Elegantbeef> Using the macro cache you can do even funkier shit aswell with symbols |
00:51:05 | FromDiscord | <rlipsc> yes, that I have been caught by. Learned my lesson to always `.copy` from macrocache |
00:51:32 | FromDiscord | <rlipsc> things get funky, fast |
00:53:09 | FromDiscord | <rlipsc> sent a code paste, see https://play.nim-lang.org/#ix=4kBM |
00:53:20 | FromDiscord | <rlipsc> 😬 |
00:54:11 | FromDiscord | <Elegantbeef> `genSym` is fun |
00:55:27 | FromDiscord | <rlipsc> I feel like that example should fail when the symbol is redefined, or something. |
00:57:13 | FromDiscord | <rlipsc> sent a code paste, see https://paste.rs/jX1 |
01:04:33 | FromDiscord | <Elegantbeef> Yea gensym + symbols are interesting |
01:06:59 | FromDiscord | <rlipsc> Yeah, that was a bit of a gotcha for me. Although, I guess it allows some pretty crazy things in metaprogramming, in theory. Perhaps at the cost of sanity, though. |
01:07:40 | FromDiscord | <auxym> In reply to @jtv "https://play.nim-lang.org/#ix=4kBH": this works fyi: ` setMagicFunc(some(addFive.TestType))` |
01:07:49 | FromDiscord | <Elegantbeef> The plus side is you can technically rewrite any procedure that exists inside a macro |
01:07:50 | FromDiscord | <rlipsc> I was trying to work out why the symbol was being added to multiple times even though the code "clearly" instantiated the variable and updated it once. Well, turns out things aren't that simple with genSym 🙂 |
01:08:06 | FromDiscord | <Elegantbeef> Say you want to make yourself a tail call optimiser, it's not impossible to do |
01:09:47 | FromDiscord | <rlipsc> huh, yeah... actually I can see it being really useful for rewriting things. I guess it's no different from `bindSym` in a way. |
01:10:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kBR |
01:11:16 | FromDiscord | <Elegantbeef> Yea it's the generative antonym of `bindsym` |
01:14:36 | FromDiscord | <rlipsc> In reply to @Elegantbeef "In the above case": Not quite the same, though. I needed to reference `sym` in different code blocks so I needed a generated variable that I could refer to. |
01:15:45 | FromDiscord | <rlipsc> Also, I keep meaning to look into `genAst`, is it going to replace `quote`? |
01:16:21 | FromDiscord | <Elegantbeef> It kinda does replace quote yes |
01:16:28 | FromDiscord | <Elegantbeef> It's a bit nicer imo since it doesnt require backticks |
01:18:18 | FromDiscord | <rlipsc> it'd be nice to not need backticks for some of my larger macros, though I'm a bit concerned there'd be some surprise symbol clashing. Probably not, though. |
01:18:39 | FromDiscord | <Elegantbeef> You explicitly pass in catched symbols |
01:18:42 | FromDiscord | <Elegantbeef> cached symbols rather |
01:20:26 | FromDiscord | <rlipsc> I remember being put off by `genAst` for that reason; if you have 30+ idents to reference it might become onerous. It might mean I'd have to, like, write better code or something. |
01:22:42 | FromDiscord | <Elegantbeef> Eh i find it better than `let a = x` |
01:25:27 | FromDiscord | <rlipsc> sent a code paste, see https://paste.rs/Smg |
01:25:48 | FromDiscord | <rlipsc> I know you can change the quote char, but it's still awkward |
01:25:48 | FromDiscord | <Elegantbeef> Well in that case you could tell quote to use `@` or similar |
01:25:55 | FromDiscord | <Elegantbeef> Lol |
01:47:09 | FromDiscord | <ambient> sent a code paste, see https://play.nim-lang.org/#ix=4kBY |
01:48:05 | FromDiscord | <ambient> Maybe Nim stack and C stack mean different things |
01:54:10 | FromDiscord | <ambient> Ok it talks about seqs separately, nvm |
02:00:43 | FromDiscord | <pietroppeter> In reply to @pietroppeter "Yep no problem, will": @ElegantBeef done, but this time is tricky, we have a couple of somewhat big assets and maybe it is better to link to an outside link... see https://github.com/nim-lang/website/pull/356 |
02:01:09 | FromDiscord | <Elegantbeef> Miran will tell you 😄 |
02:01:39 | FromDiscord | <pietroppeter> yep, will see |
02:06:59 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kC1 |
02:07:29 | FromDiscord | <ambient> In reply to @auxym "what? You mean trying": var foo = seq[int](64_000_000_000); or something like that |
02:07:39 | FromDiscord | <ambient> but I already got most of my question answered |
02:08:07 | FromDiscord | <auxym> seqs are implicitly heap allocated, but use value semantics, so an assignment will copy |
02:08:12 | FromDiscord | <ambient> I assume that stack has some limit and is not dynamically changed if it requires more space |
02:08:24 | FromDiscord | <auxym> no it's like in C |
02:09:01 | FromDiscord | <auxym> by default gcc allocates 1 mb of stack size, or something like that, if you try to create a 64 gb array you'll segfault |
02:09:10 | FromDiscord | <ambient> yep |
02:31:56 | FromDiscord | <demotomohiro> !eval var ary: array[512 1024 1024]; echo ary[^1] |
02:32:00 | NimBot | Compile failed: /usercode/in.nim(1, 20) Error: invalid token: (\29) |
02:36:31 | FromDiscord | <demotomohiro> !eval var ary: array[64 1024 1024, int]; echo ary[^1] |
02:36:34 | NimBot | Compile failed: /usercode/in.nim(1, 19) Error: invalid token: (\29) |
02:54:58 | * | arkurious quit (Quit: Leaving) |
03:31:05 | * | azimut quit (Ping timeout: 255 seconds) |
04:12:15 | FromDiscord | <pyolyokh> In reply to @demotomohiro "!eval var ary: array[64": that's the right syntax, but outside of a proc that's not going to be stack-allocated. |
04:13:37 | FromDiscord | <pyolyokh> it's also not going to be heap-allocated. the heap/stack dichotomy probably confuses more than it enlightens. |
04:18:48 | * | ltriant joined #nim |
04:26:01 | FromDiscord | <Require Support> how do I decide between using `orc` or `arc`. compiling for windows, using threading, not using async |
04:26:19 | FromDiscord | <Elegantbeef> Easy use orc |
04:27:39 | FromDiscord | <Require Support> thanks, any quick explanation to why use orc? so I don't ask here everytime I have to make this decision |
04:27:58 | FromDiscord | <Elegantbeef> It handles cyclical types and is only used in a type that can be cyclical |
04:28:05 | FromDiscord | <Elegantbeef> It has 0 overhead if you dont have cyclical types |
04:36:55 | FromDiscord | <NibbleNueva> orc is also the default in nim 2.0 (which looks to be very soon) |
05:00:00 | * | oprypin_ quit (Quit: Bye) |
05:16:22 | FromDiscord | <albassort> is scanning more efficient when reading from a stream by manually incrementing the pos by 1 |
05:16:36 | FromDiscord | <albassort> or doing it byte by byte until it matches a buffer |
06:15:02 | FromDiscord | <brendo-m> sent a code paste, see https://paste.rs/pXY |
06:32:05 | FromDiscord | <demotomohiro> @pyolyokh Variables outside of procs are allocated on a place called "static storage" in C lang. |
07:27:51 | * | pro joined #nim |
07:27:58 | * | ltriant quit (Ping timeout: 272 seconds) |
07:30:18 | * | ltriant joined #nim |
07:50:40 | * | ltriant quit (Ping timeout: 252 seconds) |
07:51:31 | * | ltriant joined #nim |
07:56:44 | * | pro quit (Quit: pro) |
08:04:42 | * | Batzy quit (Ping timeout: 272 seconds) |
09:00:35 | FromDiscord | <pyryrin> does nim automatically inline some functions |
09:01:29 | FromDiscord | <Elegantbeef> C does, Nim doesnt |
09:01:53 | FromDiscord | <Elegantbeef> If you want to inline code you use templates/macros |
09:02:02 | * | pro joined #nim |
09:02:16 | * | pro quit (Client Quit) |
09:02:27 | FromDiscord | <pyryrin> wasnt there `{.inline.}` pragma or something |
09:02:46 | FromDiscord | <Elegantbeef> There is but that still just tells the C compiler that it should inline it |
09:03:03 | FromDiscord | <Elegantbeef> Nim does not have any mechanism to inline code that doesnt rely on the backend compiler |
09:03:05 | FromDiscord | <pyryrin> so it makes no difference? |
09:03:33 | FromDiscord | <Elegantbeef> It makes a difference but it's up to the C compiler to inline |
09:04:17 | FromDiscord | <pyryrin> i think nowdays it doesn't make a difference and the c compiler will decide |
09:04:53 | FromDiscord | <Elegantbeef> > Nim does not have any mechanism to inline code that doesnt rely on the backend compiler↵I should say aside from templates which guarantee inlining, but yes inline annotation is the proper thing to do in 99% of cases that you want a procedure inlined |
09:05:01 | FromDiscord | <Elegantbeef> Though in most cases the C compiler is smart enough |
09:06:30 | FromDiscord | <pyryrin> i trust the c compiler |
09:26:01 | FromDiscord | <ShalokShalom> Sounds heroic |
09:40:11 | FromDiscord | <albassort> @ElegantBeef |
09:40:31 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4kD0 |
09:40:33 | FromDiscord | <albassort> how do i optimize |
09:40:47 | FromDiscord | <albassort> order is a smol array its not the bottleneck |
09:41:55 | FromDiscord | <albassort> im matching for strings in a pool of data |
09:42:08 | FromDiscord | <albassort> "0000000OPTXOOOO" eg |
09:53:29 | FromDiscord | <albassort> sent a code paste, see https://paste.rs/10C |
09:56:21 | FromDiscord | <ElegantBeef> A prefix table or similar likely |
09:56:58 | FromDiscord | <ElegantBeef> You havent give much of a explanation of what you're doing |
09:57:58 | FromDiscord | <ElegantBeef> doing `data.toOpenArray(y, y + 3) in order[]` will reduce copying which will make it a bit faster aswell but yes need to remove the costly contains check |
09:59:18 | FromDiscord | <albassort> what is a prefix table |
09:59:37 | FromDiscord | <albassort> im looking for chunk markets in a binary |
10:00:01 | FromDiscord | <ElegantBeef> Which means what exactly |
10:00:06 | FromDiscord | <ElegantBeef> You have binary data and have a needle? |
10:00:21 | FromDiscord | <albassort> In reply to @albassort ""0000000OPTXOOOO" eg": here |
10:00:30 | FromDiscord | <albassort> im gonna move it to a hashset and see if thats better |
10:00:37 | FromDiscord | <ElegantBeef> You arent making any sense |
10:00:46 | FromDiscord | <ElegantBeef> Yes that's the data, but what are you searching for |
10:01:27 | FromDiscord | <albassort> the chunk markers in the array |
10:01:44 | FromDiscord | <ElegantBeef> Which are? |
10:01:57 | FromDiscord | <albassort> im reading the data, and if its a chunk marker, i add its position to the output hashtables |
10:02:11 | FromDiscord | <ElegantBeef> And what is a chunk marker |
10:02:16 | FromDiscord | <albassort> strings of size 4 |
10:02:22 | FromDiscord | <ElegantBeef> "It's a marker that marks a chunk" |
10:02:38 | FromDiscord | <albassort> my response was worse than your mockery lol |
10:02:46 | FromDiscord | <ElegantBeef> Yes |
10:03:56 | FromDiscord | <ElegantBeef> So what is order |
10:04:10 | FromDiscord | <albassort> order is a hashset of strings which i am looking for |
10:04:39 | FromDiscord | <ElegantBeef> Seems `array[4, char]` would be a tinge better |
10:06:03 | FromDiscord | <albassort> moving it to a hashset has made it 100% faster alone |
10:06:19 | FromDiscord | <ElegantBeef> The hell was it before? |
10:06:34 | FromDiscord | <albassort> a seq |
10:06:37 | FromDiscord | <ElegantBeef> ... |
10:06:44 | FromDiscord | <albassort> i know i should know better |
10:06:52 | FromDiscord | <ElegantBeef> Another thing you could do is store the start/end characters you've seen in a set |
10:07:18 | FromDiscord | <albassort> they are |
10:07:23 | FromDiscord | <ElegantBeef> then you could do something like `if data[y] in startSet and data[y + 3] in endSet` which might be a bit faster |
10:07:53 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4kD2 |
10:07:58 | FromDiscord | <ElegantBeef> A bitset |
10:08:00 | FromDiscord | <ElegantBeef> Of characters |
10:08:18 | FromDiscord | <ElegantBeef> No hashing required to quickly see if the chunk has been seen |
10:08:21 | FromDiscord | <albassort> bitset? |
10:08:26 | FromDiscord | <ElegantBeef> `set[char]` |
10:08:32 | FromDiscord | <ElegantBeef> For the first and last character of a chunk |
10:09:02 | FromDiscord | <ElegantBeef> I imagine it's faster than hashing |
10:09:27 | FromDiscord | <ElegantBeef> Basically you filter out impossible chunks with a cheaper set |
10:09:37 | FromDiscord | <ElegantBeef> Probably could just do first character |
10:10:07 | FromDiscord | <ElegantBeef> Though I again dont know the actual data and variance of it |
10:10:26 | FromDiscord | <ElegantBeef> I just assumed that the start/end were not extremely invariant so one could check both to reduce hashing |
10:10:51 | FromDiscord | <ElegantBeef> But anyway you can use a `array[4, char]` to make it faster probably |
10:11:13 | FromDiscord | <albassort> an array of array[4, char]? |
10:11:15 | FromDiscord | <ElegantBeef> since comparison of that could just be a comparison of a 4 byte number |
10:11:17 | FromDiscord | <albassort> of set of array[4 |
10:11:20 | FromDiscord | <albassort> (edit) "array[4" => "array, 4" |
10:11:20 | FromDiscord | <ElegantBeef> .... |
10:11:30 | FromDiscord | <albassort> sorry brain melting |
10:11:54 | FromDiscord | <ElegantBeef> I thought you were using `Hashset[string]` |
10:11:59 | FromDiscord | <albassort> i am |
10:12:23 | FromDiscord | <ElegantBeef> So instead of that use `HashSet[array[4, char]]` |
10:13:06 | FromDiscord | <ElegantBeef> Since your key is really just an array of 4 chars |
10:13:16 | FromDiscord | <ElegantBeef> This will likely make it much faster |
10:14:01 | FromDiscord | <albassort> is there any... non cbt away to convert my strings to chars |
10:14:36 | FromDiscord | <ElegantBeef> sent a code paste, see https://paste.rs/2qM |
10:15:35 | FromDiscord | <ElegantBeef> Also removes your useless string copy |
10:18:01 | FromDiscord | <albassort> i mean for the declaration |
10:18:09 | FromDiscord | <ElegantBeef> What? |
10:18:18 | FromDiscord | <albassort> nooo dont what me fuck |
10:18:33 | FromDiscord | <albassort> "ABC" => array[3, char[ |
10:18:34 | FromDiscord | <ElegantBeef> Maybe if you spoke in full sentences that explained the issue we'd be a lot happier |
10:18:35 | FromDiscord | <albassort> (edit) "char[" => "char]" |
10:18:59 | FromDiscord | <albassort> the strings in the declaration, casting them to arrays of characters |
10:19:46 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=4kD7 |
10:20:03 | FromDiscord | <ElegantBeef> I guess that should be `charArr` |
10:20:07 | FromDiscord | <ElegantBeef> but who makes the rules |
10:20:16 | FromDiscord | <Rika> chArr xd |
10:20:18 | FromDiscord | <Rika> i joke |
10:20:26 | FromDiscord | <ElegantBeef> Imagine if you said "But how would i make string literals into an array" |
10:20:32 | FromDiscord | <ElegantBeef> We wouldnt have egg on our collective faces |
10:20:41 | FromDiscord | <albassort> no its just my face |
10:20:42 | FromDiscord | <Rika> inb4 "but my strings arent literals" |
10:21:04 | FromDiscord | <ElegantBeef> Luckily i go to sleep soon, so it becomes someone elses problem |
10:21:14 | FromDiscord | <Rika> not mine hopefully |
10:21:54 | FromDiscord | <albassort> its very hot in my room |
10:22:08 | FromDiscord | <albassort> so im probably more insane than usual |
10:22:25 | FromDiscord | <ElegantBeef> Dont know if insane is the 'i' word i'd use |
10:23:33 | * | oprypin joined #nim |
10:24:06 | FromDiscord | <ElegantBeef> Alba here really better type faster if they want to report their code exploding |
10:25:07 | FromDiscord | <ElegantBeef> Though to be honest i'm quite surprised `strArr` worked as it's written, didnt require any hacks |
10:29:57 | FromDiscord | <ElegantBeef> Well have fun alba |
10:30:43 | FromDiscord | <albassort> i wont |
10:32:51 | FromDiscord | <albassort> we're down from around 1 minute to 7 seconds |
10:33:13 | FromDiscord | <Rika> thats gotrta be good enough |
10:33:50 | FromDiscord | <albassort> thats what we tell ourselves before bed but while we try to sleep we think to ourselves "is 6 seconds possible" |
10:33:57 | FromDiscord | <albassort> but there are indeed no easy optimizations from here |
10:34:02 | FromDiscord | <albassort> that i can think of |
10:34:11 | FromDiscord | <albassort> so probably good enough |
10:35:09 | FromDiscord | <albassort> if we wanna get technical its 28 seconds because its threaded |
10:35:22 | FromDiscord | <albassort> which is unacceptable |
10:39:23 | * | azimut joined #nim |
11:00:37 | FromDiscord | <pmp-p> need some help with the forum, i did receive confirmation but way too late and it is expired but i can't find a button to resend it |
11:01:18 | FromDiscord | <enthus1ast> there (still) is none |
11:01:37 | FromDiscord | <enthus1ast> one of the mods must enable you |
11:02:10 | FromDiscord | <pmp-p> In reply to @enthus1ast "one of the mods": thx, then my profile is there https://forum.nim-lang.org/profile/pmp-p |
11:15:28 | om3ga | Hi! const name: int = 3 is equivalent to #define name 3? |
11:19:29 | * | pro joined #nim |
11:22:18 | * | azimut quit (Remote host closed the connection) |
11:22:44 | * | azimut joined #nim |
11:22:51 | FromDiscord | <Rika> not exactly, roughly yes |
11:24:21 | om3ga | Rika, thanks! |
11:30:26 | FromDiscord | <Vindaar> In reply to @pmp-p "thx, then my profile": activated |
11:41:13 | * | pro quit (Quit: pro) |
11:45:37 | FromDiscord | <federico3> any timeline on the release of 2.0? |
11:47:44 | FromDiscord | <albassort> choosenim #head #fed |
11:47:50 | FromDiscord | <albassort> (edit) removed "#fed" |
11:54:50 | FromDiscord | <jmgomez> In reply to @federico3 "any timeline on the": hopefully when all of this is fixed (and not before) https://github.com/nim-lang/Nim/labels/ARC%2FORC%20Memory%20Management |
11:58:50 | FromDiscord | <pmp-p> In reply to @Vindaar "activated": thnak you very much |
12:29:09 | * | krux02 joined #nim |
12:38:26 | * | pro joined #nim |
12:38:58 | * | pro quit (Client Quit) |
13:33:06 | * | pro joined #nim |
13:36:20 | * | pro quit (Client Quit) |
13:59:38 | * | jmdaemon quit (Ping timeout: 255 seconds) |
13:59:51 | * | pro joined #nim |
14:04:19 | * | pro quit (Ping timeout: 260 seconds) |
14:04:43 | * | pro joined #nim |
14:40:51 | * | pro quit (Quit: pro) |
14:54:23 | * | arkurious joined #nim |
14:56:18 | FromDiscord | <FullValueRider> I'm getting this error message. Apart from rechecking my code for my errors what else can I do? |
14:56:29 | FromDiscord | <FullValueRider> sent a code paste, see https://paste.rs/0hV |
15:01:13 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/C27 |
15:01:31 | FromDiscord | <4zv4l> like why I cannot reverse the array in comptime ? ↵it doesn't return the array so I cant' do it for `const` |
15:01:53 | FromDiscord | <4zv4l> and the cast doesn't work for `const` also 🥺 |
15:04:20 | FromDiscord | <Phil> Does it have to be the same array? Can't you just do a transformation? |
15:04:39 | FromDiscord | <Phil> Basically create a second array as you desire |
15:05:32 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEe |
15:05:32 | FromDiscord | <4zv4l> In reply to @Isofruit "Basically create a second": how ? |
15:05:36 | FromDiscord | <4zv4l> reverse doesn't return the value |
15:05:41 | FromDiscord | <4zv4l> it reverse the same array |
15:10:28 | FromDiscord | <Phil> I'll need to look into it, worst case scenario you write your own reverse proc for an array, should be like 5 or 6 loc |
15:10:51 | FromDiscord | <Phil> It would work at compile time as well, so no performance penalty |
15:11:16 | FromDiscord | <Phil> Got to wait till after sport though. |
15:15:47 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEh |
15:16:16 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4kEi |
15:16:27 | FromDiscord | <Rika> or use `reversed` |
15:17:13 | FromDiscord | <Rika> ah, reversed returns a seq |
15:17:14 | FromDiscord | <Rika> lo |
15:17:34 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4kEj |
15:19:58 | * | PMunch joined #nim |
15:25:08 | FromDiscord | <4zv4l> In reply to @auxym "are you aware of:": the purpose is to not use ipaddress lib xD |
15:25:21 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEn |
15:27:17 | FromDiscord | <4zv4l> well just need the const cast xD |
15:28:45 | FromDiscord | <auxym> @4zv4l you can also use the stuff in std/endians (or endians2 on nimble) to reverse the bytes |
15:29:20 | FromDiscord | <auxym> endians uses pointers though so no go at compile time |
15:30:30 | FromDiscord | <4zv4l> oh yeah↵thanks, the purpose is to be at compile time |
15:30:39 | FromDiscord | <4zv4l> `var a = [1'u8, 2, 3, 4]`↵how does this work `1'u8` ? |
15:31:01 | FromDiscord | <4zv4l> I thought there isn't the type `u8` in nim but `uint8` |
15:32:16 | FromDiscord | <auxym> `'u8` is a suffix just used for literals |
15:33:25 | FromDiscord | <4zv4l> I was wondering also↵` var arr: array[4, byte] = [byte 127,0,0,1]`↵why do I need to precise byte inside the array ? |
15:33:40 | FromDiscord | <4zv4l> with the type info it should know that I want bytes |
15:34:40 | FromDiscord | <auxym> something something nim's type inference system is not smart enough |
15:35:13 | FromDiscord | <auxym> ` var arr: array[4, byte] = [127'u8,0,0,1]` would also work, byte is an alias for uint8 |
15:36:00 | FromDiscord | <auxym> you can implement your own `toU32BE` that works at CT using shift + or as explained here (sort of) https://justine.lol/endian.html |
15:38:18 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEq |
15:38:56 | FromDiscord | <4zv4l> In reply to @auxym "` var arr: array[4,": oooh good to know ! |
15:40:51 | FromDiscord | <auxym> which is what endians2 does if you want to use that instead of rolling your own: https://github.com/status-im/nim-stew/blob/master/stew/endians2.nim#L137 |
15:41:27 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEs |
15:41:30 | FromDiscord | <4zv4l> otherwise the or wouldn't always work |
15:41:54 | FromDiscord | <auxym> yes, nim zeroes everything always |
15:42:22 | FromDiscord | <auxym> but actually I think that might not work, you'll get cpu-native endian instead |
15:43:18 | FromDiscord | <auxym> thats why endians2 does swapbytes |
15:44:41 | FromDiscord | <auxym> yeah |
15:44:41 | FromDiscord | <4zv4l> yeah it doesn't seem to work |
15:44:41 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEt |
15:44:44 | FromDiscord | <4zv4l> it only prints `127` |
15:45:04 | FromDiscord | <4zv4l> and I expect `2130706433` |
15:52:10 | FromDiscord | <auxym> In reply to @4zv4l "and I expect `2130706433`": here: https://play.nim-lang.org/#ix=4kEu |
15:52:59 | FromDiscord | <auxym> the shift was overflowing the uint8, need to convert to uint32 before |
15:59:18 | FromDiscord | <4zv4l> seems good |
15:59:20 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEw |
15:59:26 | FromDiscord | <4zv4l> would be nice to be able to cast at comptime tho |
16:06:22 | FromDiscord | <Rika> casts arent a runtime thing |
16:06:38 | FromDiscord | <auxym> cast means reinterpet memory, and the VM doesn't actually access (real) memory, so yeah |
16:06:46 | FromDiscord | <Rika> at least to my knowledge, casts are just an "annotation" of sorts to tell the type system |
16:07:48 | PMunch | Hmm, is there a way to get every type which inherits from a type? |
16:08:32 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEB |
16:21:35 | FromDiscord | <EyeCon> @PMunch do we expect futhark to be able to install into WSL with `libclang-dev` installed? I assumed so and get a compilation error when installing the HEAD with nimble |
16:22:15 | FromDiscord | <scipio> Hello there! 🙂 👋 |
16:22:51 | PMunch | @EyeCon, honestly I have no idea. Haven't used Windows since before WSL was a thing.. |
16:23:06 | PMunch | But it's Linux-like right? So I guess it should work |
16:23:11 | PMunch | What's the error you get |
16:23:18 | PMunch | (by the way, it should also work without WSL) |
16:23:20 | PMunch | @scipio, hello |
16:23:38 | FromDiscord | <EyeCon> Everything is very linux-like, that's why I was surprised, let me get the error into a pastebin |
16:24:22 | FromDiscord | <scipio> I just discovered NIm yesterday 😁, spent all day reading `Dominik Picheta - Nim in Action-Manning Publications (2017)` |
16:24:28 | FromDiscord | <scipio> (edit) "NIm" => "Nim" |
16:24:35 | PMunch | @scipio, oh nice |
16:24:41 | PMunch | Welcome to the community :) |
16:25:52 | FromDiscord | <scipio> Well thanks! I am a hardcore Python fan, its syntax at least, so reading about Nim sparked a lot of enthusiasm. ↵However, in all honesty, what would be the preferred current GUI framework if I'd wanted to go fullstack Nim? |
16:26:16 | FromDiscord | <scipio> I'm also involved with the Flet project |
16:26:27 | FromDiscord | <scipio> https://flet.dev/ |
16:26:44 | FromDiscord | <EyeCon> sent a code paste, see https://play.nim-lang.org/#ix=4kEG |
16:26:51 | FromDiscord | <EyeCon> Do I need to have 11? |
16:27:14 | FromDiscord | <Array in ∀ Matrix> for GUI you probably want to look onto using gtk or qt↵(@scipio) |
16:27:18 | PMunch | Shouldn't require 11 |
16:27:20 | PMunch | Gotta go |
16:27:21 | * | PMunch quit (Quit: leaving) |
16:27:27 | FromDiscord | <auxym> In reply to @scipio "Well thanks! I am": GUI is not Nim's strong suit, still, unfortunately. There are bindings to many popular C GUI frameworks though: GTK (gintro), QT Quick / QML, wx. There's also the pure-nim nimx |
16:27:38 | FromDiscord | <Array in ∀ Matrix> ^ this |
16:28:39 | FromDiscord | <Array in ∀ Matrix> using electron or other js based webapp might be another option |
16:29:19 | FromDiscord | <scipio> Suppose I'd go with a Nim "local" backend, like Flask (Python), and then a barebones html, css, js frontend, to run on the same device as a macOS `.app`, what would then be the preferred framework stack? |
16:29:41 | FromDiscord | <scipio> In reply to @Array in ∀ Matrix "using electron or other": is there something like Tauri for Nim? |
16:30:15 | FromDiscord | <Array in ∀ Matrix> not that i know of maybe there is bindings for it?↵(@scipio) |
16:33:13 | FromDiscord | <scipio> Interesting: most NIm (ui) repos I come across haven't had updates in a while, some are 6-7 years old. Why is that? |
16:34:15 | FromDiscord | <scipio> When I'm reading the Nim language specs and Dominik Picheta's book: Nim seems like a dream come true. Why are these projects "abandoned" to a certain extent / isn't Nim as well-known as Rust lang is now? WHat's the catch? |
16:34:22 | FromDiscord | <pmunch> There are some options for building apps with web tech in Nim |
16:34:53 | FromDiscord | <ambient> Some people discount Nim because it's compiled into C or C++ |
16:34:57 | FromDiscord | <pmunch> Otherwise there's the basic ones like WxWidgets, Gtk, Windows whateveritscalled |
16:35:19 | FromDiscord | <scipio> In reply to @ambient "Some people discount Nim": isn't that a huge advantage? To me that's a pre. |
16:35:43 | FromDiscord | <ambient> It depends on what you want to do |
16:38:37 | FromDiscord | <auxym> In reply to @scipio "When I'm reading the": rust has mozilla behind it, which lead to picking up a large community pretty fast. Nim's community is pretty small still, in part because it doesn't have corporate backing, so people are doubtful about investing their time in it (learning it, maintaining libraries, etc) |
16:38:43 | FromDiscord | <auxym> that's my take anyways |
16:39:10 | FromDiscord | <ambient> Rust had Mozilla behind it |
16:39:53 | FromDiscord | <ambient> Plus Rust does offer something new, namely no GC but memory safety. |
16:40:38 | FromDiscord | <ambient> Plus the performance is as good as C or C++ |
16:41:34 | FromDiscord | <ambient> Nim seems to have perf in the same ballpark as C#, which also coincidentally seems to be developing into it's own thing outside .NET |
16:42:03 | * | jjido joined #nim |
16:42:16 | FromDiscord | <auxym> tbf nim's ORC is also pretty unique, and perf should be just as good as hand-written C if you know what you are doing. |
16:42:47 | FromDiscord | <ambient> I will believe it when I see it. The current benchmark give Nim similar results to C# |
16:43:23 | FromDiscord | <auxym> "fair" benchmarks are really hard to do though |
16:43:43 | FromDiscord | <jmgomez> In reply to @ambient "I will believe it": where is that current benchmark? |
16:44:38 | FromDiscord | <pyolyokh> "fair" Nim is also generally going to be slower than "Nim if you know what you're doing". It's natural to make more copies and do more allocation than necessary. |
16:45:04 | FromDiscord | <ambient> In reply to @jmgomez "where is that current": https://programming-language-benchmarks.vercel.app/nim-vs-csharp here's one |
16:46:12 | FromDiscord | <Gumbercules> In reply to @ambient "https://programming-language-benchmarks.vercel.app/": Benchmarks are dumb |
16:46:23 | FromDiscord | <Recruit_main707> c#? 🥴 |
16:46:34 | FromDiscord | <ambient> In reply to @Gumbercules "Benchmarks are dumb": If you have better data for me to pick programming languages based on performance, I'm happy to receive it |
16:46:57 | FromDiscord | <ambient> Given what a mediocre programmer (me) can achieve with it |
16:47:05 | FromDiscord | <pyolyokh> numbers are numbers. I'd sell Nim as having very good numbers if you write it like it's a scripting language, and excellent numbers if you write it like it's C. An advantage over other languages is that this is still "writing Nim" and not switching to a different language. |
16:47:08 | FromDiscord | <Gumbercules> https://blog.johnnovak.net/2017/04/22/nim-performance-tuning-for-the-uninitiated/ |
16:47:19 | FromDiscord | <Recruit_main707> nim, c, zig, rust all sit way closer than c# to nim i think |
16:47:54 | FromDiscord | <Gumbercules> It's not difficult to get Nim to outperform Rust |
16:47:54 | FromDiscord | <ambient> In reply to @Gumbercules "https://blog.johnnovak.net/2017/04/22/nim-performan": Microbenchmarks are worse than benchmarks |
16:47:56 | FromDiscord | <jmgomez> In reply to @pyolyokh ""fair" Nim is also": Especially if you dont, Nim can be faster than raw cpp |
16:48:09 | Amun-Ra | ambient: that depends what do you need… I'm writing image viewer atm, speed doesn't matter to me that much |
16:48:11 | FromDiscord | <Gumbercules> And it's not difficult to get close to C performance |
16:48:41 | FromDiscord | <Gumbercules> I can go write code in any language with no idea wtf I'm doing and write a poorly performing program |
16:48:48 | FromDiscord | <Gumbercules> Nim isn't special in this regard |
16:49:01 | FromDiscord | <Recruit_main707> In reply to @Gumbercules "I can go write": relatable |
16:49:21 | FromDiscord | <ambient> Well Rust makes it easy to write fast code. You have to include the parameter that matters the most: the average programmer |
16:49:27 | FromDiscord | <Recruit_main707> not knowing what im doing is programming language agnostic in my case tho |
16:49:28 | FromDiscord | <Gumbercules> If you want to remain convinced it has similar performance to C# when everyone and their grandma is telling you you're mistaken, that's on you |
16:49:31 | FromDiscord | <jmgomez> In reply to @ambient "https://programming-language-benchmarks.vercel.app/": I wouldnt infer from there that C# and Nim are equally faster. If you want to see them compete in the context of a big application. Compare UnrealCLR with NimForUE |
16:49:32 | FromDiscord | <Gumbercules> Go use rust then |
16:50:07 | FromDiscord | <ambient> In reply to @Gumbercules "If you want to": Like I said, if you have information I would like to see it |
16:50:28 | FromDiscord | <Gumbercules> You don't have information besides some random ass benchmark and your intuition |
16:50:39 | FromDiscord | <Gumbercules> Several of us have had this same debate with other people |
16:50:44 | FromDiscord | <ambient> In reply to @Gumbercules "You don't have information": Which is why I'm not making claims but asking questions |
16:50:53 | FromDiscord | <Gumbercules> You're not asking questions though |
16:50:59 | FromDiscord | <Gumbercules> You're telling us the way it is |
16:51:03 | FromDiscord | <Recruit_main707> how about other benchmarks? |
16:51:06 | FromDiscord | <Gumbercules> And then saying why Rust is better |
16:51:21 | Amun-Ra | "rust" and "makes it easy" rarely come in one sentence ;> |
16:51:26 | FromDiscord | <Recruit_main707> Ive always seen some weird numbers on that web you shared |
16:51:26 | FromDiscord | <Gumbercules> Go use Rust then if you're so convinced |
16:51:46 | FromDiscord | <Recruit_main707> Quite different to those in most other benchmarks |
16:52:01 | FromDiscord | <Recruit_main707> and i can tell you ive been obsessed with performance quite a lot |
16:52:16 | FromDiscord | <Gumbercules> It's a waste of time to sit here and post / compare benchmarka |
16:52:26 | FromDiscord | <pyolyokh> In reply to @ambient "Well Rust makes it": what Rust actually does it make it possible, with the borrow checker, for library writers to offer interfaces that are fast while not being too unsafe to be the default interface. I wouldn't say "easy" for either authors or users. But that's possible where the realistic alternatives in Nim are a) a safe not-as-fast interface, b) an as-fast interface that you can cut yourself on |
16:52:47 | FromDiscord | <Recruit_main707> wasnt going to, ive got other more important things to waste my time, like studying :/ |
16:52:47 | FromDiscord | <ambient> Everything is a tradeoff, and we have to make decisions based on insufficient information. I have some experience and based on that experience I try to make good decisions. Sharing what I have as a starting point to figure out where I have to look to understand the situation better doesn't seem to me an unreasonable thing to do. |
16:52:55 | FromDiscord | <Gumbercules> I just linked to a blog post explaining optimization techniques commonly used with Nim and you didn't even read it |
16:53:40 | FromDiscord | <demotomohiro> Here is another language benchmark: https://github.com/niklas-heer/speed-comparison |
16:53:55 | FromDiscord | <ambient> In reply to @Gumbercules "I just linked to": I have read it before and I skimmed it enough to see micro benchmarks and JIT warmup (which is a pointless metric for most my usecases) |
16:54:00 | FromDiscord | <pyolyokh> a handy example of that is <https://forum.nim-lang.org/t/9688> , where cligen gives you speed but you now have to care about the lifetime of its slices. |
16:54:38 | FromDiscord | <Recruit_main707> In reply to @demotomohiro "Here is another language": first benchmark i see fortran leading for once 🥴 |
16:55:03 | FromDiscord | <pyolyokh> that should tell you that allocation isn't going to be the issue with the benchmark |
16:56:59 | FromDiscord | <Gumbercules> In reply to @ambient "I have read it": But benchmarks are going to make you write faster code in Nim? |
16:57:17 | FromDiscord | <Gumbercules> You realize that benchmarks are s** because people can do things to optimize the result right? |
16:57:40 | FromDiscord | <Gumbercules> So you're saying you want to language where it's easy to write performant code without knowing what you're doing |
16:57:46 | FromDiscord | <Gumbercules> And you want benchmarks to back that up |
16:58:14 | FromDiscord | <pyolyokh> even derisively I wouldn't use "easy" with Rust ... |
16:58:43 | FromDiscord | <ambient> In reply to @Gumbercules "But benchmarks are going": Benchmarks give an idea of the ceiling what a language can achieve. Also useful information I would like to have is how many hoops I have to jump through to write optimal code. |
16:58:45 | FromDiscord | <pyolyokh> you can use a library that won't let your code compile unless it's performant, while you don't know what you're doing. That's pretty good. |
16:59:05 | FromDiscord | <Gumbercules> In reply to @ambient "Benchmarks give an idea": You have to jump through as many hoops with name as any other language because you need to know what the f you're doing |
16:59:28 | FromDiscord | <Gumbercules> It's easy to write a s** program in C if you don't know what you're doing |
16:59:37 | FromDiscord | <Gumbercules> Just like every other language |
17:00:25 | FromDiscord | <ambient> Well so far I have failed to phrase my questions in a way that would create any useful response |
17:00:30 | FromDiscord | <Gumbercules> Why don't you write a program in Rust |
17:00:38 | FromDiscord | <Gumbercules> And write the equivalent in Nim |
17:00:46 | FromDiscord | <Gumbercules> And draw your own conclusions? |
17:01:00 | FromDiscord | <ambient> I already did write my program in Rust, and I'm going to write it in Nim |
17:01:02 | FromDiscord | <Gumbercules> That would probably be 1000 times more effective than staring at benchmarks |
17:01:09 | FromDiscord | <pyolyokh> In reply to @ambient "Benchmarks give an idea": well there are two benchmarks just above. Number-heavy stuff: Nim = Rust. Allocation-heavy stuff: Nim = C#. If C# is unacceptably slow for you, that's a thing to consider. You can look at that forum link, and cligen, to see the kind of stuff you might have to do in the second case. |
17:01:35 | FromDiscord | <Gumbercules> The you can ask questions about why one program is slower / binary is larger / whatever |
17:01:41 | FromDiscord | <Gumbercules> And get actual answers |
17:01:41 | FromDiscord | <ambient> but there are many unknowns unknowns that I'm trying to figure out and I assume people here could help with that |
17:01:54 | FromDiscord | <Gumbercules> Well we can when we have code to look at |
17:02:00 | FromDiscord | <Gumbercules> Until then it's just conjecture |
17:02:07 | FromDiscord | <ambient> It's commercial/propertiary atm |
17:03:11 | FromDiscord | <Gumbercules> I can't help you there. I think there are a plethora of examples of questions like this on the forums though |
17:03:28 | FromDiscord | <Gumbercules> Like why doesn't my program perform as well as this python program? |
17:03:42 | FromDiscord | <Gumbercules> And then pages of people replying and explaining why |
17:04:25 | FromDiscord | <Gumbercules> Very rarely is the answer because Nim is slow and memory is managed |
17:04:44 | FromDiscord | <Gumbercules> And I'd you're still dissatisfied you can always ditch automatic memory management and roll your own |
17:04:57 | FromDiscord | <Gumbercules> Just be prepared to not use any strings or sequences |
17:05:19 | FromDiscord | <ambient> if seqs are just dynamic arrays, they are plenty fast when pre-allocated |
17:05:53 | FromDiscord | <ambient> both C++ and Rust use them as the base data struct |
17:06:02 | FromDiscord | <pyolyokh> yeah, just a small bit of care can really benefit like that. |
17:06:22 | FromDiscord | <demotomohiro> If you pre-allocate heap of seq: https://nim-lang.org/docs/system.html#newSeqOfCap,Natural |
17:10:29 | FromDiscord | <pyolyokh> sent a long message, see https://paste.rs/5BL |
17:11:12 | FromDiscord | <ambient> Well why I'm personally trying it out is that it's easy to do exploratory code and easy to write very good abstractions to complex problems, while Rust makes it quite slow to write code and it's a lot of work to re-order the core logic |
17:11:21 | FromDiscord | <pyolyokh> with Rust, people could write the easy/unsafe (c) libraries, but for cultural reasons they won't. They'll only write safe libraries, and it's never quite as easy |
17:11:40 | FromDiscord | <ambient> Only place I need unsafe in Rust is user input, that's it |
17:15:42 | FromDiscord | <Gumbercules> In reply to @ambient "if seqs are just": This wasn't my point |
17:16:05 | FromDiscord | <Gumbercules> If you decide to ditch Nims automatic memory management, Nim sequences and strings won't work |
17:16:09 | FromDiscord | <ambient> I understood that after I wrote it, but I'm also not going to use a language that doesn't have some form of seq |
17:16:18 | FromDiscord | <Gumbercules> You'd need to bring your own stdlib |
17:16:33 | FromDiscord | <Gumbercules> Well you can roll your own |
17:16:40 | FromDiscord | <Gumbercules> But yeah... It's work |
17:16:42 | FromDiscord | <ambient> F that |
17:16:55 | FromDiscord | <jmgomez> Or bind one from the cpp std |
17:16:57 | FromDiscord | <Gumbercules> Eh in some spaces people don't have much of a choice |
17:17:06 | FromDiscord | <ambient> I'm not on embedded |
17:17:11 | FromDiscord | <Gumbercules> Yeah or use some C/C++ lib |
17:17:27 | FromDiscord | <Gumbercules> Fair, just pointing out that the GC is opt-in |
17:17:40 | FromDiscord | <Gumbercules> With some fairly substantial consequences of not doing so |
17:18:21 | FromDiscord | <ambient> at some point people are just going to tell me to rewrite the entirety of Nim to suit my usecase |
17:18:22 | FromDiscord | <Gumbercules> I've been writing Nim for seven years and others longer than me |
17:18:30 | FromDiscord | <jmgomez> I feel like it's under appreciated what I just said. You can have full generic support in a few lines of code binding |
17:18:42 | FromDiscord | <Gumbercules> If it had performance characteristics of C# we'd be long gone |
17:18:50 | FromDiscord | <ambient> Well that's fair |
17:19:20 | FromDiscord | <Gumbercules> Well Nim being hackable and malleable and extensible is one of it's strengths |
17:19:23 | FromDiscord | <ambient> C# is fairly fast tho, and stuff like https://github.com/bflattened/bflat do look pretty neat |
17:20:11 | FromDiscord | <Gumbercules> If you like writing object oriented code sure |
17:20:43 | FromDiscord | <Gumbercules> I'm not a fan of C# or Golang after having used both for work |
17:21:00 | FromDiscord | <Gumbercules> Wouldn't touch either for hobby time |
17:21:13 | FromDiscord | <ambient> From ergonomics perspective Nim is far ahead, I agree |
17:21:16 | FromDiscord | <pyolyokh> and you can 'abandon the GC' in narrow parts of your program where it matters. It's the same argument people use with Python, but it applies much better here. See that csv-parsing thread. The mslice code is using completely different memory management but after you've parsed everything as fast as possible you can go right back to normal Nim. |
17:21:51 | FromDiscord | <ambient> In reply to @pyolyokh "and you can 'abandon": Link thread? |
17:22:29 | FromDiscord | <pyolyokh> In reply to @pyolyokh "a handy example of": there |
17:23:55 | * | pro joined #nim |
17:24:12 | FromDiscord | <pyolyokh> cblake's post, specifically |
17:24:17 | * | pro quit (Client Quit) |
17:24:19 | FromDiscord | <ambient> In reply to @jmgomez "I feel like it's": Is there some example code how to achieve this? |
17:25:06 | FromDiscord | <Gumbercules> In reply to @jmgomez "I feel like it's": I appreciate it but most people aren't interoping with cop |
17:25:13 | FromDiscord | <Gumbercules> (edit) "cop" => "cpp" |
17:25:24 | FromDiscord | <Gumbercules> That's quite the advanced use case |
17:25:51 | FromDiscord | <ambient> I have a need to interop with some huge legacy CPP libs that are awful |
17:26:09 | FromDiscord | <Ailuros 💖🧡💛💚💙💜🖤> sent a code paste, see https://play.nim-lang.org/#ix=4kF3 |
17:26:33 | FromDiscord | <Gumbercules> Well Nim can do it, but C++ interop / codegen is probably one of the more frustrating areas of using Nim |
17:27:06 | FromDiscord | <jmgomez> In reply to @ambient "Is there some example": https://scripter.co/binding-nim-to-c-plus-plus-std-list/↵There is a std repo that someone started out with a few examples and also NimForUE is full of that stuff |
17:27:22 | FromDiscord | <Gumbercules> jmgomez is probably an expert at making the cpp backend behave at this point |
17:27:36 | FromDiscord | <ambient> Thanks, I have a lot of reading to do |
17:28:30 | FromDiscord | <jmgomez> In reply to @Gumbercules "jmgomez is probably an": let's say it's kinda tamed almost a year later 😛 |
17:28:47 | FromDiscord | <Gumbercules> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "Hey all, through trial": Address sanitizer or valgrind |
17:28:57 | FromDiscord | <Gumbercules> With -d:useMalloc |
17:29:11 | FromDiscord | <ambient> is Nim CPP binding platform independent? |
17:29:22 | FromDiscord | <ambient> or do I have to include some if else compile time trickery? |
17:29:27 | FromDiscord | <demotomohiro> There is Nim bindings for the C++ STL: https://github.com/Clonkk/nim-cppstl |
17:29:52 | FromDiscord | <jmgomez> In reply to @demotomohiro "There is Nim bindings": That's the one I was referring too I forgot about the name |
17:31:31 | FromDiscord | <jmgomez> In reply to @ambient "is Nim CPP binding": For the most part you should be fine. There a few edge cases, i.e. we have Unreal bindings working in Mac (clang) and Win (msvc) and there arent much bifurcations on the Nim code (OC the cpp code it is platform dep) |
17:39:18 | FromDiscord | <Ailuros 💖🧡💛💚💙💜🖤> In reply to @Gumbercules "Address sanitizer or valgrind": am currently developing/testing on Windows, doesn't look like I can easily use valgrind (not sure about address sanitizer 😮 )↵can check if maybe I can easily reproduce under linux |
17:39:59 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kF9 |
17:44:42 | FromDiscord | <ambient> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "am currently developing/testing on": Yeah I'm also on Windows and am figuring out if I have to write my own debug code generator/objdump parser thing |
17:57:14 | FromDiscord | <auxym> In reply to @4zv4l "I don't know if": you should use `byte(u shr xx)` instead of the cast. the fact that the cast works is likely accidental because you are on a LE machine is the LSB is at the lowest address. |
17:58:35 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How would i make a modifiable, compile-time and global table? |
17:59:25 | FromDiscord | <@thatrandomperson5-6310e3b26da03> with a NimNode arg |
17:59:30 | FromDiscord | <auxym> Also https://justine.lol/endian.html recommends masking before the shift, mostly sign extension issues, but it might not be necessary if you're only doing unsigned (the conversion to byte should overflow to the correct result |
18:00:48 | FromDiscord | <auxym> In reply to @@thatrandomperson5-6310e3b26da03 "How would i make": you can make a macro that returns a `var ...` definition using table-initialization syntax |
18:01:07 | FromDiscord | <auxym> https://nim-lang.org/docs/manual.html#statements-and-expressions-table-constructor |
18:01:27 | FromDiscord | <auxym> put that into dumpTree to see the AST, then make a macro that generates that AST |
18:01:40 | * | pro joined #nim |
18:01:50 | * | pro quit (Client Quit) |
18:03:01 | FromDiscord | <auxym> `dumpTree: var myTable = {"key1": "value1", "key2": "value2"}.toTable |
18:03:12 | FromDiscord | <auxym> (edit) ""value2"}.toTable" => ""value2"}.toTable`" |
18:12:47 | FromDiscord | <Gumbercules> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "am currently developing/testing on": Asan should work |
18:13:07 | FromDiscord | <Gumbercules> Not sure which compiler tool chain you're using |
18:14:07 | * | pro joined #nim |
18:14:47 | * | pro quit (Client Quit) |
18:23:57 | * | pro joined #nim |
18:25:30 | * | pro left #nim (#nim) |
18:27:17 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kFl |
18:29:23 | FromDiscord | <enthus1ast> the kind cannot be changed later, you must put this in the object constructor |
18:29:45 | FromDiscord | <enthus1ast> myObj(kind\: rnkRegister) |
18:30:49 | FromDiscord | <auxym> ah. is that new in 1.6.10? Never encountered it before, pretty sure I have discriminant assignments littered all over my codebases |
18:30:53 | FromDiscord | <Ailuros 💖🧡💛💚💙💜🖤> In reply to @Gumbercules "Asan should work": Just got it running in linux container with valgrind: |
18:31:12 | FromDiscord | <enthus1ast> think this is since a few versions |
18:31:18 | FromDiscord | <Ailuros 💖🧡💛💚💙💜🖤> Now I have to look at what this means 😄 https://media.discordapp.net/attachments/371759389889003532/1061713725440131082/message.txt |
18:32:55 | FromDiscord | <Ailuros 💖🧡💛💚💙💜🖤> Does this mean that the memory at that address was "free'd" by GC, or something else entirely:↵==4815== Address 0x4a24940 is 0 bytes inside a block of size 248 free'd |
18:36:43 | FromDiscord | <@thatrandomperson5-6310e3b26da03> @auxym) |
18:36:52 | FromDiscord | <ambient> Turns out it wasn't Nim that was broken, it was my profiler after Windows update 🤦♂️ https://media.discordapp.net/attachments/371759389889003532/1061715122973851778/sleepy_z5dADHaYgv.png |
18:37:06 | FromDiscord | <auxym> In reply to @@thatrandomperson5-6310e3b26da03 "> you can make": if you can the macro from the global scope, yes |
18:37:41 | FromDiscord | <auxym> well it will at the module scope, nim doesn't have "true" globals |
18:38:13 | FromDiscord | <auxym> (edit) "can" => "call it" |
18:38:54 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Ill try, but remember is has to be accessible at compile-time from other macros↵(@auxym) |
18:41:15 | FromDiscord | <auxym> hm I'm not sure you'll have access to the table from other macros |
18:41:40 | FromDiscord | <auxym> you can write a regular proc that takes NimNode and returns a table though. |
18:42:43 | FromDiscord | <4zv4l> In reply to @auxym "you should use `byte(u": But I get an error with that because the number is too big to enter in a uint8 |
18:43:24 | FromDiscord | <scipio> https://media.discordapp.net/attachments/371759389889003532/1061716770215432353/image.png |
18:43:25 | FromDiscord | <auxym> In reply to @4zv4l "But I get an": then mask it, before the shift |
18:43:29 | FromDiscord | <scipio> here we go 😉 |
18:46:42 | FromDiscord | <4zv4l> In reply to @auxym "then mask it, before": Mask ? |
18:46:50 | FromDiscord | <jmgomez> In reply to @@thatrandomperson5-6310e3b26da03 "Ill try, but remember": use `macrocache` |
18:47:12 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kFq |
18:50:24 | om3ga | internal error: genAssignment: tyUncheckedArray <--- This is bad, right? |
18:59:33 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/ZHc |
19:00:08 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/Zrs |
19:00:09 | FromDiscord | <4zv4l> this one works then |
19:00:17 | FromDiscord | <4zv4l> but having to precise the type is sick |
19:00:20 | FromDiscord | <auxym> `'u32` is shorter but yeah |
19:01:23 | FromDiscord | <4zv4l> In reply to @auxym "`'u32` is shorter but": this syntax is nice tho |
19:01:30 | FromDiscord | <⚶ Zeno> i use `<whatever> shr <24/16/8/0> and 0xFF`, you can use that |
19:01:36 | FromDiscord | <⚶ Zeno> (edit) "i use `<whatever> shr <24/16/8/0> and 0xFF`, you can use that ... " added "for your purpose" |
19:01:40 | FromDiscord | <⚶ Zeno> i think it seems more |
19:01:42 | FromDiscord | <⚶ Zeno> readable |
19:01:43 | FromDiscord | <⚶ Zeno> (edit) "readable ... " added "?" |
19:01:48 | FromDiscord | <4zv4l> why don't they directly keep that for the type name ?↵`u8` instead of `uint8`↵`i8` instead of `int8` |
19:02:34 | FromDiscord | <auxym> you can define them yourself if you want that. `type i8 = int8` |
19:03:50 | FromDiscord | <4zv4l> well yeah, extra work xD |
19:04:41 | FromDiscord | <4zv4l> sent a long message, see http://ix.io/4kFu |
19:05:08 | FromDiscord | <auxym> i guess most people don't feel the need? If you want it it |
19:05:32 | FromDiscord | <auxym> it's like 8 lines, publish it on nimble and it's just an import away anytime you want it |
19:05:38 | FromDiscord | <ambient> ushort, ulong, uwhatever |
19:05:59 | FromDiscord | <ambient> uint seems much more exact and is fast to type |
19:06:14 | FromDiscord | <4zv4l> In reply to @auxym "it's like 8 lines,": yeah, I need to understand how nimble do to find a packet github without even knowing it's from github |
19:06:27 | FromDiscord | <4zv4l> (edit) "packet" => "package on " |
19:06:44 | FromDiscord | <4zv4l> or it doesn't↵idk |
19:06:46 | FromDiscord | <4zv4l> I'll check |
19:07:46 | FromDiscord | <4zv4l> is nimble like the go package manager ?↵like doesn't rely on any special platform ? |
19:07:53 | FromDiscord | <auxym> In reply to @4zv4l "yeah, I need to": nimble has a registry, you have to PR it if you want to get on there |
19:08:05 | FromDiscord | <auxym> otherwise you can `nimble install` a github url directly |
19:08:07 | FromDiscord | <4zv4l> oh, no way to do it decentralised ? |
19:08:14 | FromDiscord | <4zv4l> perfect |
19:08:42 | FromDiscord | <auxym> https://github.com/nim-lang/packages |
19:10:19 | FromDiscord | <pyryrin> when to use `object` and when `ref object`? |
19:12:36 | FromDiscord | <auxym> In reply to @pyryrin "when to use `object`": https://internet-of-tomohiro.netlify.app/nim/faq.en.html#type-when-to-use-ref-object-vs-plain-object-qmark |
19:13:26 | FromDiscord | <auxym> usually plain object by default unless you have a specific reason to need ref |
19:13:29 | FromDiscord | <jtv> ref essentially means when you pass it around, anyone that can access the fields can set the fields. Without ref, people will get copying semantics, unless passed to a parameter of type var YourObject |
19:14:06 | * | arkurious quit (Read error: Connection reset by peer) |
19:14:23 | FromDiscord | <jtv> The language is smart enough to not do extra copying unless necessary, so definitely good not to use ref by default |
19:15:08 | FromDiscord | <jmgomez> I would empathize that ref is stored on the heap and object is stored on the stack though |
19:16:15 | FromDiscord | <jtv> I don't think that's strictly true, is it? The language automatically figures out based on the context. And certainly if you have a non-ref object embedded in a ref object you still get the same semantics |
19:17:44 | FromDiscord | <auxym> yes, it is strictly true, to the best of my knowledge |
19:18:05 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/rap |
19:18:05 | FromDiscord | <pyryrin> should it be ref object if the type contains string or some dynamic memory types? because they take long to copy? |
19:18:16 | FromDiscord | <4zv4l> is that normal ? or distinct is for when passing to a function ? |
19:18:44 | FromDiscord | <jtv> No, that's not a consideration |
19:19:37 | FromDiscord | <4zv4l> wdym ? |
19:21:00 | FromDiscord | <auxym> I think they were replying to @pyryrin |
19:21:24 | FromDiscord | <auxym> @4zv4l I'm not sure how typeof handles aliases. |
19:21:25 | FromDiscord | <pyryrin> i dont understand what he mean |
19:22:03 | FromDiscord | <auxym> he means that performance should not be a consideration when choosing between ref or plain object |
19:22:29 | FromDiscord | <auxym> (IMO: in some cases it could be a consideration, but by default you should still use plain object) |
19:22:49 | FromDiscord | <pyryrin> i thought the whole point was performance |
19:25:55 | FromDiscord | <jtv> No, it's more about mutability |
19:26:29 | FromDiscord | <auxym> the point is many-to-one relationships, heap storage (stack may be size limited), OOP, and sometimes performance |
19:26:34 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Can you use the borrow pragma on an iterator? |
19:26:41 | FromDiscord | <jtv> It can occasionally make a difference, but objects are not copied if you pass them around, tuntil there's an assignment |
19:27:11 | FromDiscord | <auxym> refs can also be slower in some cases, because of allocation and deallocation overhead. hence it should be on a case by case basis |
19:27:51 | FromDiscord | <cow> refs can also be faster, for example if you have many of them in a seq |
19:28:22 | FromDiscord | <cow> (edit) "refs can also be faster, for example if ... you" added "they hold a lot of data" |
19:28:30 | FromDiscord | <cow> (edit) "refs can also be faster, for example if they hold a lot of data ... you" added "and" |
19:28:34 | FromDiscord | <jtv> Yeah, lots of small allocations and deallocations can always be an issue, but generally it won't matter in most cases. Good optimization practices are to build the most natural way, and then profile and optimize based on actual data |
19:28:48 | FromDiscord | <jtv> Instead of guessing about your bottlenecks 🙂 |
19:29:16 | FromDiscord | <cow> and with cpu caches, large objects can fill the cache with junk |
19:29:42 | FromDiscord | <cow> it's hard to reason about yeah |
19:29:47 | FromDiscord | <jtv> Yes, there's so much complexity beneath the abstractions you're using, it's much better to use data |
19:30:46 | FromDiscord | <jtv> And "conventional wisdom" on what's faster is often YEARS out of date due to various changes under the various hoods of all the things you're building on top of |
19:31:08 | FromDiscord | <auxym> In reply to @jtv "Yeah, lots of small": agreed entirely |
19:32:53 | FromDiscord | <cow> In reply to @jtv "No, it's more about": and ownership i guess, if ownership is unclear and GC is needed |
19:35:16 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How do i make a compile time var, not const, i keep on getting “Cannot evaluate at compile time” |
19:36:07 | FromDiscord | <jtv> Well, depends on the context, like if you're calling a function from a macro, you don't have to do anything. But you can just do a `static:` block and do a var in it |
19:37:01 | FromDiscord | <@thatrandomperson5-6310e3b26da03> But then it’s not global context and my procs can’t find it↵(@jtv) |
19:37:27 | FromDiscord | <jtv> Yeah, sure, because it's compile-time |
19:37:39 | FromDiscord | <jtv> Set at compile time but available at run-time is what const is for |
19:38:18 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kFF |
19:38:37 | FromDiscord | <jtv> If you do const x = someCode(), someCode() gets run at compile time |
19:38:50 | FromDiscord | <jtv> Otherwise, x could never hold a const 🙂 |
19:39:20 | FromDiscord | <jtv> const variables get put in a section of the binary that is absolutely read-only. |
19:40:33 | FromDiscord | <@thatrandomperson5-6310e3b26da03> > ↵> If you do const x = someCode(), someCode() gets run at compile time↵> I need to call some procs on x that require `var x` |
19:40:57 | FromDiscord | <jtv> Yeah, have somefunc() declare it as a var. |
19:42:12 | FromDiscord | <enthus1ast> thatrandomperson5 (not logged in or am I? )\:↵https://play.nim-lang.org/#ix=4kFH |
19:42:17 | FromDiscord | <@thatrandomperson5-6310e3b26da03> sent a code paste, see https://paste.rs/oOR |
19:42:38 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How?↵(@jtv) |
19:44:14 | FromDiscord | <jtv> https://play.nim-lang.org/#ix=4kFI |
19:44:41 | FromDiscord | <jtv> The computeAtCompileTime() function is where your compile time code would go |
19:45:13 | FromDiscord | <jtv> And as long as it only calls things that CAN run at compile time, then it will work and be compile time code, even if it looks like 'normal' code |
19:45:22 | FromDiscord | <enthus1ast> thatrandomperson5 (not logged in or am I? )\: wanted a compile time global or? |
19:45:35 | FromDiscord | <jtv> You will get an obvious error if you do something that cannot be done at compile time |
19:50:43 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Just found out the hanging is unrelated to this issue, thanks for the help |
20:20:04 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kFR |
20:21:05 | FromDiscord | <enthus1ast> you could overload `=` |
20:22:13 | FromDiscord | <4zv4l> it wouldn't use the heap right ? |
20:22:24 | FromDiscord | <4zv4l> since the string is hard coded |
20:23:04 | FromDiscord | <jtv> https://play.nim-lang.org/#ix=4kFS |
20:23:16 | FromDiscord | <jtv> You can skip the const if you make it a macro or template |
20:26:18 | FromDiscord | <enthus1ast> sent a code paste, see https://paste.rs/rdw |
20:26:27 | FromDiscord | <4zv4l> In reply to @jtv "https://play.nim-lang.org/#ix=4kFS": idk if you checked the result but |
20:26:30 | FromDiscord | <4zv4l> doesn't work for me |
20:26:30 | FromDiscord | <4zv4l> xD |
20:26:44 | FromDiscord | <4zv4l> In reply to @enthus1ast "mh seems that overloading": hmmmmm |
20:26:55 | FromDiscord | <4zv4l> well it's alright↵was just for testing |
20:28:48 | FromDiscord | <jtv> No I didn't, try this: https://play.nim-lang.org/#ix=4kFW |
20:28:52 | FromDiscord | <enthus1ast> = does not work but |
20:28:59 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kFY |
20:29:20 | FromDiscord | <enthus1ast> maybe there is a way with = but idk |
20:30:24 | FromDiscord | <jtv> IDK shouldn't take long to figure out, the library def has a way to go from a string to an array of bytes, just need to look it up |
20:30:34 | FromDiscord | <jtv> And then a macro or whatever will work fine |
20:31:37 | FromDiscord | <enthus1ast> or a little bit more type explicit\: |
20:31:45 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kG0 |
20:36:32 | FromDiscord | <huantian> Why are you overloading = |
20:36:44 | FromDiscord | <huantian> Can’t we just make a proc that converts a static string to an array |
20:37:39 | FromDiscord | <enthus1ast> because he asked↵(@4zv4l) |
20:38:05 | FromDiscord | <enthus1ast> yeah↵(@huantian) |
20:38:07 | FromDiscord | <4zv4l> yeah I wanted something c-like |
20:38:11 | FromDiscord | <4zv4l> xD |
20:38:41 | FromDiscord | <4zv4l> sorry for bothering 👉 👈 xD |
20:39:01 | FromDiscord | <jtv> Uh, just use cstring then? |
20:39:45 | FromDiscord | <jtv> I mean, even the string type is just going to be an array of chars w/ an extra field for length. Converting to a cstring just returns a pointer to the start of the array |
20:40:04 | FromDiscord | <jtv> So ask yourself why you want to do this 🙂 |
20:41:42 | FromDiscord | <4zv4l> but cstring in Nim are still on the heap right ? |
20:41:58 | Zevv | s[0].addr is your array[char] |
20:42:02 | Zevv | on the heap |
20:42:27 | Zevv | well, no guarentees btw about that. |
20:42:28 | FromDiscord | <4zv4l> but since the string is hard coded↵would still be on the heap ? |
20:42:37 | Zevv | right |
20:42:40 | FromDiscord | <4zv4l> not be a pointer to the string in the binary in rodata ? |
20:42:43 | Zevv | or even on the stack, if it comes from C |
20:42:47 | Zevv | you can't tell. it's just a pointer |
20:42:53 | FromDiscord | <jtv> If you declare it as a local, and there's no chance a reference is leaving the function, nim should stick it on the stack |
20:43:00 | FromDiscord | <jtv> If it's a string |
20:43:17 | Zevv | check the C source for that |
20:43:52 | FromDiscord | <jtv> I know there's definitely been work on lifetime analysis to do such things. Might only be ARC/ORC work though, IDK |
20:44:24 | Zevv | strings in nim do not go on the stack |
20:44:37 | Zevv | check the generated C code |
20:44:53 | Zevv | https://play.nim-lang.org/#ix=4kG5 |
20:45:29 | Zevv | global: `static const struct {NI cap; NIM_CHAR data[5+1]; } ... = { 5 | NIM_STRLIT_FLAG, "Hello" }; |
20:45:48 | Zevv | and that "Hello" will be put in .rodata by the C compiler, typically |
20:46:08 | FromDiscord | <4zv4l> how can I check the C code↵in `.cache/nim/<folder>/.c` ? |
20:46:15 | Zevv | yes |
20:46:25 | Zevv | the file names suck though |
20:46:37 | Zevv | foo.nim will be @mfoo.nim.c |
20:47:21 | Zevv | if you've never looked at nim generated C: it's not a fun job |
20:47:38 | FromDiscord | <4zv4l> yes I see that |
20:47:38 | FromDiscord | <4zv4l> xD |
20:47:39 | Zevv | but it's not ment for reading, right |
20:47:40 | FromDiscord | <4zv4l> ahahahah |
20:47:52 | Zevv | after the first few weeks your eys will stop bleeding |
20:48:00 | FromDiscord | <4zv4l> I don't find the NimMain |
20:48:07 | FromDiscord | <4zv4l> if that's where the code is supposed to be |
20:48:10 | FromDiscord | <4zv4l> but↵` STRING_LITERAL(TMPwklBah9a4x1aFG9cTW1Wh5Q_2, "Hello, World !", 14);` |
20:48:22 | Zevv | it's there |
20:48:23 | Zevv | look for `N_CDECL(void, NimMain)(void)` |
20:49:15 | FromDiscord | <4zv4l> pattern not found |
20:49:16 | FromDiscord | <4zv4l> xD |
20:49:29 | FromDiscord | <4zv4l> `N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) ` |
20:49:30 | FromDiscord | <4zv4l> this ? |
20:49:33 | Zevv | you and I are on different nim versions, so you're probably right |
20:49:37 | Zevv | just follow from C main() |
20:50:03 | FromDiscord | <4zv4l> `N_CDECL(void, NimMain)(void)` |
20:50:04 | FromDiscord | <4zv4l> this |
20:50:06 | FromDiscord | <4zv4l> I guess |
20:50:22 | Zevv | main() -> NimMain() -> PreMain() + NimMainInner() -> NimMainModule() |
20:50:46 | FromDiscord | <4zv4l> oh my eyes |
20:50:47 | FromDiscord | <4zv4l> xD |
20:50:53 | Zevv | the C compiler will throw most of that away. C compilers are amazing |
20:50:55 | FromDiscord | <4zv4l> https://tenor.com/view/my-eyes-spongebob-squarepants-spongebob-my-eyes-gif-13564660 |
20:51:39 | FromDiscord | <4zv4l> In reply to @Zevv "the C compiler will": indeed ! |
20:53:09 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/rWX |
20:53:09 | FromDiscord | <4zv4l> and the loop and echo ? |
20:53:11 | FromDiscord | <4zv4l> i've no idea |
20:53:13 | FromDiscord | <4zv4l> xD |
20:53:25 | FromDiscord | <4zv4l> I tried to look for `echo` |
20:53:26 | Zevv | all the steps are there for you to inspect |
20:53:40 | Zevv | `echoBinSafe()` |
20:55:59 | * | jvinet quit (Remote host closed the connection) |
20:56:23 | FromDiscord | <4zv4l> that's in another file right ? |
20:57:14 | Zevv | that'll be in ...system.nim.c |
20:58:35 | Zevv | it basically collapses to fwrite() of your data followed by fwrite() of a newline, with a lock around it |
21:01:28 | FromDiscord | <System64 ~ Flandre Scarlet> Hi↵https://plugins.jetbrains.com/plugin/15128-nim↵Is this plugin good? |
21:21:47 | FromDiscord | <ElegantBeef> sent a code paste, see https://paste.rs/RJX |
21:43:56 | FromDiscord | <sabrus> Hi, is there an compiler option in Nim to open an interactive console (a.k.a REPL) with the results of compiling the module, as in python -i my_awesome_module.py ? |
21:45:03 | FromDiscord | <EyeCon> In reply to @sabrus "Hi, is there an": If you install inim, you can do (IIRC) `inim -s myfile.nim` |
21:45:07 | FromDiscord | <jtv> That I don't know, but on nimble there's a package called "inim" which gives you an interactive shell. It's not quite the same because, for instance, once you define a var in the global namespace, you can't redefine the type. And it's got some oddities for entering functions on the command line |
21:45:11 | FromDiscord | <jtv> But it's good enough |
21:45:52 | FromDiscord | <sabrus> In reply to @EyeCon "If you install inim,": thx ! |
22:20:01 | FromDiscord | <sOkam!> I heard the statement that if you use gc:none, you "lose access to std libraries"↵How can I know which parts of std/ are going to be out of reach, or which parts would work, in more practical terms? |
22:27:48 | FromDiscord | <Elegantbeef> If the module or types use `seq` or `string` or `ref` it's going to be off limits |
22:28:01 | FromDiscord | <Elegantbeef> When you use something that isnt freed with `gc:none` the compiler tells you |
22:28:14 | FromDiscord | <Elegantbeef> Though yet again i would suggest using `--gc:arc` even if you're learning manual memory management |
22:36:00 | FromDiscord | <sOkam!> why arc for mm? |
22:36:53 | FromDiscord | <Elegantbeef> Cause it's identical to manually managing memory |
22:37:04 | FromDiscord | <Elegantbeef> you can still use the stdlib and `ref` |
22:37:15 | FromDiscord | <Elegantbeef> well everything that's not cyclic |
22:37:53 | FromDiscord | <sOkam!> but isn't arc automatic memory management in some way? |
22:38:09 | FromDiscord | <Elegantbeef> Arc is literally identical to what you'd do with manual memory management |
22:39:27 | FromDiscord | <sOkam!> i don't get why, i thought arc was reference counting |
22:39:36 | FromDiscord | <Elegantbeef> Arc inserts destructors |
22:39:50 | FromDiscord | <Elegantbeef> So you can manual manage memory without having to manually calling `destroy` |
22:41:06 | FromDiscord | <sOkam!> im not sure if i understand enough of the topic to grasp the implications of what you mean |
22:41:20 | FromDiscord | <Elegantbeef> Arc means you do not need to manually call destructors |
22:41:25 | FromDiscord | <Elegantbeef> You can write hooks and handle things sanely |
22:45:07 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How to i prevent xmlparser from stripping the text data, i need it un-stripped |
22:47:04 | FromDiscord | <Gumbercules> In reply to @sOkam! "im not sure if": Without arc / orc you need to make your own heap allocations with alloc |
22:47:09 | FromDiscord | <Gumbercules> And company |
22:47:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kGr |
22:47:20 | FromDiscord | <Gumbercules> And subsequently free them |
22:47:34 | * | adium quit (Ping timeout: 260 seconds) |
22:47:39 | FromDiscord | <Elegantbeef> Here is an example of why you'd use arc |
22:47:39 | FromDiscord | <Elegantbeef> The above compiles and frees it automatically, but you're still managing manually |
22:47:55 | FromDiscord | <Gumbercules> ARC allows you to essentially RAII |
22:48:08 | FromDiscord | <Gumbercules> Similar to C++ |
22:48:34 | * | adium joined #nim |
22:50:04 | FromDiscord | <Elegantbeef> The benefit of having arc in the above example is your strings are managed for you |
22:50:05 | FromDiscord | <Elegantbeef> There literally is no reason not to use Orc/Arc with manual memory management |
22:50:47 | FromDiscord | <Gumbercules> Well |
22:50:56 | FromDiscord | <Gumbercules> There are reasons but |
22:51:15 | FromDiscord | <Elegantbeef> If your types dont use them then you dont have any overhead |
22:51:23 | FromDiscord | <Elegantbeef> Even embedded users use arc |
22:52:33 | FromDiscord | <Gumbercules> Sure but there are still certain things you can't do with arc/orc |
22:53:00 | FromDiscord | <Gumbercules> Like provide a specific allocator for a specific allocation |
22:53:08 | FromDiscord | <Elegantbeef> I mean you can |
22:53:33 | FromDiscord | <Elegantbeef> Not apart of arc/orc directly but you can certainly make a type using arc and it's own allocator |
22:53:45 | FromDiscord | <Gumbercules> That's not what I mean |
22:54:07 | FromDiscord | <Gumbercules> I can't say allocate this Nim string using this specific allocator |
22:54:18 | FromDiscord | <Elegantbeef> Yes i dont disagree there |
22:54:30 | FromDiscord | <Gumbercules> That would be lovely |
22:54:31 | FromDiscord | <Elegantbeef> But for non Nim gc'd types you certainly can |
22:54:35 | FromDiscord | <Gumbercules> Yeah |
22:54:38 | FromDiscord | <Gumbercules> Fair enough |
22:55:57 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/blob/master/remoterefs.nim#L5-L33 i've tried my damndest to make it work with Nim's gc'd types |
22:55:57 | FromDiscord | <scipio> sent a code paste, see https://paste.rs/yL0 |
22:55:57 | FromDiscord | <Elegantbeef> But yea it's a shame you cannot |
22:55:58 | FromDiscord | <Elegantbeef> Nim really needs some mechanism to override the allocator used like `string[AllocProc =..., ReallocProc = ..., DeallocProc = ...]` |
22:56:12 | FromDiscord | <Gumbercules> Yup I agree |
22:56:16 | FromDiscord | <Elegantbeef> You change your default indent to using `spaces` |
22:56:42 | FromDiscord | <Gumbercules> Even just having an optional argument for every allocation would be enough |
22:56:51 | FromDiscord | <Elegantbeef> No it wouldnt |
22:56:56 | FromDiscord | <Gumbercules> Use them concepts |
22:57:09 | FromDiscord | <Gumbercules> Why not? As long as they all fulfill the same contract |
22:57:16 | FromDiscord | <Elegantbeef> strings can grow |
22:57:21 | FromDiscord | <Elegantbeef> So they'd need to track their allocator |
22:57:26 | FromDiscord | <Gumbercules> So have a realloc |
22:57:37 | FromDiscord | <Gumbercules> Oh yeah |
22:57:46 | FromDiscord | <Elegantbeef> This information is best tied to the type so it works with Arc |
22:57:53 | FromDiscord | <Gumbercules> Well I mean you could still pass one and the runtime could track it |
22:58:00 | FromDiscord | <Elegantbeef> Nah no reason to runtime track it |
22:58:04 | FromDiscord | <Elegantbeef> You can statically track it |
22:58:24 | FromDiscord | <Gumbercules> Well however someone wants to do it |
22:58:29 | FromDiscord | <Elegantbeef> `RemoteRefs` is proof that the best way to do it is to generalise allocation procedures and allow optional ones |
22:58:48 | FromDiscord | <Elegantbeef> Well when you statically track it you can make the allocation procedures `inline` and then the compiler can inline them if it sees fit |
22:58:56 | FromDiscord | <Gumbercules> I don't even know what remoterefs is but I'm going to find out now |
22:58:59 | FromDiscord | <Elegantbeef> When you runtime track them allocation calls are always a pointer proc away |
22:59:21 | FromDiscord | <Elegantbeef> Remote refs is just a Arc managed type that you supply your `alloc` and `dealloc` procedures to |
22:59:35 | FromDiscord | <Elegantbeef> It's like Odin/Zig contexts but type attached instead of an argument |
22:59:38 | FromDiscord | <Gumbercules> Gotcha |
22:59:42 | FromDiscord | <Elegantbeef> It's much more sane imo since it works with RAII |
23:00:08 | FromDiscord | <Elegantbeef> Since they're type attached they get all the benefits of a procedure being statically called, which means they can be inlined called |
23:00:17 | FromDiscord | <Elegantbeef> They also dont increase the type's size |
23:01:13 | FromDiscord | <Elegantbeef> They mostly appeared due to Girvo talking about wanting to have a reference that is allocated using an embeded's SPI allocator |
23:01:13 | FromDiscord | <Elegantbeef> Which is a persistent storage |
23:01:30 | FromDiscord | <Elegantbeef> So the downside is of course since we cannot provide allocators for string and friends only stack types can be used sensibly |
23:02:30 | FromDiscord | <Gumbercules> In reply to @Elegantbeef "So the downside is": Yeah 😢 |
23:02:32 | FromDiscord | <sOkam!> In reply to @scipio "n00b question (I've installed": you need to configure sublime to not insert tabs. that's an assumption that doesn't work in many cases, and nim is one example of such situation |
23:02:48 | FromDiscord | <Elegantbeef> I mean 99% of editors insert spaces by default |
23:02:57 | FromDiscord | <sOkam!> (edit) "that's" => ""the user will only need tabs" is" | ""the user will only need tabs" isan ... assumption" added "editor" |
23:03:06 | FromDiscord | <Elegantbeef> Very few editors insert tabs by default, i've never used one that has |
23:03:19 | FromDiscord | <Elegantbeef> Even VS uses(d) spaces |
23:03:33 | FromDiscord | <auxym> notepad.exe |
23:04:24 | FromDiscord | <sOkam!> i started with sublime too, and i don't see it as something foreign. but i moved quickly to vscode, and soon after removed tabs of my workflow entirely in every lang, so i don't have a good perspective |
23:04:49 | FromDiscord | <scipio> sent a code paste, see https://play.nim-lang.org/#ix=4kGw |
23:04:58 | FromDiscord | <scipio> .. seems to work |
23:05:02 | FromDiscord | <sOkam!> yep! that's it 🙂 |
23:05:24 | FromDiscord | <Elegantbeef> But yea gumber if interested in seeing it actually used i do have this test https://github.com/beef331/nimtrest/blob/master/tremoterefs.nim |
23:05:48 | FromDiscord | <Elegantbeef> It's a cool idea overall, but just sad about the whole Nim thing 😄 |
23:09:00 | FromDiscord | <sOkam!> @ElegantBeef @Gumbercules i understand what you mean by using arc, but my goal is to learn C/Zig style of memory management, except with the beauty of Nim code as the main tool instead |
23:09:26 | FromDiscord | <jtv> "style"? |
23:09:27 | FromDiscord | <sOkam!> If it was any sort of "production" code, I would 100% go arc minimum |
23:09:34 | FromDiscord | <Gumbercules> Zig allows for custom allocators |
23:09:36 | FromDiscord | <jtv> C++ has a style, RAII |
23:10:25 | FromDiscord | <sOkam!> In reply to @jtv ""style"?": John Carmack C code has a style, and Zig allows custom allocators as mentioned. My goal is learning that, to be specific |
23:10:26 | FromDiscord | <Gumbercules> Nim isn't as flexible but you can still use Nims manual allocation procs and Nims general purpose allocator |
23:10:31 | FromDiscord | <jtv> But C programs are largely handled ad-hoc. Depends on the program, but there's not really a preferred "style" |
23:10:55 | FromDiscord | <Gumbercules> There are a lot of C libraries that allow you to provide your own allocation callbacks |
23:11:10 | FromDiscord | <Gumbercules> And they will default to using malloc |
23:11:13 | FromDiscord | <jtv> 100%, and a wealth of custom allocators too |
23:11:14 | FromDiscord | <Gumbercules> Or their own allocator |
23:11:17 | FromDiscord | <jtv> Some pretty good ones |
23:11:30 | FromDiscord | <Gumbercules> Nim isn't as flexible hete |
23:11:33 | FromDiscord | <jtv> Esp for multi-threaded programs |
23:11:53 | FromDiscord | <Gumbercules> But you can patch the stdlib and use mimalloc or whatever |
23:12:14 | FromDiscord | <Gumbercules> You just can't say, for this specific string allocation use my linear allocator |
23:12:24 | FromDiscord | <Gumbercules> And for the next one use Nims |
23:12:43 | FromDiscord | <jtv> Yeah, I do crap like that all the time in C, heh |
23:12:53 | FromDiscord | <Gumbercules> Of course nothing is stopping you from reserving a bunch of heap space and allocating from there |
23:13:13 | FromDiscord | <Gumbercules> It's just a contrived example |
23:13:45 | FromDiscord | <jtv> Yeah, and you could definitely hit the lower-level memory management interface to get mapped pages, etc. directly from the OS |
23:19:47 | FromDiscord | <Gumbercules> Vale's promising a lot of very interesting memory management facilities |
23:21:08 | FromDiscord | <Gumbercules> Honestly if you want to learn about manual memory management, just write some C |
23:21:39 | FromDiscord | <jtv> Yeah I agree w/ that. You'll learn a lot more about the system underneath |
23:21:40 | FromDiscord | <Gumbercules> Or look at well authored C libraries |
23:24:27 | FromDiscord | <sOkam!> In reply to @Gumbercules "Honestly if you want": I've dealt with C nightmare enough for a lifetime. I would choose Nim every single time for every single task, unless I'm forced to (which im not) |
23:25:23 | FromDiscord | <sOkam!> Low level doesn't need to mean ugly code. For me, personally, C is super ugly. I like the minimalism a lot, but Nim does have that too, so nothing lost for me personally |
23:25:24 | FromDiscord | <jtv> Well, C is definitely hard to write well, and even when you get good at it, bugs can be incredibly subtle and take a very long time to debug. A huge part of that though is the manual memory management 🙂 |
23:25:26 | FromDiscord | <Elegantbeef> I get you're cloning quake, but that doesnt mean you have to write code like quakes |
23:25:41 | FromDiscord | <Elegantbeef> I personally do not get why anyone wouldnt use arc even learning manual memory management |
23:25:46 | FromDiscord | <jtv> Agreed |
23:26:04 | FromDiscord | <jtv> If you're doing manual memory management well, it'd often look a heck of a lot like arc |
23:26:10 | FromDiscord | <Elegantbeef> You can use whatever allocator you want per a type, and you dont need to pretend it's C |
23:26:57 | FromDiscord | <Elegantbeef> Though i personally do not get the want to learn manual memory management pass the basics of allocating and freeing and how that works |
23:27:05 | FromDiscord | <Elegantbeef> There isnt much there |
23:28:16 | FromDiscord | <jtv> The specifics of storage management algorithms can be interesting, but beyond that, 100% |
23:28:17 | FromDiscord | <sOkam!> In reply to @Elegantbeef "I get you're cloning": Sometimes you have to understand the intricacies of john's code to even begin understanding the overview of his stuff. He was way way too deep into low level code, and from an artist brain like mine grasping that is extremely hard |
23:29:24 | FromDiscord | <sOkam!> It's hard to explain without having experienced it. His stuff is just hard to follow without his level of knowledge, so I'm just trying to lessen the knowledge gap as much as I can |
23:32:06 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
23:32:14 | FromDiscord | <jtv> I skimmed through the quake code once, it looked like normal C code. I remember they did have a custom zone malloc, but even that was straightforward |
23:34:43 | FromDiscord | <sOkam!> skimming is hella easy. working with it daily is a different story. at least that's the case for q3 stuff, which is what i keep myself with. i rarely open q1, so i have no clue of how different it is. all i know is that q3 is super hard to follow, unless you really know what you are doing (in which case it looks a lot like normal c code, sure... but that's because you already have the knowledge) |
23:36:08 | FromDiscord | <jtv> Well, I've been mainly a C developer for about 30 years, but I just spent a few mins again, the C in their gpl'd repos all look like regular well-written C code |
23:37:06 | FromDiscord | <sOkam!> i just passed my first year of coding in any lang, and it was all self taught starting with johns code from day1. that probably explains a lot |
23:37:31 | FromDiscord | <sOkam!> plus i have an artist brain, low level stuff is not intutive |
23:37:43 | FromDiscord | <sOkam!> (edit) "intutive" => "intuitive" |
23:38:05 | FromDiscord | <sOkam!> (edit) "plus i have an artist brain, low level stuff is not intuitive ... " added "for me" |
23:38:51 | FromDiscord | <jtv> Yeah, even back when C/C++ was often a first language, people who wrote in them every day for a year still didn't have that great a mastery of the language |
23:39:04 | FromDiscord | <sOkam!> yeah i figure |
23:39:16 | FromDiscord | <jtv> If you want to get good at C, it's worth reading the book, "Deep C Secrets" |
23:39:38 | FromDiscord | <sOkam!> i'd rather learn deep nim secrets. it fits my brain much better |
23:39:46 | FromDiscord | <sOkam!> 🙂 |
23:39:54 | FromDiscord | <jtv> Well, it would help you understand id code better 🙂 |
23:40:13 | FromDiscord | <sOkam!> that's tru. will keep it in mind ✍️ |
23:51:39 | FromDiscord | <RukkaPlus> Hi there! Do you know a way to download the standard library documentation for offline use? |
23:52:55 | FromDiscord | <sOkam!> i've noticed that Nim uses uncheckedArrays for dealing with most low level things↵What's different between having a, lets say, `ptr uint8` vs an `uncheckedArray[uint8]`? |
23:53:00 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/9800 |
23:53:16 | FromDiscord | <Elegantbeef> The difference between `ptr UncheckedArray[T]` and `ptr T` is that Nim is statically typed |
23:53:25 | FromDiscord | <Elegantbeef> It says "Not all pointers are an array" |
23:55:41 | FromDiscord | <jtv> Yeah, that's one oddity of C that is hard to grok, especially because strings are declared as "char ", leads people to think that pointers are effectively arrays. Semantically, that's mostly (but not entirely) true in C, but it's a horrible habit |
23:56:32 | FromDiscord | <sOkam!> i thought that was the case, lol |
23:56:44 | FromDiscord | <sOkam!> but yeah, i think i get what you mean |
23:57:17 | FromDiscord | <sOkam!> so ptr T could be just a single item, or many. but array would mean more than one by definition?↵or am i missing something |
23:57:31 | FromDiscord | <Elegantbeef> Correct |
23:57:38 | FromDiscord | <Elegantbeef> In Nim you'd use an unchecked array if the data is a contiguous collection of T |
23:57:54 | FromDiscord | <Elegantbeef> In C you'd use `T` regardless if it was one or many |
23:58:06 | FromDiscord | <sOkam!> ic |
23:58:31 | FromDiscord | <Elegantbeef> Nim is more 'exact' in it's typing |