<< 27-01-2023 >>

00:00:31termeroh god, now I need to do compiler silliness for switching between asyncdispatch and chronos
00:11:39termerlol the docs weren't lying
00:11:47termerasynchttpserver is super not production ready
00:12:06termerIt's safe running behind nginx though lol
00:14:11FromDiscord<Rika> I personally think not even behind nginx is it safe to deploy in production…
00:17:22termerin this case it doesn't crash so yay
00:17:32termerhttpbeast and httpx both crash under ORC
00:17:56termerregardless of whether you're opening too many connections
00:18:09termerso ironically asynchttpserver is much more stable for this purpose
00:36:04FromDiscord<sOkam!> whats the state of other multithreading things? can a job-task system be created for production with some other module?
00:40:56FromDiscord<michaelb.eth> sent a long message, see http://ix.io/4mix
00:41:28FromDiscord<michaelb.eth> With `orc` being the default gc in forthcoming v2.0, hopefully the experience will be better and more flexible, since there's just one shared heap between threads.
00:41:52FromDiscord<michaelb.eth> (edit) "http://ix.io/4mix" => "http://ix.io/4miy"
00:42:28FromDiscord<michaelb.eth> (edit) "With `orc` being the default gc in forthcoming v2.0, hopefully the experience will be better and more flexible, since there's just one ... sharedby" added "heap" | "heap between" => "by"
00:43:17FromDiscord<michaelb.eth> In reply to @termer "httpbeast and httpx both": is chronos "ORC ready" now? if so, that's great news
00:43:31termerI have no idea
00:43:36termerIf not, I'm not using it
00:43:48termerbut it looks like I'm just going to be using normal asynchttpserver behind nginx for this
00:44:39termerUnless you've got some legacy code, it seems like it would be a waste not to use ORC
00:44:54FromDiscord<michaelb.eth> chronos had some problems with ORC for quite awhile, but the Status teams using it in production were happy with `refc`, so it wasn't practical/priority to fix that, but it might well have been fixed
00:46:11termerhttps://github.com/status-im/nim-chronos/issues/325
00:46:13termerfound this
00:46:15FromDiscord<michaelb.eth> by happy with `refc` I mean a great amount of engineering effort had gone into making sure that the prod code performed well and is stable with `refc`, and it wasn't practical to solve the ORC problem when more pressing matters were at hand
00:46:56termerWith Nim 2 up and coming, I think the reasoning for upgrading will be mounting
00:47:34FromDiscord<sOkam!> In reply to @michaelb.eth "It depends on the": makes senses, ty↵you seem to know a lot about the topic. do you have any articles/references to read to learn multithreading concepts?↵All i seem to find are either extremely advanced articles, or very superficial things with not much use. So any pointers would be very welcome
00:48:38FromDiscord<michaelb.eth> Sadly, I do not have any articles/references to share, just my own experiences.
00:49:05termerMultithreading is very hard in nim compared to other languages because the head is thread-local
00:49:07FromDiscord<sOkam!> how would you recommend me to learn about the topic?
00:49:15termertrial and error :)
00:49:21termerThat's how I learned
00:49:36FromDiscord<sOkam!> trial and error still needs a start point and a path 🙈
00:49:38termerBut I think the most important concept for you to understand is that memory in nim can't be shared between threads by default
00:49:43FromDiscord<michaelb.eth> I did work with a team member to create a highly experimental "task runner" library that used multithreading, chronos, and "async channels" (not an official part of chronos), you can look at that code if you want, but the library was never finished and had some problems
00:49:43termerwell what do you want to build?
00:50:44FromDiscord<sOkam!> In reply to @termer "well what do you": https://fabiensanglard.net/doom3_bfg/threading.php something like this
00:51:05FromDiscord<sOkam!> a joblist manager for a game engine, using only atomic operations
00:51:50FromDiscord<michaelb.eth> well the "no shared" aspect of `refc` is going to make something just like that practically impossible
00:52:00termeryou *can* share memory
00:52:06termerbut you have to create and free it explicitly
00:52:12termersee createShared and freeShared
00:52:18FromDiscord<michaelb.eth> sure, I suggested that above
00:52:22FromDiscord<sOkam!> i see
00:52:43termerTread lightly with those APIs, because you can very easily create memory leaks
00:52:53FromDiscord<sOkam!> what part of that type of system uses shared memory? i thought it was all non-shared due to the atomics
00:53:04FromDiscord<sOkam!> yeah i imagine
00:53:11FromDiscord<michaelb.eth> In reply to @michaelb.eth "well the "no shared"": I should have added there too, unless you will accept the burden of allocating and freeing correctly upon yourself
00:53:31FromDiscord<michaelb.eth> (edit) "too, unless" => "too: "unless" | "yourself" => "yourself""
00:53:42termerThe difference between the memory you get with normal automatic allocation and createShared is createShared returns an unsafe pointer (ptr instead of ref)
00:53:50termeror rather, unmanaged pointer
00:53:57termerSo it's not part of the GC lifecycle at all
00:54:01termerthat's why you have to manage it yourself
00:54:22termerthe other difference is that you have to dereference it manually by adding the [] suffix
00:54:29termerso myData[] = "thing"
00:54:41FromDiscord<michaelb.eth> maybe someone is already cooking up a worker pool lib that assumes on `orc`
00:54:42FromDiscord<sOkam!> ye i imagine
00:55:08FromDiscord<sOkam!> that would be epic
00:55:30FromDiscord<michaelb.eth> I think someone made a forum post about that awhile back
00:55:33FromDiscord<michaelb.eth> let me try to find it...
00:56:11FromDiscord<sOkam!> what's the simplest version of an app that could run with a system like this?↵something like a test bed for trying this functionality
00:56:26FromDiscord<michaelb.eth> this isn't the forum post I was thinking of, but see https://forum.nim-lang.org/t/8791#57344
00:56:28termerI can't imagine making a worker thread library would be too hard under orc as long as you make good use of channels
00:56:38FromDiscord<michaelb.eth> (edit) "https://forum.nim-lang.org/t/8791#57344" => "https://forum.nim-lang.org/t/8791"
00:56:39FromDiscord<sOkam!> what are channels?
00:56:50termerChannels are threadsafe ways of passing data to and from threads
00:57:07termerthey're basically lock-enforced FIFO buffers
00:57:37termers0kam! https://nim-lang.org/docs/channels_builtin.html
00:57:59termerThey're threadsafe because all data that passes through them are deep-copied
00:58:03termerso there are no cross-thread references
00:58:24FromDiscord<michaelb.eth> yeah, but you can't `await` on a channel with std async, which can be frustrating depending on what you want to do
00:58:32termerthat's not really a problem
00:58:48termeryou can tryRecv and loop around that with a small async sleep between checks
00:58:54termerand then wrap that in a promise
00:58:58termer*future
00:59:43FromDiscord<michaelb.eth> what if I want to run a thousand++ concurrent async http gets on a worker thread where the signal re: what to fetch is a message on a std channel
00:59:47FromDiscord<michaelb.eth> (edit) "channel" => "channel?"
01:00:16FromDiscord<michaelb.eth> I can't `await` for a message re: what to get while also concurrently doing the http stuff
01:00:37termeryou're not gonna get them in any particular order but you will have a nice little await API to use
01:00:46termerbut I don't see the issue with the approach I mentioned
01:00:57termerif you need to queue them, then you need to do more nonsense with async streams and all that
01:01:05termerbut a simple worker queue doesn't require that
01:01:38FromDiscord<michaelb.eth> what I mean is that I want to concurrently `await` messages on the channel, and concurrently do async http gets re: messages already received
01:01:52FromDiscord<michaelb.eth> all on the same thread
01:02:08FromDiscord<michaelb.eth> with chronos' unofficial async channels that's possible, but not with std channels, afaik
01:03:05termerthen create a proc to do that and then do asyncCheck
01:03:56termerif you want to do any work concurrently within the same thread and still have nice awaits, create an async proc (can be nested in your current proc) and then call it with asyncCheck
01:04:39termerjust make sure that it has the possibility of exiting and has proper error handling, otherwise errors will be raised from them whereever polling is happening
01:04:57termerso if an uncatch error is raised inside of a proc called with asyncCheck, it'
01:05:03termerll end up coming up whereever you ran runForver
01:05:07termerfor waitFor
01:07:23FromDiscord<michaelb.eth> maybe it can work, I was not able to do in a straightforward manner what I wanted with std async and channels↵what I did have good luck with was extracting code from this unmerged chronos PR, catching up with (then) latest chronos and building worker-threads and worker-pools on top: https://github.com/status-im/nim-chronos/pull/45
01:07:33FromDiscord<michaelb.eth> (edit) "maybe it can work, I was not able to do in a straightforward manner what I wanted with std async and ... channels↵what" added "std"
01:08:31FromDiscord<michaelb.eth> https://github.com/status-im/nim-chronos/blob/achannels/tests/testchannels.nim#L34
01:09:02FromDiscord<michaelb.eth> you can await recv on a worker thread (either standalone or in a pool) while concurrently doing other async stuff in that thread
01:09:07FromDiscord<michaelb.eth> nice paradigm
01:09:25termerthat's a nice thing
01:14:04FromDiscord<michaelb.eth> a challenge was that those async channels were no good for sending non-gc-safe data re: `refc`... so, you have to have some conventions around createShared then copying then sending then receiving then freeing... which can be helped by along by macros... but even then there were mysterious crashes
01:14:36FromDiscord<michaelb.eth> I should revisit it once Nim 2.0 is released
01:15:00termers0kam! I forgot to mention, you should read this chapter, and the one about concurrency on Nim By Example https://nim-by-example.github.io/channels/
01:25:19FromDiscord<sOkam!> In reply to @termer "s0kam! I forgot to": ty 🙏
01:26:53FromDiscord<sOkam!> isn't the point of atomics that you don't share information between threads?
01:28:17termerI'm pretty sure yeah
01:28:20termerwell
01:28:21FromDiscord<sOkam!> i saw you guys mention thread communication a lot, and this channels thing, but im not following how atomics work. i thought they were independent and separate tasks that can be executed without touching other threads, so they dont need to be shared. but maybe i misunderstood
01:28:23termernot share state
01:28:38termerthe point of atomics I believe is to avoid concurrent modification
01:28:46FromDiscord<sOkam!> yep
01:28:46termerwhich is why you need things like threads
01:28:47termer*locks
01:28:49termernot threads lol
01:28:59termerSo as long as your communication is threadsafe, you're ok
01:29:07termerthreads would be useless if we couldn't share data between them
01:29:16FromDiscord<sOkam!> why?
01:29:40FromDiscord<sOkam!> if you have a task that can be run independently of everything else, why do you need to share information with other threads?
01:29:41termerbecause we use threads to do work concurrently, and most work shares some common data
01:29:58termeronly very simple tasks or very specific tasks don't required shared state
01:30:06termeror where work has no global state
01:30:19FromDiscord<sOkam!> right, but this idtech4 idea is about separating data and isolating it from each other, so they don't need to be shared. at least that's what I understood
01:30:25termerFor eaxmple, you could do a REST web application without thread communication, assuming you have no state between threads
01:30:39termerWell let's give an example from the idtech thing
01:30:47termerThere is a joystick input thread
01:30:56termerHow are we going to use that information? Joystick info is needed in other threads
01:31:21FromDiscord<sOkam!> you store it in memory, and then send it where its needed?
01:31:22termerThreads aren't about isolation (unless you're using them specifically for that purpose), they're about parallel work
01:31:44termerstoring it in memory and making it available to other threads would be sharing state
01:32:02termerif you're not sharing any state with other threads, that joystick data will just sick in thread-local memory and never be used
01:32:08FromDiscord<jtv> There are definitely circumstances where you don't NEED locks and can get a tiny bit of extra performance with lock-free solutions instead
01:32:15FromDiscord<jtv> Even if you do share data across threads
01:32:50FromDiscord<sOkam!> In reply to @termer "if you're not sharing": so then the input thread would pass the data back to the main thread, i guess?
01:32:57termerif you only have one thread writing to data and don't mind threads accessing at the same time then it's ok not to use locks
01:33:10termers0kam! Right, or make it available in shared memory
01:33:23termereither way, you need some shared state between threads to make the data useful
01:33:30FromDiscord<jtv> If you want to learn more about that sOkam!, since you're interested in C code anyway, you can check out a project I did least year: https://github.com/viega/hatrack
01:33:56FromDiscord<sOkam!> so shared memory is about not having a "ruler" thread, but what i mention might be about having that ruler that controls all the data, as far as i understand? 🤔
01:34:50termerShared memory is about having memory that is accessible to multiple threads
01:34:56FromDiscord<michaelb.eth> sent a long message, see http://ix.io/4miH
01:34:57FromDiscord<jtv> You don't need a single thread to control anything. That approach tends to end up with a lot of bottlenecks waiting on other threads
01:35:02termerHow you choose to use that data, what protections you use for it, etc are up to you
01:35:27FromDiscord<sOkam!> In reply to @jtv "If you want to": i can read C, but I only trust Carmack. if there is anything specific you want me to look at, let me know where it is. Because dealing with his weirdness is enough to fry my brain for the whole day, let alone figure out a project about a topic I know nothing about 😔
01:36:10FromDiscord<sOkam!> happy to read it, but I won't be able to find my way around the project, thats guaranteed
01:36:19termerHere's an example of how you could use shared memory to expose joystick state to other threads
01:36:25termerYou create an object called JoystickState
01:36:33termeryou create some shared memory that contains a JoystickState object
01:36:46termerthen in your joystick input thread, you read from your joystick and modify JoystickState accordingly
01:36:58FromDiscord<sOkam!> (edit) "project," => "project without any specific pointers,"
01:37:00termerother threads at their leisure can read from the shared JoystickState object
01:37:13FromDiscord<jtv> Well the thing is that I am here and answer questions, you have no line to John Carmack.
01:37:31termersomething tells me John Carmack isn't interested in working in Nim
01:37:45FromDiscord<jtv> I'm not going to take initiative to help you learn, but if you take that initiative, I would support you.
01:37:52madpropsa cacodemon told me
01:38:01FromDiscord<michaelb.eth> In reply to @termer "something tells me John": hey, he got very into Racket at some point, so maybe he could be 🙂
01:38:08FromDiscord<sOkam!> @jtv yes, that's why i mentioned im happy to read it. my point was about me being stupidly lost in unknown C projects, and his stuff already consumes the little energy I can spend a day in pure C weirdness
01:38:32termerso if you're working in C, why are you here
01:38:34termerare you wanting to work in Nim
01:38:35FromDiscord<sOkam!> so if anything is relevant, just let me know where it is and will go there. but figuring out navigation will be out of my league
01:38:38FromDiscord<jtv> You will find that I invested a lot of time in documenting; there's a lot of work there meant to be instructive, not just useful.
01:38:46FromDiscord<jtv> For him it's a stepping stone to getting lower level
01:38:57termerfair enough I suppose
01:38:57FromDiscord<sOkam!> In reply to @termer "so if you're working": im not. i learn in C in quake engines, and code in Nim
01:39:06termerI find C to be a pain in the ass when working outside of embedded hardware
01:39:20FromDiscord<sOkam!> it is a pain in the ass to do anything, basically
01:39:35termerUnix wizards, I kneel
01:39:47FromDiscord<sOkam!> nim spoils us, though. this lang is just too good
01:40:56FromDiscord<michaelb.eth> if you think and type really, really fast and have an expert setup and a huge mental space for all the ins and outs of the language re: program correctness, I'm sure C is fine for many, many things...↵↵but that's not me for sure, and not a lot of people
01:40:58termerexcept when working in threads lol
01:40:59termerand async
01:41:04termermostly threads + async
01:42:09FromDiscord<sOkam!> 🙈
01:42:13termer90% of the stuff I do with Nim is async + threading so it gets a little tiresome lol
01:42:18FromDiscord<jtv> I hate the async model in any language. I think it's an attempt to abstract something inherently hard, which is noble, but in a way that fails to be clear and easy enough semantically. That's one place where the Go model is better.
01:42:26termernode.js async is super great
01:42:31termercause there's only one thread lol
01:42:52FromDiscord<michaelb.eth> In reply to @termer "cause there's only one": not anymore! haha
01:43:01termeryou *can* spawn more threads but nobody does
01:43:02FromDiscord<michaelb.eth> well, if you're in Node.js or similar runtime
01:43:15termerI've used a worker thread before in Node for cryptography
01:43:16termerthat's it
01:43:17FromDiscord<michaelb.eth> with the more recent APIs they do
01:43:20FromDiscord<jtv> Well, that still to me is not a great way to deal with things. Abusing iterators leads to confusing semantics for most people
01:43:34termerfix your stack traces and you're golden
01:43:39termerI want everything to be async by default
01:43:46FromDiscord<michaelb.eth> concurrency is a difficult problem, always will be
01:44:02FromDiscord<sOkam!> In reply to @jtv "I hate the async": what does Go do instead? 🤔
01:44:04FromDiscord<michaelb.eth> because you have to build a strong mental model around what the lang/computer is doing
01:44:08termerGo does channels everywhere
01:44:16termerI didn't like Go when I tried it
01:44:36termermichaelb.eth Yeah lol I don't hate it only cause I've been doing it for so long
01:44:44FromDiscord<jtv> Yes, and w/ async now that extends to iterators too, where people already aren't comfortable
01:44:49termerbeen knee-deep in async for at least 5 years
01:44:51FromDiscord<jtv> Oh, I don't like Go, but that's one place where it shines
01:45:03termercome on, iterators are just generator functions with yields and stuff
01:45:05termerit's not that bad
01:45:08FromDiscord<michaelb.eth> AsyncIterable and IxJS are pretty nice, fwiw
01:45:15FromDiscord<michaelb.eth> and underappreciated still
01:45:26termerWaiting for nim asyncstreams to become stable lol
01:45:38termerI was shitting myself trying to use it in one of my projects with asynchttpserver's body
01:45:51termerthat's mostly asynchttpserver's fault
01:45:55termerwhat a horrible HTTP implementation
01:46:47FromDiscord<jtv> I have, at various times in my 30+ years in the industry, taught programming languages and compilers at the uni level at a well known school, and I can say that a lot of smart people don't really get how iterators actually work.
01:47:18FromDiscord<jtv> They're easy to use if you don't have to know that's how items() is implemented
01:47:28FromDiscord<michaelb.eth> next/done, yield, why so complicated?
01:47:28termerI don't know how they work under the hood really, I just know they yield and then the next call basically continues in a loop-type fashion
01:47:30FromDiscord<jtv> But they don't want to even write their own iterators
01:47:43termerIt's not that hard to understand if you accept that it's weird to begin with
01:47:48termerbut programming is weird to begin with
01:48:03termeryou just learn different parts of it and develop different mental models
01:48:37termerJust don't do what .NET did and make a getter that looks like a field on a future implementation that actually blocks the thread until the result is ready
01:48:38FromDiscord<jtv> Then when you go to the async model, people a) often don't understand that's how they're implemented which leads to huge confusion and a lot of thrashing and b) when they do learn, still get it wrong because it's not clear to them what's the iterator, etc.
01:48:44FromDiscord<jtv> Because they're used unintuitively
01:49:07termerjtv lol at work people have 0 idea how async works
01:49:17termerthey just slap "async" onto their function and use async APIs along with blocking ones
01:49:35termerit's so pervasive that I don't even bother trying to fix it anymore
01:49:47madpropsconcurrency in crystal seems confusing
01:49:55madpropschannels and that
01:49:55FromDiscord<jtv> Right
01:50:30madpropsseems like a spaghetti code thing
01:50:39madpropslike old-school gotos
01:51:01termeroveruse of channels are way worse than await
01:51:05FromDiscord<sOkam!> @jtv what part of that project should i even open first, to understand the underlying concepts of how idtech4 multithreading works?↵what i meant before is that i don't even know how to navigate the repo. i click on folders and im just lost because i don't understand a word
01:51:15FromDiscord<jtv> The documentation
01:51:32FromDiscord<sOkam!> so saying something like "here, look at this function or this file" would be much appreciated, and that's what i was trying to mean
01:51:35FromDiscord<jtv> Then it'll explain where to start in the code, and those parts are very well commented
01:51:47FromDiscord<jtv> It walks through all of the ins and outs
01:52:04FromDiscord<sOkam!> but are all those things needed to understand the model of id4?
01:52:23FromDiscord<sOkam!> like, there is a crap ton of content out there about everything. how can i filter if i don't understand a word about the concepts
01:52:38FromDiscord<michaelb.eth> sent a long message, see http://ix.io/4miK
01:53:24FromDiscord<michaelb.eth> Harel invented statecharts to help EEs and programmers working on fighter jets, who were drowning in concurrency bugs
01:53:44termerI'm eventually gonna have to write an async runtime for nim for use with microcontrollers
01:53:51termercause the current one uses heap a lot
01:54:05termerFutures are allocated on the heap and that can use a lot of memory
01:54:16termeralso not use exceptions
01:54:22FromDiscord<michaelb.eth> it was a visual formalism at first, for whiteboarding and documenting; only a few years later he and some colleagues created a company around it for compiling serialized statecharts into C
01:55:25FromDiscord<jtv> Cool will check it out
01:57:03FromDiscord<michaelb.eth> the original paper from '86 is here
01:57:47FromDiscord<michaelb.eth> https://www.wisdom.weizmann.ac.il/~harel/SCANNED.PAPERS/Statecharts.pdf
01:59:00FromDiscord<jtv> Even better, thanks
01:59:03FromDiscord<michaelb.eth> various implementations for turning statecharts into executable code have been in use in niche programming corners for decades, unfortunately there's not a whole lot of open source libs dedicated to that, though there seems to be renewed interest
01:59:37FromDiscord<jtv> It's really all about what abstractions can provide the most value w/ the least pain 🙂
02:00:19FromDiscord<michaelb.eth> (edit) "various implementations for turning ... statecharts" added "(serialized)"
02:53:51*crem1 quit (Ping timeout: 265 seconds)
03:13:20FromDiscord<voidwalker> What's your favourite config file (.ini-like) parsing lib ? I tried to use parsecfg form stdlib but it considers `,` as a new entry separator :\
03:20:13FromDiscord<Elegantbeef> I do like toml and have used https://github.com/status-im/nim-toml-serialization
03:20:24FromDiscord<Elegantbeef> But it lacks user defined parsing hooks so that's a bit of a shame
03:20:25FromDiscord<Elegantbeef> Atleast i think it does
03:21:28FromDiscord<Elegantbeef> perhaps one can with `readValue`
03:55:30FromDiscord<voidwalker> https://github.com/joncampbell123/dosbox-x/blob/master/dosbox-x.reference.conf - this is what I want to parse
03:56:11FromDiscord<voidwalker> `priority = higher,normal` this is the troublesome line, all else looks tame
04:01:02FromDiscord<voidwalker> It's not enclosed by square brackets like toml seems to want
04:01:32FromDiscord<Elegantbeef> Yea that's not a toml compliant file
04:01:48FromDiscord<Elegantbeef> I thought you were just generally asking for a ini like parser
04:02:01FromDiscord<Elegantbeef> ini/conf is generally spec-less and down to the implementer
04:03:57FromDiscord<Rika> I think it’s strange that Nim’s configuration parser would parse that separately like you say though
04:04:24FromDiscord<Rika> Since the docs mention that inline comments are optionally supported because otherwise they can’t use # or ; for values
04:04:39*arkurious quit (Quit: Leaving)
04:24:04*Guest43 joined #nim
04:25:09*Guest43 quit (Client Quit)
04:26:36FromDiscord<voidwalker> but `,` is not a comment char ?
04:27:24FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj6
04:27:44FromDiscord<voidwalker> I think values have to be made of those chars ?
04:28:06FromDiscord<Rika> In reply to @voidwalker "but `,` is not": That’s not my point
04:28:27FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj7
04:28:35FromDiscord<Rika> My point is that why would they use , for something if they had the thought to make sure inline comments are toggleable
04:28:41FromDiscord<voidwalker> sent a code paste, see https://paste.rs/q96
04:28:46FromDiscord<voidwalker> (edit)
04:29:32FromDiscord<voidwalker> not sure what you mean
04:30:03FromDiscord<voidwalker> the `,` doesn't appear to be specifically used anywhere in the code, as I see. It's just that it skips a beat i f it encounters a char not of that set above, I think
04:34:12FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj9
04:34:36FromDiscord<voidwalker> for which: ` # empty string value is not allowed =`
04:34:57FromDiscord<voidwalker> so parsecfg is no good :\
04:46:02FromDiscord<Girvo> Can ref objects have destructors?
04:50:14FromDiscord<Elegantbeef> Nope but distincts can
04:50:58FromDiscord<Girvo> 👍
04:51:04FromDiscord<Girvo> Tbh this didn't need to be a ref object anyway so
04:51:05FromDiscord<Elegantbeef> Though you can also make a destructor for the internal object
04:52:31FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mjc
04:52:35FromDiscord<Girvo> Oh interesting
04:56:21FromDiscord<Elegantbeef> From now on i'll ignore you if you say `ref` in any sentence↵(@Girvo)
04:57:09FromDiscord<Girvo> This was the literal last usage left of it anyway lol, it's gone now
06:56:00FromDiscord<ringabout> Can Nim amd64 be used with msvc 32 bit?
07:20:39*ltriant quit (Ping timeout: 256 seconds)
07:26:05FromDiscord<sOkam!> sent a long message, see http://ix.io/4mjy
07:33:43*PMunch joined #nim
07:49:51*dv^_^ quit (Quit: Ping timeout (120 seconds))
07:50:17*dv^_^ joined #nim
08:15:11FromDiscord<sOkam!> I have a file called `yaml.nim` where I store all my nimyaml functionality↵But the file needs to `import yaml`, since that's the name of the nimyaml library import↵is there a way to have my file called `yaml.nim` without complaining of importing itself?
08:16:48Amun-Rais the yaml lib in your project path? if no, not really
08:19:03FromDiscord<Elegantbeef> `import pkg/yaml as nimyaml`
08:19:14FromDiscord<Elegantbeef> Then you can do `import myProg/yaml`
08:21:28PMunchRight! I seemed to remember there was a prefix similar to `std` for external packages
08:22:14FromDiscord<Elegantbeef> Naming a module after a file format has to be up there for silly names though
08:26:59PMunchWell I think it makes sense for the nimyaml package
08:27:17PMunchBut just calling a part of your program for "yaml" is a bit silly
08:29:37FromDiscord<Rika> In reply to @PMunch "Well I think it": It kinda squats the name for any other implementations
08:30:49FromDiscord<Elegantbeef> You cannot even distinguish if you have `nimyaml` and `myotheryaml` from nimble
08:31:28FromDiscord<Elegantbeef> I'd also say it's just the wrong way to do top level packages, the toplevel module should be the package name
08:32:47FromDiscord<sOkam!> handy, ty!
08:32:51FromDiscord<sOkam!> didn't remember that either
08:34:27PMunchFair enough, but think of it the other way around. When I'm reading my imports I want to easily be able to tell what is imported "yaml", much like "json" tells me that this module works with the "yaml" format. I'm not a huge fan of everything just being "nim*" e.g. "nimyaml" because I'm already writing in Nim so that's not any new information, so people (myself included) come up with strange names. I'm not sure "import futhark" really tells you anything for
08:34:27PMunchexample.
08:35:16FromDiscord<Elegantbeef> Sure but we could have `import yamler` or `import nimyaml/yaml` 😄
08:35:24FromDiscord<Elegantbeef> Something that's slightly more unique and way less likely to cause import issues
08:39:47FromDiscord<Elegantbeef> it doesnt matter that much since it's highly unlikely that you'd have two competing yaml libraries in your nimble file
08:39:48FromDiscord<Elegantbeef> But hey it's possible
08:41:40Amun-RaSystem64 yesterday was playing with compiling to wasm so I made my first wasm port of my wip project too: https://retro.rocks/tmp/rn/
08:42:31FromDiscord<Elegantbeef> Nice, I still need a small program to toy with my wasm interop
08:42:59Amun-Ranormally I use dlsym for sdl2, emcc requires static calls, I have to make a macro that will generate dlsym/importc calls depending on the target
08:43:36FromDiscord<Elegantbeef> Nico has a config that does it without a macro
08:43:44FromDiscord<Elegantbeef> Since you can use `dynLibOverride`
08:43:49Amun-Rahmm, I have to look it up
08:43:59FromDiscord<Elegantbeef> https://github.com/ftsf/nico/blob/main/exampleApp/config.nims
08:44:26Amun-Raah, I don't think dynLibOverride will work in my case
08:44:34FromDiscord<Elegantbeef> `dynlib` for all of it's faults can be overridden which means with the right flags you can statically link
08:44:44Amun-RaI do not use dynlib pragma
08:44:58FromDiscord<Elegantbeef> So silly
08:45:34Amun-RaI don't rely on a spacific lib binding that way
08:45:54FromDiscord<Elegantbeef> What?
08:48:20*azimut_ quit (Ping timeout: 255 seconds)
08:48:42Amun-RaElegantbeef: https://pastebin.com/AKBb9WC9
08:49:06Amun-RaElegantbeef: I have bindings for SDL1.2, SDL2, XCB, X11, GTK2, GTK3, and GTK4
08:49:31Amun-Raat least one of those libraries have to be installed in the system and I don't really care which one
08:49:54FromDiscord<Elegantbeef> Ah
08:50:52Amun-RaElegantbeef: the con is I have to implement different code for static calls: https://play.nim-lang.org/#ix=4mjP
08:51:09Amun-Ras/that/then/
08:51:16FromDiscord<Elegantbeef> Yea i get it
08:52:23Amun-RaI wrote a lib ( https://github.com/amnr/dynlibutils ) some time ago for automatic dlsym, I have to think of something similar for statics
08:54:27FromDiscord<Elegantbeef> Yea makes sense
08:55:50Amun-Raright now I do the conversion via python script
08:57:27FromDiscord<Elegantbeef> Not ideal but you could do something like `--define:dynlibutilsStatic:"libsdl2, libSomeOtherLib"` then take a `static string` for `loadLibrary` if it matches any library in your list emit a static imported procedure
09:00:05Amun-RaI have an object with proc typed slots, I think I'll traverse such an object and generate global importc procs, than write another macro that will traverse all the members and assign these procs to the object, the same way I do with symaddr
09:00:57FromDiscord<sOkam!> if I say `-d:myFlag:10` at compile time, how can I the access that value in code?
09:01:13Amun-Ras0kam! const myflag {.intdefine.} = 666
09:01:37Amun-Ramyflag == 10 when -d=myFlag=10
09:02:19FromDiscord<sOkam!> so if i usually say `when defined blabla:` i can now say `when defined blabla == 10`?
09:02:33Amun-Raand 666 is the default value when there's nothing passed to the compiler
09:02:44Amun-Rawhen defined(blabla) and blabla == 10
09:02:50Amun-Raor use intdefine
09:03:01FromDiscord<sOkam!> oh, srsly? damn that's exactly what i needed. that default fallback value 👀
09:03:26Amun-Ras0kam!: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compileminustime-define-pragmas
09:03:50FromDiscord<sOkam!> is it possible to staticread from a yaml file in some way, to populate that data?
09:04:05FromDiscord<Elegantbeef> if nimyaml supports it
09:04:06FromDiscord<tweg> what is getFrame? i get an error saying: `Error: system module needs: getFrame`
09:04:24FromDiscord<Elegantbeef> likely a procedure related to stack tracing
09:04:55FromDiscord<Elegantbeef> I assume you're doing `--os:standalone`?
09:04:59FromDiscord<tweg> yea
09:05:06FromDiscord<Elegantbeef> `--os:any`
09:05:52FromDiscord<tweg> ah ty, any docs on the memory manager thing
09:06:03FromDiscord<tweg> like how thats ported?
09:06:32FromDiscord<Elegantbeef> Atleast i think that's preferred
09:06:37FromDiscord<Elegantbeef> No clue what you mean I've never done that low level stuff
09:06:52FromDiscord<Elegantbeef> If you use arc/orc it should not require anything fancy but to have `-d:useMalloc` and have a malloc to use
09:07:15FromDiscord<tweg> `system/osalloc.nim(218, 10) Error: Port memory manager to your platform` i get this
09:07:36FromDiscord<Elegantbeef> yea use `-d:useMalloc`
09:07:40Amun-Ra^ this
09:07:41FromDiscord<tweg> ah
09:07:45FromDiscord<Elegantbeef> With `--mm:arc` or `--mm:orc`
09:07:50FromDiscord<flajr> Hello, this is probably some zero ground, but can I call `nim compile` without project name? Basically, can I somehow add project name to `config.nims`? So that I `cd` to project working dir and than just call `nim compile`.
09:07:56FromDiscord<Elegantbeef> ^This
09:08:03Amun-Raalso you'll prolly need a few patchFiles
09:08:18FromDiscord<Elegantbeef> you can make an nimscript file with a command
09:08:39FromDiscord<sOkam!> how does one set this option? is it from the compiler confuration, or how is it defined? https://media.discordapp.net/attachments/371759389889003532/1068457497314201640/image.png
09:08:56FromDiscord<Elegantbeef> https://nim-lang.org/docs/nims.html#nimscript-as-a-build-tool
09:09:03FromDiscord<sOkam!> i assume -opt:speed does gcOptimizeSpeed?
09:09:06FromDiscord<Elegantbeef> It only matters for refc so disregard it
09:09:14FromDiscord<sOkam!> oh, nvm then
09:09:38FromDiscord<Elegantbeef> Cannot really tune Arc/Orc 😄
09:13:38FromDiscord<sOkam!> im honestly curious how arc vs orc vs none would compare in numbers 🤔↵I bet they must be really really close
09:14:18FromDiscord<Elegantbeef> Oddly in some instances arc was faster than none
09:14:29FromDiscord<sOkam!> rly? damn
09:14:39FromDiscord<Elegantbeef> You have like 4k+fps why do you care
09:15:04FromDiscord<flajr> sent a code paste, see https://play.nim-lang.org/#ix=4mjT
09:15:21FromDiscord<sOkam!> now. wait until deterministic physics and deferred rendering and VCT rendering are all working at the same time. 10fps guaranteed 😄
09:15:27FromDiscord<Elegantbeef> You should be able to do `nim build` now
09:17:17FromDiscord<sOkam!> whats the benefit of using nimble, instead of using nimscript as a build tool?
09:17:48*Amun-Ra uses Makefile
09:18:12Amun-Ra…with fat config.nims
09:18:14FromDiscord<flajr> Hmmm: `Error: invalid command: c projectName`
09:18:41FromDiscord<sOkam!> In reply to @Amun-Ra "…with fat config.nims": isn't a custom nimscript the same thing as a nimble file?
09:19:13Amun-RasOkam!: more less, I use it to define a few targets
09:19:42FromDiscord<sOkam!> just struggling to see the unique benefits of nimble files
09:20:12FromDiscord<sOkam!> i bet there must be some, but i feel like im missing which they are
09:20:36Amun-RasOkam!: small excerpt: https://play.nim-lang.org/#ix=4mjV
09:23:42FromDiscord<sOkam!> @Amun-Ra and you cannot do that in a not-nimble file?
09:24:10Amun-RasOkam!: it's config.nims, it works whether I compile with nimble or nim
09:24:52FromDiscord<sOkam!> i see. but what i don't grasp is what would you miss if you didn't use nimble
09:26:41Amun-RaI have nimble just bc it's a standard but I find writing nimble task, hmm… cumbersome; I use nim c (or nimble) with -d=target_switch_defined_in_config_nims
09:27:46PMunchsOkam, the biggest benefit is probably that Nimble is actually a package manager
09:28:12Amun-Raah, yes; my apps are usually self contained; I forgot about that feature
09:28:33FromDiscord<sOkam!> what does that mean in practice? what would you miss if you didn't have the package manager feature set?
09:29:17PMunchSo you can put requirements in there and it will pull them automatically. You can pin a dependency to a certain version and it will update it if it's out of date, or hold back a version and Nimble will ensure it only links to that correct version.
09:29:25Amun-Rayou just add "require someexternalpackage" or "require https://github.com/user/project/" and that's it
09:29:53FromDiscord<sOkam!> ah i see. makes sense
09:29:55PMunchThe `nimble task` feature is more just a side-effect of it using NimScript as a configuration language, a free feature if you'd like
09:29:57FromDiscord<ElegantBeef> Shame the bridge died
09:30:06FromDiscord<Elegantbeef> manually types `nim c -r ./file.nim`
09:30:07FromDiscord<Elegantbeef> The benefit is that nimble is dumb and validates dependencies every time you use a nimble command
09:30:08FromDiscord<Elegantbeef> So it's slow as balls ime
09:30:08PMunchThe bridge died?
09:30:11FromDiscord<ElegantBeef> Oh there it is
09:30:28FromDiscord<ElegantBeef> Yea the one that makes me the cooler dog
09:30:52PMunchAh, well Nimble certainly has issues, but they asked about the benefits :P
09:30:53Amun-Ra;P
09:31:07Amun-RaElegantBeef: I see both beefs
09:31:13FromDiscord<sOkam!> yeah, the validation can be super slow 😔
09:31:45FromDiscord<sOkam!> can you import tasks from separate files into .nimble file from a separate file, btw?
09:31:58FromDiscord<ElegantBeef> Probably
09:32:05PMunchWell since it's a very distributed system where packages.json only serves the purpose of discovery it means you need to pull every git repo every time to check the nimble file for the version
09:32:13FromDiscord<Elegantbeef> But amun you dont see both profile pictures
09:32:22Amun-Raoh
09:32:35PMunchAnd since it's NimScript it might not even be enough to only grab the .nimble file
09:32:41Amun-Rathat's bc I can see no pictures ;)
09:32:56FromDiscord<ElegantBeef> Yea but the pictures are my dogs, so you're missing out on free dog images
09:32:59Amun-RaI have discord account running somewhere in my tabs tho
09:33:05PMunchProfile pictures?
09:33:05FromDiscord<ElegantBeef> Imagine passing up on free dog images
09:33:08Amun-Ra:P
09:33:13*Amun-Ra is more of a cat person ;)
09:33:27FromDiscord<ElegantBeef> Aw you're drain bamaged
09:33:31Amun-Ra:P
09:33:32FromDiscord<sOkam!> cats are best
09:33:40PMunch~---O
09:33:45PMunch ^ ^
09:33:49Amun-RaElegantBeef: but I can appreciate having dogs… I just travel too much
09:33:51PMunchThere, an image of a dog
09:34:01PMunchKinda messed up the legs..
09:34:10FromDiscord<ElegantBeef> It just looks like a sperm pmunch
09:34:11Amun-Ra…and one don't have to walk out the cat <:
09:34:26PMunch@Elegantbeef, yeah..
09:34:27FromDiscord<sOkam!> it looks like a dog collar. actually fitting 😄
09:34:28FromDiscord<ElegantBeef> Eh i like walking my dogs, but it's too cold + too much snow for them
09:34:47FromDiscord<ElegantBeef> They're quite small rats
09:34:49FromDiscord<xoich (xoich)> hello, is there a better way to delete the last element of a seq than seq.delete(high(seq)..low(seq))?
09:35:07FromDiscord<ElegantBeef> `seq.setlen(seq.high)`
09:35:13FromDiscord<ElegantBeef> or `discard seq.pop()`
09:35:48FromDiscord<xoich (xoich)> thanks @\_discord\_145405730571288577\:t2bot.io
09:35:49FromDiscord<ElegantBeef> TIL delete can take a slice
09:36:10FromDiscord<Elegantbeef> Silly gitter users
09:36:29FromDiscord<Elegantbeef> Just use matrix already
09:37:17*azimut joined #nim
09:38:51PMunch@Elegantbeef, what dogs do you have?
09:39:12FromDiscord<Elegantbeef> A jack russell terrier, and a westie pug mix
09:39:17PMunchI mean technically they are using Matrix :P
09:39:28FromDiscord<Elegantbeef> In the most round about way
09:39:50FromDiscord<Elegantbeef> It still does cursed things like sending codeblocks as html
09:41:39FromDiscord<Elegantbeef> To quickly spam pictures of them
09:41:43FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1068465819845132288/image.png
09:42:18FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1068465966389923991/image.png
09:42:25FromDiscord<Elegantbeef> Now uhh that nim code eh
09:43:02Amun-Ranice
09:44:51FromDiscord<flajr> sent a code paste, see https://play.nim-lang.org/#ix=4mk1
09:45:11FromDiscord<Elegantbeef> Congrats
09:48:42*azimut quit (Quit: ZNC - https://znc.in)
09:49:24*azimut joined #nim
09:56:22FromDiscord<Phil> In reply to @flajr "Thanks everyone, this is": https://stackoverflow.com/questions/73393568/how-to-dynamically-link-your-nim-application-against-musl↵Just in case you want to see another approach going at it
09:57:39FromDiscord<Phil> Generally nimble tasks are pretty slick though, I agree. I do typically put the flags inside of the task though ^^
09:58:31FromDiscord<flajr> Thank you for reference!
10:22:18FromDiscord<sOkam!> what does setCommand do?↵don't tell me i've been using `exec "nimble build"` like a total noob for no actual reason 👀
10:27:51FromDiscord<Phil> Sets the Nim command that should be continued with after this Nimscript has finished.
10:28:23FromDiscord<sOkam!> ah kk
10:28:49FromDiscord<Phil> So basically, you set all the flags in the nimble task (which is basically a script file contained in your nimble file), then the nimble task ends and it executes "setCommand", which will turn into `nimble <whatever you provided setCommand>`
10:29:43Amun-Racan you add custom post-build actions too?
10:30:11FromDiscord<Phil> Like, compile then do stuff?
10:30:14Amun-Rayes
10:30:31FromDiscord<Phil> I mean, you can define a second task that executes the first and then does stuff
10:30:38Amun-Raah, right
10:31:13FromDiscord<Phil> That's how I build my docker-images for my webserver:↵I compile the musl-linked-binary first, then put it into an image, then save that image into a tar file and upload it to my server
10:31:30FromDiscord<Phil> All of these are seperate tasks that I execute in one larger "summary" task
10:33:51FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mkm
10:35:01Amun-Raah, so execs act like task chain
10:35:51FromDiscord<Phil> execs are basically just "execute this in a shell and explode if it fails"
10:36:22FromDiscord<Phil> I basically replaced any and all shell scripts I have with nimble tasks
10:36:56FromDiscord<Phil> The one notable exception being stuff I explicitly didn't want to be part of the repo, like downloading the database etc.
10:37:21FromDiscord<Phil> (edit) "downloading" => "scripts for downloading/replacing"
10:39:27PMunch@Elegantbeef, those are some nice looking dogs
10:40:54FromDiscord<hotdog> sent a code paste, see https://paste.rs/ew1
10:41:11FromDiscord<hotdog> It is slightly better as the compiler will catch missing tasks/changed names etc
10:41:52FromDiscord<hotdog> IIRC it’s e.g enabledevTask() etc
10:46:34PMunch@Elegantbeef, mind having a look at this? I thought openarray[byte] would work for strings after your forum comment? https://www.reddit.com/r/nim/comments/10m0muc/enkodo_a_small_easy_async_encryption_and/j60nz4w/
11:13:36*jmdaemon quit (Ping timeout: 248 seconds)
11:18:44FromDiscord<Ntsékees> Mmh, compiling a small test Nim script importing the `nre` module into WASM using Emscripten, I get the following error on the web console:↵> Could not load dynamic lib: libpcre.so.3
11:19:20FromDiscord<Phil> JS backend? @hotdog
11:19:21FromDiscord<Ntsékees> I suspect that, in spite of `nre` being successfully compiled, its dependency `libpcre.so` is not?
11:19:36FromDiscord<Phil> libpcre.so is a compiled library
11:19:44FromDiscord<Phil> That is a C library to be precise
11:20:01FromDiscord<Phil> What it's complaining about is that it either can't find or can't load that library
11:20:34FromDiscord<Phil> I assume you can compile this without the JS backend, so I assume you have the package that contains that file installed
11:21:06FromDiscord<Phil> Which means that you have the file, but the compilation process can't find it to give it to the nre lib to "link" against
11:21:15FromDiscord<Ntsékees> I've compiled using emcripted, a clang-like backend but that compiles to WASM (through C)
11:21:21FromDiscord<Ntsékees> (edit) "emcripted," => "emcripten,"
11:21:59FromDiscord<Phil> I haven't used either of those backends, I just use gcc to compile straight to native binary, so I have no experience elsewhere ^^'
11:35:30Amun-Raemscripten can compile to pure js too
11:37:30Amun-RaI mean not exactly pure, asm.js
11:49:26FromDiscord<Ntsékees> I'll have to try out JSRE instead of PCRE, hopefully it's not excessively different in behavior…
11:53:14Amun-RaI plan to port my viewer to js target, one of things I'll need to rewrite is u64 handling
11:54:22*arkurious joined #nim
12:01:37FromDiscord<pmp-p> In reply to @Ntsékees "I've compiled using emcripten,": here too maybe a wasm channel would be usefull
12:34:14*azimut quit (Ping timeout: 255 seconds)
13:28:27FromDiscord<Hourglass [She/Her]> Wouldn't #webdev count?
13:31:32Amun-Rait may be too hermetic for #webdev
13:45:30*ltriant joined #nim
13:50:24*ltriant quit (Ping timeout: 260 seconds)
14:12:26FromDiscord<Phil> Eh, I'd count it. It's ultimately still about web-technology, even if used in a different context
14:12:45FromDiscord<Phil> ~~Still doesn't mean I can help any there though~~
14:29:45FromDiscord<auxym> sent a code paste, see https://paste.rs/byT
14:30:33FromDiscord<Phil> I... think? I haven't tried tbh
14:31:21FromDiscord<auxym> I'll have to try, I've been using tasks defined in config.nims with selfExec, but that breaks the extra args thing
14:32:45FromDiscord<Phil> Just tried, the answer for that particular task appears to be no.↵Did it by throwing out the --define:ssl flag and then ran `nimble --define:ssl alpine`
14:33:36FromDiscord<auxym> ah, too bad
14:44:10FromDiscord<Phil> You can do it though, it's jut not "automagically" in, you do have access to the flags given to a task
14:54:09*jmdaemon joined #nim
14:59:14*jmdaemon quit (Ping timeout: 260 seconds)
15:04:28*PMunch quit (Quit: Leaving)
15:12:39FromDiscord<pmp-p> In reply to @Isofruit "Eh, I'd count it.": Wasm is not - only - a web technology, it's more of a cpu , especially when used in Wasi contexts.
15:13:00FromDiscord<pmp-p> eg https://github.com/wasmerio/kernel-wasm
15:34:37*jmdaemon joined #nim
15:52:40*jmdaemon quit (Ping timeout: 260 seconds)
16:11:12FromDiscord<spooky> hi, how i can copy an file with nim ?
16:25:16FromDiscord<rakgew> hi @spooky\: there would be `os.copyFile` in↵https://nim-lang.org/docs/os.html#copyFile%2Cstring%2Cstring
16:25:37FromDiscord<spooky> thank
16:26:12*piertoni joined #nim
16:27:53piertonihi to all! I want to retrieve environment variables of the running process to change the path and launch a subprocess with only path changed. Cannot find something to enumerate or get current environment
16:36:12piertoniSeems I have found: `getEnv` and `putEnv` and also `envPairs`
16:41:22FromDiscord<System64 ~ Flandre Scarlet> About NimScript, is it possible to copy all files in a directory?
17:01:38piertoniI Guess you can use `proc copyDir(source, dest: string)` for that
17:01:59FromDiscord<System64 ~ Flandre Scarlet> In reply to @piertoni "I Guess you can": Gotta try
17:03:16piertoniI am not sure (never using nimscript) but Is part of nim std/os, so probably is implemented also in nimscript
17:03:29FromDiscord<System64 ~ Flandre Scarlet> Thanks! It works!
17:03:57piertonicheers! :smile
17:04:52FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mmn
17:07:49piertoniwhat you mean by "execute both at once"?
17:08:19FromDiscord<System64 ~ Flandre Scarlet> I want to compile for Windows and Emscripten by defining the 2 flags
17:11:13FromDiscord<gibson> is `--os:any -d:useMalloc` supposed to allow creating cross-compiling C code? I can't get the resulting C code to build for `_MSC_VER` (windows?) systems.
17:12:38piertoniScarlet you want to compile for two platforms at once? Like launching the process twice? Don't know...
17:13:21FromDiscord<System64 ~ Flandre Scarlet> In reply to @piertoni "Scarlet you want to": yeah, compiling for Windows, then for Emscripten
17:14:43piertoniStupid solution that is ugly and maybe not working, but I guess you should spawn the compilation process twice, like calling a subProcess on "nim c mysource.nim" with wanted flags
17:15:47FromDiscord<System64 ~ Flandre Scarlet> Or good old batchfile
17:16:47piertoniif nimscript allows subprocess you could write like:
17:16:48piertoni  execShellCmd("nim c mysource.nim --flags for win")
17:16:48piertoni  execShellCmd("nim c mysource.nim --flags for emscripten")
17:17:45piertoniReading documentation is just "exec" like:
17:17:46piertoniexec "git clone https://github.com/nim-lang/nimble.git nimble"
17:18:04FromDiscord<System64 ~ Flandre Scarlet> Oh alright
17:18:27piertonicheck documentation at https://nim-lang.org/docs/nims.html
17:19:43piertoniparticularly the part `Standalone NimScript`
17:20:14*piertoni quit (Quit: Client closed)
17:21:57FromDiscord<System64 ~ Flandre Scarlet> This is interesting
17:22:39arkanoida lot of forking of status-nim repos from nim-lang user is happening
17:26:53FromDiscord<gibson> In reply to @gibson "is `--os:any -d:useMalloc` supposed": For instance, the docs say this, which makes me think producing C code on linux should compile on Windows:↵> The --os:any target makes sure Nim does not depend on any specific operating system primitives. Your platform should support only some basic ANSI C library stdlib and stdio functions which should be available on almost any platform.
17:29:31FromDiscord<gibson> If I read that carefully, it's only for Nim code, not the generated C.
17:52:22FromDiscord<auxym> @System64 ~ Flandre Scarlet check out `selfExec` in nimscript
17:52:28FromDiscord<@thatrandomperson5-6310e3b26da03> Nim just cannot find libcrypto.so, i tried having a —path arg directly to the file (yes i checked that it exisits) it is also directly in my path. Please help me fix this
17:53:00FromDiscord<System64 ~ Flandre Scarlet> In reply to @piertoni "execShellCmd("nim c mysource.nim --flags": execShellCmd doesn't work
17:53:03FromDiscord<auxym> In reply to @gibson "For instance, the docs": os:any is mostly used for bare-metal targets like embedded and OS dev
17:53:48FromDiscord<auxym> In reply to @System64 "execShellCmd doesn't work": https://nim-lang.org/docs/nimscript.html#selfExec%2Cstring
17:54:12FromDiscord<gibson> In reply to @auxym "os:any is mostly used": Seems perfect for making something so vanilla that it's cross-platform?
17:56:23FromDiscord<auxym> maybe, not sure. In any case you would still have to specify the C compiler you want to use for the platform, like `amd64.any.gcc.exe = mingw64-gcc`, or something like that for windows, in your nim.cfg/config.nims
18:09:16*azimut joined #nim
18:28:17*crem1 joined #nim
18:40:29*jmdaemon joined #nim
18:41:32FromDiscord<@thatrandomperson5-6310e3b26da03> > Nim just cannot find libcrypto.so, i tried having a —path arg directly to the file (yes i checked that it exisits) it is also directly in my path. Please help me fix this↵Any ideas?
18:43:02*PMunch_ joined #nim
18:44:15termerPMunch_ I saw your video on keyboard firmware in nim
18:44:22termerHave you ever looked at QMK?
18:45:08PMunch_termer, yes I looked at QMK before I started the project
18:45:37*PMunch_ is now known as PMunch
18:46:09PMunchPart of the reason why I started the project was because of how hard and confusing QMK was to configure
18:46:09termerdid you decide it wasn't for you? It piqued my interest since I recently got a programmable keyboard
18:46:54termeraha
18:47:09PMunchI was doing a couple things differently from most other keyboards, most notably a split keyboard with only IO extenders instead of full microcontrollers in each half
18:47:27PMunchBut also the orthogonal layout and the fact that I use Dvorak
18:47:35termeroh yeah it probably would be weird with that
18:47:42PMunchSo it was a lot of stuff I would have to configure and fiddle with
18:48:19PMunchAnd I had wanted to do low level programming of microcontrollers in Nim anyways, so I figured it was just a good a place to start as any
18:48:48termerIt's been a bit since I watched your talk, so I've forgotten some details, but how did you find Nim to be in such a lowlevel env?
18:48:59PMunchTurns out that the end result was not only smaller, but could also deliver really low latency, which was cool
18:49:06termerI've long been interested in using Nim for microcontrollers but haven't dealt with it
18:49:18PMunchHonestly it's pretty much a perfect fit
18:49:28termeryou couldn't use the stdlib, right?
18:50:04PMunchAll low-level programming is fiddly and complicated, but with meta-programming you're able to hide a lot of that fiddly stuff behind 0-cost abstractions
18:50:20termerYeah that's why I was interested in using it for that
18:50:25PMunchSo you get a nice clean API, and basically raw native performance
18:50:35PMunchYou can definitely use the stdlib
18:50:49termerstdlib seems like a minefield of heap allocations
18:51:05termerespecially with exceptions
18:51:25PMunchI did an earlier talk where I ran some samples on an ESP8266, and there I even used a library called zero-functional which aims to give you zero-cost abstractions of functional constructs
18:51:35PMunchIt wasn't written for microcontrollers but ran just fine
18:52:02PMunchTrue, you do have to be careful, and for very small chips it definitely doesn't make sense
18:52:11FromDiscord<Nilts> In reply to @@thatrandomperson5-6310e3b26da03 "> Nim just cannot": any one know why this would happen? (thatrandomperson is my gitter alt)
18:52:21termerSomeone did nim on arduino
18:52:27termerwhich must've been a real pain
18:52:33PMunchI've done that as well :P
18:52:43PMunchSmallest chip I've done is Attiny85
18:52:57termerhow much memory was in that?
18:53:00PMunch6Kb of available program memory, and 512bytes of SRAM
18:53:24termerwow
18:53:32termerthat's even worse than arduino uno
18:53:47PMunchIf I port V-USB to Nim (or bind it) I think I should be able to run my keyboard firmware on it
18:54:10PMunchThe Arduino Uno has heaps and bounds of memory :P
18:54:17termer2kb
18:54:36PMunch32Kb program memory though
18:54:43termeroh yeah that's not as much of an issue
18:54:44PMunchHave you seen this by the way? https://ratel.peterme.net/
18:54:58FromDiscord<huantian> ngl i'm suprised how many keyboard firmwares there are
18:55:01termerthe problem is that the arduino C++ library allocates all strings on the stack
18:55:04termerwhich is hilariously terrible
18:55:05FromDiscord<huantian> like QMK, ZMK, KMK
18:55:07termerso it chomps memory
18:55:15termerlemme see PMunch
18:55:33FromDiscord<@thatrandomperson5-6310e3b26da03> Great. Now im getting undefined symbol after i fixed that↵(@Nilts)
18:55:33PMunchYeah, string stuff will quickly burn through your memory
18:56:01termeryou had to use a macro to do it stack allocated
18:56:07termerwhich made everything messy
18:56:31PMunchtermer, the Nim code works similarly unfortunately
18:56:51PMunchThat p"Hello world" is an example of a string being allocated in the progmem section
18:56:52termerat least I don't have to wrap everything in String() in Nim lol
18:56:59PMunchHaha, true
18:57:02termercan'
18:57:05termert believe they used C++
18:57:10termerwhat a horrible choice, why OOP on a microcontroller
18:57:16termerC isn't that hrad
18:57:17termer*hard
18:57:21PMunchOOP used to rule the world
18:57:58PMunchIt's kind of the same with projects like MicroPython or Espruino
18:58:09PMunchPeople just want to do things the way they are used to
18:58:20termerI'm young enough to where I missed the rise of the OOP craze
18:58:28termerbut I started out writing in Java
18:58:46termerand ever since I got a taste of pure procedural and functional, I never wanted to go back
18:59:03PMunchIn one of my first talks about microcontrollers where I use the ESP8266 I explain that I'm not actually using any of the WiFi features, it was just the only chip I had lying around powerful enough to run MicroPython
18:59:29PMunch@Nilts, what exactly are you trying to do?
18:59:48termerI was going to use C on my Pico but async in C would be a nightmare
19:00:29PMunchHaha, low level C async can be a pain
19:00:49termeryeah, best to do macro stuff for that
19:00:50PMunchBut once you get used to it it's actually not *that* bad
19:01:00termernot insurmountable
19:01:07termerbut still bad
19:01:18termerI'm also not an experienced C programmer and would likely mess something up
19:01:37termerI've only ever written C with hardware interrupts on a microcontroller
19:01:40termernever done async with it
19:01:58FromDiscord<Nilts> In reply to @PMunch "<@910899642236043294>, what exactly are": use std/httpclient
19:02:06termerin any case, for a memory-efficient async impl, you couldn't use asyncdispatch
19:02:10termerthat and it uses the selectors library
19:02:42PMunch@Nilts, isn't that just import and then compile with `-d:ssl`?
19:02:51termerthe famous -d:ssl
19:03:22PMunchtermer, true, I actually wonder how that has been implemented in Nim already for microcontrollers
19:03:33PMunchI think Nesper might have support for it, or the Pico library
19:03:38FromDiscord<Nilts> In reply to @PMunch "<@910899642236043294>, isn't that just": yes, but then i got `couldn't find libcrypto.so` so i used `--passL` and now it is giving me undefined symbol error
19:03:42termernesper?
19:04:01PMunchtermer, ESP32 in Nim: https://github.com/elcritch/nesper
19:04:19FromDiscord<Nilts> (edit) "In reply to @PMunch "<@910899642236043294>, isn't that just": yes, but then i got `couldn't find libcrypto.so` so i used `--passL` and now it is giving me undefined symbol error" => "sent a code paste, see https://play.nim-lang.org/#ix=4mmQ"
19:04:30termersupports asynchttpserver, huh
19:04:52PMunchMy hope is that one day all the Nim libraries for microcontrollers will support a common API (like Ratel) and we can start writing libraries which will work across platforms
19:05:24termerRatel only supports AVR right now, right?
19:05:37termerif it had Pico support that would be awesome, but right now there's only a library that wraps the Pico stdlib
19:05:45termerhttps://github.com/EmbeddedNim/picostdlib
19:05:46FromDiscord<Nilts> In reply to @not logged in "yes, but then i": this is really starting to bug me. why is `std/httpclient` so hard to use?
19:06:09PMunch@Nilts, openssl-1.1.1 is probably your issue
19:06:17PMunchIsn't the current one 3.1 something?
19:06:44PMunchHmm I seem to have 3.0.7, and that works fine
19:07:21FromDiscord<Nilts> In reply to @PMunch "<@910899642236043294>, openssl-1.1.1 is probably": where does it say openssl 1.1.1?
19:07:49FromDiscord<huantian> are you on nix? why are you trying to manually do this
19:07:58PMunch@Nilts, in the message you sent?
19:08:14FromDiscord<Nilts> In reply to @PMunch "<@910899642236043294>, in the message": oh, i see it now
19:08:39PMunchtermer, yes currently it's AVR only
19:08:45FromDiscord<huantian> you should just need `openssl` with `nim` in your build inputs
19:08:48termeraw man
19:08:58FromDiscord<huantian> you don't need to manually pass anything
19:09:16PMunchBut I'm playing around with some other controllers. Actually started implementing it for Raspberry Pi. Figured it would be fun to be able to run the same library code on a microcontroller and a microcomputer
19:09:52FromDiscord<huantian> also I swear that the `nim` derivation already has `openssl` as a `buildInput` so you shouldn't need to do anything
19:10:02termerRPI Pico and normal RPI are very different
19:10:06termerI never liked normal Raspberry Pis
19:10:15PMunch@Nilts, it's actually really easy to use. Not sure what your specific issue is, but it's usually not this hard
19:10:17termermost people who buy them don't do anything with them
19:10:32PMunchI've got one which controls everything in my house :P
19:10:51FromDiscord<Nilts> In reply to @huantian "also I swear that": i'm not using nim derivation. At all
19:10:54PMunchBut I won mine in a competition, so I guess I don't fall in the category of people who bought them :P
19:11:21FromDiscord<Nilts> (edit) "all" => "all, since it is outdated."
19:11:25FromDiscord<huantian> In reply to @not logged in "i'm not using nim": what
19:11:31termerto be fair, I bought my Pico several months ago and haven't gotten around to it
19:11:35termerbut at least I have a purpose for it
19:11:57FromDiscord<huantian> https://media.discordapp.net/attachments/371759389889003532/1068609322747179018/Screenshot_2023-01-27_121140.png
19:12:16PMunchYeah I've got two Picos in a drawer..
19:12:30termerLOL
19:12:41termerso many toys, such little time
19:12:46FromDiscord<huantian> picos are neat might use one for my next keeb
19:13:10FromDiscord<Nilts> In reply to @huantian "": says `1.6.8` for me. Also, the nixos on the machine is very outdated (nim is on `1.4.8`). Probably why i can't get latest openssl
19:13:36FromDiscord<huantian> iirc older nixpkgs version called it `openssl_3`
19:13:50*azimut quit (Ping timeout: 255 seconds)
19:13:59FromDiscord<Nilts> In reply to @huantian "iirc older nixpkgs version": testing that one
19:14:01FromDiscord<huantian> but if you're coding you should probably be getting your packages from nixos unstable
19:14:19FromDiscord<huantian> In reply to @not logged in "says `1.6.8` for me.": also it seems like your nixos version also very outdated
19:14:31FromDiscord<huantian> you probably should at least update to nixos 22.11
19:14:33*azimut joined #nim
19:14:57FromDiscord<huantian> (edit) "but if you're coding you should probably be getting your packages from nixos ... unstablepackages" added "unstable↵at least use a dev shell with nixos" | "unstable↵at least use a dev shell with nixosunstable ... " added "packages"
19:16:50FromDiscord<Nilts> sent a code paste, see https://paste.rs/mE1
19:18:10FromDiscord<Nilts> wait, i think i fixed it
19:19:50FromDiscord<Nilts> changed it to `{ pkgs ? import <nixpkgs> {} }:` and it still installs version 1.1.1
19:22:26FromDiscord<gibson> In reply to @auxym "maybe, not sure. In": Sadly this doesn't work for the MS/VS build tooling.
19:24:06FromDiscord<huantian> In reply to @not logged in "how would i change": change the link to the latest versin
19:25:49FromDiscord<Nilts> In reply to @huantian "change the link to": what link?
19:26:21PMunchBy the way termer, we also have a #nim-embedded channel
19:30:12FromDiscord<@thatrandomperson5-6310e3b26da03> 4d2b37a84fad1091b9de401eb450aae66f1a741e?↵(@Nilts)
19:30:49termerPMunch Will join, thanks
19:31:37FromDiscord<auxym> In reply to @gibson "Sadly this doesn't work": Huh? I thought you said you were compiling on linux
19:32:15FromDiscord<huantian> In reply to @not logged in "what link?": https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gzthis one
19:32:20FromDiscord<huantian> (edit) "https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gzthis" => "https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gz this"
19:32:43FromDiscord<huantian> change the huge hash to the hash of hte latest commit in nixpkgs/unstable
19:33:08FromDiscord<huantian> (edit) "nixpkgs/unstable" => "`nixpkgs-unstable`"
19:33:19FromDiscord<huantian> <https://github.com/NixOS/nixpkgs/tree/nixpkgs-unstable>
19:35:02FromDiscord<@thatrandomperson5-6310e3b26da03> Did that, but still says 1.1.1↵(@huantian)
19:44:12FromDiscord<pmp-p> @Ntsékees your dlopen trouble is in unicodedb
19:44:45FromDiscord<pmp-p> from unicodedb/decompositions_data.nim
19:47:07FromDiscord<pmp-p> it's fixeable for emscripten target, but it would be better to just offer static linking otherwise wasi target won't work
19:47:24FromDiscord<huantian> hm maybe send over your entire shell.nix and I'll try it
19:50:42FromDiscord<@thatrandomperson5-6310e3b26da03> I don’t think that will work but ok, https://hastebin.com/corajoxema.bash My last resort is downloading from the web↵(@huantian)
19:52:01FromDiscord<pmp-p> @Ntsékees it's somewhere in there i guess https://github.com/nitely/nim-unicodedb/tree/master/src/unicodedb
19:52:42FromDiscord<pmp-p> @nitely maybe ?
19:53:14FromDiscord<Ntsékees> unicodedb/decompositions_data.nim contains just a huge autogenerated table of numbers
19:53:36FromDiscord<pmp-p> it is loading libpcre dynamically somewhere
19:55:16FromDiscord<pmp-p> sent a code paste, see https://play.nim-lang.org/#ix=4mn4
19:56:40FromDiscord<gibson> In reply to @auxym "Huh? I thought you": I'm trying to see if the (new?) --os:any can create cross-platform ANSI C, which it seems that it can. Turns out there looks to be an oversight in the codegen (nimbase.h) that ignores 3 lines that are needed for non-nix systems. I added that and my hello world nim-generated C code compiles and runs on each system. I'm curious how far this can be pushed.
19:57:50FromDiscord<@thatrandomperson5-6310e3b26da03> Does it work?
19:58:55FromDiscord<pmp-p> In reply to @Ntsékees "unicodedb/decompositions_data.nim contains just a": search in the imports what could possibly trigger the use of pcre in nim and we'll ask how to fix dynamic/static loading of that function ( which may be in nim stdlib )
19:59:19FromDiscord<pmp-p> at least fixing the soname ...
20:00:14FromDiscord<pmp-p> ( which is probably same as android that does not use versinning either for libs )
20:00:21FromDiscord<pmp-p> (edit) "versinning" => "versionning"
20:01:18FromDiscord<Ntsékees> (with regards to “libpcre.so.3”, after failing to load it it also tried “libpcre.so.2” and “libpcre.so”, incidentally)
20:02:20FromDiscord<pmp-p> for emscripten it should go directly to libpcre.so with full path
20:02:57FromDiscord<pmp-p> since preloaded .so are just swapped in FS file table
20:03:05FromDiscord<pmp-p> (edit) "since preloaded .so are just swapped in FS file table ... " added "for the original file"
20:03:53FromDiscord<pmp-p> (edit) "since preloaded .so are just swapped in FS file table for the original file ... " added "( when it does not just fail see https://github.com/emscripten-core/emscripten/pull/17956 )"
20:05:16FromDiscord<Ntsékees> https://github.com/genotrance/nimpcre
20:05:25FromDiscord<Ntsékees> I wonder if this could be helpful..
20:06:03FromDiscord<pmp-p> most likely sounds exactly what i wanted to do
20:07:39FromDiscord<pmp-p> but i would not know how to set that up for emscripten/wasi toolchain i just started Nim recently
20:08:39FromDiscord<nqeron> I'm using nim-regex and I am currently getting issues with the match macro - it's not recognizing matches. It was working not long ago. It's possible some of my other code is wrong
20:25:13FromDiscord<Ntsékees> NRE is based on PCRE1? 🤔
20:25:31FromDiscord<etra> hey, so I'm still a nim newbie, but after reading a bit of this issue: <https://github.com/nim-lang/Nim/issues/6638>, is `ref` some sort of type we should avoid if we're not messing with trees/nodes structures?
20:25:58FromDiscord<etra> because, nim would use pointers whenever a structure is bigger than 24 bytes iirc?
20:26:10om3gadear all, why that happens https://play.nim-lang.org/#ix=4mn9
20:27:59FromDiscord<pyolyokh> In reply to @om3ga "dear all, why that": `echo data[1]`. that cast is reinterpreting an array of 64-bit values as an array of 8-bit values, without any kind of numerical conversion.
20:28:15FromDiscord<huantian> In reply to @@thatrandomperson5-6310e3b26da03 "I don’t think that": got rid of some stuff but it seems to work https://media.discordapp.net/attachments/371759389889003532/1068628525655011368/shell.nix
20:28:26FromDiscord<huantian> `nim -v` gives me `1.6.10`
20:28:56FromDiscord<pyolyokh> In reply to @etra "because, nim would use": you don't need to use `ref` just to avoid passing a large object around, sure, as nim calling convention will avoid that implicitly.
20:32:04FromDiscord<Ntsékees> @pmp-p: In any case, thank you for your help.↵It appears nimpcre is a bit broken (the ftp it downloaded from doesn't serve anymore) but it's only a 43-lines script, so maybe I could manage to make it work again or at least take inspiration from it…
20:32:54FromDiscord<Ntsékees> Maybe all I need is the pcre.h and a static pcre library to link
20:34:48FromDiscord<pmp-p> In reply to @Ntsékees "NRE is based on": yeah that too is not clear it should have been libpcre2
20:35:23FromDiscord<pmp-p> (edit) "libpcre2" => "libpcre2.so.xxx"
20:35:43FromDiscord<Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1068630405995053187/image.png
20:35:57FromDiscord<Ntsékees> If it were PCRE2 it would have been pcre2.h
20:36:03FromDiscord<pmp-p> indeed
20:36:30FromDiscord<pmp-p> i should try to build it then
20:37:44FromDiscord<pmp-p> ouch `PCRE library, originally released in 1997, is at version 8.45. This version of PCRE is now at end of life, and is no longer being actively maintained.`
20:38:10FromDiscord<Elegantbeef> There are pure nim regex libraries
20:38:20FromDiscord<Elegantbeef> Not that i condone using regex for anything but searches 😄
20:38:45FromDiscord<pmp-p> how can we replace the default one with pure one when targeting emscripten/wasi
20:39:05FromDiscord<Elegantbeef> `nimble install nimregex` `import nimregex`
20:39:33FromDiscord<Elegantbeef> Ah sorry it's called `regex` in the package directory
20:39:40FromDiscord<Elegantbeef> https://github.com/nitely/nim-regex
20:40:10FromDiscord<Elegantbeef> There is also https://github.com/khchen/tinyre
20:40:42FromDiscord<pmp-p> "tiny" sounds better for a wasm build
20:41:33*lumo_e joined #nim
20:43:17FromDiscord<rakgew> nim-regex worked pretty well for me and has become my goto.
20:45:40FromDiscord<Ntsékees> I hope it has UTF8 support
20:45:55FromDiscord<Ntsékees> i.e. not matching half of a codepoint for multi-byte codepoints
20:47:44FromDiscord<Ntsékees> @pmp-p: I confirm that the `regex` module works in my WASM test
20:48:54FromDiscord<Ntsékees> I'll check if it works properly with UTF8
20:50:35FromDiscord<Ntsékees> It seems to work as expected
20:50:50FromDiscord<pmp-p> so what is the test code now ?
20:50:54FromDiscord<pmp-p> i'd like to test on wasi
20:51:17FromDiscord<Ntsékees> OK, wait a little
20:54:37FromDiscord<tfp> do u think nim compiled into wasm modules is a reasonable approach for scripting
20:54:57FromDiscord<Elegantbeef> Yes
20:55:02FromDiscord<Elegantbeef> That's my only focus for wasm
20:55:03FromDiscord<tfp> i can kind of see it working but i also see a slew of potential issues
20:55:25FromDiscord<tfp> mm
20:55:56FromDiscord<tfp> like how would i maintain binary compatibility between the two worlds
20:56:17FromDiscord<Elegantbeef> force the implementation of `getSize` for types
20:56:49FromDiscord<tfp> well i suppose it's kind of the same issues u run into with any dll?
20:56:54FromDiscord<Elegantbeef> Yes
20:57:31FromDiscord<Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1068635890794111057/test_1.zip
20:57:38FromDiscord<Elegantbeef> It's all resolvable, suggest packed annotations on types, have size procs, make a nice interop bridge
20:57:38FromDiscord<Ntsékees> ↑ @pmp-p
20:57:56FromDiscord<Elegantbeef> I personally do suggest using the wasm3 runtime since it's so portable
20:58:00FromDiscord<tfp> i am using wasm3 ye
20:58:03FromDiscord<tfp> with ur bindings i think
20:58:10FromDiscord<Elegantbeef> Ah nice
20:58:31FromDiscord<tfp> i am curious how i could say, enforce that dependencies are the same version
20:58:46FromDiscord<tfp> or binary compatibility of say a struct between the wasm environment and the host
20:58:50FromDiscord<Elegantbeef> https://github.com/beef331/wasm3/blob/hostToWasm/tests/thosttowasm.nim i'm working on some interop for Host -\> Wasm but it's still questionable
20:58:57FromDiscord<Elegantbeef> Since wasm doesnt have structs you really cannot
20:59:11FromDiscord<Elegantbeef> It doesnt have type information you need to provide it
20:59:30FromDiscord<tfp> it just has a host block of memory that u can read from right
20:59:36FromDiscord<tfp> it really doesn't seem ideal for scripting
20:59:49FromDiscord<tfp> but it should work yeah
21:00:00FromDiscord<Elegantbeef> I think it's better than the alternatives
21:00:05FromDiscord<tfp> i agree kind of
21:00:26FromDiscord<Elegantbeef> Locking down to a specific language is awful
21:00:34FromDiscord<Elegantbeef> https://github.com/beef331/aiarena/blob/master/src/core/wasmenvs.nim#L31-L40 but yea this is the type of thing I'd suggest
21:00:40FromDiscord<Elegantbeef> It removes some amount of ABI mismatch
21:00:42FromDiscord<tfp> like i guess the host has to match the wasm environment's binary layout-- or you could just do everything through RPCs
21:00:53FromDiscord<pmp-p> In reply to @Ntsékees "↑ <@334096250897170433>": looks ok for wasi
21:01:04FromDiscord<Elegantbeef> Well the nice thing is that with intelligent interop the host doesnt need types that match
21:01:15FromDiscord<Elegantbeef> But it of course needs to emit types that match
21:01:48FromDiscord<tfp> so u mean like don't worry about the types internal to each environment, just convert or serialize them at the boundary?
21:02:00FromDiscord<Elegantbeef> Partially yea
21:02:21FromDiscord<Elegantbeef> It's a bit manual but if you know the shape of the object on the wasm side you can convert in code
21:02:38FromDiscord<tfp> what do u think about ORC between the two environments
21:02:41FromDiscord<tfp> no reason it shouldn't work, right?
21:02:48FromDiscord<Elegantbeef> https://github.com/beef331/wasm3/blob/hostToWasm/tests/thosttowasm.nim#L14-L18 converts a Nim string to cstring inside wasm
21:03:03FromDiscord<Elegantbeef> You dont use ORC across the boundry
21:03:12FromDiscord<Ntsékees> In reply to @pmp-p "looks ok for wasi": I initialy had a CORS policy error with both Firefox and Chrome for loading the wasm locally in the html page, I had to tinker with Firefox settings to make it work
21:03:22FromDiscord<Ntsékees> (edit) "initialy" => "initially"
21:03:22FromDiscord<Elegantbeef> So yes there is no issue, they're two seperate systems
21:03:31FromDiscord<Elegantbeef> Infact a `ref T` in wasm is just a `int32` on the host
21:03:45FromDiscord<tfp> well i mean like
21:03:51FromDiscord<tfp> if i had a ref T in wasm, and i wanted to access it in host world
21:03:59FromDiscord<tfp> i could just cast it as a pointer and everything would work so long as u have no data race
21:04:05FromDiscord<tfp> and the binary layout was the same
21:04:15FromDiscord<Elegantbeef> Yes and since wasm is single threaded there is no issue
21:04:34FromDiscord<pmp-p> In reply to @Ntsékees "I initially had a": yeah same for python that's why i made pygbag
21:04:40FromDiscord<tfp> i think wasm has threads now
21:04:46FromDiscord<tfp> maybe not, not sure
21:05:05FromDiscord<Elegantbeef> Anyway yea should be fine
21:05:29FromDiscord<Elegantbeef> I really need to think of some test project that is feasible and fun to write code for
21:05:37FromDiscord<Elegantbeef> aiarena is a dead end even though it'd be fun in the end
21:06:05FromDiscord<tfp> ill have to play around with it
21:06:31FromDiscord<tfp> the sources u linked are helpful
21:07:12FromDiscord<tfp> what are u using to compile nim to wasm?
21:07:40FromDiscord<Elegantbeef> emcc but i might consider clang
21:07:47FromDiscord<pmp-p> and me https://github.com/WebAssembly/wasi-sdk/releases
21:08:57FromDiscord<pmp-p> btw @ElegantBeef you may want to have a look to "wace" here https://github.com/kanaka/wac it's a good addition to wasm3
21:11:50FromDiscord<@thatrandomperson5-6310e3b26da03> I think i just need to update nix, im working on it↵(@huantian)
21:13:06*xet7 quit (Remote host closed the connection)
21:20:35FromDiscord<Ntsékees> regex.match doesn't implement isSome to check if the match succeeded
21:22:32FromDiscord<nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnk
21:23:00FromDiscord<Ntsékees> Apparently I should use doAssert
21:25:24*PMunch quit (Quit: leaving)
21:29:22FromDiscord<Elegantbeef> @nqeron\: code?
21:29:45FromDiscord<Elegantbeef> Do not know if this benefits me personally↵(@pmp-p)
21:31:21FromDiscord<nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mno
21:31:38FromDiscord<nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnp
21:31:45FromDiscord<nqeron> is in a larger code block
21:32:05FromDiscord<nqeron> that I've recently modified and this bit isn't working anymore
21:32:41FromDiscord<Elegantbeef> What library?
21:32:47FromDiscord<nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnq
21:33:18FromDiscord<nqeron> In reply to @Elegantbeef "What library?": I'm using nim-regex
21:34:09FromDiscord<nqeron> This was all working before I tried coercing Move and Spread to have a generic type that used a static uint
21:34:27FromDiscord<tfp> anyone know a freetype wrapper for nim that's good
21:35:24FromDiscord<Elegantbeef> Yea this likely is an issue with generic's plus this macro
21:35:31FromDiscord<Elegantbeef> Try it with a generic procedure if it fails make an issue
21:35:39FromDiscord<Elegantbeef> tfp i'd say "just use pixie" but ymmv
21:35:47FromDiscord<pmp-p> In reply to @tfp "anyone know a freetype": what about sdl_ttf ?
21:35:47FromDiscord<tfp> i want features like hinting and stuff, i doubt pixie supports it
21:36:12FromDiscord<tfp> let's see aaa
21:36:36FromDiscord<pmp-p> In reply to @tfp "i want features like": that's is not freetype alone, it's the combo harfbuzz+freetype
21:36:48FromDiscord<pmp-p> (edit) "that's" => "that"
21:37:48FromDiscord<tfp> well hinting is like the cursed TTF feature that requires a bytecode interpreter and stuff
21:38:09FromDiscord<tfp> it's a FT feature i don't think it's only related to typesetting
21:38:45FromDiscord<tfp> ah yeah i think kerning is to typesetting as hinting is to rendering
21:39:20FromDiscord<tfp> unless you mean pixie uses harfbuzz + freetype but to me it looks like a pure nim implementation
21:41:58FromDiscord<pmp-p> idk if pixie uses hb+ft but for complete hinting support you'll need hb in, because of complex scripts that use diacritics
21:42:22FromDiscord<Elegantbeef> I dont think it does hinting
21:42:25FromDiscord<Elegantbeef> And yes it's pure nim
21:43:08FromDiscord<tfp> ugh i'll deal with typesetting later
21:43:18FromDiscord<tfp> for now just focused on glyph rendering with freetype i guess
22:03:29FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mny
22:04:09FromDiscord<sOkam!> I know I want the inner type to be a ref, but wondering if i need the outer type as reference or not 🤔
22:05:11*xet7 joined #nim
22:05:49FromDiscord<Elegantbeef> If you want to use proper inheritance(converting up to parent types and storing hetrogenous types) the latter is the only way
22:05:52FromDiscord<jtv> Well, if you have two copies of a concrete value of type One, and one of those instances has the field updated to a ref, then the other instance will not
22:05:56FromDiscord<Elegantbeef> Stack based inheritance is limited and icky
22:07:16FromDiscord<sOkam!> i see
22:13:05FromDiscord<sOkam!> sent a code paste, see https://paste.rs/3e3
22:13:24FromDiscord<Elegantbeef> If you access a ref all the fields are shared of that ref
22:13:26FromDiscord<Elegantbeef> That's the point of a ref
22:13:32FromDiscord<Elegantbeef> It's a heap allocated data type
22:13:53FromDiscord<sOkam!> k so then i don't need the inner data as ref i understand
22:14:37FromDiscord<sOkam!> point is to have a set of data that i can modify from multiple places, but that its shared for all of the outer types containing the inner type
22:15:22FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mnC
22:15:25FromDiscord<Elegantbeef> Refs are pointers
22:15:36FromDiscord<sOkam!> yep! i get it for standard variables
22:15:45FromDiscord<Elegantbeef> So it's the same semantics
22:15:55FromDiscord<sOkam!> the confusing part is from values inside ref objects
22:17:31FromDiscord<Elegantbeef> There is no difference between that and↵`var a = MyData(a: 100)`
22:17:33FromDiscord<Elegantbeef> It's the exact same semantics
22:18:04FromDiscord<sOkam!> kk ✍️
22:18:07FromDiscord<Elegantbeef> Like i said there is no difference
22:18:07FromDiscord<Elegantbeef> A ref points to a block of memory
22:18:15FromDiscord<Elegantbeef> Just as `ptr` does in the above `MyData(a: 100)`
22:19:30FromDiscord<jtv> The memory layout isn't different??? I'd assume a ref field is just a ptr_t, and if it's not a ref the actual object is embedded, no??
22:19:59FromDiscord<jtv> Not really different from the programmer's perspective, but can have some implications like cache locality
22:20:00FromDiscord<Elegantbeef> What?
22:20:19FromDiscord<Elegantbeef> There is no difference between `var a = 100` or `var a = MyData(a: 100)`
22:20:36FromDiscord<jtv> No, that's not what I'm asking
22:20:38FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mnE
22:20:48FromDiscord<Elegantbeef> a ref object is a pointer
22:20:57FromDiscord<jtv> Right, and a non-ref isn't
22:20:58FromDiscord<Elegantbeef> A non ref object is not a pointer
22:21:02FromDiscord<jtv> So if you have:
22:21:11FromDiscord<Elegantbeef> Objects are stack allocatable
22:21:15FromDiscord<Elegantbeef> So they are inline
22:21:28FromDiscord<Elegantbeef> Refs are not stack allocatable so are just pointers with the object on the heap
22:21:46FromDiscord<jtv> sent a code paste, see https://play.nim-lang.org/#ix=4mnF
22:21:50FromDiscord<jtv> I'd expect a to be a pointer
22:21:59FromDiscord<Elegantbeef> Which it is
22:21:59FromDiscord<jtv> But if you take off the ref, I would expect it NOT to be
22:22:07FromDiscord<Elegantbeef> Which it is
22:22:14FromDiscord<jtv> THAT is what I was saying.
22:22:33FromDiscord<Elegantbeef> Why are we EMPHASISING words
22:22:38FromDiscord<jtv> It's semantically not different, but has implications like in the case cache locality
22:22:49FromDiscord<jtv> Because I roll like that!
22:22:53FromDiscord<Elegantbeef> Of course
22:23:01FromDiscord<Elegantbeef> But if you use ref you should know the implications
22:23:11FromDiscord<Elegantbeef> You should use tools understanding what they do
22:23:15FromDiscord<jtv> He didn't understand, was trying to help clarify 🙂
22:25:05FromDiscord<Elegantbeef> Refs are just easiest understood as pointers that always point to heap allocated data
22:41:08*ltriant joined #nim
22:51:46FromDiscord<Gennadiy> Is there a way to return/break out early from a case statement? I am porting some C++ code.
23:00:53*Guest9364 joined #nim
23:01:32*Guest9364 quit (Client Quit)
23:09:57FromDiscord<Leftbones> What's the use case for Natural vs uint?
23:14:48FromDiscord<Elegantbeef> Nim's signed integers have under and overflow checks, it's unsigned do not, Natural is a subrange of an integer
23:15:14FromDiscord<Elegantbeef> This means it has overflow checks, compile time checks, and runtime checks to ensure it doesnt exit `0..high(int)`
23:24:56FromDiscord<voidwalker> I need some more ideas for my dosbox config file parsing/compression (to store compactly in sqlite), I'm stuck at the parsing stage. https://github.com/joncampbell123/dosbox-x/blob/master/dosbox-x.reference.conf parsecfg can't do `value = #nothing`
23:25:38FromDiscord<voidwalker> maybe I should just write my own, as it's just .ini style format. But then I have no idea how to design this.
23:27:31FromDiscord<voidwalker> Do I have a column for each type of option, with appropiate type (storing enum options as bit values, etc), or do I store just the key/values that are actually present in the .cfg file, like 1 byte for length, 1 byte for type of key, and whatever bytes needed to store the value
23:28:55FromDiscord<voidwalker> And what data structures would I use to turn .cfg into sqlite, and sqlite into .cfg, efficiently
23:39:43*lumo_e quit (Ping timeout: 252 seconds)
23:49:45*lumo_e joined #nim
23:59:29FromDiscord<sOkam!> @voidwalker https://github.com/lihf8515/parseini know of this? might be useful
23:59:50FromDiscord<sOkam!> its basically parsecfg, but without a lot of its nonsense