00:13:59 | * | xet7 quit (Ping timeout: 264 seconds) |
00:24:01 | FromDiscord | <voidwalker> UHm having a bit of trouble figuring out binarylang. I basically have to put into a stream a struct with values I already assigned. All the examples show loading the struct again from a source, and then writing that variable again to a stream. |
00:24:13 | FromDiscord | <voidwalker> (edit) "again" => "" |
00:25:07 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hDC |
00:30:42 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hDD |
00:38:46 | * | ltriant joined #nim |
00:41:18 | FromDiscord | <Just Jasmine, Please> Hey, I have a steam deck, and wanted to get to coding on it as a little laptop. I begged my boyfriend for the mastering nim book, but now whenever I try to launch nim it gets cleared from the path. Not that big of an issue because I know where the binary is. What's the bigger issue is that every time I try to run said binary, I get this error https://media.discordapp.net/attachments/371759389889003532/1048760864712429568/mess |
00:41:28 | * | jmdaemon joined #nim |
00:48:04 | FromDiscord | <tandy> looks like ur missing some dev libs↵(@Just Jasmine, Please) |
00:49:56 | FromDiscord | <yrashk> sent a long message, see http://ix.io/4hDH |
00:50:24 | * | ltriant quit (Ping timeout: 260 seconds) |
00:50:26 | FromDiscord | <Elegantbeef> A copy is required in orc/arc when a move cannot be done |
00:50:34 | FromDiscord | <Just Jasmine, Please> In reply to @tandy "looks like ur missing": Thanks! How do I go about getting them? |
00:51:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hDI |
00:52:28 | FromDiscord | <Just Jasmine, Please> In reply to @tandy "looks like ur missing": I know that I to remove the read only filesystem, but what libraries do I need |
01:07:12 | FromDiscord | <EOF> Hello, I wonder is there an array chunking/batch function in NIM ? |
01:08:18 | FromDiscord | <Elegantbeef> What's array chunking |
01:11:32 | FromDiscord | <EOF> chunks of 2: [1, 2, 3, 4, 5, 6, 7] => [[1, 2], [3, 4], [5, 6], [7]] |
01:13:30 | FromDiscord | <EOF> something like in python https://docs.python.org/3.12/library/itertools.html?highlight=batched#itertools.batched |
01:18:29 | * | xet7 joined #nim |
01:28:43 | * | ltriant joined #nim |
01:31:22 | FromDiscord | <Elegantbeef> https://github.com/narimiran/itertools has chunked |
01:33:52 | * | ltriant quit (Ping timeout: 268 seconds) |
01:34:52 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hDQ |
01:35:08 | FromDiscord | <voidwalker> quite the elegant fix to my binary crap de/serialization problem |
01:36:58 | FromDiscord | <voidwalker> Only thing that bugs me, is it possible to instantiate an object `UdpTrackerPing` with its default values, without needing to mention them again ? |
01:37:36 | FromDiscord | <Elegantbeef> `UdpTrackerPing()` |
01:37:50 | FromDiscord | <Elegantbeef> Well that defaults them to 0 |
01:37:56 | FromDiscord | <Elegantbeef> the way you'd do it for your case is make a constructor |
01:41:04 | FromDiscord | <voidwalker> sounds complicated. and something that the lib should have. but it's more than a year since sealmove commited on it.. |
01:41:26 | FromDiscord | <Elegantbeef> I mean it's a proc |
01:41:32 | FromDiscord | <voidwalker> it seems that all the nim libs are v 0 dot something, kind of not makes sense for nim to be v2 soon |
01:41:53 | FromDiscord | <Elegantbeef> `proc init(_: typedesc UdpTrackerPing, ...): UdpTrackerPing = UdpTrackerPing(...)` |
01:42:23 | FromDiscord | <Elegantbeef> "Project doesnt automatically make my code shorter 0/10" |
01:42:41 | FromDiscord | <Elegantbeef> It makes sense for Nim to be v2 soon given it's doing changes that are not backwards compatible |
01:42:48 | FromDiscord | <Elegantbeef> The very definition of semver states that's a major version |
01:42:51 | FromDiscord | <voidwalker> should have been v0.2 : P |
01:43:02 | FromDiscord | <Elegantbeef> No cause that's not how semver works |
01:43:11 | FromDiscord | <Elegantbeef> 0.0.2 is a patch version |
01:43:16 | FromDiscord | <albassort> alright beef |
01:43:21 | FromDiscord | <albassort> this is a question for you |
01:43:29 | FromDiscord | <Elegantbeef> Jeez |
01:44:12 | FromDiscord | <voidwalker> wish discord had a tip jar, didn't you beef ? : D |
01:44:15 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hDT |
01:44:21 | FromDiscord | <voidwalker> (edit) "didn't" => "don't" |
01:44:28 | FromDiscord | <albassort> but, in my own bindings, I have the same thing, as a cstring (because im not fancy) |
01:44:32 | FromDiscord | <Elegantbeef> Meh i could setup a github sponsor or something |
01:44:49 | FromDiscord | <albassort> Is there anyway I can cast my cstring to their object |
01:44:52 | FromDiscord | <voidwalker> "if I had a pennty for every nim answer.." |
01:44:55 | FromDiscord | <Elegantbeef> Seems like a lot of work to siphon money from people and to complicate taxes |
01:44:57 | FromDiscord | <voidwalker> (edit) "pennty" => "penny" |
01:45:11 | FromDiscord | <albassort> in practicality, they are the same thing, pointers to memoryt |
01:45:12 | FromDiscord | <albassort> (edit) "memoryt" => "memory" |
01:45:13 | FromDiscord | <Elegantbeef> `cast[TheirType](myCstring)` |
01:45:21 | FromDiscord | <Elegantbeef> Why you're using cstring is confounding |
01:45:51 | FromDiscord | <albassort> ye |
01:45:52 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hDU |
01:45:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/GV4 |
01:46:14 | FromDiscord | <Elegantbeef> Then again i still dont get why you're making your own bindings |
01:46:19 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4hDU" => "https://play.nim-lang.org/#ix=4hDV" |
01:46:26 | FromDiscord | <albassort> its specific binding to code i wrote in C |
01:46:35 | FromDiscord | <albassort> and idk if i want to port it to C |
01:46:42 | FromDiscord | <albassort> (edit) "C" => "Nim" |
01:46:51 | FromDiscord | <Elegantbeef> Fairly certain they're just opaque pointers |
01:46:59 | FromDiscord | <Elegantbeef> So it should be fine mostly |
01:47:01 | FromDiscord | <albassort> well lets see! |
01:47:04 | FromDiscord | <Elegantbeef> Unless strict aliasing steps in |
01:47:26 | FromDiscord | <Elegantbeef> Though given this is across ABI it's probably fine |
01:49:12 | FromDiscord | <albassort> yep |
01:49:14 | FromDiscord | <albassort> works ifne |
01:49:16 | FromDiscord | <albassort> (edit) "ifne" => "fine" |
01:49:19 | FromDiscord | <albassort> the day is good |
01:49:52 | FromDiscord | <albassort> may just port this code |
01:53:20 | * | ltriant joined #nim |
01:53:21 | FromDiscord | <voidwalker> hm your mention of taxes got me thinking beef. I for one am determined to never pay taxes ever again, not a dime. Of course, the ones that you voluntarily submit, the others are harder to avoid. But what if you could have a service to buy someone beer or pizza, without having their personal details Surely those are not subject to tax |
01:53:37 | FromDiscord | <albassort> oh god |
01:53:40 | FromDiscord | <albassort> i gotta pay taxes this year |
01:53:44 | FromDiscord | <Elegantbeef> I'm not a libertarian so.... |
01:53:49 | FromDiscord | <Elegantbeef> Yes they're subject to taxes |
01:54:01 | FromDiscord | <voidwalker> but who would know how many beers you had lol |
01:54:16 | FromDiscord | <Elegantbeef> You do realise taxes are supposed to be self reporting in that case? |
01:54:21 | FromDiscord | <albassort> In reply to @voidwalker "hm your mention of": unless you're rich taxes are unavoidable im sorry |
01:54:37 | FromDiscord | <Elegantbeef> I dont know why you're sorry, i rather like healthcare and roads |
01:54:57 | FromDiscord | <voidwalker> I already pay for roads, and healthcare is out of my own pocket.. |
01:54:58 | FromDiscord | <albassort> I'm sorry for the classifier "unless" |
01:55:15 | FromDiscord | <albassort> actually |
01:55:25 | FromDiscord | <Elegantbeef> Well move to a country that resides in the 21st century |
01:55:26 | FromDiscord | <albassort> taxes are not unavoidable, just make less then the minimum amount |
01:55:30 | FromDiscord | <amadan> In reply to @Just Jasmine, Please "I know that I": From this post https://www.reddit.com/r/SteamDeck/comments/t92ozw/for_compiling_c_code/↵It seems reinstalling `glibc` and `linux-api-headers` fixes the missing files |
01:55:43 | FromDiscord | <Elegantbeef> Not all countries have minimal amounts |
01:55:49 | FromDiscord | <albassort> in the us |
01:55:50 | FromDiscord | <albassort> The minimum income amount depends on your filing status and age. In 2021, for example, the minimum for single filing status if under age 65 is $12,550. |
01:55:54 | FromDiscord | <Elegantbeef> All income is taxable in Canada |
01:56:01 | FromDiscord | <albassort> I haven't payed taxes yet |
01:56:07 | FromDiscord | <albassort> because I've never made more than 12k |
02:09:01 | * | ltriant quit (Ping timeout: 268 seconds) |
02:14:36 | FromDiscord | <Gumbercules> something something taxes and death |
02:23:07 | FromDiscord | <voidwalker> @ElegantBeef not sure what use the constructor proc you mentioned.. I still can't access the internal data of those object fields. They are used to match values, not set values |
02:23:26 | FromDiscord | <Elegantbeef> Yea i'm not sure what you're after so i dont know |
02:24:25 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hE2 |
02:24:29 | FromDiscord | <Elegantbeef> Well you cannot do that |
02:24:43 | FromDiscord | <voidwalker> instead of writing them again. I want the struct definition to serve as both structure and data for me |
02:24:53 | FromDiscord | <Elegantbeef> "Prs welcome" 😄 |
02:25:09 | FromDiscord | <voidwalker> yeah right, I can't even figure out the code where this magic happens.. |
02:25:12 | FromDiscord | <Elegantbeef> Sealmove pops in here ever now and again so you'd be able to make an issue and get a response likely |
02:25:27 | FromDiscord | <voidwalker> already pm-ed spammed sealmove :- s |
02:25:32 | FromDiscord | <Elegantbeef> Ah |
02:25:53 | FromDiscord | <voidwalker> Figured it's faster than wait for my ping to be noticed |
02:26:44 | FromDiscord | <voidwalker> well, I am going to just eat it and duplicate the data for the initialization (for my use case, I could just discard then when defining the struct, but they look so nice, showing off the protocol definition..) |
02:27:01 | FromDiscord | <voidwalker> So I am going to keep them for aesthetic reasons and in hopes my wish will be implemented soon : ) |
02:31:07 | FromDiscord | <voidwalker> only 2 projects on github using binarylang |
02:33:37 | FromDiscord | <voidwalker> Is there something else maybe ? Or do people write their own non generic |
02:35:36 | * | ltriant joined #nim |
02:41:35 | * | ltriant quit (Ping timeout: 260 seconds) |
02:46:36 | * | ltriant joined #nim |
03:11:14 | * | ltriant quit (Ping timeout: 256 seconds) |
03:34:56 | FromDiscord | <salt rock lamp> https://stackoverflow.com/q/74672660/2954547 got an easy nim question on stackoverflow for the experts \:) |
03:35:00 | FromDiscord | <salt rock lamp> tldr\: how do i get the int value from an enum? |
03:35:43 | FromDiscord | <salt rock lamp> ultimately i want to subtract two enum values |
03:37:50 | FromDiscord | <πτ (pi man)> I have a zip file (with just a single xml file in it) that I want to read the contents (of the xml file) from, I assume I would want to use zlib? |
03:38:58 | * | ltriant joined #nim |
03:39:14 | FromDiscord | <salt rock lamp> i found this which wraps libzip instead of zlib https://github.com/nim-lang/zip↵(@πτ (pi man)) |
03:39:40 | FromDiscord | <salt rock lamp> i don't know if there is any reason to prefer one or the other of zlib or libzip |
03:43:44 | FromDiscord | <voidwalker> In reply to @salt rock lamp "https://stackoverflow.com/q/74672660/2954547 got an": https://nim-lang.org/docs/system.html#ord,T Same thing in the end, but ord kind of makes more sense, feels higher level than int : ) |
03:43:59 | * | ltriant quit (Ping timeout: 268 seconds) |
03:44:57 | FromDiscord | <πτ (pi man)> In reply to @salt rock lamp "i found this which": so would this just be `require "zip"` in the nimble file? |
03:45:37 | FromDiscord | <salt rock lamp> ah, thank you. this should probably be mentioned in the manual! https://nim-lang.org/docs/manual.html#types-enumeration-types↵(@voidwalker) |
03:46:35 | FromDiscord | <salt rock lamp> i agree, i think `ord` is the "correct" answer, and casting is a workaround for not knowing about `ord` \:) |
03:46:42 | FromDiscord | <salt rock lamp> i think so? i'm a newbie myself↵(@πτ (pi man)) |
03:47:36 | FromDiscord | <πτ (pi man)> yea I haven't used Nim in quite a while, wha's the current version btw? |
03:47:57 | FromDiscord | <salt rock lamp> 1.6.12 i think, i just updated with choosenim the other day |
03:48:08 | FromDiscord | <salt rock lamp> i started using it for advent of code, i want to spend some time getting more comfortable with it |
03:48:33 | FromDiscord | <voidwalker> what's wit this advent of code craziness.. everybody doing it |
03:48:45 | FromDiscord | <πτ (pi man)> last I used was 1.5.1 and I don't remember how to use choosenim |
03:49:04 | FromDiscord | <πτ (pi man)> but anyways `require "zip"` is correct |
03:50:39 | FromDiscord | <πτ (pi man)> In reply to @voidwalker "what's wit this advent": it's a yearly thing starting on December 1st. each day opens up a new coding challenge that gets progressively harder until December 24th |
03:50:55 | FromDiscord | <πτ (pi man)> https://adventofcode.com/ |
03:55:29 | * | ltriant joined #nim |
03:56:55 | FromDiscord | <voidwalker> meh, 1-2 minute solutions ? crazy |
04:04:20 | * | ltriant quit (Ping timeout: 268 seconds) |
04:04:57 | FromDiscord | <ChocolettePalette> Does nim have timeout for the UDP socket recvFrom procedure? I only found timeouts for TCP ones... |
04:12:56 | FromDiscord | <treeform> In reply to @πτ (pi man) "I have a zip": https://github.com/guzba/zippy |
04:13:38 | FromDiscord | <treeform> here is an example on how to load a zipfile and only read one file out of it: https://github.com/guzba/zippy/blob/master/examples/ziparchive_explore.nim |
04:14:26 | FromDiscord | <treeform> zippy is often time faster then zlib... not sure about libzip. |
04:16:01 | FromDiscord | <πτ (pi man)> if a zip only contains one file is there a way to just go strait to the uncompressed file? |
04:16:31 | FromDiscord | <voidwalker> In reply to @ChocolettePalette "Does nim have timeout": I stumbled upon the same question yesterday, it seems this is the way to do it, puts a timeout on any Future: https://nim-lang.org/docs/asyncdispatch.html#withTimeout%2CFuture%5BT%5D%2Cint |
04:16:48 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hEj |
04:21:02 | FromDiscord | <ChocolettePalette> Thanks a lot!↵(@voidwalker) |
04:32:46 | FromDiscord | <ChocolettePalette> Now I gotta rewrite all of my program to use async sockets doe... In C it would be as easy as setting a correct socket option |
04:34:51 | FromDiscord | <πτ (pi man)> am I weird for not really liking exceptions? |
04:35:00 | FromDiscord | <Elegantbeef> I say yes |
04:35:08 | FromDiscord | <Elegantbeef> But it's up to you |
04:35:29 | FromDiscord | <Elegantbeef> I find results tedious as hell |
04:35:46 | FromDiscord | <salt rock lamp> i like exceptions for things like invalid user input |
04:36:45 | FromDiscord | <Elegantbeef> I find them the most expressive way to emit/handle errors |
04:37:00 | FromDiscord | <Elegantbeef> They dont force users to handle errors and they're out of the way |
04:37:03 | FromDiscord | <πτ (pi man)> I tend to do things the C way even in other languages |
04:37:12 | FromDiscord | <Elegantbeef> Yes rust programmers `?` forces the user to handle errors |
04:37:17 | FromDiscord | <Elegantbeef> Sentinel values? |
04:38:29 | FromDiscord | <πτ (pi man)> but anyways, is there a prefered xml parser, because google brought up like 5 different libraries |
04:38:30 | FromDiscord | <salt rock lamp> i like result types when the operation is expected to occasionally fail |
04:38:46 | FromDiscord | <Elegantbeef> stdlib has one |
04:38:58 | FromDiscord | <Boston> Is there a way to convert float32 to it's array of bytes |
04:39:10 | FromDiscord | <Elegantbeef> Yes |
04:39:11 | FromDiscord | <salt rock lamp> https://nim-lang.org/docs/parsexml.html↵(@πτ (pi man)) |
04:39:18 | FromDiscord | <Elegantbeef> You can do it a variety of ways |
04:39:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hEo |
04:40:01 | FromDiscord | <salt rock lamp> that'd be a good stackoverflow question too \:) i like trying to populate SO tags for languages that i like |
04:40:14 | FromDiscord | <salt rock lamp> that'd be a good stackoverflow question too \:) i like trying to populate SO tags for languages that i like. it helps create visibility and improves the new user experience |
04:41:02 | FromDiscord | <Boston> sent a code paste, see https://play.nim-lang.org/#ix=4hEq |
04:41:02 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/mAS |
04:42:12 | FromDiscord | <Boston> Just curious, is there a package similar to system.bitconverter? |
04:42:54 | FromDiscord | <Elegantbeef> 'system.bitconverter'....? |
04:43:25 | FromDiscord | <πτ (pi man)> ok so uh... somebody want to explain to me what xml has to do with html? |
04:43:40 | FromDiscord | <Elegantbeef> Html and xml are very similar |
04:44:21 | FromDiscord | <Boston> In reply to @Elegantbeef "'system.bitconverter'....?": c# class |
04:44:57 | FromDiscord | <Elegantbeef> `copyMem` exists |
04:45:07 | FromDiscord | <Elegantbeef> No clue if anything abstracts it but that's literally all that does |
04:45:14 | FromDiscord | <huantian> Html is a subset of xml |
04:45:25 | FromDiscord | <salt rock lamp> there was a version of html ("xhtml") which was defined as a specific xml schema, whereas html 5.0 is not strictly xml |
04:45:51 | FromDiscord | <huantian> Or maybe they use the same format, but are used for different purposes |
04:46:10 | FromDiscord | <πτ (pi man)> huh, well I was asking because both xml examples in the docs say html |
04:46:15 | FromDiscord | <salt rock lamp> html5 is xml with some syntax restrictions loosened, but you can convert it to strict xml |
04:46:51 | FromDiscord | <πτ (pi man)> is the xml parser also used to parse html? |
04:47:19 | * | ltriant joined #nim |
04:47:26 | FromDiscord | <Rika> Yes |
04:47:30 | FromDiscord | <salt rock lamp> xml parsers often have an "html mode" and/or you can assume that the html is the xml-compliant subset thereof |
04:47:30 | FromDiscord | <Rika> IIRC |
04:48:29 | * | arkurious quit (Quit: Leaving) |
04:49:09 | FromDiscord | <πτ (pi man)> also VSC dosen't seem to like linting zippy :mood: |
05:25:33 | FromDiscord | <πτ (pi man)> ok quick question, from what I remember `var` is immutable and `let` is mutable, but why then do I see changes being made to variables declared with `var`? |
05:25:52 | FromDiscord | <πτ (pi man)> sent a code paste, see https://paste.rs/veE |
05:26:02 | FromDiscord | <salt rock lamp> `var` is mutable, `let` is immutable |
05:26:11 | FromDiscord | <πτ (pi man)> oh I had it backwards |
05:26:22 | FromDiscord | <πτ (pi man)> that makes sense now :LUL: |
05:28:28 | FromDiscord | <albassort> help i forgot how to convert int to seq[cint] |
05:28:32 | FromDiscord | <albassort> pretty sure its |
05:28:41 | FromDiscord | <albassort> ptr uncheckedArray[cint]↵cast something |
05:50:27 | FromDiscord | <albassort> brain melting |
05:50:40 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hEA |
05:53:26 | FromDiscord | <Elegantbeef> You cannot make a seq from an C array |
05:54:33 | FromDiscord | <albassort> In reply to @Elegantbeef "You cannot make a": how i do beef |
05:55:05 | FromDiscord | <Elegantbeef> you allocate for your sequence then `copyMem` |
05:56:14 | FromDiscord | <albassort> alright fuck that going to pass pointers into the c function |
06:15:38 | FromDiscord | <salt rock lamp> day 4 done in nim so far. this is just as nice as python and it's pretty cool that it compiles to c |
06:15:50 | FromDiscord | <salt rock lamp> the compiler is actually faster than cpython startup, lol |
06:16:11 | FromDiscord | <salt rock lamp> that is, `nim r` is about as fast as, or faster than, `python` |
06:16:22 | FromDiscord | <salt rock lamp> and that's before you even get into the running program! |
06:16:51 | FromDiscord | <voidwalker> it's just as nice as python until it's not : P |
06:17:10 | FromDiscord | <voidwalker> but you are not a "real" programmer if you only do python |
06:17:15 | FromDiscord | <salt rock lamp> hah, i am still in the shallow end |
06:17:24 | FromDiscord | <salt rock lamp> what's less-nice than python? |
06:17:46 | FromDiscord | <salt rock lamp> there seems to even be some semblance of python's generic iterator protocol, which imo is one of its best features |
06:18:06 | FromDiscord | <voidwalker> well, figuring out all sorts of wacky type conversions here and there, some dynamic typing features.. I am not missing them yet for my use cases, but who knows |
06:18:13 | FromDiscord | <huantian> Nims iterators are not on the same level as pythons |
06:18:22 | FromDiscord | <salt rock lamp> i see that `map()` isn't variadic like python `map()`, unless i misunderstood the docs |
06:18:30 | FromDiscord | <huantian> One day closure iterators will be good! |
06:18:35 | FromDiscord | <salt rock lamp> what's missing?↵(@huantian) |
06:18:48 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=4hEG |
06:19:02 | FromDiscord | <voidwalker> Although I am trying to pretend it is python, and achieve glorious oneliners, and try to use all kinds of syntactic sugars and libs.. it's close |
06:19:32 | FromDiscord | <salt rock lamp> i've definitely been writing more loops and `+=`s than i would in python, but i'm not sure if that's just because i don't know the fancier features |
06:19:46 | FromDiscord | <huantian> In reply to @salt rock lamp "what's missing? (<@300050030923087872>)": Elegantbeef (Ha get pinged) can probably explain to better than I could |
06:20:01 | FromDiscord | <Elegantbeef> Huan i've never used python |
06:20:09 | FromDiscord | <huantian> It uh |
06:20:15 | FromDiscord | <huantian> Goes iter and stuff |
06:20:17 | FromDiscord | <huantian> Or something |
06:20:37 | FromDiscord | <huantian> Look I’m sleepy I can’t explain stuff like iterators |
06:20:54 | FromDiscord | <Elegantbeef> Afaik python's iterators are like C++s |
06:20:58 | FromDiscord | <Elegantbeef> So they're just calling `.next` |
06:21:17 | FromDiscord | <Elegantbeef> So they're just dumb closure iterators |
06:21:33 | FromDiscord | <salt rock lamp> python has a two-tiered protocol\: Iterators, which implement the `next` method, and Iterables, which is anything that can be converted to an Iterator by their `iter` method (Iterators are Iterables for which `iter` returns the object itself) |
06:22:50 | FromDiscord | <salt rock lamp> sent a code paste, see https://play.nim-lang.org/#ix=4hEH |
06:23:35 | FromDiscord | <salt rock lamp> as with a lot of things in python, the internal design is actually kind of stupid (usually in a good way), and it's the syntactic sugar that makes it clever |
06:25:42 | FromDiscord | <salt rock lamp> sent a code paste, see https://play.nim-lang.org/#ix=4hEI |
06:26:08 | FromDiscord | <salt rock lamp> the `with` is a similar thing, called a context manager. another object that just implements some special methods, but the runtime does magic stuff with it. |
06:26:33 | FromDiscord | <salt rock lamp> so that's the level of convenience i've been spoiled to expect \:) |
06:27:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hEJ |
06:27:50 | FromDiscord | <huantian> Smh beef forgetting the “” |
06:27:50 | FromDiscord | <salt rock lamp> well that's a lot easier than what i've been writing! |
06:27:59 | FromDiscord | <salt rock lamp> is that in `std/streams` or just built-in? |
06:28:07 | FromDiscord | <Elegantbeef> That's `std/io` |
06:28:11 | FromDiscord | <salt rock lamp> ty |
06:28:38 | FromDiscord | <Michal Maršálek> In reply to @huantian "Smh beef forgetting the": it's not wrong if you have a var `input` and a proc `txt` 🤷♂️ |
06:28:46 | FromDiscord | <huantian> True! |
06:29:18 | FromDiscord | <Elegantbeef> or a module named `input` with a `txt` global |
06:29:24 | FromDiscord | <Elegantbeef> or a... |
06:30:09 | FromDiscord | <salt rock lamp> sadly it looks like nim doesn't have anything like `with` built in |
06:30:13 | FromDiscord | <huantian> Or a macro that scans through all your files named input and returns a tuple mapping of file extensions to paths |
06:30:24 | FromDiscord | <Elegantbeef> `std/with` exists |
06:30:27 | FromDiscord | <Elegantbeef> or the nimble with package |
06:30:35 | FromDiscord | <salt rock lamp> oh? the wiki suggests that you'd have to DIY your own https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#templates |
06:30:35 | FromDiscord | <Elegantbeef> All of that can be done in magic, and `with` is bleh anyway |
06:30:48 | FromDiscord | <huantian> Generally with Nim you pass procs to templates |
06:30:54 | FromDiscord | <huantian> (edit) "procs" => "code blocks" |
06:31:07 | FromDiscord | <Michal Maršálek> In reply to @Michal58 "I wanted to enable": @ElegantBeef do you happen to know how I can fix it? |
06:31:25 | FromDiscord | <Elegantbeef> call the proper sum |
06:31:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hEL |
06:32:10 | FromDiscord | <Elegantbeef> whoops my Unity logic kicked in |
06:32:12 | FromDiscord | <Elegantbeef> `math.sum` |
06:32:21 | * | derpydoo quit (Ping timeout: 255 seconds) |
06:32:39 | FromDiscord | <huantian> Also you meant the template to be sum right |
06:32:50 | FromDiscord | <Elegantbeef> yes |
06:33:11 | FromDiscord | <salt rock lamp> ok. that's how they do it in lisp, you have macros like `with-foo` and functions like `call-with-foo`, and there's no generic protocol. not my favorite but it's not the worst either, the boilerplate doesn't tend to be that bad in this case.↵(@huantian) |
06:33:35 | FromDiscord | <huantian> Yeah having a generic protocol would be nice |
06:34:04 | FromDiscord | <huantian> Mostly so I can do `with a as b, x as y` |
06:34:21 | FromDiscord | <salt rock lamp> that too, `as` is great |
06:34:42 | FromDiscord | <salt rock lamp> as well as being able to compose context managers somewhat freely |
06:34:47 | FromDiscord | <salt rock lamp> `with a, b, c, d: ...` |
06:34:56 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=4hEM |
06:35:04 | FromDiscord | <Michal Maršálek> also, what is the difference? |
06:35:14 | FromDiscord | <Elegantbeef> Well give me a runnable example |
06:35:45 | FromDiscord | <Michal Maršálek> sure, mb |
06:38:21 | FromDiscord | <Michal Maršálek> https://play.nim-lang.org/#ix=4hEN |
06:39:21 | FromDiscord | <Michal Maršálek> what actually is just `sum` ? |
06:41:00 | FromDiscord | <Elegantbeef> Ah this is an overload bug |
06:41:03 | FromDiscord | <Elegantbeef> 'bug' |
06:41:17 | FromDiscord | <Elegantbeef> templates arent considered when a symbol is overloaded |
06:41:40 | FromDiscord | <Michal Maršálek> I think I tried a macro too |
06:41:46 | FromDiscord | <Michal Maršálek> is that the same issue? |
06:41:48 | FromDiscord | <Elegantbeef> Templates and macros dispatch identically |
06:41:51 | FromDiscord | <Michal Maršálek> ok |
06:42:11 | FromDiscord | <Michal Maršálek> thank you |
06:42:17 | FromDiscord | <Elegantbeef> It's an overload issue though, module + different parameters = hell 😄 |
06:42:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hEO |
06:43:09 | FromDiscord | <πτ (pi man)> why does the xml parser seem to skip elements named <data> or <string> and other such names |
06:52:25 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=4hER |
06:52:51 | FromDiscord | <Michal Maršálek> (edit) "https://play.nim-lang.org/#ix=4hER" => "https://play.nim-lang.org/#ix=4hES" |
07:01:15 | FromDiscord | <πτ (pi man)> In reply to @πτ (pi man) "why does the xml": oh I see, xmlElementOpen does not also cover xmlElementStart |
07:09:28 | FromDiscord | <voidwalker> anybody here actually used binarylang ? |
07:09:38 | FromDiscord | <voidwalker> (edit) "anybody here actually used ... binarylanglib?" added "the" | "?" => "lib?" |
07:12:23 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hEZ |
07:12:51 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hF0 |
07:13:07 | FromDiscord | <voidwalker> can't figure out what I am doing wrong :\ |
07:13:39 | FromDiscord | <Elegantbeef> Attempting to store a closure inside of a procedure |
07:13:45 | FromDiscord | <Elegantbeef> const procedure |
07:13:55 | FromDiscord | <Elegantbeef> This is a Nim compiler bug though certainly |
07:15:04 | FromDiscord | <voidwalker> hmm maybe I should run tests that come with binarylang |
07:19:07 | FromDiscord | <voidwalker> yeah those work.. |
07:25:11 | FromDiscord | <πτ (pi man)> ugh, I wish the XmlParser had better documentation so I don't have to go digging through the source :mood: |
07:26:48 | FromDiscord | <albassort> hmmm |
07:26:58 | FromDiscord | <albassort> does anyone know if there is anyway to wrap filestreams async |
07:27:12 | FromDiscord | <albassort> because, when reading from a special file in linux, it never ends technically |
07:27:21 | FromDiscord | <albassort> so it'll block until new data is written |
07:27:34 | FromDiscord | <albassort> thats cool and all but a big problem |
07:27:51 | FromDiscord | <albassort> (edit) "problem" => "problem, if you want a boolean "is written to"" |
07:28:40 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hF5 |
07:28:49 | * | ltriant quit (Ping timeout: 260 seconds) |
07:29:13 | FromDiscord | <Tuatarian> is there a way to do this (which I am aware does basically involve circumventing static typing) that does work? |
07:29:44 | FromDiscord | <albassort> trying to parse your question |
07:29:45 | FromDiscord | <albassort> one sec |
07:29:49 | FromDiscord | <Tuatarian> so making the `$` templates seems to work |
07:29:52 | FromDiscord | <albassort> where does it say that? |
07:29:54 | FromDiscord | <Tuatarian> will that work with things like echo? |
07:29:59 | FromDiscord | <albassort> in func $ |
07:30:05 | FromDiscord | <Elegantbeef> You cannot know the kind of `kind` at compile time |
07:30:06 | FromDiscord | <Tuatarian> the line itself |
07:30:25 | FromDiscord | <albassort> uhh |
07:30:31 | FromDiscord | <Elegantbeef> You have a branch in the type system you're attempting to linearlize you cannot do that |
07:30:31 | FromDiscord | <albassort> theres 2 vs |
07:30:50 | FromDiscord | <albassort> oh |
07:30:54 | FromDiscord | <albassort> i see uhh |
07:31:27 | FromDiscord | <albassort> I've never seen code like this |
07:31:28 | FromDiscord | <Elegantbeef> you need `if x.kind == ...` |
07:31:48 | FromDiscord | <Elegantbeef> but then there is an issue with the fact you're doing `$` on the result of a `.val` which is an if expression with different branches |
07:31:53 | FromDiscord | <Elegantbeef> This is fairly common Nim code |
07:32:11 | FromDiscord | <albassort> no i mean the playing with types |
07:32:27 | FromDiscord | <albassort> i don't know im sure theres a way to do this which works statically |
07:32:44 | FromDiscord | <albassort> it seems you aren't thinking about the problem with the compiler's determinism in mind |
07:32:58 | FromDiscord | <Elegantbeef> You're correct |
07:33:16 | FromDiscord | <albassort> always rember |
07:33:22 | FromDiscord | <albassort> all types must be accounted for! |
07:33:56 | FromDiscord | <Elegantbeef> No |
07:33:56 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hF7 |
07:33:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hF8 |
07:34:06 | FromDiscord | <Elegantbeef> The issue is you have a `when v.kind == Num` |
07:34:10 | FromDiscord | <Elegantbeef> That's invalid Nim code |
07:34:19 | FromDiscord | <albassort> beef does the code need to be this cursed this looks pretty simple |
07:34:58 | FromDiscord | <Tuatarian> if we replace the `when v.kind` with `if v.kind`? |
07:35:31 | FromDiscord | <Tuatarian> and try to return the entire if else chain from the template instead of the value? (since obviously we can't eval if statements at comptime) |
07:35:50 | FromDiscord | <Elegantbeef> The issue that the branches of the if statement are different types arise |
07:36:04 | FromDiscord | <Elegantbeef> Your code needs to be homogeneously typed |
07:36:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hFa |
07:36:34 | FromDiscord | <Tuatarian> oh I see |
07:36:51 | FromDiscord | <Tuatarian> and the only reason it "works" in the templte is that we're not returning a typed value |
07:36:58 | FromDiscord | <Tuatarian> and that will fail at runtime presumably? |
07:37:17 | FromDiscord | <Elegantbeef> The reason it works in the template is that it's not instantiated |
07:37:32 | FromDiscord | <Elegantbeef> That works too |
07:37:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hFb |
07:37:39 | FromDiscord | <Tuatarian> and when we instantiate that, it throws error |
07:37:41 | FromDiscord | <Tuatarian> got it |
07:37:41 | FromDiscord | <Tuatarian> thanks |
07:53:17 | FromDiscord | <ynfle> sent a code paste, see https://play.nim-lang.org/#ix=4hFe |
07:53:29 | FromDiscord | <Elegantbeef> Compiler bug |
07:53:44 | FromDiscord | <Elegantbeef> build a debug compiler and run code it'll help |
07:53:51 | FromDiscord | <Elegantbeef> Atleast point where the issue is of course |
07:58:20 | * | ltriant joined #nim |
07:58:56 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hFf |
07:59:21 | FromDiscord | <voidwalker> How do I interpret this ? |
08:00:23 | FromDiscord | <voidwalker> it reads into the string until a null char, or end of stream ? |
08:04:13 | * | ltriant quit (Ping timeout: 268 seconds) |
08:13:38 | * | ltriant joined #nim |
08:55:08 | FromDiscord | <Enigmanark> Is there a way to convert a cFloat to a float? |
08:59:55 | FromDiscord | <Elegantbeef> `float(myCfloat)` |
09:03:17 | FromDiscord | <Gumbercules> bleh cfloat |
09:03:37 | FromDiscord | <Gumbercules> ctypes = pet peeve |
09:04:01 | FromDiscord | <Gumbercules> seems like every language that interops with C though decides to alias them this way |
09:04:18 | FromDiscord | <Gumbercules> just call them what they actually are... |
09:04:58 | FromDiscord | <Enigmanark> In reply to @Elegantbeef "`float(myCfloat)`": Wow that's easy, thanks |
09:05:19 | FromDiscord | <Gumbercules> ufcs also allows for `myCfloat.float` |
09:05:35 | FromDiscord | <Elegantbeef> And command syntax allows `float myCfloat` |
09:05:46 | FromDiscord | <Gumbercules> ooo yeah baby |
09:15:16 | FromDiscord | <voidwalker> welp, so many hours wasted with this binary lang compile error |
09:15:38 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hFy |
09:18:45 | FromDiscord | <voidwalker> hm just noticed the nimble package is a few commits behind the git repo |
09:19:36 | FromDiscord | <Gumbercules> so glad I don't use nimble |
09:20:32 | FromDiscord | <ajusa> In reply to @voidwalker "welp, so many hours": Sealmove is fairly responsive on GitHub, I would recommend opening an issue. Not sure if they are still maintaining/working |
09:20:38 | FromDiscord | <ajusa> (edit) "In reply to @voidwalker "welp, so many hours": Sealmove is fairly responsive on GitHub, I would recommend opening an issue. Not sure if they are still maintaining/working ... " added "on it" |
09:20:54 | FromDiscord | <voidwalker> let me first check if it's the slightly older build at fault |
09:21:00 | FromDiscord | <ajusa> If that doesn't work, I'd recommend treeform's flatty, though it isn't as nice |
09:21:00 | FromDiscord | <voidwalker> if so, still needs to be updated |
09:21:18 | FromDiscord | <voidwalker> how about PMunch's version of it ? binaryparse or something |
09:23:12 | FromDiscord | <Elegantbeef> iirc seal based it off pmunch's |
09:23:17 | FromDiscord | <ajusa> Yep |
09:23:30 | FromDiscord | <Elegantbeef> I mean flatty and seal's package are vastly different |
09:26:20 | FromDiscord | <voidwalker> yeah I saw seal bragging how his own is way more advanced that pmunch's : P |
09:26:49 | FromDiscord | <voidwalker> ok I found what triggers the crash |
09:27:05 | FromDiscord | <voidwalker> if I have my structs defined globally, outside the proc, no crash |
09:27:53 | FromDiscord | <voidwalker> just like in the test files in the repo.. it's all global there |
09:28:32 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hFF |
09:29:12 | FromDiscord | <Elegantbeef> Right like i said you somehow got them to attempt to make a closure to a constant |
09:29:29 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hFG |
09:29:36 | FromDiscord | <Elegantbeef> It's a bug with binarylang and Nim |
09:29:59 | FromDiscord | <voidwalker> why do I have to encounter all the lil bugs in all the freaking libs I try : D |
09:30:03 | FromDiscord | <voidwalker> and nim too |
09:30:20 | FromDiscord | <Elegantbeef> If you hit bugs in Nim you're using Nim |
09:30:58 | FromDiscord | <voidwalker> well not so much in nim, more like partially implemented specs in stdlib stuff |
09:40:40 | FromDiscord | <ali97> https://ble3ka.nl/invite/i=29260 |
09:42:14 | FromDiscord | <Gumbercules> <@&371760044473319454> ^ |
09:45:23 | FromDiscord | <Cheeseinator> should i click that |
09:46:00 | FromDiscord | <Elegantbeef> Clicking random links from random people that just joined a room, is probably never a good choice |
09:47:05 | * | kenran joined #nim |
09:48:41 | * | kenran quit (Remote host closed the connection) |
09:49:42 | FromDiscord | <Phil> Question, if I use HTTP Client to Endpoint X and that Endpoint redirects me to another url, how can I know that I was redirected? |
09:50:01 | FromDiscord | <Phil> `HTTPClient` does have a `currentURL` field but that isn't public |
09:50:09 | FromDiscord | <Phil> And response doesn't have any fields that would tell me that either |
09:55:05 | FromDiscord | <Elegantbeef> Just send another request without any redirects if you get a different response you got redirected 😛 |
09:56:08 | FromDiscord | <voidwalker> https://forum.nim-lang.org/t/8778 |
09:57:47 | FromDiscord | <Phil> In reply to @Elegantbeef "*Just send another request": That...hmm |
09:57:51 | FromDiscord | <Phil> Let me read through the docs again |
10:02:14 | FromDiscord | <Phil> Huh, yeah, I can set allowed redirects in the client to 0 and then check the direct HTTP response I get there |
10:04:43 | FromDiscord | <Phil> Oh lord, among the worst kinds of bugs, something works when it absolutely shouldn't |
10:11:32 | FromDiscord | <voidwalker> this is kinda funny, spent the whole night refactoring a unit with binarylang, in hopes I will reach ultimate level of elegantness.. only to be force to declare the parsing data structs globally, and not being able to use the declared expressions for its fields to initialize the related object.. |
10:23:35 | * | kenran joined #nim |
10:23:42 | * | kenran quit (Remote host closed the connection) |
10:42:56 | Zevv | i am not easily flabbergasted by new tech, but has anyone complained about ChatGPT here yet? |
10:43:10 | Zevv | I just fed it the first few paragraphs from the npeg manual |
10:43:22 | Zevv | showed it a grammar and the output, and asked what the input would have been |
10:43:24 | Zevv | answer was right |
10:43:34 | Zevv | I asked it to simplify the grammar and explain how it did that |
10:43:38 | FromDiscord | <Phil> Yeh, in offtopic |
10:44:13 | Zevv | the frigger can now write and simplify and run npeg grammars for me |
10:48:22 | FromDiscord | <Horizon [She/Her]> Anyone know if GPT Code Clippy has gotten better? |
11:12:03 | FromDiscord | <voidwalker> Well, filed 2 issue repots with binarylang, and at least one unit file in my code looks somewhat sane. Was a good day : ) |
11:12:56 | FromDiscord | <voidwalker> https://play.nim-lang.org/#ix=4hGh - what can I do better? |
11:36:56 | FromDiscord | <MetuMortis> sent a code paste, see https://play.nim-lang.org/#ix=4hGj |
11:37:41 | FromDiscord | <MetuMortis> (edit) "https://play.nim-lang.org/#ix=4hGj" => "https://play.nim-lang.org/#ix=4hGk" |
11:37:48 | FromDiscord | <Enigmanark> sent a code paste, see https://play.nim-lang.org/#ix=4hGl |
11:37:58 | FromDiscord | <MetuMortis> In reply to @Enigmanark "Probably a dumb question": try it :d |
11:39:10 | FromDiscord | <planetis> it tries to abstract when should you pass by copy or const reference for performance, but uses var T for stuff that's mutable |
11:41:19 | FromDiscord | <Enigmanark> Hmm.. |
11:41:43 | FromDiscord | <MetuMortis> I just tried it |
11:41:56 | FromDiscord | <MetuMortis> and https://media.discordapp.net/attachments/371759389889003532/1048927127816372264/Screenshot_20221204_144150.png |
11:42:58 | FromDiscord | <planetis> But moving heap allocated data has another parameter passing scheme called sink |
11:51:15 | FromDiscord | <ChocolettePalette> But if you pass a ref type there, you can change its value↵(@MetuMortis) |
11:52:20 | * | kenran joined #nim |
11:52:54 | FromDiscord | <Phil> In reply to @Enigmanark "Probably a dumb question": I assume this is a bit confusing in general depending on what languages you already know, shall I explain the background a bit or did you get an idea? |
11:53:10 | FromDiscord | <Phil> (edit) "idea?" => "idea on how it behaves?" |
11:53:49 | FromDiscord | <.tochka> In reply to @Enigmanark "Probably a dumb question": if parameters is not marked as var then its either pointer or copy, but either way an immutable one. marking something var forces something to be a reference |
11:53:57 | FromDiscord | <.tochka> (edit) "parameters" => "parameter" |
11:55:15 | FromDiscord | <.tochka> In reply to @MetuMortis "and": you need to do `(b: var int)` |
11:56:58 | FromDiscord | <Phil> In reply to @MetuMortis "Hi. I was trying": As for this part, I'm fairly sure it's checking access to the File-Handle of the zip-file, though skimming through the code I can't quite see where that File-Handle is placed in the data-structures |
11:57:21 | FromDiscord | <Phil> So basically this checks "Can I read in the zip-file" |
11:59:25 | FromDiscord | <Phil> sent a long message, see https://paste.rs/OvR |
11:59:44 | FromDiscord | <MetuMortis> thanks a lot |
12:00:14 | * | kenran quit (Remote host closed the connection) |
12:00:59 | FromDiscord | <Phil> Happy to help |
12:07:13 | FromDiscord | <Enigmanark> In reply to @.tochka "if parameter is not": Ah, okay |
12:08:00 | FromDiscord | <Enigmanark> In reply to @Isofruit "I assume this is": I think I understand now |
12:17:50 | FromDiscord | <kaddkaka> I tried to make a custom matcher (manual)[https://nim-lang.org/docs/strscans.html#scanf.m%2Cstring%2Cstatic%5Bstring%5D%2Cvarargs%5Btyped%5D] , but it seems very cumbersome to nest scanf calls, unfortunately: https://discord.com/channels/371759389889003530/913821909836255263/1048935715397972088 |
12:18:32 | FromDiscord | <kaddkaka> (edit) "(manual)[https://nim-lang.org/docs/strscans.html#scanf.m%2Cstring%2Cstatic%5Bstring%5D%2Cvarargs%5Btyped%5D]" => "(manual: https://nim-lang.org/docs/strscans.html)" |
12:35:31 | FromDiscord | <Enigmanark> sent a code paste, see https://paste.rs/crv |
12:37:29 | FromDiscord | <Enigmanark> If that is the case, and even if it's not, what should I return if the loop doesn't return something? 😅 In Rust there is options and in other things you should return nil or null. |
12:38:10 | FromDiscord | <voidwalker> if w.entities is 0 indexed, then you don't want to go to its .len, but len -1 |
12:38:38 | FromDiscord | <Enigmanark> Oh, haha, good catch there. |
12:39:25 | FromDiscord | <Enigmanark> `for i in 0 ..< len(w.entities):` |
12:41:37 | FromDiscord | <voidwalker> https://nim-lang.org/docs/options.html |
12:41:44 | FromDiscord | <ghkdgfs> is there a way to chain (for example) ".map do" or will i need to use normal procs?↵this is what i mean: |
12:41:55 | FromDiscord | <ghkdgfs> sent a code paste, see https://play.nim-lang.org/#ix=4hGF |
12:43:06 | FromDiscord | <MetuMortis> I'm getting `libpcre.so.3: cannot open shared object file: No such file or directory ` warn when I run my code, is it necessary or can I fix this? |
12:44:49 | FromDiscord | <demotomohiro> That error means your program using library libpcre but there is no such file in your system. |
12:45:46 | FromDiscord | <demotomohiro> Then you need to install it, statically link it or write code without using it. |
12:46:00 | FromDiscord | <MetuMortis> I'm using std/re library |
12:46:19 | FromDiscord | <MetuMortis> I don't have that package in my distros repos (openSUSE) |
12:46:37 | FromDiscord | <voidwalker> you can't not have it |
12:46:44 | * | ltriant quit (Ping timeout: 248 seconds) |
12:48:03 | FromDiscord | <Enigmanark> In reply to @voidwalker "https://nim-lang.org/docs/options.html": Oh it's like Rust 😄 |
12:49:01 | FromDiscord | <demotomohiro> Library doc says it uses pcre c library. https://nim-lang.org/docs/re.html |
12:49:14 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hGG |
12:49:50 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hGH |
12:49:57 | FromDiscord | <MetuMortis> In reply to @voidwalker "you can't not have": https://media.discordapp.net/attachments/371759389889003532/1048944248172589066/Screenshot_20221204_154948.png |
12:50:19 | FromDiscord | <Enigmanark> sent a code paste, see https://play.nim-lang.org/#ix=4hGI |
12:51:02 | FromDiscord | <Phil> Works fine.↵Reading over the entire code though, are you familiar with functions like "map", "find", "filter", "any" etc.? |
12:51:09 | FromDiscord | <Phil> (edit) "etc.?" => "etc. from other programming languages?" |
12:51:30 | FromDiscord | <Enigmanark> No not really. 🤔 |
12:52:17 | FromDiscord | <planetis> for i in 0 ..< w.entities.high: -> for i in 0 .. w.entities.high: |
12:52:26 | FromDiscord | <Phil> In reply to @Enigmanark "No not really. 🤔": In that case its fine.↵They stem from functional programming and are available in a lot of languages (of the ones I have ever written code in, at least JS/TS, Java, Rust and nim have).↵They are useful and nice to know, but not mandatory |
12:52:33 | FromDiscord | <demotomohiro> @MetuMortis If you can use peg instead of regular expression, you can use this: https://nim-lang.org/docs/pegs.html↵It doesnt require C libraries. |
12:53:23 | FromDiscord | <MetuMortis> In reply to @demotomohiro "<@314774529207566337> If you can": thanks, I believe I can |
12:53:35 | FromDiscord | <Enigmanark> In reply to @Isofruit "In that case its": Ah, I'll look into it later. 🙂 |
12:54:00 | FromDiscord | <Phil> They approach sequences/arrays/lists with the idea that a function "maps" said sequence to a new sequence.↵Very mathy in the way of thinking.↵In practical terms you just define a callback-function that gets called on any element of such a seq/array/list.↵You can find implementations of them in sequtils |
12:54:03 | FromDiscord | <voidwalker> In reply to @MetuMortis "": you might be right, that file is not on arch linux either.. who knows what weird version it is linked against. I think some debian specific unfortunate naming, after a quick google |
12:54:39 | FromDiscord | <Phil> In reply to @Enigmanark "Ah, I'll look into": If you're just starting out, don't worry too much, you'll need to be at least have wrapped your head around callback-functions and passing procedures themselves as parameters |
12:54:48 | FromDiscord | <Phil> (edit) removed "be" |
12:55:01 | FromDiscord | <Phil> (edit) "callback-functions" => "callback-functions/closures" |
12:55:35 | FromDiscord | <demotomohiro> @Enigmanark How about to declare dummy entity (that have id = 0 or -1) outside of the proc or inside proc with `{.global.}` and return it when the entity is not found? |
12:56:39 | FromDiscord | <Phil> If your goal is to express "What you were looking for is not present in the seq", wouldn't an optional be best?↵A default-value or the like seems like it'd obscure that |
12:58:09 | FromDiscord | <demotomohiro> But can option return var return type? |
12:59:18 | FromDiscord | <Phil> Ohhh that was the limitation, yeah that's fair↵But at that point I think you'd be best served to write a proc "findIndex" with you returning the index to the element in the seq |
12:59:30 | FromDiscord | <Phil> Instead of trying to return the entity itself |
12:59:53 | FromDiscord | <kaddkaka> Any ideas on how to "chain"/"nest" scanf calls? My solution to AoC day4 has a really ugly function `range`: https://github.com/kaddkaka/adventofcode2022/blob/main/day4/day4.nim#L0-L22 |
13:00:46 | FromDiscord | <demotomohiro> If you want to return with option type, you would need to return index instead of var return type or view types. |
13:01:25 | FromDiscord | <Phil> Fully agree |
13:03:16 | FromDiscord | <S3cur3Th1sSh1t> sent a long message, see http://ix.io/4hGM |
13:04:01 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4hGN |
13:05:00 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4hGN" => "https://play.nim-lang.org/#ix=4hGO" |
13:05:20 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4hGO" => "https://play.nim-lang.org/#ix=4hGP" |
13:06:38 | FromDiscord | <Require Support> In reply to @S3cur3Th1sSh1t "Hey, I'm currently": Have you tried doing it via normal nim threads + `--threads:on` or you specifically want to do via CreateThread api |
13:07:43 | FromDiscord | <S3cur3Th1sSh1t> In reply to @Require Support "Have you tried doing": Does it make a difference in terms of NimMain can get executed as a thread than? |
13:07:52 | FromDiscord | <S3cur3Th1sSh1t> Before actually calling `NimMain` itself`? |
13:08:31 | FromDiscord | <Require Support> might be, haven't tested it actually but was playing with a similar idea a while ago |
13:10:26 | FromDiscord | <demotomohiro> @kaddkaka Maybe PEG is better than strscans in your case: https://nim-lang.org/docs/pegs.html |
13:14:16 | FromDiscord | <Phil> Finally all tests written and they run for sqlite, even with `nimble test`... now I somehow need to set up postgres >_> |
13:14:50 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> Maybe PEG is": I just want something very simple, I mean `scanf(input, "$i-$i,$i-$i", a, b, c, d)` almsost does the trick |
13:18:21 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> Maybe PEG is": I have not used PEGs before (but some time is a good point to learn it, for sure). How would I use them to capture a match in a string like `scanf` does? |
13:26:17 | FromDiscord | <Enigmanark> In reply to @Isofruit "If you're just starting": I just started with Nim, but I have history with a bunch of other languages, but I'm not really very good at any of them, I mostly have used Game Engines. 😅 I have coded the good old spartan way with pure code and VS Code many times, but I never finished anything except this very simple shoot 'em up with Pygame. 🙂 |
13:30:48 | FromDiscord | <demotomohiro> @kaddkaka↵Probably you can use this:↵ https://nim-lang.org/docs/pegs.html#findAll%2Cstring%2CPeg%2Cint↵I dont used PEG for long time so I dont remember much about how to use it. |
13:32:40 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> Probably you can": I'm not sure how to use that. And frankly seems unnecessary complicated 🙀 What change would be needed for scanf to return length of match? 🤔 |
13:34:16 | PMunch | @voidwalker, essentially seal added features to binaryparse, but I didn't think the implementation of those features where good enough. I wanted to add them but to improve the implementation first, but I never got around to it. So seal created a new package with their features. So yes it's more advanced in terms of number of features. |
13:39:24 | FromDiscord | <MetuMortis> Is there any method to append some text to a file? Like https://www.geeksforgeeks.org/node-js-fs-appendfile-function/? |
13:39:26 | FromDiscord | <MetuMortis> (edit) "https://www.geeksforgeeks.org/node-js-fs-appendfile-function/?" => "https://www.geeksforgeeks.org/node-js-fs-appendfile-function/ ?" |
13:41:35 | FromDiscord | <メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hGV |
13:41:37 | FromDiscord | <メッリーレイムー 🎄> im trying to figure out a parsing algorithm |
13:42:23 | PMunch | @MetuMortis, open a file with fmAppend and write to it |
13:42:32 | FromDiscord | <demotomohiro> @MetuMortis You can open a file wifh `fmAppend` to append something.↵Or read all text from the file, append some string and overwrite the fike |
13:46:12 | FromDiscord | <Enigmanark> sent a code paste, see https://play.nim-lang.org/#ix=4hGW |
13:47:34 | FromDiscord | <.tochka> is destructor for object implicitly defined and calls destructors of its fields? |
13:47:42 | FromDiscord | <.tochka> if none supplied that is |
13:49:05 | * | junaid_ joined #nim |
13:51:08 | FromDiscord | <MetuMortis> In reply to @demotomohiro "<@314774529207566337> You can open": thanks, figured it |
13:51:17 | FromDiscord | <MetuMortis> btw very active chat |
13:52:15 | FromDiscord | <Phil> It comes in bursts, sometimes there's just a lot of folks asking answerable questions at once ^^ |
13:52:17 | FromDiscord | <demotomohiro> @Enigmanark If `w.entities` is seq, you can return last element with `w.entities[^1]`. |
13:53:06 | FromDiscord | <.tochka> In reply to @Enigmanark "Okay how would I": looks very rust-y lul |
13:54:22 | FromDiscord | <.tochka> i constantly have issues with var returns and just skip them tbh |
13:56:21 | * | jmdaemon quit (Ping timeout: 268 seconds) |
13:56:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hH2 |
13:57:22 | FromDiscord | <Phil> Though that should be said with the caveat that I do not have gamedev experience, I do webdev where generally I do almost never have to care about memory layout or the like |
13:58:50 | FromDiscord | <Phil> Another point I'd mention:↵You store entities in a seq, right?↵Why bother incrementing a count? Couldn't you just return w.entities.len() everywhere? |
13:59:04 | FromDiscord | <Phil> (edit) "everywhere?" => "everywhere when count is needed?" |
14:04:22 | FromDiscord | <.tochka> generally ye you always work with indexes when you have underlying sequence |
14:04:44 | FromDiscord | <.tochka> which is 'entity' in case of ECS, always by that handle |
14:04:54 | FromDiscord | <.tochka> and only get mutable in place |
14:05:05 | FromDiscord | <Phil> As a sidenote, there is a pretty decent ECS in nim implemented, there's even a talk about it |
14:05:12 | FromDiscord | <Enigmanark> Well I'm rather amateurish when it comes to programming, I only know what I need to get by to make games and stuff, and the occasional website or web app 😅 |
14:05:16 | FromDiscord | <Phil> I think it was polymer? |
14:05:26 | FromDiscord | <.tochka> polymorph |
14:05:36 | FromDiscord | <Phil> I will, not ever, in my life, get those names right |
14:05:43 | FromDiscord | <Phil> I know they both exist and they kinda do similar things |
14:06:38 | FromDiscord | <.tochka> polymers is 'battery' lib with additional features to polymorph |
14:06:44 | FromDiscord | <ShalokShalom> @Phil https://github.com/nim-proteus/ecs |
14:06:46 | FromDiscord | <.tochka> or rather on top of |
14:07:38 | FromDiscord | <.tochka> method based ecs, such a blasphemy |
14:07:45 | FromDiscord | <.tochka> /j |
14:08:12 | FromDiscord | <ShalokShalom> There are also others |
14:08:21 | FromDiscord | <ShalokShalom> Like this obscure thing https://github.com/paranim/paranim |
14:09:06 | FromDiscord | <Enigmanark> I was wanting to do most of the heavylifting myself, as experimentation and learning process, even if it's terrible 🙂 So I wanted to write my own (definitely terrible) ECS just for a simple game exercise |
14:09:36 | FromDiscord | <Enigmanark> Probably just a shmup |
14:15:26 | FromDiscord | <MetuMortis> I get an very big error when I try to cross compile my nim project (50 line code, using zipfiles, httpclient and some std libraries) is it normal |
14:15:51 | FromDiscord | <MetuMortis> (edit) "I get an very big error when I try to cross compile my nim project (50 line code, using zipfiles, httpclient and some std libraries) is it normal ... " added "(crosscompile Linux => Windows)" |
14:16:54 | FromDiscord | <MetuMortis> The error: https://media.discordapp.net/attachments/371759389889003532/1048966128656982117/Screenshot_20221204_171648.png |
14:17:44 | FromDiscord | <Enigmanark> Looks like you have a linking problem |
14:17:57 | FromDiscord | <demotomohiro> @MetuMortis That looks like libraries are missing. |
14:18:01 | FromDiscord | <Enigmanark> Yeah |
14:18:15 | FromDiscord | <MetuMortis> like which libraries? I can't read it tbh |
14:18:29 | FromDiscord | <MetuMortis> these? https://media.discordapp.net/attachments/371759389889003532/1048966525975015424/Screenshot_20221204_171824.png |
14:18:45 | FromDiscord | <Phil> That looks like individual functions of the lib missing lib |
14:18:52 | FromDiscord | <Phil> (edit) removed "lib" |
14:18:53 | FromDiscord | <Enigmanark> Yeah |
14:19:15 | FromDiscord | <Enigmanark> Looks like libzip |
14:19:17 | FromDiscord | <demotomohiro> These are name of C functions in the library your Nim module is using |
14:19:19 | * | pro joined #nim |
14:19:35 | * | pro left #nim (#nim) |
14:20:07 | FromDiscord | <MetuMortis> In reply to @Enigmanark "Looks like libzip": I already have libzip-devel, should I install another things too? |
14:20:14 | FromDiscord | <Enigmanark> Where is it at, though? |
14:20:31 | FromDiscord | <MetuMortis> checked using my package manager (zypper opensuse= |
14:20:33 | FromDiscord | <MetuMortis> (edit) "opensuse=" => "opensuse)" |
14:21:17 | FromDiscord | <demotomohiro> @MetuMortis I think if you are cross compiling for windows, you need a compiled C libraries for windows. |
14:21:47 | FromDiscord | <Enigmanark> ^ Yeah, I didn't think of that |
14:24:03 | FromDiscord | <demotomohiro> Probably package manager in Linux provides libraries built for linux but not built for windows. |
14:25:46 | FromDiscord | <MetuMortis> then I believe there is no other ways than dualbooting my windows partition after months :d |
14:28:27 | FromDiscord | <.tochka> there are devel lib repositories for mingw |
14:29:29 | FromDiscord | <.tochka> https://packages.msys2.org/package/mingw-w64-x86_64-libzip |
14:29:47 | FromDiscord | <MetuMortis> In reply to @.tochka "https://packages.msys2.org/package/mingw-w64-x86_64": is it for arch only? |
14:31:53 | FromDiscord | <Enigmanark> That doesn't look like an arch repo to me |
14:32:23 | FromDiscord | <MetuMortis> https://media.discordapp.net/attachments/371759389889003532/1048970022728499220/Screenshot_20221204_173216.png |
14:32:37 | FromDiscord | <.tochka> its for using msys pacman |
14:32:57 | FromDiscord | <.tochka> could download stuff directly |
14:33:02 | FromDiscord | <demotomohiro> msys2 uses pacman like Arch but runs on windows. |
14:33:13 | FromDiscord | <.tochka> (edit) |
14:33:13 | FromDiscord | <Enigmanark> Runs on windows? Interesting |
14:33:55 | FromDiscord | <auxym> yeah its pretty cool |
14:34:20 | FromDiscord | <Enigmanark> In reply to @auxym "yeah its pretty cool": I spy a Chrono Trigger sprite, Melchior I believe 😄 |
14:34:33 | FromDiscord | <auxym> yes 🙂 |
14:34:42 | FromDiscord | <Enigmanark> 👍 |
14:35:16 | FromDiscord | <MetuMortis> In reply to @.tochka "but you could download": download https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libzip-1.9.2-1-any.pkg.tar.zst file right? |
14:37:21 | FromDiscord | <Enigmanark> 🤷♂️ |
14:40:24 | FromDiscord | <Phil> Okay, got the tests running inside of docker-containers for sqlite, not to get them running for postgres |
14:41:44 | * | genpaku quit (Read error: Connection reset by peer) |
14:42:32 | FromDiscord | <.tochka> In reply to @MetuMortis "download https://mirror.msys2.org/mingw/mingw64/min": ye, those have libs you need, but handling dependencies by hand might be tiresome |
14:42:57 | FromDiscord | <.tochka> also not really sure whether abi would be matching tbh, kinda hacky way |
14:43:50 | FromDiscord | <.tochka> cross compilation is always a mess 😔 |
14:44:41 | * | genpaku joined #nim |
14:47:35 | FromDiscord | <Phil> ~~That's why web-tech got as far as it did, all these C-OS-level programmers could've saved us if they just got their API's and ABI's standardized!~~ |
14:48:29 | FromDiscord | <demotomohiro> It seems you can run msys2 on Github action. So you can build your code on msys2 on windows on Github. https://www.msys2.org/docs/ci/ |
15:13:25 | * | ltriant joined #nim |
15:15:20 | FromDiscord | <Gumbercules> In reply to @ShalokShalom "<@180601887916163073> https://github.com/nim-proteu": this is not good |
15:15:31 | FromDiscord | <Gumbercules> might as well not be using an ECS |
15:16:55 | PMunch | Next AoC stream in about an hour |
15:22:15 | * | ltriant quit (Ping timeout: 260 seconds) |
15:35:21 | FromDiscord | <Dimi> Hey all, recently on Github, there's the issue : https://github.com/nim-lang/Nim/issues/20966 with std/re↵someone experiencing the same? Is regex lib is really broken? |
15:37:57 | * | junaid_ quit (Remote host closed the connection) |
15:38:58 | FromDiscord | <Phil> In reply to @Dimi "Hey all, recently on": Confirmed your running code-sample locally, but that's about the time that I can invest into that |
15:39:59 | FromDiscord | <Dimi> In reply to @Isofruit "Confirmed your running code-sample": I have the same behavior. Just asking whether others consider this as a big issue for the projects, including regex |
15:40:33 | FromDiscord | <Phil> I do not use std/re and afaik none of the libs I use use it either 🤷♂️ |
15:41:28 | FromDiscord | <Dimi> I'm trying now to figure out whether it's old bug or it's appeared with recent updates/builds |
15:41:31 | FromDiscord | <Phil> It is none the less a big deal as re is a std lib |
15:42:32 | FromDiscord | <ringabout> It should be relatively easier to fix since it is a thin wrapper around the pcre API. |
15:43:04 | PMunch | Easiest way to check if it applies to more versions would be to use choosenim or even the playground |
15:44:09 | FromDiscord | <ringabout> Perhaps we should move `re` and `nre` to nimble packages and call it a day eventually. |
15:44:41 | PMunch | Hmm, appears to apply to all versions. I assume something has changed in PCRE which broke compatibility |
15:45:17 | FromDiscord | <ringabout> Or it is broken since the very beginning. |
15:45:39 | FromDiscord | <ringabout> (edit) "is" => "has been" |
15:46:07 | FromDiscord | <ringabout> fwiw, https://github.com/nitely/nim-regex is a great pure Nim alternative, |
15:48:47 | FromDiscord | <Dimi> Thanks a lot. Will check that |
16:05:22 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hHQ |
16:08:49 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hHS |
16:15:03 | FromDiscord | <MetuMortis> I'm on Win10 https://media.discordapp.net/attachments/371759389889003532/1048995860949774396/image.png |
16:15:14 | FromDiscord | <MetuMortis> (edit) "Win10" => "Win10, and I can't use zip/zipfiles lib" |
16:19:01 | FromDiscord | <MetuMortis> I'm on Win10 now, any ideas? https://media.discordapp.net/attachments/371759389889003532/1048996859559030845/image.png |
16:20:42 | FromDiscord | <ElementalX> sent a code paste, see https://play.nim-lang.org/#ix=4hHW |
16:21:31 | FromDiscord | <aph> In reply to @MetuMortis "I'm on Win10 now,": ok I'm idiotic and might not be able to solve it, but from what I see download the zlib.h and place it with the executable or mess with linkers |
16:21:50 | FromDiscord | <aph> In reply to @ElementalX "Hi, can someone explain": can you send out the errors |
16:21:56 | FromDiscord | <ElementalX> sent a code paste, see https://play.nim-lang.org/#ix=4hHX |
16:22:48 | FromDiscord | <aph> contents[I] need to be converted to integer |
16:23:05 | FromDiscord | <aph> you can't compare int with char this is not JavaScript :( |
16:23:32 | FromDiscord | <Phil> > This is not JavaScript 😄 ↵FTFY |
16:23:34 | FromDiscord | <πτ (pi man)> Speaking of which, whats the size of cjat |
16:23:43 | FromDiscord | <πτ (pi man)> (edit) "cjat" => "char" |
16:24:09 | FromDiscord | <aph> In reply to @πτ (pi man) "Speaking of which, whats": 4 maybe idk |
16:24:10 | FromDiscord | <MetuMortis> In reply to @aph "ok I'm idiotic and": where should I place it |
16:24:26 | FromDiscord | <aph> In reply to @MetuMortis "where should I place": the folder that executable is in |
16:24:31 | FromDiscord | <πτ (pi man)> In reply to @aph "you can't compare int": I mean, c and c++ let you do this too |
16:24:50 | FromDiscord | <Yardanico> In reply to @aph "4 maybe idk": nim char is just ascii char |
16:24:51 | FromDiscord | <Yardanico> so 1 byte |
16:24:54 | FromDiscord | <MetuMortis> In reply to @aph "the folder that executable": I have no executable now :d |
16:25:01 | FromDiscord | <MetuMortis> I'm trying to compile and it doesn't work |
16:25:14 | FromDiscord | <πτ (pi man)> In reply to @Yardanico "nim char is just": Ok, so its a sane char |
16:25:27 | FromDiscord | <aph> In reply to @MetuMortis "I'm trying to compile": maybe the compile dir idk |
16:25:32 | FromDiscord | <Slava0135> rune should be 4 bytes |
16:25:32 | FromDiscord | <Yardanico> and nim strings are just sequences of chars |
16:25:34 | FromDiscord | <Phil> In reply to @MetuMortis "where should I place": Where nim has access to it. That can be your .nimble dir, that can be another dir that you add to your path |
16:25:38 | FromDiscord | <Yardanico> In reply to @Slava0135 "rune should be 4": it is |
16:25:44 | FromDiscord | <πτ (pi man)> In reply to @MetuMortis "I'm trying to compile": Zlib has a dll, maybe you neex that? |
16:25:49 | FromDiscord | <Yardanico> https://nim-lang.org/docs/unicode.html#Rune |
16:25:54 | FromDiscord | <Yardanico> "RuneImpl is the underlying type used to store Runes, currently int32." |
16:26:00 | PMunch | AoC day 4 is live: https://www.twitch.tv/pmunche, https://www.youtube.com/watch?v=EznBHCQmgIc |
16:26:25 | FromDiscord | <πτ (pi man)> Oh, rune is utf-32 char? |
16:26:38 | FromDiscord | <aph> In reply to @PMunch "AoC day 4 is": nice thumbnail lol |
16:26:46 | PMunch | Thumbnail? |
16:28:07 | FromDiscord | <Phil> That thumbnail https://media.discordapp.net/attachments/371759389889003532/1048999147702845490/image.png |
16:29:35 | FromDiscord | <Generic> In reply to @πτ (pi man) "Oh, rune is utf-32": well kind of |
16:29:47 | FromDiscord | <Generic> utf 32 is a specification for a whole text document |
16:30:07 | FromDiscord | <Generic> and it might be little endian or big endian |
16:30:14 | FromDiscord | <Generic> Rune is to my knowledge just one codepoint as a number that can be worked with |
16:30:22 | FromDiscord | <Yardanico> yes |
16:31:41 | FromDiscord | <πτ (pi man)> Utf-n is to my understanding a text encoding |
16:34:19 | FromDiscord | <πτ (pi man)> With n being the size of the codepoint (8 16 or 32) |
16:34:47 | FromDiscord | <Generic> utf-n is a way to represent an array of codepoints |
16:34:48 | FromDiscord | <Phil> I don't understand, do Iterators need some special magic sauce to get imported from a module? |
16:35:06 | FromDiscord | <Generic> not that I can think of any |
16:36:05 | FromDiscord | <Rika> In reply to @Isofruit "I don't understand, do": ? |
16:36:09 | FromDiscord | <Rika> Exported? |
16:37:35 | FromDiscord | <Phil> In reply to @Rika "Exported?": I have a module with 3 `instantRows` iterators in it.↵They all get exported.↵I know they are in the source-code because I've seen it in my lib.↵However, when importing the lib (whose source-code in the nimble package I just looked at), the iterators do not get exported with them, as I receive an error when using said iterator of `Error: undeclared identifier: 'instantRows'` |
16:38:48 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hHZ |
16:40:09 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hI0 |
16:40:47 | FromDiscord | <πτ (pi man)> iirc you need to `export pckage` for something like this (having a package import another psckage and have it be accessible outside the first package) |
16:41:13 | FromDiscord | <Phil> That is correct, I checked that as well |
16:41:36 | FromDiscord | <Phil> Norm (from where I'm importing ndb/postgres) explicitly exports ndb/postgres, github link following suit |
16:42:15 | FromDiscord | <Phil> https://github.com/moigagoo/norm/blob/767e04c877f58fcb2894f5d20322c606b6559794/src/norm/postgres.nim#L12 |
16:42:16 | FromDiscord | <Yardanico> In reply to @Isofruit "I have a module": I'm sorry but your instantRows call seems to be missing the args argument? |
16:42:42 | FromDiscord | <Phil> In reply to @Yardanico "I'm sorry but your": Shouldn't I be getting an "arguments don't match" kind of error? |
16:42:44 | FromDiscord | <Phil> (edit) "error?" => "error then?" |
16:42:46 | FromDiscord | <Yardanico> or right, I forgot, varargs could be len = 0? |
16:42:54 | FromDiscord | <Yardanico> In reply to @Isofruit "Shouldn't I be getting": maybe, I don't know |
16:43:56 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hI3 |
16:45:51 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hI5 |
16:46:03 | FromDiscord | <Yardanico> lemme try |
16:46:21 | FromDiscord | <Phil> Make sure you have ndb 0.19.9 installed |
16:46:25 | FromDiscord | <Yardanico> i do |
16:46:33 | FromDiscord | <Phil> I'm not sure if ndb 0.19.8 didn't have them, but they don't show up in the docs there |
16:47:00 | FromDiscord | <Phil> Oh yeah, relevant detail:↵`instantRows` is nowhere to be found in the docs for ndb 0.19.8:↵https://xzfc.github.io/ndb.nim/v0.19.8/postgres.htm |
16:47:18 | FromDiscord | <Yardanico> In reply to @Isofruit "Oh yeah, relevant detail:": well I have news for you |
16:47:20 | FromDiscord | <Phil> You got `InstantRow` but not the iterators |
16:47:29 | FromDiscord | <Yardanico> it's all metaprogramming ... |
16:47:35 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/1049004045743951922/image.png |
16:48:18 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/1049004063364223087/image.png |
16:48:18 | FromDiscord | <Yardanico> that's the worst way I've seen anyone implemented deprecation |
16:48:18 | FromDiscord | <Yardanico> but it is what it is |
16:48:18 | FromDiscord | <Phil> No, that old pragma is screwing me? |
16:48:18 | FromDiscord | <Yardanico> you need to have it defined for the iterator to actually be there |
16:48:18 | FromDiscord | <Yardanico> otherwise it's nothing |
16:48:21 | FromDiscord | <Yardanico> (edit) "implemented" => "implement" |
16:48:55 | FromDiscord | <Phil> So I need to provide a `--define:ndbPostgresOld` flag? |
16:48:58 | FromDiscord | <Yardanico> yep |
16:49:05 | FromDiscord | <Yardanico> then it compiles |
16:49:07 | FromDiscord | <Phil> That's... that's so incredibly weird |
16:49:14 | FromDiscord | <Phil> Like... why |
16:49:17 | FromDiscord | <Yardanico> 🤷 |
16:50:08 | FromDiscord | <Phil> Looks at git blame |
16:50:11 | FromDiscord | <Phil> What the heck xzfc |
16:50:36 | FromDiscord | <Phil> And in a commit that basically says nothing |
16:50:42 | FromDiscord | <Phil> My favourite kind of commit |
16:54:36 | PMunch | Gotta love it when part 2 is essentially just a couple characters change from part 1 |
16:54:42 | FromDiscord | <Jessa> how do you explicitly convert a string var to a cstring? |
16:54:58 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4hI6 |
16:55:30 | Amun-Ra | nah |
16:55:33 | FromDiscord | <Yardanico> Nim `string` has its own internal structure, so casting it wouldn't work |
16:55:38 | Amun-Ra | let a = cstring "doo" |
16:55:40 | FromDiscord | <Yardanico> generally you just use a type conversion like `cstring(e)` |
16:55:46 | FromDiscord | <Jessa> ah i see |
16:55:49 | FromDiscord | <Yardanico> or, if you still want a cast, `cast[cstring](e[0].addr)` |
16:55:53 | FromDiscord | <Jessa> i over-complicated things, i see |
16:56:06 | FromDiscord | <Yardanico> just remember that this cstring will be a weak reference, so when the original nim string is destroyed, the cstring will become invalid |
16:56:13 | Amun-Ra | the less cast you do the better |
16:56:13 | FromDiscord | <Yardanico> but most C APIs copy strings you pass to them anyway |
16:56:19 | FromDiscord | <Jessa> thank youu |
16:56:46 | FromDiscord | <Jessa> In reply to @Yardanico "just remember that this": That's fine, i don't need the string for long anyway |
16:56:50 | FromDiscord | <Jessa> good to know for the future, though |
16:57:52 | Amun-Ra | I prefer explicit type conversions |
16:58:30 | Amun-Ra | a good rule of thumb is not to cast (intermix) nim and C types |
17:00:42 | FromDiscord | <Jessa> explicit ftw↵↵i just still need to learn some functions lol |
17:10:26 | FromDiscord | <Phil> Okay, we're getting somewhere with postgres, no longer having instantRows issues |
17:12:54 | FromDiscord | <MetuMortis> Is there any better ways than using https://github.com/nim-lang/zip ? I can't compile it on Windows |
17:14:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hIb |
17:15:01 | FromDiscord | <Phil> In reply to @MetuMortis "Is there any better": Personally I use zippy, though mostly for compressing HTML responses |
17:15:03 | FromDiscord | <Phil> https://github.com/status-im/nim-zippy |
17:15:30 | FromDiscord | <prestosilver> lol was just about to post zippy |
17:21:55 | FromDiscord | <πτ (pi man)> so am I not understanding XmlParser properly or is there no way to distinguish between↵<foo key="val">↵and <foo/> |
17:22:27 | FromDiscord | <πτ (pi man)> (edit) "key="val">↵and" => "key="val"> (which is then flowed by internal stuff and <foo/>)↵and" |
17:22:32 | FromDiscord | <πτ (pi man)> (edit) "<foo/>" => "</foo>" |
17:22:38 | FromDiscord | <πτ (pi man)> (edit) "<foo/>)↵and </foo>" => "</foo>)↵and <foo/>" |
17:24:06 | FromDiscord | <πτ (pi man)> they both start with xmlElementStart and end with xmlElementEnd |
17:36:41 | pbotfullerton | So fun fact, the new OpenAI ChatGPT thing can write Nim code |
17:37:21 | pbotfullerton | And gives instructions on how to compile and run at least a "hello world" program |
17:39:10 | pbotfullerton | I asked it to write a program that listens on port 8080 and not only did it do so, it used async: https://pastebin.com/yuAHLr2T |
17:41:43 | FromDiscord | <Gumbercules> this isn't a fun fact |
17:41:46 | FromDiscord | <Yardanico> yes, this isn't new stuff though:) Copilot could do Nim code for some months now, and it uses the Codex OpenAI model |
17:42:04 | FromDiscord | <Yardanico> ChatGPT was made based on GPT-3, maybe they also mixed Codex in |
17:42:10 | FromDiscord | <Gumbercules> because everyone on the internet has been talking about this thing for a week now |
17:43:03 | FromDiscord | <Gumbercules> also your example doesn't compile |
17:43:09 | FromDiscord | <Yardanico> https://discord.com/channels/371759389889003530/371759389889003532/1015824985497026590 |
17:43:16 | FromDiscord | <Require Support> oh man I forgot about copilot |
17:43:27 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hIj |
17:44:43 | FromDiscord | <πτ (pi man)> I can't use the word `type` for a variable name can I? :mood: |
17:44:53 | FromDiscord | <Gumbercules> you can use `type` |
17:44:57 | FromDiscord | <Gumbercules> errr |
17:45:02 | FromDiscord | <Gumbercules> ``type`` |
17:45:04 | FromDiscord | <Gumbercules> god damnit |
17:45:06 | FromDiscord | <Yardanico> xd |
17:45:13 | FromDiscord | <Yardanico> `\`type\`` |
17:45:14 | FromDiscord | <Yardanico> lol |
17:45:15 | FromDiscord | <Gumbercules> I feel like this is a setup |
17:45:28 | FromDiscord | <Gumbercules> trick question |
17:45:38 | FromDiscord | <Gumbercules> @πτ (pi man) bravo |
17:45:50 | FromDiscord | <πτ (pi man)> I have no idea what you guys are tyring to type :LUL: |
17:45:58 | FromDiscord | <Gumbercules> ` `type` ` |
17:46:01 | FromDiscord | <Gumbercules> so type surrounded by backticks |
17:46:03 | FromDiscord | <Gumbercules> omg |
17:46:05 | FromDiscord | <Gumbercules> discord |
17:46:06 | FromDiscord | <Gumbercules> fu |
17:46:10 | FromDiscord | <πτ (pi man)> aoh ok |
17:46:13 | FromDiscord | <πτ (pi man)> (edit) "aoh" => "ah" |
17:46:31 | FromDiscord | <Gumbercules> if you're trying to use a reserved word as a variable / field name |
17:46:39 | FromDiscord | <Gumbercules> and the compiler is complaining, backticks are the answer |
17:47:09 | FromDiscord | <πτ (pi man)> oh also there was a way to use bitfields wasnt there? |
17:47:29 | FromDiscord | <Gumbercules> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-bitsize-pragma |
17:47:30 | FromDiscord | <πτ (pi man)> so like the first 10 bits of an int32 as one field and the rest for another field? |
17:48:02 | FromDiscord | <πτ (pi man)> and unions use `{.union.}`? |
17:48:28 | FromDiscord | <Gumbercules> if you want the fields of the type to be overlaid in memory, yes |
17:49:07 | FromDiscord | <Gumbercules> like C's `union` |
17:49:10 | FromDiscord | <πτ (pi man)> yes |
17:49:13 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "and unions use `{.union.}`?": in most cases you'd just use object variants, but for interfacing with C unions or if you specifically want the same as in C, you use this |
17:49:23 | FromDiscord | <πτ (pi man)> In reply to @Yardanico "in most cases you'd": object variants? |
17:49:25 | FromDiscord | <Yardanico> Just beware that union won't work for GC'd types |
17:49:34 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "object variants?": algebraic types |
17:49:36 | FromDiscord | <Gumbercules> soooo |
17:50:01 | FromDiscord | <πτ (pi man)> well I need string, int, customType at least |
17:50:11 | FromDiscord | <Gumbercules> https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants |
17:50:40 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "well I need string,": what's `customType`? |
17:50:53 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hIp |
17:50:55 | FromDiscord | <Yardanico> object variants |
17:50:57 | FromDiscord | <Gumbercules> `kind` is a discriminator |
17:51:09 | FromDiscord | <Gumbercules> based on its value the field type changes |
17:51:13 | FromDiscord | <Gumbercules> it's a sum type or algebraic type |
17:51:38 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hIr |
17:51:58 | FromDiscord | <Gumbercules> object variants are not going to achieve the same thing as C's `union` or `{.union.}` |
17:52:14 | FromDiscord | <Gumbercules> if you're concerned about memory layout in your struct, don't worry about object variants |
17:52:18 | FromDiscord | <Gumbercules> they're not going to help you |
17:52:26 | FromDiscord | <πτ (pi man)> In reply to @Gumbercules "object variants are not": it looks like a compile time union? |
17:53:11 | FromDiscord | <Require Support> In reply to @Yardanico "yes, this isn't new": you tried copilot on nim? is it good? |
17:53:21 | FromDiscord | <Yardanico> In reply to @Require Support "you tried copilot on": it's not perfect, but yes, it works |
17:53:25 | FromDiscord | <Yardanico> it knows some of nim stdlib |
17:53:27 | FromDiscord | <Gumbercules> they're mapped to a union but do not function as C unions |
17:53:29 | FromDiscord | <Yardanico> even macros a bit |
17:53:51 | FromDiscord | <Require Support> not bad |
17:54:00 | FromDiscord | <Gumbercules> it's a tagged union essentially |
17:54:04 | FromDiscord | <πτ (pi man)> sent a long message, see https://paste.rs/ua5 |
17:54:22 | FromDiscord | <Gumbercules> not sure how many other names I can remember for this language feature xD |
17:54:33 | FromDiscord | <Gumbercules> if you don't require them to be overlaid in memory |
17:54:36 | FromDiscord | <πτ (pi man)> so how does a variant work |
17:54:43 | FromDiscord | <Gumbercules> then an object variant should work |
17:54:58 | FromDiscord | <Gumbercules> https://en.wikipedia.org/wiki/Tagged_union |
17:55:24 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "so how *does* a": but why do you need to know? do you have specific abi requirements? |
17:55:39 | FromDiscord | <Yardanico> I mean for the C backend Nim uses C unions for object variants, yes |
17:55:42 | FromDiscord | <πτ (pi man)> In reply to @Yardanico "but why do you": I want to know so I can use it correctly |
17:55:42 | FromDiscord | <Yardanico> but that's an implementation detail |
17:55:50 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "I want to know": you don't need to know to use it correctly |
17:56:03 | FromDiscord | <Yardanico> nim object variants are quite high level, you don't have to worry about pointers or casting or whatnot when using them |
17:56:11 | FromDiscord | <Phil> Narrowed my error search down.↵So `Error: unhandled exception: Cannot assign requested address [OSError]` appears to be a C error. that occurs when an address (? port?) is busy |
17:56:28 | FromDiscord | <Phil> What that has to do with `std/httpclient` I have no idae |
17:56:30 | FromDiscord | <Phil> (edit) "idae" => "idea" |
17:56:37 | FromDiscord | <πτ (pi man)> In reply to @Yardanico "you don't need to": well I'm not really understanding what they do right now |
17:57:23 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "well I'm not really": they allow you to create a type that can hold fields of different types depending on runtime conditions |
17:57:32 | FromDiscord | <Yardanico> you can't just say that a function can return type A or B because Nim is compiled |
17:57:39 | FromDiscord | <Yardanico> so if types can't be determined at compile time it won't work |
17:57:55 | FromDiscord | <Yardanico> and object variants allow you to determine what _case_ (branch) of an object variant you want to use at runtime |
17:58:12 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#types-object-variants explains it kind of okay I think |
18:00:54 | FromDiscord | <Gumbercules> they're not unique to Nim |
18:01:11 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hIt |
18:01:27 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4hIt" => "https://play.nim-lang.org/#ix=4hIu" |
18:01:42 | FromDiscord | <Require Support> https://forum.nim-lang.org/t/9683↵↵This makes me wanna switch to using threads now 😄 |
18:02:00 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4hIu" => "https://play.nim-lang.org/#ix=4hIv" |
18:02:12 | FromDiscord | <Gumbercules> one doesn't really "switch to using threads" |
18:02:25 | FromDiscord | <Gumbercules> and I don't understand the whole "ancient ways of threads" thing |
18:04:50 | FromDiscord | <Require Support> most of the time I've been using async just because it's easier and I didn't wanna deal with threads but that project seems interesting |
18:05:10 | FromDiscord | <Gumbercules> you generally don't use async and threads for the same workloads |
18:05:22 | FromDiscord | <Gumbercules> threads are generally for cpu bound tasks and async is generally for I/O bound tasks |
18:05:44 | FromDiscord | <Gumbercules> async requires an event loop which is inherently single threaded |
18:06:49 | * | ltriant joined #nim |
18:07:40 | FromDiscord | <Phil> I guess the good news is that strictly speaking I don't really need that client get and with it commented out I get further than before |
18:07:43 | FromDiscord | <Phil> But still kinda meh |
18:07:46 | FromDiscord | <Gumbercules> you can certainly have multiple threads each running an event loop, which is what httpbeast and probably mummy do |
18:07:58 | FromDiscord | <Gumbercules> (edit) "do" => "does" |
18:08:08 | FromDiscord | <Gumbercules> (edit) "you can certainly have multiple threads each running an event loop, which is what httpbeast ... andas" added "does," | "does" => "as well" |
18:08:37 | FromDiscord | <Gumbercules> I haven't looked into mummy's code yet |
18:09:01 | FromDiscord | <treeform> httpbeast runs an async event loop per thread |
18:09:28 | FromDiscord | <treeform> while mummy runs a single thread as a reactor and then queues up work for handlers |
18:10:32 | FromDiscord | <Gumbercules> so it's a thread pool |
18:10:38 | FromDiscord | <treeform> In reply to @Gumbercules "threads are generally for": thats the general wisdom yes, but the more we looked into threaded solution the more it looks like threads are just good at IO as well. |
18:11:32 | * | ltriant quit (Ping timeout: 248 seconds) |
18:11:39 | FromDiscord | <treeform> Async makes you put await, {.async.} and Future[] everywhere - which is annoying. While with threaded code you don't need to do that. |
18:11:57 | FromDiscord | <treeform> You still need locks with Async code... so it does not really save you from that. |
18:11:57 | FromDiscord | <πτ (pi man)> does nim have a 128 byte integer type? |
18:12:04 | FromDiscord | <Yardanico> not in stdlib |
18:12:14 | FromDiscord | <Yardanico> There's https://github.com/status-im/nim-stint |
18:12:25 | FromDiscord | <Yardanico> also https://github.com/nim-lang/bigints but it's not particularly performant |
18:12:29 | FromDiscord | <Require Support> What does `{.raises: [].}` mean |
18:12:36 | FromDiscord | <Yardanico> In reply to @Require Support "What does `{.raises: [].}`": that the function can't raise any exceptions at all |
18:12:37 | FromDiscord | <Gumbercules> yeah well there's a reason green threads exist |
18:12:47 | FromDiscord | <πτ (pi man)> I don't need computation, only storage, so I'll just use two int64s |
18:13:03 | FromDiscord | <Gumbercules> OS scheduler does all sorts of fun things when context switching between threads |
18:13:26 | FromDiscord | <Gumbercules> one shouldn't pick between threads and async because one requires some extra boilerplate |
18:13:41 | FromDiscord | <treeform> In reply to @Gumbercules "yeah well there's a": It also looks like for most workloads, on modern machines, green threads are not needed... regular threads are better supported by the OS and just easier to use. |
18:13:41 | FromDiscord | <Gumbercules> that's not really a technically strong reason in my estimation but 🤷 |
18:13:47 | FromDiscord | <Gumbercules> if you say so |
18:14:13 | Zevv | gumbercules |
18:14:24 | FromDiscord | <πτ (pi man)> green threads? |
18:14:46 | Zevv | i happen to have been working on something recently |
18:14:52 | FromDiscord | <treeform> By common wisdom, using async or green threads you should get a benefit... but we just don't see that in real web apps. |
18:15:02 | Zevv | if you are interested, i can eloborate |
18:15:40 | FromDiscord | <Gumbercules> Zevv: sure - I'm about to be holding a baby but I will try to keep up 🙂 |
18:15:42 | FromDiscord | <πτ (pi man)> what are green threads? |
18:15:45 | FromDiscord | <Gumbercules> software threads |
18:15:52 | FromDiscord | <Gumbercules> (edit) "software ... threads" added "/ userland" |
18:15:52 | FromDiscord | <πτ (pi man)> software threads? |
18:15:56 | FromDiscord | <treeform> In reply to @πτ (pi man) "green threads?": green threads usually refers to user level threads where the user program simulates the real threads to be faster then OS threads. |
18:15:58 | FromDiscord | <Gumbercules> just google it |
18:15:58 | FromDiscord | <jmgomez> Is it expected that anything that works for Refc does work fine in ORC? |
18:15:59 | Zevv | its early work that got started a few weeks after i asked araq about claifications about arc and safe moves |
18:16:02 | FromDiscord | <Require Support> is there documentation on threads usage for nim devel / 2.0 ? iirc there was gonna be some changes |
18:17:05 | FromDiscord | <treeform> In reply to @Require Support "is there documentation on": I don't know about docs, but Nim 2.0's ORC/ARC and threads on by default is a very good for threaded model. |
18:17:12 | FromDiscord | <Gumbercules> green threads / fibers / continuations all refer to basically the same concurrency primitve |
18:17:13 | FromDiscord | <treeform> I expect more nim things to use threads in Nim 2.0 |
18:17:23 | Zevv | what i have working now is an early proto, i can basically run millions of "processes" on N threads, scheduling both CPU and IO heavy work |
18:17:53 | Zevv | communication is done using an actor model that is rather tightly modelled after elixir/erlang OTP processes |
18:18:35 | Zevv | i was not sure if i could pull it through the initial huge pains i had, but it seems to go the right way |
18:19:00 | Zevv | its share-nothing multithreading, so no locks, waitconds, and other pita |
18:19:16 | Zevv | but we rely on nim to "safely" move data along |
18:19:18 | FromDiscord | <Require Support> oh now I remember, it wasn't threads it was `std/tasks` that was gonna be new for Nim 2 |
18:19:31 | FromDiscord | <Gumbercules> like channels? |
18:19:48 | Zevv | a channel is nothing but a waitcond and a dequque, so yes |
18:20:09 | FromDiscord | <Gumbercules> sounds like ni m's original memory model |
18:20:11 | FromDiscord | <πτ (pi man)> so what's the difference between green threads and async? |
18:20:14 | FromDiscord | <Gumbercules> with thread local heaps |
18:20:22 | Zevv | the problem is that nim has a hard time keeping promises about isolation |
18:21:38 | Zevv | my conclusion was that nim misses some essential mechanics to do this propery, but when careful, things *can* be done |
18:21:51 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "so what's the difference": async uses green threads |
18:22:28 | FromDiscord | <πτ (pi man)> oh, so async is just a type of green thread then? that makes sense |
18:22:32 | FromDiscord | <Gumbercules> hno |
18:22:34 | FromDiscord | <Gumbercules> no |
18:22:50 | FromDiscord | <Gumbercules> 1 sec holdin babby |
18:24:47 | FromDiscord | <Gumbercules> this requires an understanding of the difference between concurrency and parallelism |
18:24:55 | Zevv | also, event loops are not inheritely single threaded. I can dedicate N actors to watching fd/socket events, and have these run on N threads sharing the work |
18:25:35 | FromDiscord | <Gumbercules> sure but then it's parallelizing work and not scheduling it concurrently |
18:26:03 | FromDiscord | <Gumbercules> concurrency is splitting work across a single CPU core - so sharing the CPU core and doing work when the CPU has cycles to do it |
18:26:13 | FromDiscord | <Gumbercules> once you enter the territory of threads you're talking about parallelizing work |
18:26:19 | FromDiscord | <Gumbercules> and spreading it across multiple CPU cores |
18:26:34 | FromDiscord | <Gumbercules> I mean I know you know all of this Zevv I'm just trying to provide context for @πτ (pi man) |
18:26:50 | FromDiscord | <Gumbercules> async is just a pattern where you have an event loop and a scheduler |
18:27:04 | Zevv | sure. in 2022 i dont undestand how people even are considering concurrency without parallelism |
18:27:13 | FromDiscord | <Gumbercules> the scheduler is responsible for scheduling work typically on a single core |
18:27:21 | FromDiscord | <Gumbercules> or historically |
18:27:22 | Zevv | even my 5yo phone has 20 cores |
18:27:41 | FromDiscord | <Gumbercules> NodeJS for instance uses a single thread in its event loop |
18:27:48 | FromDiscord | <Gumbercules> unless things have changed recently |
18:29:54 | Zevv | there is a very important difference between 'async/concurrent' and paralellism |
18:30:15 | Zevv | in the first, you basically don't have to think about your world being mutable by others while your program is running |
18:30:25 | Zevv | you are scheduling/yielding at discrete points in your code |
18:30:30 | Zevv | in between, all invariants hold |
18:30:35 | FromDiscord | <Gumbercules> this is why Nim's original memory model was able to be so fast and garbage collected |
18:30:36 | Zevv | which make programmers happpy |
18:30:46 | Zevv | when you go full threading, you suffer. |
18:31:12 | Zevv | you need to sit on your locks, thing a thousand times harder about your data models |
18:31:22 | Zevv | and the pain only begins when things do *not* work as expected |
18:31:28 | Zevv | threading is *hard* |
18:31:34 | FromDiscord | <treeform> AMD just announced a 96 core 192 thread server CPU, you can get like two fo them in a motherboard |
18:31:36 | Zevv | async/concurrency is almost life as you know it |
18:31:53 | FromDiscord | <Gumbercules> @πτ (pi man) here is my fiber based job system for my game engine |
18:31:53 | FromDiscord | <treeform> Soon we will have 384 cores... |
18:31:55 | FromDiscord | <treeform> we need to use them |
18:32:00 | FromDiscord | <Gumbercules> if you want to see fun with threads and fibers (green threads) |
18:32:05 | Zevv | IMHO the only sane way to do multithreading is by not sharing data, or have something do it for you |
18:32:08 | Zevv | under the hood |
18:32:22 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/job.nim |
18:32:46 | Zevv | I think golang, pony, elixir/erlang have seen the light. These languages know how to do it |
18:33:03 | FromDiscord | <Gumbercules> for non realtime stuff sure |
18:33:18 | FromDiscord | <Gumbercules> for realtime / soft realtime systems you generally don't have a choice |
18:33:25 | Zevv | if you want hard real time, you don't |
18:33:35 | Zevv | but then again, with nim there is this far away promise |
18:33:40 | Zevv | that without a GC we could do things better |
18:33:44 | Zevv | we have arc these days. |
18:33:53 | Zevv | a shared heap |
18:34:05 | Zevv | and movable data, that will currently kill you if you move it wrong |
18:34:40 | Zevv | but the thing i'm currently working on is waht i've been looking for for a few years |
18:34:53 | Zevv | I kind of left nim, but returned recently, because I missed the fun of the language itself |
18:35:00 | Zevv | but it has such a /baaahd/ multithreading story |
18:35:18 | Zevv | you can't have a proper language at this time and not have a proper story about how to efficently use your cores |
18:38:20 | Zevv | anyhow, got a social call. If anyome might be interested in chatting about these subjects, let me know, I'm game |
18:38:35 | Zevv | I could do with some rightful critique and eyes on my first implementation |
18:41:11 | FromDiscord | <πτ (pi man)> In reply to @Zevv "but it has such": as long as it has threads and has semaphors/mutexs/synchronization that's all I really ask for |
18:41:53 | Zevv | too bad, it has threads, but it has no semaphores,mutexes or other synchronization |
18:42:17 | FromDiscord | <πτ (pi man)> so there's no way to prevent concurrent execution? |
18:42:37 | Zevv | just do not share data between processes. Ever. |
18:42:45 | Zevv | you pass it around so it is owned by one process at a time |
18:42:46 | FromDiscord | <πτ (pi man)> between processes or threads |
18:42:52 | Zevv | these are abstracted away |
18:43:03 | Zevv | I run millions of processes on a handful of threads |
18:43:30 | Zevv | data is moved, but there is always only one reference to this data at any time, which is always in one process at a time |
18:43:30 | FromDiscord | <πτ (pi man)> what? processes run threads though, not threads running processes |
18:43:51 | Zevv | it's not a process or a thread or a fiber, it needs a different name |
18:43:58 | Zevv | i've called it an Actor for now |
18:44:06 | Zevv | which is the somewhat scienitfic name for this kind of thing |
18:44:16 | FromDiscord | <πτ (pi man)> also what do you mean passing around? |
18:44:37 | Zevv | If you have data on the heap, you typically have a pointer somewhere to access this data |
18:44:40 | Zevv | that lives in your ref |
18:44:43 | FromDiscord | <πτ (pi man)> afaik the only thing a thread owns is it's stack |
18:44:52 | Zevv | right. And we have done away with the stack |
18:45:20 | Zevv | the stack gets abstracted away and goes into a thing called an 'environment', which is a little bag of memory that lives on the heap |
18:45:31 | Zevv | with real threads, one of the problems is that you need large stacks |
18:45:45 | Zevv | because your local flow control and local variasbles will grow and shrink your stacks. |
18:46:05 | Zevv | you can't tell in advance how big is 'big enough', if you choose your stacks too small you run out and go down |
18:46:14 | Zevv | or you leave it to the OS, an that is when you call it a thread |
18:46:33 | Zevv | but real threads are expensive. You would not choose to run single thread for every connection on a busy server, for example |
18:46:45 | Zevv | but you can spawn actors like mad, they cost a few hundred bytes each |
18:47:13 | Zevv | they get scheduled on a low number of threads, which would typicallly be somewhere twice your number of cores or so |
18:47:35 | Zevv | that is how go and erlang do it |
18:48:04 | FromDiscord | <Gumbercules> back - had some chores to do and needed to start a bottle for that baby |
18:48:15 | Zevv | erlang can do it because programs are basically ran on a VM, on which it is easy to 'schedule away' |
18:48:24 | Zevv | on erlang they do not have the shared memory problem because it is fully FP |
18:48:28 | FromDiscord | <guttural666> can I loop over the fields of a typedesc(object) and get the field names? |
18:48:31 | Zevv | everyting is readonly / unmutable by default |
18:49:15 | FromDiscord | <Bung> can I casting type without check ? |
18:49:55 | FromDiscord | <Gumbercules> well you can implement your own semaphores, spinlocks, mutexes, etc... it's not difficult |
18:50:09 | FromDiscord | <Gumbercules> but I mean, you also need to know and understand what you are doing |
18:50:36 | Zevv | but in practice, do you /choose/ to use multithreading using semaphores mutexes etc? |
18:50:49 | Zevv | is that a model that scales and makes your code better and you happier as a programmer? |
18:51:04 | FromDiscord | <Gumbercules> if you're writing a game engine in C/C++ or Nim, I'd say yes |
18:51:15 | Zevv | because, I am past emberassement, I have decades ago decided that I am not smart enough to properly write multithreaded code like that |
18:51:17 | FromDiscord | <Gumbercules> if you're writing a web application server, probably not |
18:51:33 | FromDiscord | <πτ (pi man)> honestly java's `synchronize` is the best thread protection imo that i've come across |
18:51:47 | FromDiscord | <Gumbercules> I mean there is reading material out there on the subject matter |
18:51:57 | FromDiscord | <Gumbercules> and plenty of example code from people that know what they are doing |
18:52:07 | Zevv | πτ (pi man): I invite you to have a look on the other side of the play field, take a few days to dive into golang if you have not done taht yet |
18:52:10 | Zevv | or even better, elixri |
18:52:19 | FromDiscord | <Gumbercules> I use Elixir at work but I'd never write a game in Elixir |
18:52:25 | FromDiscord | <Gumbercules> the backend for a multiplayer game - sure |
18:52:28 | FromDiscord | <Gumbercules> but never a gamem client |
18:52:31 | FromDiscord | <Gumbercules> (edit) "gamem" => "game" |
18:52:35 | FromDiscord | <πτ (pi man)> I think I looked at golang once and decieded I probably wouldn't like it |
18:52:49 | Zevv | I hate the language |
18:52:53 | Zevv | but boy do I *love* the runtime |
18:53:03 | Zevv | you just do 'recv()' |
18:53:08 | Zevv | tadaaa |
18:53:16 | Zevv | it just does what you ask it |
18:53:26 | FromDiscord | <πτ (pi man)> `recv()`? |
18:53:26 | Zevv | *that is how I want to do my multithreading |
18:53:33 | Zevv | receive on a socket, for example |
18:53:41 | Zevv | It's typically a blocking call on your OS |
18:53:52 | Zevv | blocking calls are bad, right. |
18:54:03 | Zevv | so either you go threaded, and get all the pain of managing your shared memory |
18:54:11 | Zevv | or you go async, and suffer burning 1 of yor 96 cores |
18:56:34 | Zevv | anyway, that's just my $0.02, sorry for my rambling and ranting. |
18:57:21 | NimEventer | New post on r/nim by Akronae: Is anybody using snake case?, see https://reddit.com/r/nim/comments/zci3nd/is_anybody_using_snake_case/ |
18:59:16 | FromDiscord | <πτ (pi man)> sent a long message, see http://ix.io/4hIQ |
19:00:50 | FromDiscord | <Require Support> hey it was a good rant, as a newcomer I've learned from it 😄 |
19:01:08 | FromDiscord | <guttural666> how can I loop over the fields of a typedesc(object) and get the field names? |
19:01:11 | FromDiscord | <πτ (pi man)> rants like this are almost always welcome imo |
19:01:19 | FromDiscord | <Gumbercules> these memory and concurrency models are great but they just aren't useful in certain contexts |
19:02:24 | FromDiscord | <Gumbercules> generally thick client performance sensitive applications are going to avoid message passing and the overhead they'd incur |
19:04:14 | FromDiscord | <Gumbercules> https://www.gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine is a good talk |
19:04:34 | FromDiscord | <QuiteQuietQ> is there a builtin way to check if a range is a subrange of other range? ↵e.g. `2..3 in 1..4` would return `true` ? |
19:06:05 | arkanoid | do you know how to select interpolation method in pixie? |
19:06:19 | arkanoid | I'm getting bilinear or something, I want pixel |
19:07:08 | FromDiscord | <Gumbercules> In reply to @guttural666 "how can I loop": this is better done via macros |
19:07:22 | FromDiscord | <Gumbercules> see the note at the top of this module's docs: https://nim-lang.org/docs/typeinfo.html#fields.i%2CAny |
19:08:01 | FromDiscord | <guttural666> In reply to @Gumbercules "this is better done": I remember there was a way with an object instead of a typedesc, but I can't remember how that works |
19:08:10 | FromDiscord | <Gumbercules> In reply to @QuiteQuietQ "is there a builtin": you could use sets |
19:08:37 | FromDiscord | <Gumbercules> In reply to @guttural666 "I remember there was": Not sure - I think macros are the best approach here regardless |
19:09:17 | FromDiscord | <Gumbercules> Nim doesn't really focus on RTTI because of its metaprogramming capabilities and ability to inspect and modify the program's AST at compile time |
19:10:54 | FromDiscord | <Gumbercules> https://nim-lang.org/docs/system.html#contains%2Cset%5BT%5D%2CT |
19:11:01 | FromDiscord | <Gumbercules> @QuiteQuietQ ^ |
19:12:50 | FromDiscord | <demotomohiro> @guttural666 You can use: https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CT |
19:13:22 | FromDiscord | <QuiteQuietQ> In reply to @Gumbercules "https://nim-lang.org/docs/system.html#contains%2Cse": this checks if a single element is in a set, not set in set↵is there something else than sets? like an operator? if no, i will create my own |
19:13:40 | FromDiscord | <huantian> In reply to @QuiteQuietQ "is there a builtin": No, you have to write one yourself |
19:13:45 | FromDiscord | <Gumbercules> not to my knowledge |
19:13:45 | FromDiscord | <huantian> Quite easy though |
19:14:06 | FromDiscord | <πτ (pi man)> huh?↵how does an enum named `BACOID` redefine an object type named `BACoid`? |
19:14:07 | FromDiscord | <guttural666> In reply to @demotomohiro "<@375727321958580228> You can use:": yes, that was it, thanks for reminding me |
19:14:19 | FromDiscord | <huantian> Just make a contains proc for HSlice[int, int] and you can use int |
19:14:22 | FromDiscord | <huantian> (edit) "int" => "in" |
19:15:38 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hIX |
19:16:41 | FromDiscord | <demotomohiro> @πτ (pi man) Nim is style insensitive: https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality |
19:17:08 | FromDiscord | <πτ (pi man)> wtf |
19:17:15 | FromDiscord | <Gumbercules> lol, new that was coming |
19:17:24 | FromDiscord | <πτ (pi man)> that makes no sense |
19:17:45 | FromDiscord | <demotomohiro> So `BACoid` and `BACOID` are same identifier |
19:18:24 | FromDiscord | <πτ (pi man)> great, so I need to append `_TYPE` to all my enums? that's annoying |
19:18:52 | FromDiscord | <Gumbercules> no |
19:18:55 | FromDiscord | <Gumbercules> get creative |
19:19:26 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hIY |
19:19:37 | FromDiscord | <demotomohiro> This is why Nim is style insensitive: https://github.com/nim-lang/Nim/wiki/Unofficial-FAQ#why-is-it-caseunderscore-insensitive |
19:19:49 | FromDiscord | <Gumbercules> I rarely use enums though since I do so much C interop - mostly `distinct unit32` to represent enums |
19:19:56 | FromDiscord | <Gumbercules> (edit) "unit32`" => "uint32`" |
19:21:57 | FromDiscord | <Gumbercules> and unless you make your enum `{.pure.}` if that's still a thing, you can just use the member names without any qualification |
19:22:20 | FromDiscord | <Gumbercules> you don't need to do like - `DataType.dtString` you can just use `dtString` |
19:22:44 | FromDiscord | <Gumbercules> but adding a prefix before the enum member name allows the reader to easily disambigiuate which member the enum belongs to |
19:22:51 | FromDiscord | <Gumbercules> (edit) "disambigiuate" => "disambiguate" |
19:23:18 | FromDiscord | <πτ (pi man)> sent a long message, see http://ix.io/4hJ0 |
19:23:44 | FromDiscord | <Gumbercules> I've been coding in Nim since 2015 - you get over it quickly, trus tme |
19:23:47 | FromDiscord | <Gumbercules> (edit) "trus tme" => "trust me" |
19:23:56 | FromDiscord | <Phil> In reply to @πτ (pi man) "that makes no sense": Imagine you're a python dev and use my lib. You want to do snake-case, while I insist on CamelCase.↵Do you want to use my 500 procs allgoing camel case? |
19:24:05 | FromDiscord | <Phil> (edit) "allgoing" => "all going" |
19:24:24 | FromDiscord | <Phil> I've been told it's also pretty nice for C-interop but so far I'm staying far away from that |
19:24:35 | FromDiscord | <πτ (pi man)> In reply to @Isofruit "Imagine you're a python": I already said this condition "makes sense" |
19:24:52 | FromDiscord | <Gumbercules> I don't know if Id say it's nice for C interop |
19:25:03 | FromDiscord | <Gumbercules> I mean if you have a function in C named `hello_world` |
19:25:05 | FromDiscord | <πτ (pi man)> C is case sensitive, how would this help? |
19:25:34 | FromDiscord | <Gumbercules> and you `{.importc: "helloWorld".}` |
19:25:40 | FromDiscord | <Yardanico> In reply to @Gumbercules "and you `{.importc: "helloWorld".}`": ? |
19:25:42 | FromDiscord | <Yardanico> that won't work |
19:25:48 | FromDiscord | <Gumbercules> sorry |
19:26:01 | FromDiscord | <Gumbercules> `proc helloWorld() {.importc.}` |
19:26:06 | FromDiscord | <Gumbercules> it's going to import `hello_world` |
19:26:13 | FromDiscord | <Gumbercules> well - at least allow you to call into it |
19:26:37 | FromDiscord | <Gumbercules> so, I mean yes it's nice in that you don't have to name your functions like their C alternatives |
19:26:50 | FromDiscord | <Gumbercules> but this is why `proc helloWorld() {.importc: "hello_world".}` exists |
19:26:53 | FromDiscord | <Gumbercules> so you can be explicit about the import |
19:27:28 | FromDiscord | <Gumbercules> lack of sleep killing my brain |
19:27:34 | FromDiscord | <Gumbercules> damn babby |
19:27:49 | FromDiscord | <Yardanico> In reply to @Gumbercules "it's going to import": again, no, you need sleep :P |
19:28:00 | FromDiscord | <Yardanico> importc uses the Nim function name if you didn't provide the name |
19:28:14 | FromDiscord | <Yardanico> what you mean is that you can do `proc hello_world() {.importc.}` and use it as `helloWorld()` |
19:28:17 | FromDiscord | <Gumbercules> yes |
19:28:21 | FromDiscord | <Gumbercules> this |
19:28:21 | FromDiscord | <Gumbercules> thank you |
19:28:26 | arkanoid | I am reading jsons with jsony. Each json has a "type" field that I can use to wrap my type system. Problem is that I have not yet found a procedural solution, but just a OOP solution with dynamic dispatch. The limitation seems rooted on this https://github.com/nim-lang/RFCs/issues/368 that doesnt let me use object variants |
19:28:38 | FromDiscord | <Gumbercules> and yes I do - I can't though 😭 |
19:28:57 | FromDiscord | <Gumbercules> have a baby they said, it'd be fun they said! - actually I don't think anyone said this |
19:29:07 | arkanoid | do I have better alternatives to avoid dynamic dispatch? |
19:29:22 | FromDiscord | <Yardanico> In reply to @arkanoid "I am reading jsons": That RFC won't help you because as I assume you would want to assign the same field name to different types |
19:29:27 | FromDiscord | <Yardanico> in different branches |
19:29:34 | FromDiscord | <Yardanico> this RFC only covers same field name with same type in different branches |
19:30:08 | FromDiscord | <Yardanico> and well, there's no "alternative" since object variants are also dynamic dispatch, but you can abstract stuff away with macros/templates to make your code nicer to work with |
19:30:18 | FromDiscord | <πτ (pi man)> In reply to @Gumbercules "have a baby they": my mom keeps saying she wants grandchildren↵~~but I don't even have a gf and my sister is trans~~ |
19:30:39 | FromDiscord | <Gumbercules> well we were blursed with one at the ripe ages of 37 and 38 |
19:30:40 | arkanoid | Yardanico, exactly, I would need an object variant that reflects the json structure I receive, but shared names among only some "types" and not others and the inflexibility of object variants makes them not usable in this context |
19:30:53 | FromDiscord | <Gumbercules> we wanted one, but my goodness they are work! |
19:31:07 | FromDiscord | <Gumbercules> and they don't like programming for whatever weird reason |
19:31:42 | FromDiscord | <Gumbercules> then again, neither do I really so I can't blame them |
19:33:06 | FromDiscord | <πτ (pi man)> ugh, I swear this xml parser is causing more issues than writing my own would |
19:34:11 | FromDiscord | <Gumbercules> which one? |
19:34:59 | FromDiscord | <πτ (pi man)> XmlParser |
19:36:45 | FromDiscord | <Gumbercules> isn't https://nim-lang.org/docs/parsexml.html the one most folks use? |
19:37:47 | FromDiscord | <Gumbercules> the module I mean - I realize the former utilizes the latter |
19:38:02 | FromDiscord | <πτ (pi man)> that's the one I'm using |
19:38:17 | FromDiscord | <πτ (pi man)> XmlParser is the object |
19:38:42 | FromDiscord | <Gumbercules> gotcha |
19:38:57 | FromDiscord | <Gumbercules> I don't do much XML parsing thankfully so I haven't had to dive into those modules anytime recently |
19:39:14 | FromDiscord | <πτ (pi man)> I can't tell the difference between `>` and `/>` |
19:39:28 | FromDiscord | <πτ (pi man)> they both parse as `xmlElementEnd` |
19:39:35 | FromDiscord | <πτ (pi man)> but mean different things |
19:39:45 | FromDiscord | <Gumbercules> `xmlElementClose` |
19:40:02 | FromDiscord | <πτ (pi man)> `xmlElementCose` parses `</name>` |
19:40:05 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJ6 |
19:40:06 | FromDiscord | <Gumbercules> heh |
19:40:13 | FromDiscord | <Yardanico> In reply to @πτ (pi man) "I can't tell the": do you want to parse xml into tokens or ready-to-use tree? |
19:40:35 | FromDiscord | <πτ (pi man)> In reply to @Yardanico "do you want to": either, though ready to use tree would be more useful |
19:40:43 | FromDiscord | <Yardanico> are you using the parsexml module? |
19:40:46 | FromDiscord | <πτ (pi man)> yes |
19:40:52 | FromDiscord | <Yardanico> then you need to use a different one |
19:40:56 | FromDiscord | <Yardanico> https://nim-lang.org/docs/xmltree.html |
19:40:59 | FromDiscord | <Yardanico> see https://nim-lang.org/docs/xmlparser.html |
19:41:01 | FromDiscord | <πτ (pi man)> or write my own parser |
19:42:57 | FromDiscord | <πτ (pi man)> I just need to get the data out of the xml file |
19:43:58 | FromDiscord | <Yardanico> just use xmlparser |
19:44:28 | FromDiscord | <Gumbercules> https://github.com/OpenSystemsLab/q.nim ooo |
19:44:36 | FromDiscord | <Gumbercules> not suggesting you use this, but this looks nice |
19:45:01 | FromDiscord | <Horizon [She/Her]> I despise webdev so much |
19:45:15 | FromDiscord | <Gumbercules> I'm a card carrying member of that club as well |
19:45:38 | FromDiscord | <Gumbercules> https://forum.nim-lang.org/t/9687 |
19:45:46 | FromDiscord | <Horizon [She/Her]> Using Nim for my project because it's so much more familiar than JS and it's allowing me to structure it exactly how i want |
19:46:23 | FromDiscord | <πτ (pi man)> I don't want to query the xml, I need to extract all the data out of it |
19:46:32 | FromDiscord | <Gumbercules> @exelotl I think it's fine for NimForum to exist I'd just rather it not be the software behind forum.nim-lang.org |
19:46:39 | FromDiscord | <Gumbercules> but I've beaten this horse to death, and then some |
19:47:04 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "I don't want to": I understand |
19:47:37 | FromDiscord | <Gumbercules> In reply to @Event Horizon "Using Nim for my": I plan on using elixir for my project's backend - no idea what I will use for JS. I'm hoping I have to write very little to none |
19:47:46 | FromDiscord | <Phil> In reply to @Event Horizon "I despise webdev so": Yeah but you got to be specific my guy |
19:47:55 | FromDiscord | <Phil> why do you hate webdev?↵There's so many valid reasons! |
19:48:47 | FromDiscord | <Gumbercules> I should correct myself - I loathe modern web development |
19:48:49 | * | ofelas joined #nim |
19:49:00 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "I plan on using": Fair haha |
19:49:11 | FromDiscord | <Gumbercules> when people weren't obsessively overengineering everything |
19:49:17 | FromDiscord | <Gumbercules> because they had nothing better to do / didn't know any better |
19:50:11 | FromDiscord | <Horizon [She/Her]> In reply to @Isofruit "*why* do you hate": I hate webdev because JS is bloated, it's not suitable for sites nowadays because it has little to no structure, and then you also have to worry about supporting an eons old browser for Sharon on Windows 95 lmao |
19:50:16 | FromDiscord | <Gumbercules> and people weren't making horrible engineering decisions left and right so they could write some shitty blog post about how they made some todo react app |
19:50:41 | FromDiscord | <Horizon [She/Her]> Also, HTML and CSS feels like it needs to be revamped, but none of it is as bad as JS, imo |
19:50:59 | FromDiscord | <Gumbercules> I mean JS is the assembly language of the web |
19:51:03 | FromDiscord | <Phil> In reply to @Event Horizon "I hate webdev because": Oh yeah, the entire no-typing is just pure hell |
19:51:08 | FromDiscord | <Gumbercules> JS has types |
19:51:12 | FromDiscord | <Gumbercules> just weak types |
19:51:30 | FromDiscord | <Phil> In reply to @Gumbercules "JS has types": If you don't have a compiler that complains to me that my type is wrong, you have no types to me |
19:51:41 | FromDiscord | <Gumbercules> well that's static type checking |
19:51:42 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "I mean JS is": It's horrid xD |
19:51:54 | FromDiscord | <Gumbercules> Python has types too - and it is a strongly typed language |
19:51:57 | FromDiscord | <πτ (pi man)> wasm |
19:51:59 | FromDiscord | <Horizon [She/Her]> Was created in 10 days iirc, and then now so much stuff is being put onto it |
19:52:05 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "Python has types too": Typehinting |
19:52:20 | FromDiscord | <Gumbercules> well no it has actual types |
19:52:25 | FromDiscord | <Horizon [She/Her]> In reply to @πτ (pi man) "*wasm*": Sad thing about WASM is that file sizes get big and support isn't all the way there yet |
19:52:42 | FromDiscord | <Gumbercules> it's just the interpreter won't care if you mess them up |
19:52:57 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "well no it has": Ah yeah i know that, but not really enforced unless you do an operation requiring a specific method |
19:53:00 | FromDiscord | <Gumbercules> there's some python addon that adds compile time type checking kind of |
19:53:02 | FromDiscord | <Horizon [She/Her]> Ducktyping is what it has |
19:53:05 | FromDiscord | <Phil> And the interpreter caring is what makes JS/Python painful to deal with |
19:53:07 | FromDiscord | <Gumbercules> yes |
19:53:32 | FromDiscord | <Gumbercules> I don't find JS all that awful - then again I've been coding in it for a long time |
19:53:34 | FromDiscord | <Phil> (edit) "interpreter" => "interpreter/JIT compiler or whatnot not" |
19:53:44 | FromDiscord | <Gumbercules> I just don't enjoy coding in it more because of the environment and ecosystem |
19:53:51 | FromDiscord | <Gumbercules> and well, I'm not making browser games |
19:54:34 | FromDiscord | <Phil> I've been coding in it for the last 3 years and its just... not for me.↵I enjoy aspects of it.↵The functional aspects of it are nice, tooling in it has made me appreciate Dependency Injection all the more |
19:54:44 | FromDiscord | <Gumbercules> would be nice to see more jQuery out in the wild and less react / vue / svelte / karax / whatever |
19:54:56 | FromDiscord | <Phil> But generally working with JS is a whole lot of bleh. |
19:55:03 | FromDiscord | <Horizon [She/Her]> In reply to @πτ (pi man) "*wasm*": Though, I believe it could be a solution to supporting (future) legacy browsers, because if all you needed was a minimal API for direct-access to the browser internals, that WASM could be shipped with, you could update the browser's JS runtime like a package (of course, WASM ran by websites wouldn't be able to access said APIs) |
19:55:14 | FromDiscord | <Gumbercules> wasm still has a long way to go |
19:55:17 | FromDiscord | <Phil> I'll take any react/vue/svelte whatever over any jquery any day of the week any time |
19:55:23 | FromDiscord | <Gumbercules> why? |
19:55:26 | FromDiscord | <Gumbercules> jquery is stupid simple |
19:55:35 | FromDiscord | <Phil> Because the testing to be done with them is going to be so much better |
19:55:38 | FromDiscord | <Gumbercules> and it does the job in almost every situation |
19:55:44 | FromDiscord | <πτ (pi man)> idk any of this cause I don't do web dev |
19:55:55 | FromDiscord | <Gumbercules> why? you can easily write unit tests for jquery if you're so inclined |
19:56:27 | FromDiscord | <Gumbercules> you can probably even use Jest or some other bs to do it |
19:56:34 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "wasm still has a": Definitely, but I believe it has a place in the web in some places |
19:56:39 | FromDiscord | <Phil> After having done testing in Angular, the fact that you have a chance to completely set up your entire test environment so you can get rid of any interference from non-test-code made my life significantly easier when dealing with brownfield projects |
19:56:43 | FromDiscord | <Horizon [She/Her]> Even outside of the web |
19:56:46 | FromDiscord | <Gumbercules> I'd rather have a slim <100kb JS file to serve my app than an entire framework |
19:57:28 | FromDiscord | <Gumbercules> In reply to @Event Horizon "Definitely, but I believe": well it will once they get the safety issues worked out and support multiple threads |
19:57:40 | FromDiscord | <Gumbercules> until then it's basically flash |
19:57:47 | FromDiscord | <Horizon [She/Her]> What safety issues does it have right now? I wasn't aware of that |
19:58:08 | FromDiscord | <Gumbercules> Oh I guess they added threads |
19:58:12 | FromDiscord | <Horizon [She/Her]> Threading has a proposal already, not sure if it's anywhere near close to being included tho |
19:58:16 | FromDiscord | <Horizon [She/Her]> Yeah |
19:58:26 | FromDiscord | <Gumbercules> yeah vendor implementation is another horrible thing about the web / wasm |
19:58:31 | FromDiscord | <Gumbercules> webgpu too |
19:58:44 | FromDiscord | <Horizon [She/Her]> You mean the WASM runtime in the browser? |
19:59:17 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hJa |
19:59:19 | FromDiscord | <Gumbercules> just what browsers will support what features of the runtime at any point in time |
19:59:23 | FromDiscord | <Horizon [She/Her]> Probably because they do AOT compilation for whatever runtime they use, ik wasm3 is just a WASM interpreter without any fancy speed boosts |
19:59:25 | FromDiscord | <Gumbercules> https://www.usenix.org/system/files/sec20-lehmann.pdf |
19:59:35 | FromDiscord | <Gumbercules> this is from 2020 |
19:59:39 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "just what browsers will": Ah fair |
19:59:41 | FromDiscord | <Gumbercules> not sure how much still applies but I'm pretty sure a fair bit |
19:59:57 | FromDiscord | <πτ (pi man)> now I just have to figure out how to move through the Xml tree cause there is no documentation on that |
20:01:33 | FromDiscord | <Gumbercules> running external code in the browser is just a nightmare |
20:01:55 | FromDiscord | <Gumbercules> flash, silverlight, activeX all these technologies did it at one point and they all ended up dying for the same reasons |
20:02:29 | FromDiscord | <Gumbercules> and https://wasmer.io/ is the same idea again |
20:02:48 | FromDiscord | <Horizon [She/Her]> Fair |
20:03:16 | FromDiscord | <πτ (pi man)> In reply to @Gumbercules "running external code in": sounds like a security nightmare |
20:03:17 | FromDiscord | <Gumbercules> but I mean - I think it's cool as hell still |
20:03:40 | FromDiscord | <Gumbercules> https://github.com/zacharycarter/zengine ran in the browser via emscripten + wasm |
20:03:54 | FromDiscord | <Gumbercules> and that's precisely when I stopped working on it xD |
20:04:04 | FromDiscord | <Horizon [She/Her]> Even if it's not used to run untrusted code from websites, could defintiely be used for what i said earlier (WASM implementations of JS runtimes, or other browser internals, so even if it stops getting maintained, as long as an API is followed, it could be updated/reimplemented in the future) |
20:04:16 | FromDiscord | <Gumbercules> sure |
20:08:52 | FromDiscord | <demotomohiro> I hope no one recreate ActiveX |
20:09:02 | FromDiscord | <spaceLobster> sent a long message, see http://ix.io/4hJf |
20:09:49 | FromDiscord | <Gumbercules> because the value you're passing to the subscript operator must be static |
20:09:59 | FromDiscord | <Gumbercules> in other words, known at compile time |
20:10:19 | FromDiscord | <Gumbercules> although |
20:10:19 | FromDiscord | <spaceLobster> .. <- subscript operator? |
20:10:27 | FromDiscord | <Gumbercules> I'm not really sure what you're trying to do here |
20:10:41 | FromDiscord | <spaceLobster> Im trying to fil an array with a range from say 1 to 5 |
20:11:04 | FromDiscord | <spaceLobster> and then make it into a hashset |
20:12:33 | FromDiscord | <πτ (pi man)> arrays have compile time lengths |
20:12:38 | FromDiscord | <πτ (pi man)> (afaik) |
20:13:49 | FromDiscord | <spaceLobster> I thought they had to have alength only when instantiated |
20:14:11 | FromDiscord | <Gumbercules> what does your input data look like |
20:14:16 | FromDiscord | <Gumbercules> "1-2-3,4-5-6"? |
20:14:34 | FromDiscord | <spaceLobster> almost ... 1-2,3-4 |
20:14:35 | FromDiscord | <Gumbercules> no wait... |
20:14:37 | FromDiscord | <Gumbercules> thanks |
20:14:45 | FromDiscord | <πτ (pi man)> if you want length determined at runtime use a seq I think |
20:19:59 | FromDiscord | <demotomohiro> !eval import std/[sets, sequtils]; echo toSeq(1..4).toHashSet |
20:20:04 | NimBot | Compile failed: {3, 4, 2, 1} |
20:21:49 | FromDiscord | <Gumbercules> sorry I had to go attend to something |
20:22:01 | FromDiscord | <Gumbercules> but uh, yeah what @demotomohiro said - `split` is already going to return a sequence anyway |
20:22:13 | FromDiscord | <Gumbercules> of strings - so you could do something like |
20:23:37 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJj |
20:23:51 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4hJk |
20:24:15 | FromDiscord | <πτ (pi man)> how do I get a ref of an object? |
20:24:21 | FromDiscord | <Gumbercules> you dont |
20:24:22 | FromDiscord | <πτ (pi man)> or do I need to use ptr? |
20:24:30 | FromDiscord | <Gumbercules> you can either use pointer or you can box the object |
20:24:34 | FromDiscord | <Gumbercules> so something like |
20:24:49 | FromDiscord | <πτ (pi man)> actually wait, nvm I can do something else |
20:25:15 | FromDiscord | <demotomohiro> `parseInt("3")..parseInt("7")` is iterator and `toSeq`create a seq from it. |
20:26:52 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJl |
20:26:55 | FromDiscord | <Gumbercules> my advice - don't fear pointer |
20:27:02 | FromDiscord | <Gumbercules> or `ptr T` |
20:27:15 | FromDiscord | <Gumbercules> ymmv |
20:27:36 | FromDiscord | <πτ (pi man)> how do I insert a default element to a table? |
20:27:44 | FromDiscord | <demotomohiro> @πτ (pi man) Or copy content of an object to ref object like `myRefObj[] = myObj`. `myRefObj` must not be nil. |
20:28:17 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "how do I insert": what do you mean? |
20:28:41 | FromDiscord | <Gumbercules> like - try to retrieve a value from it and if it doesn't exist, return a default instead? |
20:28:57 | FromDiscord | <πτ (pi man)> I have this↵`objects[currObject].metasysRef = val`↵but objects[currObject] doesn't exist yet so it gives an error |
20:29:14 | FromDiscord | <Gumbercules> `getOrDefault` |
20:29:39 | FromDiscord | <Gumbercules> `getOrDefault(objects, currObject, "default goes here") |
20:29:41 | FromDiscord | <Gumbercules> (edit) "here")" => "here")`" |
20:29:50 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/tables.html#getOrDefault%2CTable%5BA%2CB%5D%2CA%2CB |
20:30:04 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hJn |
20:30:18 | FromDiscord | <Gumbercules> well Nim ain't C++ |
20:30:20 | FromDiscord | <Gumbercules> for better or worse |
20:30:21 | FromDiscord | <πτ (pi man)> (edit) "https://play.nim-lang.org/#ix=4hJn" => "https://play.nim-lang.org/#ix=4hJo" |
20:30:32 | FromDiscord | <Gumbercules> probably better |
20:30:32 | FromDiscord | <πτ (pi man)> right, that's why i'm asking how to do it |
20:30:34 | FromDiscord | <Gumbercules> but 🤷 |
20:30:42 | FromDiscord | <Gumbercules> yeah - Nim doesn't really have any shorthand syntax like that |
20:30:49 | FromDiscord | <Gumbercules> but it would be easy enough to do with a macro |
20:30:58 | FromDiscord | <Gumbercules> maybe even a template |
20:31:03 | FromDiscord | <πτ (pi man)> getOrDefault should work if it adds it to the table |
20:31:24 | FromDiscord | <Generic> nah you can use hasKeyOrPut |
20:31:33 | FromDiscord | <Generic> (edit) "hasKeyOrPut" => "mgetOrPut" |
20:31:44 | FromDiscord | <πτ (pi man)> or I make a proc to return a default instance of BACnetObject I guess |
20:32:16 | FromDiscord | <Generic> `objects.mgetOrPut(currObject, default(whatevertype)).field = 42 |
20:32:20 | FromDiscord | <Generic> (edit) "42" => "42`" |
20:32:39 | FromDiscord | <πτ (pi man)> In reply to @πτ (pi man) "normally I would do": oh, there's a default keyword? |
20:32:52 | FromDiscord | <πτ (pi man)> (edit) "In reply to @πτ (pi man) "normally I would do": oh, there's a default keyword? ... " added "(woops that was not supposed to still be reply lol)" |
20:33:00 | FromDiscord | <Generic> also that should work |
20:33:07 | FromDiscord | <Generic> `[]=` != `[]` in Nim |
20:33:27 | FromDiscord | <Generic> `[]=` does create new fields in Nim |
20:33:36 | FromDiscord | <πτ (pi man)> so I can do `objects[currentObject] = default(BACnetObject)`? |
20:33:40 | FromDiscord | <Generic> yes, that works |
20:33:49 | FromDiscord | <πτ (pi man)> that's what I was looking for then, thanks |
20:33:56 | FromDiscord | <Generic> `objects[currentObject].field = uiae` |
20:34:05 | FromDiscord | <Generic> doesn't though, if currentObject doesn't exist yet in the table |
20:34:21 | FromDiscord | <Generic> then you have to use mgetOrPut |
20:34:29 | FromDiscord | <πτ (pi man)> yes, I wasn't really expecting it to work, but I didn't know how else to try and put the object into the table |
20:34:50 | FromDiscord | <πτ (pi man)> (because I know for a fact that it doesn't yet exist) |
20:34:53 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJq |
20:35:38 | FromDiscord | <πτ (pi man)> and Nim not having constructors I wasn't sure how to get a default object inline |
20:36:17 | FromDiscord | <Gumbercules> taking things a step further |
20:36:22 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJt |
20:37:00 | FromDiscord | <Horizon [She/Her]> What exceptions does `document.getElementById` raise? Doesn't say it raises any, but i thought an error would be raised if an ID doesn't exist |
20:37:19 | FromDiscord | <Gumbercules> look at what that does in JS |
20:37:32 | FromDiscord | <Gumbercules> Nim is just going to do whatever JS does |
20:37:34 | FromDiscord | <Generic> https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById |
20:37:36 | FromDiscord | <Generic> apparently it returns null |
20:37:43 | * | ofelas quit (Quit: Leaving) |
20:37:45 | FromDiscord | <Gumbercules> so it will return `nil` |
20:37:53 | FromDiscord | <πτ (pi man)> welp........ I get the key for the object after I get other data for the object so this was all pointless anyways :mood: |
20:38:06 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "Nim is just going": Ah, would be nice if these behaviours were explained in the Nim docs at least |
20:39:09 | FromDiscord | <Horizon [She/Her]> I hope the `Element` is mutable, should be, if we're going by JS' logic |
20:39:31 | FromDiscord | <Gumbercules> isn't every JS object mutable? |
20:39:53 | FromDiscord | <Horizon [She/Her]> Yup |
20:40:10 | FromDiscord | <Gumbercules> Nim should follow JS semantics |
20:40:16 | FromDiscord | <Gumbercules> like Nim's implementation of that function |
20:40:19 | FromDiscord | <Horizon [She/Her]> Alright, thanks! |
20:40:47 | FromDiscord | <Gumbercules> I'm guessing is - `proc getElementById(d: Document): HTMLElement {.importcpp: "getElementById(#)".}` or something similar to that |
20:41:23 | FromDiscord | <Gumbercules> so Nim is just binding to the JS function |
20:41:56 | FromDiscord | <Gumbercules> oh well I forgot the `cstring` arg but yeah |
20:42:09 | FromDiscord | <Horizon [She/Her]> Yup that's right (similar) |
20:42:30 | FromDiscord | <Gumbercules> https://github.com/nim-lang/Nim/blob/version-1-6/lib/js/dom.nim#L1438 |
20:45:05 | Zevv | i want to add a few words to my earlier rant: I do not think there are any feasible alternatives to sane threading in nim exactly *because* of arc: if you share nim-managed memory (ie refs) between threads, arc will set you world on fire becuase the reference counters are not atomic. If you share a ref, two threads will go pulling the RCs, unsynchronized, leading to UB/disaster. The only alternative left then |
20:45:11 | Zevv | is to use raw ptrs (like mratsims weave, for example), but then we might as well go back to C or C++. ARC is ment to make life easier on the developers, but it makes practical sharing of memory over threads basically impossible. |
20:45:15 | FromDiscord | <Gumbercules> lol at one point I ported https://viperhtml.js.org/hyper.html tto Nim |
20:45:15 | FromDiscord | <Gumbercules> that was fun |
20:45:36 | Zevv | fwiw. |
20:45:39 | FromDiscord | <Gumbercules> In reply to @Zevv "is to use raw": I don't get this - it's not impossible |
20:45:54 | FromDiscord | <Gumbercules> is it easy? no - but multithreading and sharing memory has never been |
20:46:05 | FromDiscord | <Gumbercules> and outside of a higher level abstraction like message passing, there is no real answer |
20:46:11 | Zevv | tell me how to share a ref over threads |
20:46:13 | FromDiscord | <Gumbercules> besides "don't share memory between threads" |
20:46:29 | FromDiscord | <Gumbercules> okay well now we're introducing the requirement that we need to share refs |
20:46:51 | Zevv | well, you want to share data, likely? |
20:46:52 | FromDiscord | <Gumbercules> you can do it with `gc_ref` `gc_unref` probably but it's not going to be pretty or fun |
20:46:58 | FromDiscord | <πτ (pi man)> are objects in nim default stack or heap? |
20:47:06 | FromDiscord | <Gumbercules> sure - but there's no reason I need to manage that memory with Nim's GC |
20:47:15 | FromDiscord | <Gumbercules> I can manually allocate and free memory |
20:47:21 | FromDiscord | <Gumbercules> and with destructors this gets easier |
20:47:33 | Zevv | ok, so maybe i'm funny for wanting the language to support me instead of having to do things manually |
20:47:33 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "are objects in nim": stack - refs are allocated on the heap |
20:47:40 | FromDiscord | <Gumbercules> no |
20:47:51 | FromDiscord | <Gumbercules> but I think whether you're using Rust or Zig or Nim or D or whatever you're going to run into this issue |
20:47:54 | FromDiscord | <πτ (pi man)> I like doing things manually tbh |
20:48:17 | FromDiscord | <Gumbercules> and then your answers are the same |
20:48:20 | Zevv | well, sure, then you are good to go |
20:48:33 | FromDiscord | <Gumbercules> resort to message passing or get your hands really dirty |
20:49:11 | FromDiscord | <Gumbercules> I think Nim is in a pretty good spot honestly - being able to introduce RAII like semantics is swell |
20:49:32 | Zevv | the inbetween way is passing refs. it does not have the cost of copying, you can pass arbitrary large data structures around at virtually no cost |
20:50:01 | FromDiscord | <Gumbercules> if your program is written entirely in Nim then sure |
20:50:16 | Zevv | i like my nim programs to be written in nim, generally |
20:50:22 | FromDiscord | <Gumbercules> I'm not sure how you're going to do this with C/C++ interop |
20:50:28 | FromDiscord | <Gumbercules> this isn't feasible for me |
20:50:52 | FromDiscord | <Gumbercules> then again, I think we want different things from our usage of Nim |
20:50:57 | FromDiscord | <Gumbercules> you want sane and safe concurrency / parallelism |
20:51:12 | * | xet7 quit (Quit: Leaving) |
20:51:25 | FromDiscord | <Gumbercules> I don't really care if what I'm doing is safe in my game client code for the most part |
20:51:38 | Zevv | fair enough. |
20:51:45 | * | xet7 joined #nim |
20:52:19 | FromDiscord | <Gumbercules> I agree with you 100% though - Elixir, Golang, Pony - these languages have very rosy concurrency pictures |
20:52:57 | FromDiscord | <Gumbercules> I haven't used Pony - just stared at a bunch of Pony code, but I have used both Golang and Elixir and well, I code in Elixir for my job so I guess I like it a bit |
20:53:20 | Zevv | pony i hell, 9 different pointer types and all their relations dont fit in my mind |
20:53:43 | FromDiscord | <Gumbercules> even though they told me I'd get to code in Nim 😒 |
20:54:04 | FromDiscord | <Gumbercules> Pony is one of those languages relegated to academia I think |
20:54:41 | Zevv | i think nim can be made to get close to go or elixir, we "fiberize" the code the same was as go does, allowing us to schedule it similary to how go does. I like the process model of elixir a lot, allowing to build supervisor trees and gensever-like models, and this is also proven to be doable. |
20:55:17 | FromDiscord | <Gumbercules> https://www.ponylang.io/media/papers/a_string_of_ponies.pdf |
20:55:30 | * | arkurious joined #nim |
20:55:31 | FromDiscord | <Gumbercules> as long as we don't give up what we ahave now |
20:55:41 | FromDiscord | <Gumbercules> and the runtime is opt-in |
20:55:52 | * | ltriant joined #nim |
20:56:08 | FromDiscord | <Gumbercules> I'd be cool with that - would give me a reason to use Nim for my game server instead of Elixir as well |
20:56:41 | FromDiscord | <Gumbercules> lot of engineering effort went into BEAM though, like decades |
20:56:58 | FromDiscord | <Gumbercules> but I mean, I agree I'm sure it could be done if someone was willing to invest the time and had the know how |
21:00:39 | Zevv | well, no one builds stuff like this on their own, right |
21:00:49 | * | ltriant quit (Ping timeout: 260 seconds) |
21:05:35 | FromDiscord | <πτ (pi man)> what's the best way to get the last item in a sequence? |
21:05:58 | * | kenran joined #nim |
21:08:18 | FromDiscord | <Kermithos> I think [^1] |
21:09:12 | FromDiscord | <Kermithos> https://play.nim-lang.org/#ix=4hJE |
21:09:51 | * | jmdaemon joined #nim |
21:10:06 | FromDiscord | <πτ (pi man)> yep, never did get used to index operators |
21:11:10 | FromDiscord | <πτ (pi man)> In reply to @Gumbercules "I haven't used Pony": I get to use visual scripting for my job :LUL: |
21:17:23 | * | ltriant joined #nim |
21:18:28 | * | xet7 quit (Read error: Connection reset by peer) |
21:26:22 | FromDiscord | <πτ (pi man)> ok, how do I return a taggedUnion? |
21:26:40 | FromDiscord | <πτ (pi man)> (edit) "taggedUnion?" => "taggedUnion using result?" |
21:26:45 | FromDiscord | <πτ (pi man)> or do I just not use result |
21:26:56 | FromDiscord | <πτ (pi man)> actually probably better to just use return I guess |
21:27:18 | FromDiscord | <Gumbercules> In reply to @Zevv "well, no one builds": truth, took Ericsson to build ERlang |
21:27:20 | FromDiscord | <Gumbercules> (edit) "ERlang" => "Erlang" |
21:27:51 | FromDiscord | <Gumbercules> In reply to @πτ (pi man) "I get to use": heh, my second "programming" job was using TIBCO |
21:27:56 | FromDiscord | <Gumbercules> absolute horror show |
21:28:05 | FromDiscord | <πτ (pi man)> idk what TIBCO is |
21:28:15 | FromDiscord | <Gumbercules> also have had to touch informatica and other ETL / integration solutions before, yuck |
21:28:33 | FromDiscord | <Gumbercules> https://www.tibco.com/products/tibco-businessworks |
21:35:40 | * | TakinOver quit (Ping timeout: 256 seconds) |
21:37:18 | FromDiscord | <πτ (pi man)> does Nim have "struct initialization" (like C does) |
21:38:20 | * | TakinOver joined #nim |
21:45:27 | FromDiscord | <Elegantbeef> No you have to do `MyObject(field: arg, field2: arg2)` |
21:46:22 | FromDiscord | <kaddkaka> So, how can I get som discussion/traction for my scanf change suggestion (returning length:int instead of result:bool)? |
21:46:33 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "No you have to": well thats kind of what I meant |
21:46:42 | FromDiscord | <πτ (pi man)> you don't have to define that as a proc right? |
21:46:56 | FromDiscord | <kaddkaka> (Or make a sibling for scanf) |
21:47:12 | FromDiscord | <Elegantbeef> No you do not |
21:47:41 | FromDiscord | <Elegantbeef> A well written RFC, but even then it's not overly likely to happen, but who knows↵(@kaddkaka) |
21:48:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hJO |
21:48:11 | FromDiscord | <Elegantbeef> That works fine |
21:48:24 | * | PMunch quit (Quit: leaving) |
21:48:42 | FromDiscord | <kaddkaka> In reply to @Elegantbeef "A well written RFC,": Why isn't it likely to happen you mean? Because breaking changes to std library are un-nice? |
21:49:58 | FromDiscord | <Elegantbeef> Indeed |
21:50:46 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hJP |
21:52:03 | FromDiscord | <Elegantbeef> Yes |
21:52:09 | FromDiscord | <Elegantbeef> though using `type` is a dumb idea |
21:52:15 | FromDiscord | <Elegantbeef> use `kind` or `typ` |
21:55:41 | * | kenran quit (Remote host closed the connection) |
21:57:54 | FromDiscord | <kaddkaka> In reply to @Elegantbeef "Indeed": Was that an answer to me? |
21:57:58 | FromDiscord | <Gumbercules> re: the conversation around threads vs green threads earlier, this is why it's often at your disadvantage to leverage a thread pool for I/O bound work - https://en.wikipedia.org/wiki/Preemption_(computing)#Preemptive_multitasking |
21:58:10 | FromDiscord | <Elegantbeef> Yes that was an answer to you |
21:58:23 | * | pro joined #nim |
21:58:43 | * | pro left #nim (#nim) |
21:59:11 | FromDiscord | <kaddkaka> 👍 I will propose another version of scanf in that case. Any name suggestions? `scanfl` 🤔 |
21:59:38 | FromDiscord | <kaddkaka> I will write something up during the week ☺️ |
22:05:04 | * | xet7 joined #nim |
22:08:02 | NimEventer | New thread by elcritch: ROS2 Library port (Robotics), see https://forum.nim-lang.org/t/9693 |
22:08:23 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hJX |
22:10:13 | FromDiscord | <Gumbercules> https://berb.github.io/diploma-thesis/original/042_serverarch.html good read if you're authoring a web sever |
22:10:22 | FromDiscord | <Require Support> what does NimMain do, other than GC initialization? |
22:10:41 | FromDiscord | <Gumbercules> look at the generated C code 🙂 |
22:10:43 | FromDiscord | <Elegantbeef> Call all top level code |
22:11:12 | FromDiscord | <Require Support> so it always has to be called 🤔 |
22:11:26 | FromDiscord | <Elegantbeef> Yes it should always be called |
22:11:26 | FromDiscord | <Gumbercules> there's a {.nomain.} pragma |
22:11:48 | FromDiscord | <Require Support> ye but then you'd have to call it yourself |
22:11:58 | FromDiscord | <Require Support> I think |
22:12:05 | FromDiscord | <Gumbercules> err sorry |
22:12:12 | FromDiscord | <Gumbercules> not pragma but compiler option |
22:12:12 | FromDiscord | <Elegantbeef> there is also `--noMain` 😄 |
22:12:12 | FromDiscord | <Gumbercules> yes |
22:12:40 | FromDiscord | <Elegantbeef> That doesnt generate a main equivalent to C it still has `NimMain` |
22:12:45 | FromDiscord | <Gumbercules> mmhmm |
22:12:55 | FromDiscord | <Gumbercules> useful if you plan on having a C program host your Nim code |
22:13:23 | FromDiscord | <Gumbercules> or whatever language you're hosting your Nim code with that is going to have its own `main` entrypoint |
22:13:37 | FromDiscord | <Gumbercules> what are you trying to do @Require Support ? |
22:14:37 | FromDiscord | <Require Support> I saw a comment by Araq on the forums that said when using `--mm:orc` you dont need to call NimMain |
22:15:24 | FromDiscord | <Require Support> trying to create a dll with --nomain that doesnt require me to call NimMain |
22:15:27 | FromDiscord | <Elegantbeef> You dont need to but you certainly should |
22:17:05 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "Yes": hmm, I'm getting just `0` when I shouldn't be |
22:17:10 | FromDiscord | <πτ (pi man)> (edit) "In reply to @Elegantbeef "Yes": hmm, I'm getting just `0` when I shouldn't be ... " added "though" |
22:20:06 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hJZ |
22:20:23 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hK0 |
22:21:21 | FromDiscord | <πτ (pi man)> (btw I renamed type to objectID) |
22:21:51 | FromDiscord | <πτ (pi man)> an echo of the BACoid gives `(type: 0, instanceID: 0)` |
22:22:38 | FromDiscord | <Require Support> In reply to @Elegantbeef "You dont *need* to": yeah but was just curious if I could get it running without crashing |
22:23:00 | FromDiscord | <Elegantbeef> Yes you can |
22:25:48 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hK2 |
22:26:08 | FromDiscord | <Elegantbeef> Object variant is the name |
22:26:50 | * | pro joined #nim |
22:27:00 | * | pro left #nim (#nim) |
22:27:24 | FromDiscord | <Elegantbeef> Getting 0s means you are not always getting to your `result. =` branches |
22:28:03 | * | dtomato4 quit (Quit: The Lounge - https://thelounge.chat) |
22:29:25 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "Getting 0s means you": but I can see that I am because of the echos |
22:30:59 | FromDiscord | <Elegantbeef> Are you parsing a single xml node? |
22:32:53 | FromDiscord | <πτ (pi man)> I'm parsing a singl xml document of which there are lots of BACoid nodes |
22:34:21 | FromDiscord | <Elegantbeef> So are you certain that the nodes that have 0 are the ones that get to the assignment branches? |
22:36:03 | FromDiscord | <πτ (pi man)> as far as I can tell from the echos, yes |
22:36:28 | FromDiscord | <πτ (pi man)> so in otherwords i'm 99% certain |
22:41:13 | FromDiscord | <Elegantbeef> Well without runnable code i can only say "Yep" |
22:41:20 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hK8 |
22:43:01 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hK9 |
22:44:04 | FromDiscord | <πτ (pi man)> every single print is this way |
22:44:52 | FromDiscord | <Elegantbeef> What memory management are you using? |
22:45:31 | FromDiscord | <πτ (pi man)> default? |
22:45:54 | FromDiscord | <πτ (pi man)> the issue seems to be the assignment though |
22:46:04 | FromDiscord | <Elegantbeef> What version of Nim 1.6 or 1.7? |
22:46:09 | FromDiscord | <πτ (pi man)> 1.5.1 |
22:46:13 | FromDiscord | <Gumbercules> In reply to @Require Support "trying to create a": try `--app:lib` |
22:46:19 | FromDiscord | <Elegantbeef> Why 1.5.1.... |
22:46:24 | FromDiscord | <Gumbercules> here is how I compile the plugins for my game server |
22:46:25 | FromDiscord | <πτ (pi man)> because I don't remember how to update |
22:46:28 | FromDiscord | <Gumbercules> err sorry game engine |
22:46:29 | FromDiscord | <Elegantbeef> That's a devel of a devel |
22:47:10 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/config.nims |
22:47:38 | FromDiscord | <Gumbercules> oh wait |
22:47:41 | FromDiscord | <Gumbercules> no... that's not right |
22:47:56 | FromDiscord | <πτ (pi man)> I have choosenim, but I don't remember how to use it |
22:48:00 | FromDiscord | <Gumbercules> there |
22:48:01 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hKb |
22:48:05 | FromDiscord | <Elegantbeef> `choosenim stable` |
22:48:10 | FromDiscord | <Elegantbeef> `choosenim update stable` |
22:48:35 | FromDiscord | <Gumbercules> plus ` nim c --app:lib --out:shell-shocked.dll .\main.nim` |
22:48:39 | FromDiscord | <πτ (pi man)> updating |
22:48:41 | FromDiscord | <Elegantbeef> `--app:lib --mm:orc` is all you really should need |
22:49:05 | FromDiscord | <πτ (pi man)> updating to 1.6.10 |
22:49:19 | FromDiscord | <Elegantbeef> I guess maybe you'd need `--app:lib --mm:orc --noMain:on` but `lib` should imply the latter |
22:49:22 | FromDiscord | <Gumbercules> you don't even need `--mm:orc` if you want to use the original memory model |
22:49:23 | FromDiscord | <Gumbercules> yeah it does |
22:49:51 | FromDiscord | <Elegantbeef> Well they dont want to have to init the GC so they dont want to use refc |
22:50:17 | FromDiscord | <Gumbercules> but then you probably will need `nim c -d:useNimRtl myprog.nim` |
22:50:21 | FromDiscord | <Gumbercules> ah okay gotcha |
22:50:47 | FromDiscord | <πτ (pi man)> updated nim and still same issue, the issue seems to be assignment of the object variant btw |
22:51:11 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hKc |
22:51:37 | FromDiscord | <Elegantbeef> Try `--mm:orc` pi |
22:51:59 | FromDiscord | <Elegantbeef> I'm curious if something with Nim's old memory management is accidentally incorrectly zeroing memory |
22:52:18 | FromDiscord | <Cheeseinator> If I'm on 1.6.10 should I use `--mm:orc` or `--gc:orc`? |
22:52:19 | FromDiscord | <Elegantbeef> You dont have a custom copy hook do you? |
22:52:27 | FromDiscord | <πτ (pi man)> same thing, (ran `nimble run --mm:orc`) |
22:52:28 | FromDiscord | <Elegantbeef> it's the same thing |
22:52:32 | FromDiscord | <Elegantbeef> `--mm` is an alias |
22:52:37 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "You dont have a": nope |
22:52:46 | FromDiscord | <Elegantbeef> `--gc` is deprecated now |
22:52:56 | FromDiscord | <Elegantbeef> Well if you can get me a runnable example i'll take a look |
22:53:05 | FromDiscord | <πτ (pi man)> just executable? |
22:53:12 | FromDiscord | <πτ (pi man)> or source code |
22:53:17 | FromDiscord | <Elegantbeef> Source |
22:53:47 | FromDiscord | <πτ (pi man)> https://paste.myst.rs/tmxxrmn3 |
22:54:26 | * | clemens3 left #nim (WeeChat 2.7) |
22:54:58 | FromDiscord | <Elegantbeef> god so many stropped fields 😄 |
22:55:30 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
22:58:25 | FromDiscord | <Gumbercules> `result.properties[^1].data.bacoid.objectID.int`😬 |
22:58:32 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4hKd this works fine |
22:59:27 | FromDiscord | <Elegantbeef> can i get the .caf file or is this locked behind doors |
23:00:14 | FromDiscord | <Elegantbeef> Honestly the stropping and the screaming undescore cased enums is worse to me gumber 😄 |
23:01:05 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=4hKd this works fine": right, but this doesn't have a second data object |
23:01:36 | FromDiscord | <πτ (pi man)> if I do `d = a` and print `d` it shows `0, 0` |
23:01:39 | FromDiscord | <Gumbercules> In reply to @Elegantbeef "Honestly the stropping and": yeah it's a close contest |
23:01:53 | FromDiscord | <πτ (pi man)> https://media.discordapp.net/attachments/371759389889003532/1049098241410605087/Test_NCE.caf |
23:02:30 | FromDiscord | <Elegantbeef> The issue is the bitsize pragma |
23:02:32 | FromDiscord | <Elegantbeef> So this is a compiler bug |
23:02:47 | FromDiscord | <πτ (pi man)> yay :mood: |
23:03:05 | FromDiscord | <πτ (pi man)> I guess I just won't use bitsize then |
23:04:07 | FromDiscord | <πτ (pi man)> yep, now it works |
23:10:01 | FromDiscord | <Elegantbeef> Odd the string branch seems to cause it |
23:10:01 | FromDiscord | <Elegantbeef> Reproduction |
23:10:03 | FromDiscord | <Elegantbeef> change `string` to `int` and it still errors |
23:10:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/Chb |
23:10:07 | FromDiscord | <Elegantbeef> I mean it doesnt error |
23:10:27 | * | wallabra_ joined #nim |
23:10:37 | * | dtomato4 joined #nim |
23:10:50 | FromDiscord | <Elegantbeef> `ref`/`string`/`seq` cause this it seems |
23:13:08 | * | wallabra quit (Ping timeout: 256 seconds) |
23:13:08 | * | wallabra_ is now known as wallabra |
23:14:25 | FromDiscord | <πτ (pi man)> but also removing the bitsize also fixes it |
23:14:34 | FromDiscord | <メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hKq |
23:15:37 | FromDiscord | <メッリーレイムー 🎄> (edit) "https://play.nim-lang.org/#ix=4hKq" => "https://play.nim-lang.org/#ix=4hKr" |
23:15:48 | FromDiscord | <メッリーレイムー 🎄> (edit) "https://play.nim-lang.org/#ix=4hKr" => "https://play.nim-lang.org/#ix=4hKs" |
23:16:25 | FromDiscord | <Gumbercules> https://play.nim-lang.org/#ix=4hKt works |
23:16:36 | FromDiscord | <Gumbercules> @πτ (pi man) |
23:16:37 | FromDiscord | <メッリーレイムー 🎄> how do i make it a ref |
23:19:42 | FromDiscord | <Elegantbeef> `raise (ref LexerError)(src: "...", line: ...., msg: ...)` |
23:20:29 | FromDiscord | <メッリーレイムー 🎄> i mean doing this worked too |
23:20:36 | FromDiscord | <メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hKv |
23:20:57 | FromDiscord | <Just Jasmine, Please> In reply to @amadan "From this post https://www.reddit.com/r/SteamDeck/c": Thank you so much! I figured this out through trial and error, but I appreciate you putting in the effort! |
23:21:02 | FromDiscord | <メッリーレイムー 🎄> is ref like a pointer/reference type? |
23:21:25 | FromDiscord | <Elegantbeef> ref is a heap allocated traced pointer |
23:23:12 | FromDiscord | <treeform> In reply to @ajusa "If that doesn't work,": re: "flatty isn't as nice" How can I make flatty nicer? |
23:23:25 | FromDiscord | <メッリーレイムー 🎄> In reply to @Elegantbeef "ref is a heap": gotcha |
23:24:56 | * | wallabra_ joined #nim |
23:26:10 | * | wallabra quit (Ping timeout: 256 seconds) |
23:26:21 | * | wallabra_ is now known as wallabra |
23:37:01 | FromDiscord | <メッリーレイムー 🎄> when to use {.raises: e.} |
23:39:56 | FromDiscord | <Elegantbeef> When you want ensure a procedure only raises specific things |
23:40:07 | FromDiscord | <Elegantbeef> Most people do `{.raises: [].}` on procedures they want to never error |
23:41:04 | FromDiscord | <メッリーレイムー 🎄> gotchu |
23:41:32 | FromDiscord | <メッリーレイムー 🎄> so its not like java throws |
23:41:51 | FromDiscord | <Elegantbeef> It's the opposite of it |
23:42:00 | FromDiscord | <Elegantbeef> In Nim procedures implicitly are tracked |
23:42:23 | FromDiscord | <Elegantbeef> So `{.raises:[...].}` is an explicit annotation to say 'I want the compiler to tell me when an error that isnt in this list is raised |
23:43:46 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "So `{.raises:[...].}` is an": but that's the same with Java is it not? |
23:43:53 | FromDiscord | <Elegantbeef> Nope |
23:44:01 | FromDiscord | <Elegantbeef> Java forces the developer to annotate procedures that raise |
23:46:11 | FromDiscord | <Elegantbeef> Nim infers it and the developer states when they want to limit or constrain what can be raised |
23:47:59 | FromDiscord | <albassort> alright heres a question |
23:48:37 | FromDiscord | <albassort> should I spawn a thread for my "async" timeouts one time and have a system where you feed sleep to it or should i spawn it every time i need it |
23:49:07 | FromDiscord | <albassort> and also is there an interruptible sleep so i can cancel it via a while look |
23:50:39 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hKC |
23:51:05 | FromDiscord | <albassort> im starting to realize i sound insane |
23:55:29 | FromDiscord | <ChocolettePalette> The former. Spawning threads is huge overhead↵(@albassort) |
23:56:11 | FromDiscord | <albassort> i smell the need for a closure |
23:56:24 | FromDiscord | <albassort> cursed code day, it is |