00:00:31 | termer | oh god, now I need to do compiler silliness for switching between asyncdispatch and chronos |
00:11:39 | termer | lol the docs weren't lying |
00:11:47 | termer | asynchttpserver is super not production ready |
00:12:06 | termer | It's safe running behind nginx though lol |
00:14:11 | FromDiscord | <Rika> I personally think not even behind nginx is it safe to deploy in production… |
00:17:22 | termer | in this case it doesn't crash so yay |
00:17:32 | termer | httpbeast and httpx both crash under ORC |
00:17:56 | termer | regardless of whether you're opening too many connections |
00:18:09 | termer | so ironically asynchttpserver is much more stable for this purpose |
00:36:04 | FromDiscord | <sOkam!> whats the state of other multithreading things? can a job-task system be created for production with some other module? |
00:40:56 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4mix |
00:41:28 | FromDiscord | <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:52 | FromDiscord | <michaelb.eth> (edit) "http://ix.io/4mix" => "http://ix.io/4miy" |
00:42:28 | FromDiscord | <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:17 | FromDiscord | <michaelb.eth> In reply to @termer "httpbeast and httpx both": is chronos "ORC ready" now? if so, that's great news |
00:43:31 | termer | I have no idea |
00:43:36 | termer | If not, I'm not using it |
00:43:48 | termer | but it looks like I'm just going to be using normal asynchttpserver behind nginx for this |
00:44:39 | termer | Unless you've got some legacy code, it seems like it would be a waste not to use ORC |
00:44:54 | FromDiscord | <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:11 | termer | https://github.com/status-im/nim-chronos/issues/325 |
00:46:13 | termer | found this |
00:46:15 | FromDiscord | <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:56 | termer | With Nim 2 up and coming, I think the reasoning for upgrading will be mounting |
00:47:34 | FromDiscord | <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:38 | FromDiscord | <michaelb.eth> Sadly, I do not have any articles/references to share, just my own experiences. |
00:49:05 | termer | Multithreading is very hard in nim compared to other languages because the head is thread-local |
00:49:07 | FromDiscord | <sOkam!> how would you recommend me to learn about the topic? |
00:49:15 | termer | trial and error :) |
00:49:21 | termer | That's how I learned |
00:49:36 | FromDiscord | <sOkam!> trial and error still needs a start point and a path 🙈 |
00:49:38 | termer | But 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:43 | FromDiscord | <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:43 | termer | well what do you want to build? |
00:50:44 | FromDiscord | <sOkam!> In reply to @termer "well what do you": https://fabiensanglard.net/doom3_bfg/threading.php something like this |
00:51:05 | FromDiscord | <sOkam!> a joblist manager for a game engine, using only atomic operations |
00:51:50 | FromDiscord | <michaelb.eth> well the "no shared" aspect of `refc` is going to make something just like that practically impossible |
00:52:00 | termer | you *can* share memory |
00:52:06 | termer | but you have to create and free it explicitly |
00:52:12 | termer | see createShared and freeShared |
00:52:18 | FromDiscord | <michaelb.eth> sure, I suggested that above |
00:52:22 | FromDiscord | <sOkam!> i see |
00:52:43 | termer | Tread lightly with those APIs, because you can very easily create memory leaks |
00:52:53 | FromDiscord | <sOkam!> what part of that type of system uses shared memory? i thought it was all non-shared due to the atomics |
00:53:04 | FromDiscord | <sOkam!> yeah i imagine |
00:53:11 | FromDiscord | <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:31 | FromDiscord | <michaelb.eth> (edit) "too, unless" => "too: "unless" | "yourself" => "yourself"" |
00:53:42 | termer | The difference between the memory you get with normal automatic allocation and createShared is createShared returns an unsafe pointer (ptr instead of ref) |
00:53:50 | termer | or rather, unmanaged pointer |
00:53:57 | termer | So it's not part of the GC lifecycle at all |
00:54:01 | termer | that's why you have to manage it yourself |
00:54:22 | termer | the other difference is that you have to dereference it manually by adding the [] suffix |
00:54:29 | termer | so myData[] = "thing" |
00:54:41 | FromDiscord | <michaelb.eth> maybe someone is already cooking up a worker pool lib that assumes on `orc` |
00:54:42 | FromDiscord | <sOkam!> ye i imagine |
00:55:08 | FromDiscord | <sOkam!> that would be epic |
00:55:30 | FromDiscord | <michaelb.eth> I think someone made a forum post about that awhile back |
00:55:33 | FromDiscord | <michaelb.eth> let me try to find it... |
00:56:11 | FromDiscord | <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:26 | FromDiscord | <michaelb.eth> this isn't the forum post I was thinking of, but see https://forum.nim-lang.org/t/8791#57344 |
00:56:28 | termer | I 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:38 | FromDiscord | <michaelb.eth> (edit) "https://forum.nim-lang.org/t/8791#57344" => "https://forum.nim-lang.org/t/8791" |
00:56:39 | FromDiscord | <sOkam!> what are channels? |
00:56:50 | termer | Channels are threadsafe ways of passing data to and from threads |
00:57:07 | termer | they're basically lock-enforced FIFO buffers |
00:57:37 | termer | s0kam! https://nim-lang.org/docs/channels_builtin.html |
00:57:59 | termer | They're threadsafe because all data that passes through them are deep-copied |
00:58:03 | termer | so there are no cross-thread references |
00:58:24 | FromDiscord | <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:32 | termer | that's not really a problem |
00:58:48 | termer | you can tryRecv and loop around that with a small async sleep between checks |
00:58:54 | termer | and then wrap that in a promise |
00:58:58 | termer | *future |
00:59:43 | FromDiscord | <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:47 | FromDiscord | <michaelb.eth> (edit) "channel" => "channel?" |
01:00:16 | FromDiscord | <michaelb.eth> I can't `await` for a message re: what to get while also concurrently doing the http stuff |
01:00:37 | termer | you're not gonna get them in any particular order but you will have a nice little await API to use |
01:00:46 | termer | but I don't see the issue with the approach I mentioned |
01:00:57 | termer | if you need to queue them, then you need to do more nonsense with async streams and all that |
01:01:05 | termer | but a simple worker queue doesn't require that |
01:01:38 | FromDiscord | <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:52 | FromDiscord | <michaelb.eth> all on the same thread |
01:02:08 | FromDiscord | <michaelb.eth> with chronos' unofficial async channels that's possible, but not with std channels, afaik |
01:03:05 | termer | then create a proc to do that and then do asyncCheck |
01:03:56 | termer | if 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:39 | termer | just 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:57 | termer | so if an uncatch error is raised inside of a proc called with asyncCheck, it' |
01:05:03 | termer | ll end up coming up whereever you ran runForver |
01:05:07 | termer | for waitFor |
01:07:23 | FromDiscord | <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:33 | FromDiscord | <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:31 | FromDiscord | <michaelb.eth> https://github.com/status-im/nim-chronos/blob/achannels/tests/testchannels.nim#L34 |
01:09:02 | FromDiscord | <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:07 | FromDiscord | <michaelb.eth> nice paradigm |
01:09:25 | termer | that's a nice thing |
01:14:04 | FromDiscord | <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:36 | FromDiscord | <michaelb.eth> I should revisit it once Nim 2.0 is released |
01:15:00 | termer | s0kam! 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:19 | FromDiscord | <sOkam!> In reply to @termer "s0kam! I forgot to": ty 🙏 |
01:26:53 | FromDiscord | <sOkam!> isn't the point of atomics that you don't share information between threads? |
01:28:17 | termer | I'm pretty sure yeah |
01:28:20 | termer | well |
01:28:21 | FromDiscord | <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:23 | termer | not share state |
01:28:38 | termer | the point of atomics I believe is to avoid concurrent modification |
01:28:46 | FromDiscord | <sOkam!> yep |
01:28:46 | termer | which is why you need things like threads |
01:28:47 | termer | *locks |
01:28:49 | termer | not threads lol |
01:28:59 | termer | So as long as your communication is threadsafe, you're ok |
01:29:07 | termer | threads would be useless if we couldn't share data between them |
01:29:16 | FromDiscord | <sOkam!> why? |
01:29:40 | FromDiscord | <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:41 | termer | because we use threads to do work concurrently, and most work shares some common data |
01:29:58 | termer | only very simple tasks or very specific tasks don't required shared state |
01:30:06 | termer | or where work has no global state |
01:30:19 | FromDiscord | <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:25 | termer | For eaxmple, you could do a REST web application without thread communication, assuming you have no state between threads |
01:30:39 | termer | Well let's give an example from the idtech thing |
01:30:47 | termer | There is a joystick input thread |
01:30:56 | termer | How are we going to use that information? Joystick info is needed in other threads |
01:31:21 | FromDiscord | <sOkam!> you store it in memory, and then send it where its needed? |
01:31:22 | termer | Threads aren't about isolation (unless you're using them specifically for that purpose), they're about parallel work |
01:31:44 | termer | storing it in memory and making it available to other threads would be sharing state |
01:32:02 | termer | if 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:08 | FromDiscord | <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:15 | FromDiscord | <jtv> Even if you do share data across threads |
01:32:50 | FromDiscord | <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:57 | termer | if 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:10 | termer | s0kam! Right, or make it available in shared memory |
01:33:23 | termer | either way, you need some shared state between threads to make the data useful |
01:33:30 | FromDiscord | <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:56 | FromDiscord | <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:50 | termer | Shared memory is about having memory that is accessible to multiple threads |
01:34:56 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4miH |
01:34:57 | FromDiscord | <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:02 | termer | How you choose to use that data, what protections you use for it, etc are up to you |
01:35:27 | FromDiscord | <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:10 | FromDiscord | <sOkam!> happy to read it, but I won't be able to find my way around the project, thats guaranteed |
01:36:19 | termer | Here's an example of how you could use shared memory to expose joystick state to other threads |
01:36:25 | termer | You create an object called JoystickState |
01:36:33 | termer | you create some shared memory that contains a JoystickState object |
01:36:46 | termer | then in your joystick input thread, you read from your joystick and modify JoystickState accordingly |
01:36:58 | FromDiscord | <sOkam!> (edit) "project," => "project without any specific pointers," |
01:37:00 | termer | other threads at their leisure can read from the shared JoystickState object |
01:37:13 | FromDiscord | <jtv> Well the thing is that I am here and answer questions, you have no line to John Carmack. |
01:37:31 | termer | something tells me John Carmack isn't interested in working in Nim |
01:37:45 | FromDiscord | <jtv> I'm not going to take initiative to help you learn, but if you take that initiative, I would support you. |
01:37:52 | madprops | a cacodemon told me |
01:38:01 | FromDiscord | <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:08 | FromDiscord | <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:32 | termer | so if you're working in C, why are you here |
01:38:34 | termer | are you wanting to work in Nim |
01:38:35 | FromDiscord | <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:38 | FromDiscord | <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:46 | FromDiscord | <jtv> For him it's a stepping stone to getting lower level |
01:38:57 | termer | fair enough I suppose |
01:38:57 | FromDiscord | <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:06 | termer | I find C to be a pain in the ass when working outside of embedded hardware |
01:39:20 | FromDiscord | <sOkam!> it is a pain in the ass to do anything, basically |
01:39:35 | termer | Unix wizards, I kneel |
01:39:47 | FromDiscord | <sOkam!> nim spoils us, though. this lang is just too good |
01:40:56 | FromDiscord | <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:58 | termer | except when working in threads lol |
01:40:59 | termer | and async |
01:41:04 | termer | mostly threads + async |
01:42:09 | FromDiscord | <sOkam!> 🙈 |
01:42:13 | termer | 90% of the stuff I do with Nim is async + threading so it gets a little tiresome lol |
01:42:18 | FromDiscord | <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:26 | termer | node.js async is super great |
01:42:31 | termer | cause there's only one thread lol |
01:42:52 | FromDiscord | <michaelb.eth> In reply to @termer "cause there's only one": not anymore! haha |
01:43:01 | termer | you *can* spawn more threads but nobody does |
01:43:02 | FromDiscord | <michaelb.eth> well, if you're in Node.js or similar runtime |
01:43:15 | termer | I've used a worker thread before in Node for cryptography |
01:43:16 | termer | that's it |
01:43:17 | FromDiscord | <michaelb.eth> with the more recent APIs they do |
01:43:20 | FromDiscord | <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:34 | termer | fix your stack traces and you're golden |
01:43:39 | termer | I want everything to be async by default |
01:43:46 | FromDiscord | <michaelb.eth> concurrency is a difficult problem, always will be |
01:44:02 | FromDiscord | <sOkam!> In reply to @jtv "I hate the async": what does Go do instead? 🤔 |
01:44:04 | FromDiscord | <michaelb.eth> because you have to build a strong mental model around what the lang/computer is doing |
01:44:08 | termer | Go does channels everywhere |
01:44:16 | termer | I didn't like Go when I tried it |
01:44:36 | termer | michaelb.eth Yeah lol I don't hate it only cause I've been doing it for so long |
01:44:44 | FromDiscord | <jtv> Yes, and w/ async now that extends to iterators too, where people already aren't comfortable |
01:44:49 | termer | been knee-deep in async for at least 5 years |
01:44:51 | FromDiscord | <jtv> Oh, I don't like Go, but that's one place where it shines |
01:45:03 | termer | come on, iterators are just generator functions with yields and stuff |
01:45:05 | termer | it's not that bad |
01:45:08 | FromDiscord | <michaelb.eth> AsyncIterable and IxJS are pretty nice, fwiw |
01:45:15 | FromDiscord | <michaelb.eth> and underappreciated still |
01:45:26 | termer | Waiting for nim asyncstreams to become stable lol |
01:45:38 | termer | I was shitting myself trying to use it in one of my projects with asynchttpserver's body |
01:45:51 | termer | that's mostly asynchttpserver's fault |
01:45:55 | termer | what a horrible HTTP implementation |
01:46:47 | FromDiscord | <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:18 | FromDiscord | <jtv> They're easy to use if you don't have to know that's how items() is implemented |
01:47:28 | FromDiscord | <michaelb.eth> next/done, yield, why so complicated? |
01:47:28 | termer | I 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:30 | FromDiscord | <jtv> But they don't want to even write their own iterators |
01:47:43 | termer | It's not that hard to understand if you accept that it's weird to begin with |
01:47:48 | termer | but programming is weird to begin with |
01:48:03 | termer | you just learn different parts of it and develop different mental models |
01:48:37 | termer | Just 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:38 | FromDiscord | <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:44 | FromDiscord | <jtv> Because they're used unintuitively |
01:49:07 | termer | jtv lol at work people have 0 idea how async works |
01:49:17 | termer | they just slap "async" onto their function and use async APIs along with blocking ones |
01:49:35 | termer | it's so pervasive that I don't even bother trying to fix it anymore |
01:49:47 | madprops | concurrency in crystal seems confusing |
01:49:55 | madprops | channels and that |
01:49:55 | FromDiscord | <jtv> Right |
01:50:30 | madprops | seems like a spaghetti code thing |
01:50:39 | madprops | like old-school gotos |
01:51:01 | termer | overuse of channels are way worse than await |
01:51:05 | FromDiscord | <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:15 | FromDiscord | <jtv> The documentation |
01:51:32 | FromDiscord | <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:35 | FromDiscord | <jtv> Then it'll explain where to start in the code, and those parts are very well commented |
01:51:47 | FromDiscord | <jtv> It walks through all of the ins and outs |
01:52:04 | FromDiscord | <sOkam!> but are all those things needed to understand the model of id4? |
01:52:23 | FromDiscord | <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:38 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4miK |
01:53:24 | FromDiscord | <michaelb.eth> Harel invented statecharts to help EEs and programmers working on fighter jets, who were drowning in concurrency bugs |
01:53:44 | termer | I'm eventually gonna have to write an async runtime for nim for use with microcontrollers |
01:53:51 | termer | cause the current one uses heap a lot |
01:54:05 | termer | Futures are allocated on the heap and that can use a lot of memory |
01:54:16 | termer | also not use exceptions |
01:54:22 | FromDiscord | <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:25 | FromDiscord | <jtv> Cool will check it out |
01:57:03 | FromDiscord | <michaelb.eth> the original paper from '86 is here |
01:57:47 | FromDiscord | <michaelb.eth> https://www.wisdom.weizmann.ac.il/~harel/SCANNED.PAPERS/Statecharts.pdf |
01:59:00 | FromDiscord | <jtv> Even better, thanks |
01:59:03 | FromDiscord | <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:37 | FromDiscord | <jtv> It's really all about what abstractions can provide the most value w/ the least pain 🙂 |
02:00:19 | FromDiscord | <michaelb.eth> (edit) "various implementations for turning ... statecharts" added "(serialized)" |
02:53:51 | * | crem1 quit (Ping timeout: 265 seconds) |
03:13:20 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> I do like toml and have used https://github.com/status-im/nim-toml-serialization |
03:20:24 | FromDiscord | <Elegantbeef> But it lacks user defined parsing hooks so that's a bit of a shame |
03:20:25 | FromDiscord | <Elegantbeef> Atleast i think it does |
03:21:28 | FromDiscord | <Elegantbeef> perhaps one can with `readValue` |
03:55:30 | FromDiscord | <voidwalker> https://github.com/joncampbell123/dosbox-x/blob/master/dosbox-x.reference.conf - this is what I want to parse |
03:56:11 | FromDiscord | <voidwalker> `priority = higher,normal` this is the troublesome line, all else looks tame |
04:01:02 | FromDiscord | <voidwalker> It's not enclosed by square brackets like toml seems to want |
04:01:32 | FromDiscord | <Elegantbeef> Yea that's not a toml compliant file |
04:01:48 | FromDiscord | <Elegantbeef> I thought you were just generally asking for a ini like parser |
04:02:01 | FromDiscord | <Elegantbeef> ini/conf is generally spec-less and down to the implementer |
04:03:57 | FromDiscord | <Rika> I think it’s strange that Nim’s configuration parser would parse that separately like you say though |
04:04:24 | FromDiscord | <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:36 | FromDiscord | <voidwalker> but `,` is not a comment char ? |
04:27:24 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj6 |
04:27:44 | FromDiscord | <voidwalker> I think values have to be made of those chars ? |
04:28:06 | FromDiscord | <Rika> In reply to @voidwalker "but `,` is not": That’s not my point |
04:28:27 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj7 |
04:28:35 | FromDiscord | <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:41 | FromDiscord | <voidwalker> sent a code paste, see https://paste.rs/q96 |
04:28:46 | FromDiscord | <voidwalker> (edit) |
04:29:32 | FromDiscord | <voidwalker> not sure what you mean |
04:30:03 | FromDiscord | <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:12 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mj9 |
04:34:36 | FromDiscord | <voidwalker> for which: ` # empty string value is not allowed =` |
04:34:57 | FromDiscord | <voidwalker> so parsecfg is no good :\ |
04:46:02 | FromDiscord | <Girvo> Can ref objects have destructors? |
04:50:14 | FromDiscord | <Elegantbeef> Nope but distincts can |
04:50:58 | FromDiscord | <Girvo> 👍 |
04:51:04 | FromDiscord | <Girvo> Tbh this didn't need to be a ref object anyway so |
04:51:05 | FromDiscord | <Elegantbeef> Though you can also make a destructor for the internal object |
04:52:31 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mjc |
04:52:35 | FromDiscord | <Girvo> Oh interesting |
04:56:21 | FromDiscord | <Elegantbeef> From now on i'll ignore you if you say `ref` in any sentence↵(@Girvo) |
04:57:09 | FromDiscord | <Girvo> This was the literal last usage left of it anyway lol, it's gone now |
06:56:00 | FromDiscord | <ringabout> Can Nim amd64 be used with msvc 32 bit? |
07:20:39 | * | ltriant quit (Ping timeout: 256 seconds) |
07:26:05 | FromDiscord | <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:11 | FromDiscord | <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:48 | Amun-Ra | is the yaml lib in your project path? if no, not really |
08:19:03 | FromDiscord | <Elegantbeef> `import pkg/yaml as nimyaml` |
08:19:14 | FromDiscord | <Elegantbeef> Then you can do `import myProg/yaml` |
08:21:28 | PMunch | Right! I seemed to remember there was a prefix similar to `std` for external packages |
08:22:14 | FromDiscord | <Elegantbeef> Naming a module after a file format has to be up there for silly names though |
08:26:59 | PMunch | Well I think it makes sense for the nimyaml package |
08:27:17 | PMunch | But just calling a part of your program for "yaml" is a bit silly |
08:29:37 | FromDiscord | <Rika> In reply to @PMunch "Well I think it": It kinda squats the name for any other implementations |
08:30:49 | FromDiscord | <Elegantbeef> You cannot even distinguish if you have `nimyaml` and `myotheryaml` from nimble |
08:31:28 | FromDiscord | <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:47 | FromDiscord | <sOkam!> handy, ty! |
08:32:51 | FromDiscord | <sOkam!> didn't remember that either |
08:34:27 | PMunch | Fair 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:27 | PMunch | example. |
08:35:16 | FromDiscord | <Elegantbeef> Sure but we could have `import yamler` or `import nimyaml/yaml` 😄 |
08:35:24 | FromDiscord | <Elegantbeef> Something that's slightly more unique and way less likely to cause import issues |
08:39:47 | FromDiscord | <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:48 | FromDiscord | <Elegantbeef> But hey it's possible |
08:41:40 | Amun-Ra | System64 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:31 | FromDiscord | <Elegantbeef> Nice, I still need a small program to toy with my wasm interop |
08:42:59 | Amun-Ra | normally 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:36 | FromDiscord | <Elegantbeef> Nico has a config that does it without a macro |
08:43:44 | FromDiscord | <Elegantbeef> Since you can use `dynLibOverride` |
08:43:49 | Amun-Ra | hmm, I have to look it up |
08:43:59 | FromDiscord | <Elegantbeef> https://github.com/ftsf/nico/blob/main/exampleApp/config.nims |
08:44:26 | Amun-Ra | ah, I don't think dynLibOverride will work in my case |
08:44:34 | FromDiscord | <Elegantbeef> `dynlib` for all of it's faults can be overridden which means with the right flags you can statically link |
08:44:44 | Amun-Ra | I do not use dynlib pragma |
08:44:58 | FromDiscord | <Elegantbeef> So silly |
08:45:34 | Amun-Ra | I don't rely on a spacific lib binding that way |
08:45:54 | FromDiscord | <Elegantbeef> What? |
08:48:20 | * | azimut_ quit (Ping timeout: 255 seconds) |
08:48:42 | Amun-Ra | Elegantbeef: https://pastebin.com/AKBb9WC9 |
08:49:06 | Amun-Ra | Elegantbeef: I have bindings for SDL1.2, SDL2, XCB, X11, GTK2, GTK3, and GTK4 |
08:49:31 | Amun-Ra | at least one of those libraries have to be installed in the system and I don't really care which one |
08:49:54 | FromDiscord | <Elegantbeef> Ah |
08:50:52 | Amun-Ra | Elegantbeef: the con is I have to implement different code for static calls: https://play.nim-lang.org/#ix=4mjP |
08:51:09 | Amun-Ra | s/that/then/ |
08:51:16 | FromDiscord | <Elegantbeef> Yea i get it |
08:52:23 | Amun-Ra | I 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:27 | FromDiscord | <Elegantbeef> Yea makes sense |
08:55:50 | Amun-Ra | right now I do the conversion via python script |
08:57:27 | FromDiscord | <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:05 | Amun-Ra | I 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:57 | FromDiscord | <sOkam!> if I say `-d:myFlag:10` at compile time, how can I the access that value in code? |
09:01:13 | Amun-Ra | s0kam! const myflag {.intdefine.} = 666 |
09:01:37 | Amun-Ra | myflag == 10 when -d=myFlag=10 |
09:02:19 | FromDiscord | <sOkam!> so if i usually say `when defined blabla:` i can now say `when defined blabla == 10`? |
09:02:33 | Amun-Ra | and 666 is the default value when there's nothing passed to the compiler |
09:02:44 | Amun-Ra | when defined(blabla) and blabla == 10 |
09:02:50 | Amun-Ra | or use intdefine |
09:03:01 | FromDiscord | <sOkam!> oh, srsly? damn that's exactly what i needed. that default fallback value 👀 |
09:03:26 | Amun-Ra | s0kam!: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compileminustime-define-pragmas |
09:03:50 | FromDiscord | <sOkam!> is it possible to staticread from a yaml file in some way, to populate that data? |
09:04:05 | FromDiscord | <Elegantbeef> if nimyaml supports it |
09:04:06 | FromDiscord | <tweg> what is getFrame? i get an error saying: `Error: system module needs: getFrame` |
09:04:24 | FromDiscord | <Elegantbeef> likely a procedure related to stack tracing |
09:04:55 | FromDiscord | <Elegantbeef> I assume you're doing `--os:standalone`? |
09:04:59 | FromDiscord | <tweg> yea |
09:05:06 | FromDiscord | <Elegantbeef> `--os:any` |
09:05:52 | FromDiscord | <tweg> ah ty, any docs on the memory manager thing |
09:06:03 | FromDiscord | <tweg> like how thats ported? |
09:06:32 | FromDiscord | <Elegantbeef> Atleast i think that's preferred |
09:06:37 | FromDiscord | <Elegantbeef> No clue what you mean I've never done that low level stuff |
09:06:52 | FromDiscord | <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:15 | FromDiscord | <tweg> `system/osalloc.nim(218, 10) Error: Port memory manager to your platform` i get this |
09:07:36 | FromDiscord | <Elegantbeef> yea use `-d:useMalloc` |
09:07:40 | Amun-Ra | ^ this |
09:07:41 | FromDiscord | <tweg> ah |
09:07:45 | FromDiscord | <Elegantbeef> With `--mm:arc` or `--mm:orc` |
09:07:50 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> ^This |
09:08:03 | Amun-Ra | also you'll prolly need a few patchFiles |
09:08:18 | FromDiscord | <Elegantbeef> you can make an nimscript file with a command |
09:08:39 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/nims.html#nimscript-as-a-build-tool |
09:09:03 | FromDiscord | <sOkam!> i assume -opt:speed does gcOptimizeSpeed? |
09:09:06 | FromDiscord | <Elegantbeef> It only matters for refc so disregard it |
09:09:14 | FromDiscord | <sOkam!> oh, nvm then |
09:09:38 | FromDiscord | <Elegantbeef> Cannot really tune Arc/Orc 😄 |
09:13:38 | FromDiscord | <sOkam!> im honestly curious how arc vs orc vs none would compare in numbers 🤔↵I bet they must be really really close |
09:14:18 | FromDiscord | <Elegantbeef> Oddly in some instances arc was faster than none |
09:14:29 | FromDiscord | <sOkam!> rly? damn |
09:14:39 | FromDiscord | <Elegantbeef> You have like 4k+fps why do you care |
09:15:04 | FromDiscord | <flajr> sent a code paste, see https://play.nim-lang.org/#ix=4mjT |
09:15:21 | FromDiscord | <sOkam!> now. wait until deterministic physics and deferred rendering and VCT rendering are all working at the same time. 10fps guaranteed 😄 |
09:15:27 | FromDiscord | <Elegantbeef> You should be able to do `nim build` now |
09:17:17 | FromDiscord | <sOkam!> whats the benefit of using nimble, instead of using nimscript as a build tool? |
09:17:48 | * | Amun-Ra uses Makefile |
09:18:12 | Amun-Ra | …with fat config.nims |
09:18:14 | FromDiscord | <flajr> Hmmm: `Error: invalid command: c projectName` |
09:18:41 | FromDiscord | <sOkam!> In reply to @Amun-Ra "…with fat config.nims": isn't a custom nimscript the same thing as a nimble file? |
09:19:13 | Amun-Ra | sOkam!: more less, I use it to define a few targets |
09:19:42 | FromDiscord | <sOkam!> just struggling to see the unique benefits of nimble files |
09:20:12 | FromDiscord | <sOkam!> i bet there must be some, but i feel like im missing which they are |
09:20:36 | Amun-Ra | sOkam!: small excerpt: https://play.nim-lang.org/#ix=4mjV |
09:23:42 | FromDiscord | <sOkam!> @Amun-Ra and you cannot do that in a not-nimble file? |
09:24:10 | Amun-Ra | sOkam!: it's config.nims, it works whether I compile with nimble or nim |
09:24:52 | FromDiscord | <sOkam!> i see. but what i don't grasp is what would you miss if you didn't use nimble |
09:26:41 | Amun-Ra | I 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:46 | PMunch | sOkam, the biggest benefit is probably that Nimble is actually a package manager |
09:28:12 | Amun-Ra | ah, yes; my apps are usually self contained; I forgot about that feature |
09:28:33 | FromDiscord | <sOkam!> what does that mean in practice? what would you miss if you didn't have the package manager feature set? |
09:29:17 | PMunch | So 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:25 | Amun-Ra | you just add "require someexternalpackage" or "require https://github.com/user/project/" and that's it |
09:29:53 | FromDiscord | <sOkam!> ah i see. makes sense |
09:29:55 | PMunch | The `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:57 | FromDiscord | <ElegantBeef> Shame the bridge died |
09:30:06 | FromDiscord | <Elegantbeef> manually types `nim c -r ./file.nim` |
09:30:07 | FromDiscord | <Elegantbeef> The benefit is that nimble is dumb and validates dependencies every time you use a nimble command |
09:30:08 | FromDiscord | <Elegantbeef> So it's slow as balls ime |
09:30:08 | PMunch | The bridge died? |
09:30:11 | FromDiscord | <ElegantBeef> Oh there it is |
09:30:28 | FromDiscord | <ElegantBeef> Yea the one that makes me the cooler dog |
09:30:52 | PMunch | Ah, well Nimble certainly has issues, but they asked about the benefits :P |
09:30:53 | Amun-Ra | ;P |
09:31:07 | Amun-Ra | ElegantBeef: I see both beefs |
09:31:13 | FromDiscord | <sOkam!> yeah, the validation can be super slow 😔 |
09:31:45 | FromDiscord | <sOkam!> can you import tasks from separate files into .nimble file from a separate file, btw? |
09:31:58 | FromDiscord | <ElegantBeef> Probably |
09:32:05 | PMunch | Well 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:13 | FromDiscord | <Elegantbeef> But amun you dont see both profile pictures |
09:32:22 | Amun-Ra | oh |
09:32:35 | PMunch | And since it's NimScript it might not even be enough to only grab the .nimble file |
09:32:41 | Amun-Ra | that's bc I can see no pictures ;) |
09:32:56 | FromDiscord | <ElegantBeef> Yea but the pictures are my dogs, so you're missing out on free dog images |
09:32:59 | Amun-Ra | I have discord account running somewhere in my tabs tho |
09:33:05 | PMunch | Profile pictures? |
09:33:05 | FromDiscord | <ElegantBeef> Imagine passing up on free dog images |
09:33:08 | Amun-Ra | :P |
09:33:13 | * | Amun-Ra is more of a cat person ;) |
09:33:27 | FromDiscord | <ElegantBeef> Aw you're drain bamaged |
09:33:31 | Amun-Ra | :P |
09:33:32 | FromDiscord | <sOkam!> cats are best |
09:33:40 | PMunch | ~---O |
09:33:45 | PMunch | ^ ^ |
09:33:49 | Amun-Ra | ElegantBeef: but I can appreciate having dogs… I just travel too much |
09:33:51 | PMunch | There, an image of a dog |
09:34:01 | PMunch | Kinda messed up the legs.. |
09:34:10 | FromDiscord | <ElegantBeef> It just looks like a sperm pmunch |
09:34:11 | Amun-Ra | …and one don't have to walk out the cat <: |
09:34:26 | PMunch | @Elegantbeef, yeah.. |
09:34:27 | FromDiscord | <sOkam!> it looks like a dog collar. actually fitting 😄 |
09:34:28 | FromDiscord | <ElegantBeef> Eh i like walking my dogs, but it's too cold + too much snow for them |
09:34:47 | FromDiscord | <ElegantBeef> They're quite small rats |
09:34:49 | FromDiscord | <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:07 | FromDiscord | <ElegantBeef> `seq.setlen(seq.high)` |
09:35:13 | FromDiscord | <ElegantBeef> or `discard seq.pop()` |
09:35:48 | FromDiscord | <xoich (xoich)> thanks @\_discord\_145405730571288577\:t2bot.io |
09:35:49 | FromDiscord | <ElegantBeef> TIL delete can take a slice |
09:36:10 | FromDiscord | <Elegantbeef> Silly gitter users |
09:36:29 | FromDiscord | <Elegantbeef> Just use matrix already |
09:37:17 | * | azimut joined #nim |
09:38:51 | PMunch | @Elegantbeef, what dogs do you have? |
09:39:12 | FromDiscord | <Elegantbeef> A jack russell terrier, and a westie pug mix |
09:39:17 | PMunch | I mean technically they are using Matrix :P |
09:39:28 | FromDiscord | <Elegantbeef> In the most round about way |
09:39:50 | FromDiscord | <Elegantbeef> It still does cursed things like sending codeblocks as html |
09:41:39 | FromDiscord | <Elegantbeef> To quickly spam pictures of them |
09:41:43 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1068465819845132288/image.png |
09:42:18 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1068465966389923991/image.png |
09:42:25 | FromDiscord | <Elegantbeef> Now uhh that nim code eh |
09:43:02 | Amun-Ra | nice |
09:44:51 | FromDiscord | <flajr> sent a code paste, see https://play.nim-lang.org/#ix=4mk1 |
09:45:11 | FromDiscord | <Elegantbeef> Congrats |
09:48:42 | * | azimut quit (Quit: ZNC - https://znc.in) |
09:49:24 | * | azimut joined #nim |
09:56:22 | FromDiscord | <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:39 | FromDiscord | <Phil> Generally nimble tasks are pretty slick though, I agree. I do typically put the flags inside of the task though ^^ |
09:58:31 | FromDiscord | <flajr> Thank you for reference! |
10:22:18 | FromDiscord | <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:51 | FromDiscord | <Phil> Sets the Nim command that should be continued with after this Nimscript has finished. |
10:28:23 | FromDiscord | <sOkam!> ah kk |
10:28:49 | FromDiscord | <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:43 | Amun-Ra | can you add custom post-build actions too? |
10:30:11 | FromDiscord | <Phil> Like, compile then do stuff? |
10:30:14 | Amun-Ra | yes |
10:30:31 | FromDiscord | <Phil> I mean, you can define a second task that executes the first and then does stuff |
10:30:38 | Amun-Ra | ah, right |
10:31:13 | FromDiscord | <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:30 | FromDiscord | <Phil> All of these are seperate tasks that I execute in one larger "summary" task |
10:33:51 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mkm |
10:35:01 | Amun-Ra | ah, so execs act like task chain |
10:35:51 | FromDiscord | <Phil> execs are basically just "execute this in a shell and explode if it fails" |
10:36:22 | FromDiscord | <Phil> I basically replaced any and all shell scripts I have with nimble tasks |
10:36:56 | FromDiscord | <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:21 | FromDiscord | <Phil> (edit) "downloading" => "scripts for downloading/replacing" |
10:39:27 | PMunch | @Elegantbeef, those are some nice looking dogs |
10:40:54 | FromDiscord | <hotdog> sent a code paste, see https://paste.rs/ew1 |
10:41:11 | FromDiscord | <hotdog> It is slightly better as the compiler will catch missing tasks/changed names etc |
10:41:52 | FromDiscord | <hotdog> IIRC it’s e.g enabledevTask() etc |
10:46:34 | PMunch | @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:44 | FromDiscord | <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:20 | FromDiscord | <Phil> JS backend? @hotdog |
11:19:21 | FromDiscord | <Ntsékees> I suspect that, in spite of `nre` being successfully compiled, its dependency `libpcre.so` is not? |
11:19:36 | FromDiscord | <Phil> libpcre.so is a compiled library |
11:19:44 | FromDiscord | <Phil> That is a C library to be precise |
11:20:01 | FromDiscord | <Phil> What it's complaining about is that it either can't find or can't load that library |
11:20:34 | FromDiscord | <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:06 | FromDiscord | <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:15 | FromDiscord | <Ntsékees> I've compiled using emcripted, a clang-like backend but that compiles to WASM (through C) |
11:21:21 | FromDiscord | <Ntsékees> (edit) "emcripted," => "emcripten," |
11:21:59 | FromDiscord | <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:30 | Amun-Ra | emscripten can compile to pure js too |
11:37:30 | Amun-Ra | I mean not exactly pure, asm.js |
11:49:26 | FromDiscord | <Ntsékees> I'll have to try out JSRE instead of PCRE, hopefully it's not excessively different in behavior… |
11:53:14 | Amun-Ra | I 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:37 | FromDiscord | <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:27 | FromDiscord | <Hourglass [She/Her]> Wouldn't #webdev count? |
13:31:32 | Amun-Ra | it may be too hermetic for #webdev |
13:45:30 | * | ltriant joined #nim |
13:50:24 | * | ltriant quit (Ping timeout: 260 seconds) |
14:12:26 | FromDiscord | <Phil> Eh, I'd count it. It's ultimately still about web-technology, even if used in a different context |
14:12:45 | FromDiscord | <Phil> ~~Still doesn't mean I can help any there though~~ |
14:29:45 | FromDiscord | <auxym> sent a code paste, see https://paste.rs/byT |
14:30:33 | FromDiscord | <Phil> I... think? I haven't tried tbh |
14:31:21 | FromDiscord | <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:45 | FromDiscord | <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:36 | FromDiscord | <auxym> ah, too bad |
14:44:10 | FromDiscord | <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:39 | FromDiscord | <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:00 | FromDiscord | <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:12 | FromDiscord | <spooky> hi, how i can copy an file with nim ? |
16:25:16 | FromDiscord | <rakgew> hi @spooky\: there would be `os.copyFile` in↵https://nim-lang.org/docs/os.html#copyFile%2Cstring%2Cstring |
16:25:37 | FromDiscord | <spooky> thank |
16:26:12 | * | piertoni joined #nim |
16:27:53 | piertoni | hi 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:12 | piertoni | Seems I have found: `getEnv` and `putEnv` and also `envPairs` |
16:41:22 | FromDiscord | <System64 ~ Flandre Scarlet> About NimScript, is it possible to copy all files in a directory? |
17:01:38 | piertoni | I Guess you can use `proc copyDir(source, dest: string)` for that |
17:01:59 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @piertoni "I Guess you can": Gotta try |
17:03:16 | piertoni | I am not sure (never using nimscript) but Is part of nim std/os, so probably is implemented also in nimscript |
17:03:29 | FromDiscord | <System64 ~ Flandre Scarlet> Thanks! It works! |
17:03:57 | piertoni | cheers! :smile |
17:04:52 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mmn |
17:07:49 | piertoni | what you mean by "execute both at once"? |
17:08:19 | FromDiscord | <System64 ~ Flandre Scarlet> I want to compile for Windows and Emscripten by defining the 2 flags |
17:11:13 | FromDiscord | <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:38 | piertoni | Scarlet you want to compile for two platforms at once? Like launching the process twice? Don't know... |
17:13:21 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @piertoni "Scarlet you want to": yeah, compiling for Windows, then for Emscripten |
17:14:43 | piertoni | Stupid 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:47 | FromDiscord | <System64 ~ Flandre Scarlet> Or good old batchfile |
17:16:47 | piertoni | if nimscript allows subprocess you could write like: |
17:16:48 | piertoni | execShellCmd("nim c mysource.nim --flags for win") |
17:16:48 | piertoni | execShellCmd("nim c mysource.nim --flags for emscripten") |
17:17:45 | piertoni | Reading documentation is just "exec" like: |
17:17:46 | piertoni | exec "git clone https://github.com/nim-lang/nimble.git nimble" |
17:18:04 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright |
17:18:27 | piertoni | check documentation at https://nim-lang.org/docs/nims.html |
17:19:43 | piertoni | particularly the part `Standalone NimScript` |
17:20:14 | * | piertoni quit (Quit: Client closed) |
17:21:57 | FromDiscord | <System64 ~ Flandre Scarlet> This is interesting |
17:22:39 | arkanoid | a lot of forking of status-nim repos from nim-lang user is happening |
17:26:53 | FromDiscord | <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:31 | FromDiscord | <gibson> If I read that carefully, it's only for Nim code, not the generated C. |
17:52:22 | FromDiscord | <auxym> @System64 ~ Flandre Scarlet check out `selfExec` in nimscript |
17:52:28 | FromDiscord | <@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:00 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @piertoni "execShellCmd("nim c mysource.nim --flags": execShellCmd doesn't work |
17:53:03 | FromDiscord | <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:48 | FromDiscord | <auxym> In reply to @System64 "execShellCmd doesn't work": https://nim-lang.org/docs/nimscript.html#selfExec%2Cstring |
17:54:12 | FromDiscord | <gibson> In reply to @auxym "os:any is mostly used": Seems perfect for making something so vanilla that it's cross-platform? |
17:56:23 | FromDiscord | <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:32 | FromDiscord | <@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:15 | termer | PMunch_ I saw your video on keyboard firmware in nim |
18:44:22 | termer | Have you ever looked at QMK? |
18:45:08 | PMunch_ | termer, yes I looked at QMK before I started the project |
18:45:37 | * | PMunch_ is now known as PMunch |
18:46:09 | PMunch | Part of the reason why I started the project was because of how hard and confusing QMK was to configure |
18:46:09 | termer | did you decide it wasn't for you? It piqued my interest since I recently got a programmable keyboard |
18:46:54 | termer | aha |
18:47:09 | PMunch | I 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:27 | PMunch | But also the orthogonal layout and the fact that I use Dvorak |
18:47:35 | termer | oh yeah it probably would be weird with that |
18:47:42 | PMunch | So it was a lot of stuff I would have to configure and fiddle with |
18:48:19 | PMunch | And 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:48 | termer | It'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:59 | PMunch | Turns out that the end result was not only smaller, but could also deliver really low latency, which was cool |
18:49:06 | termer | I've long been interested in using Nim for microcontrollers but haven't dealt with it |
18:49:18 | PMunch | Honestly it's pretty much a perfect fit |
18:49:28 | termer | you couldn't use the stdlib, right? |
18:50:04 | PMunch | All 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:20 | termer | Yeah that's why I was interested in using it for that |
18:50:25 | PMunch | So you get a nice clean API, and basically raw native performance |
18:50:35 | PMunch | You can definitely use the stdlib |
18:50:49 | termer | stdlib seems like a minefield of heap allocations |
18:51:05 | termer | especially with exceptions |
18:51:25 | PMunch | I 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:35 | PMunch | It wasn't written for microcontrollers but ran just fine |
18:52:02 | PMunch | True, you do have to be careful, and for very small chips it definitely doesn't make sense |
18:52:11 | FromDiscord | <Nilts> In reply to @@thatrandomperson5-6310e3b26da03 "> Nim just cannot": any one know why this would happen? (thatrandomperson is my gitter alt) |
18:52:21 | termer | Someone did nim on arduino |
18:52:27 | termer | which must've been a real pain |
18:52:33 | PMunch | I've done that as well :P |
18:52:43 | PMunch | Smallest chip I've done is Attiny85 |
18:52:57 | termer | how much memory was in that? |
18:53:00 | PMunch | 6Kb of available program memory, and 512bytes of SRAM |
18:53:24 | termer | wow |
18:53:32 | termer | that's even worse than arduino uno |
18:53:47 | PMunch | If I port V-USB to Nim (or bind it) I think I should be able to run my keyboard firmware on it |
18:54:10 | PMunch | The Arduino Uno has heaps and bounds of memory :P |
18:54:17 | termer | 2kb |
18:54:36 | PMunch | 32Kb program memory though |
18:54:43 | termer | oh yeah that's not as much of an issue |
18:54:44 | PMunch | Have you seen this by the way? https://ratel.peterme.net/ |
18:54:58 | FromDiscord | <huantian> ngl i'm suprised how many keyboard firmwares there are |
18:55:01 | termer | the problem is that the arduino C++ library allocates all strings on the stack |
18:55:04 | termer | which is hilariously terrible |
18:55:05 | FromDiscord | <huantian> like QMK, ZMK, KMK |
18:55:07 | termer | so it chomps memory |
18:55:15 | termer | lemme see PMunch |
18:55:33 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Great. Now im getting undefined symbol after i fixed that↵(@Nilts) |
18:55:33 | PMunch | Yeah, string stuff will quickly burn through your memory |
18:56:01 | termer | you had to use a macro to do it stack allocated |
18:56:07 | termer | which made everything messy |
18:56:31 | PMunch | termer, the Nim code works similarly unfortunately |
18:56:51 | PMunch | That p"Hello world" is an example of a string being allocated in the progmem section |
18:56:52 | termer | at least I don't have to wrap everything in String() in Nim lol |
18:56:59 | PMunch | Haha, true |
18:57:02 | termer | can' |
18:57:05 | termer | t believe they used C++ |
18:57:10 | termer | what a horrible choice, why OOP on a microcontroller |
18:57:16 | termer | C isn't that hrad |
18:57:17 | termer | *hard |
18:57:21 | PMunch | OOP used to rule the world |
18:57:58 | PMunch | It's kind of the same with projects like MicroPython or Espruino |
18:58:09 | PMunch | People just want to do things the way they are used to |
18:58:20 | termer | I'm young enough to where I missed the rise of the OOP craze |
18:58:28 | termer | but I started out writing in Java |
18:58:46 | termer | and ever since I got a taste of pure procedural and functional, I never wanted to go back |
18:59:03 | PMunch | In 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:29 | PMunch | @Nilts, what exactly are you trying to do? |
18:59:48 | termer | I was going to use C on my Pico but async in C would be a nightmare |
19:00:29 | PMunch | Haha, low level C async can be a pain |
19:00:49 | termer | yeah, best to do macro stuff for that |
19:00:50 | PMunch | But once you get used to it it's actually not *that* bad |
19:01:00 | termer | not insurmountable |
19:01:07 | termer | but still bad |
19:01:18 | termer | I'm also not an experienced C programmer and would likely mess something up |
19:01:37 | termer | I've only ever written C with hardware interrupts on a microcontroller |
19:01:40 | termer | never done async with it |
19:01:58 | FromDiscord | <Nilts> In reply to @PMunch "<@910899642236043294>, what exactly are": use std/httpclient |
19:02:06 | termer | in any case, for a memory-efficient async impl, you couldn't use asyncdispatch |
19:02:10 | termer | that and it uses the selectors library |
19:02:42 | PMunch | @Nilts, isn't that just import and then compile with `-d:ssl`? |
19:02:51 | termer | the famous -d:ssl |
19:03:22 | PMunch | termer, true, I actually wonder how that has been implemented in Nim already for microcontrollers |
19:03:33 | PMunch | I think Nesper might have support for it, or the Pico library |
19:03:38 | FromDiscord | <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:42 | termer | nesper? |
19:04:01 | PMunch | termer, ESP32 in Nim: https://github.com/elcritch/nesper |
19:04:19 | FromDiscord | <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:30 | termer | supports asynchttpserver, huh |
19:04:52 | PMunch | My 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:24 | termer | Ratel only supports AVR right now, right? |
19:05:37 | termer | if it had Pico support that would be awesome, but right now there's only a library that wraps the Pico stdlib |
19:05:45 | termer | https://github.com/EmbeddedNim/picostdlib |
19:05:46 | FromDiscord | <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:09 | PMunch | @Nilts, openssl-1.1.1 is probably your issue |
19:06:17 | PMunch | Isn't the current one 3.1 something? |
19:06:44 | PMunch | Hmm I seem to have 3.0.7, and that works fine |
19:07:21 | FromDiscord | <Nilts> In reply to @PMunch "<@910899642236043294>, openssl-1.1.1 is probably": where does it say openssl 1.1.1? |
19:07:49 | FromDiscord | <huantian> are you on nix? why are you trying to manually do this |
19:07:58 | PMunch | @Nilts, in the message you sent? |
19:08:14 | FromDiscord | <Nilts> In reply to @PMunch "<@910899642236043294>, in the message": oh, i see it now |
19:08:39 | PMunch | termer, yes currently it's AVR only |
19:08:45 | FromDiscord | <huantian> you should just need `openssl` with `nim` in your build inputs |
19:08:48 | termer | aw man |
19:08:58 | FromDiscord | <huantian> you don't need to manually pass anything |
19:09:16 | PMunch | But 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:52 | FromDiscord | <huantian> also I swear that the `nim` derivation already has `openssl` as a `buildInput` so you shouldn't need to do anything |
19:10:02 | termer | RPI Pico and normal RPI are very different |
19:10:06 | termer | I never liked normal Raspberry Pis |
19:10:15 | PMunch | @Nilts, it's actually really easy to use. Not sure what your specific issue is, but it's usually not this hard |
19:10:17 | termer | most people who buy them don't do anything with them |
19:10:32 | PMunch | I've got one which controls everything in my house :P |
19:10:51 | FromDiscord | <Nilts> In reply to @huantian "also I swear that": i'm not using nim derivation. At all |
19:10:54 | PMunch | But I won mine in a competition, so I guess I don't fall in the category of people who bought them :P |
19:11:21 | FromDiscord | <Nilts> (edit) "all" => "all, since it is outdated." |
19:11:25 | FromDiscord | <huantian> In reply to @not logged in "i'm not using nim": what |
19:11:31 | termer | to be fair, I bought my Pico several months ago and haven't gotten around to it |
19:11:35 | termer | but at least I have a purpose for it |
19:11:57 | FromDiscord | <huantian> https://media.discordapp.net/attachments/371759389889003532/1068609322747179018/Screenshot_2023-01-27_121140.png |
19:12:16 | PMunch | Yeah I've got two Picos in a drawer.. |
19:12:30 | termer | LOL |
19:12:41 | termer | so many toys, such little time |
19:12:46 | FromDiscord | <huantian> picos are neat might use one for my next keeb |
19:13:10 | FromDiscord | <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:36 | FromDiscord | <huantian> iirc older nixpkgs version called it `openssl_3` |
19:13:50 | * | azimut quit (Ping timeout: 255 seconds) |
19:13:59 | FromDiscord | <Nilts> In reply to @huantian "iirc older nixpkgs version": testing that one |
19:14:01 | FromDiscord | <huantian> but if you're coding you should probably be getting your packages from nixos unstable |
19:14:19 | FromDiscord | <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:31 | FromDiscord | <huantian> you probably should at least update to nixos 22.11 |
19:14:33 | * | azimut joined #nim |
19:14:57 | FromDiscord | <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:50 | FromDiscord | <Nilts> sent a code paste, see https://paste.rs/mE1 |
19:18:10 | FromDiscord | <Nilts> wait, i think i fixed it |
19:19:50 | FromDiscord | <Nilts> changed it to `{ pkgs ? import <nixpkgs> {} }:` and it still installs version 1.1.1 |
19:22:26 | FromDiscord | <gibson> In reply to @auxym "maybe, not sure. In": Sadly this doesn't work for the MS/VS build tooling. |
19:24:06 | FromDiscord | <huantian> In reply to @not logged in "how would i change": change the link to the latest versin |
19:25:49 | FromDiscord | <Nilts> In reply to @huantian "change the link to": what link? |
19:26:21 | PMunch | By the way termer, we also have a #nim-embedded channel |
19:30:12 | FromDiscord | <@thatrandomperson5-6310e3b26da03> 4d2b37a84fad1091b9de401eb450aae66f1a741e?↵(@Nilts) |
19:30:49 | termer | PMunch Will join, thanks |
19:31:37 | FromDiscord | <auxym> In reply to @gibson "Sadly this doesn't work": Huh? I thought you said you were compiling on linux |
19:32:15 | FromDiscord | <huantian> In reply to @not logged in "what link?": https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gzthis one |
19:32:20 | FromDiscord | <huantian> (edit) "https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gzthis" => "https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gz this" |
19:32:43 | FromDiscord | <huantian> change the huge hash to the hash of hte latest commit in nixpkgs/unstable |
19:33:08 | FromDiscord | <huantian> (edit) "nixpkgs/unstable" => "`nixpkgs-unstable`" |
19:33:19 | FromDiscord | <huantian> <https://github.com/NixOS/nixpkgs/tree/nixpkgs-unstable> |
19:35:02 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Did that, but still says 1.1.1↵(@huantian) |
19:44:12 | FromDiscord | <pmp-p> @Ntsékees your dlopen trouble is in unicodedb |
19:44:45 | FromDiscord | <pmp-p> from unicodedb/decompositions_data.nim |
19:47:07 | FromDiscord | <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:24 | FromDiscord | <huantian> hm maybe send over your entire shell.nix and I'll try it |
19:50:42 | FromDiscord | <@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:01 | FromDiscord | <pmp-p> @Ntsékees it's somewhere in there i guess https://github.com/nitely/nim-unicodedb/tree/master/src/unicodedb |
19:52:42 | FromDiscord | <pmp-p> @nitely maybe ? |
19:53:14 | FromDiscord | <Ntsékees> unicodedb/decompositions_data.nim contains just a huge autogenerated table of numbers |
19:53:36 | FromDiscord | <pmp-p> it is loading libpcre dynamically somewhere |
19:55:16 | FromDiscord | <pmp-p> sent a code paste, see https://play.nim-lang.org/#ix=4mn4 |
19:56:40 | FromDiscord | <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:50 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Does it work? |
19:58:55 | FromDiscord | <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:19 | FromDiscord | <pmp-p> at least fixing the soname ... |
20:00:14 | FromDiscord | <pmp-p> ( which is probably same as android that does not use versinning either for libs ) |
20:00:21 | FromDiscord | <pmp-p> (edit) "versinning" => "versionning" |
20:01:18 | FromDiscord | <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:20 | FromDiscord | <pmp-p> for emscripten it should go directly to libpcre.so with full path |
20:02:57 | FromDiscord | <pmp-p> since preloaded .so are just swapped in FS file table |
20:03:05 | FromDiscord | <pmp-p> (edit) "since preloaded .so are just swapped in FS file table ... " added "for the original file" |
20:03:53 | FromDiscord | <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:16 | FromDiscord | <Ntsékees> https://github.com/genotrance/nimpcre |
20:05:25 | FromDiscord | <Ntsékees> I wonder if this could be helpful.. |
20:06:03 | FromDiscord | <pmp-p> most likely sounds exactly what i wanted to do |
20:07:39 | FromDiscord | <pmp-p> but i would not know how to set that up for emscripten/wasi toolchain i just started Nim recently |
20:08:39 | FromDiscord | <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:13 | FromDiscord | <Ntsékees> NRE is based on PCRE1? 🤔 |
20:25:31 | FromDiscord | <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:58 | FromDiscord | <etra> because, nim would use pointers whenever a structure is bigger than 24 bytes iirc? |
20:26:10 | om3ga | dear all, why that happens https://play.nim-lang.org/#ix=4mn9 |
20:27:59 | FromDiscord | <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:15 | FromDiscord | <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:26 | FromDiscord | <huantian> `nim -v` gives me `1.6.10` |
20:28:56 | FromDiscord | <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:04 | FromDiscord | <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:54 | FromDiscord | <Ntsékees> Maybe all I need is the pcre.h and a static pcre library to link |
20:34:48 | FromDiscord | <pmp-p> In reply to @Ntsékees "NRE is based on": yeah that too is not clear it should have been libpcre2 |
20:35:23 | FromDiscord | <pmp-p> (edit) "libpcre2" => "libpcre2.so.xxx" |
20:35:43 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1068630405995053187/image.png |
20:35:57 | FromDiscord | <Ntsékees> If it were PCRE2 it would have been pcre2.h |
20:36:03 | FromDiscord | <pmp-p> indeed |
20:36:30 | FromDiscord | <pmp-p> i should try to build it then |
20:37:44 | FromDiscord | <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:10 | FromDiscord | <Elegantbeef> There are pure nim regex libraries |
20:38:20 | FromDiscord | <Elegantbeef> Not that i condone using regex for anything but searches 😄 |
20:38:45 | FromDiscord | <pmp-p> how can we replace the default one with pure one when targeting emscripten/wasi |
20:39:05 | FromDiscord | <Elegantbeef> `nimble install nimregex` `import nimregex` |
20:39:33 | FromDiscord | <Elegantbeef> Ah sorry it's called `regex` in the package directory |
20:39:40 | FromDiscord | <Elegantbeef> https://github.com/nitely/nim-regex |
20:40:10 | FromDiscord | <Elegantbeef> There is also https://github.com/khchen/tinyre |
20:40:42 | FromDiscord | <pmp-p> "tiny" sounds better for a wasm build |
20:41:33 | * | lumo_e joined #nim |
20:43:17 | FromDiscord | <rakgew> nim-regex worked pretty well for me and has become my goto. |
20:45:40 | FromDiscord | <Ntsékees> I hope it has UTF8 support |
20:45:55 | FromDiscord | <Ntsékees> i.e. not matching half of a codepoint for multi-byte codepoints |
20:47:44 | FromDiscord | <Ntsékees> @pmp-p: I confirm that the `regex` module works in my WASM test |
20:48:54 | FromDiscord | <Ntsékees> I'll check if it works properly with UTF8 |
20:50:35 | FromDiscord | <Ntsékees> It seems to work as expected |
20:50:50 | FromDiscord | <pmp-p> so what is the test code now ? |
20:50:54 | FromDiscord | <pmp-p> i'd like to test on wasi |
20:51:17 | FromDiscord | <Ntsékees> OK, wait a little |
20:54:37 | FromDiscord | <tfp> do u think nim compiled into wasm modules is a reasonable approach for scripting |
20:54:57 | FromDiscord | <Elegantbeef> Yes |
20:55:02 | FromDiscord | <Elegantbeef> That's my only focus for wasm |
20:55:03 | FromDiscord | <tfp> i can kind of see it working but i also see a slew of potential issues |
20:55:25 | FromDiscord | <tfp> mm |
20:55:56 | FromDiscord | <tfp> like how would i maintain binary compatibility between the two worlds |
20:56:17 | FromDiscord | <Elegantbeef> force the implementation of `getSize` for types |
20:56:49 | FromDiscord | <tfp> well i suppose it's kind of the same issues u run into with any dll? |
20:56:54 | FromDiscord | <Elegantbeef> Yes |
20:57:31 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1068635890794111057/test_1.zip |
20:57:38 | FromDiscord | <Elegantbeef> It's all resolvable, suggest packed annotations on types, have size procs, make a nice interop bridge |
20:57:38 | FromDiscord | <Ntsékees> ↑ @pmp-p |
20:57:56 | FromDiscord | <Elegantbeef> I personally do suggest using the wasm3 runtime since it's so portable |
20:58:00 | FromDiscord | <tfp> i am using wasm3 ye |
20:58:03 | FromDiscord | <tfp> with ur bindings i think |
20:58:10 | FromDiscord | <Elegantbeef> Ah nice |
20:58:31 | FromDiscord | <tfp> i am curious how i could say, enforce that dependencies are the same version |
20:58:46 | FromDiscord | <tfp> or binary compatibility of say a struct between the wasm environment and the host |
20:58:50 | FromDiscord | <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:57 | FromDiscord | <Elegantbeef> Since wasm doesnt have structs you really cannot |
20:59:11 | FromDiscord | <Elegantbeef> It doesnt have type information you need to provide it |
20:59:30 | FromDiscord | <tfp> it just has a host block of memory that u can read from right |
20:59:36 | FromDiscord | <tfp> it really doesn't seem ideal for scripting |
20:59:49 | FromDiscord | <tfp> but it should work yeah |
21:00:00 | FromDiscord | <Elegantbeef> I think it's better than the alternatives |
21:00:05 | FromDiscord | <tfp> i agree kind of |
21:00:26 | FromDiscord | <Elegantbeef> Locking down to a specific language is awful |
21:00:34 | FromDiscord | <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:40 | FromDiscord | <Elegantbeef> It removes some amount of ABI mismatch |
21:00:42 | FromDiscord | <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:53 | FromDiscord | <pmp-p> In reply to @Ntsékees "↑ <@334096250897170433>": looks ok for wasi |
21:01:04 | FromDiscord | <Elegantbeef> Well the nice thing is that with intelligent interop the host doesnt need types that match |
21:01:15 | FromDiscord | <Elegantbeef> But it of course needs to emit types that match |
21:01:48 | FromDiscord | <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:00 | FromDiscord | <Elegantbeef> Partially yea |
21:02:21 | FromDiscord | <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:38 | FromDiscord | <tfp> what do u think about ORC between the two environments |
21:02:41 | FromDiscord | <tfp> no reason it shouldn't work, right? |
21:02:48 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/hostToWasm/tests/thosttowasm.nim#L14-L18 converts a Nim string to cstring inside wasm |
21:03:03 | FromDiscord | <Elegantbeef> You dont use ORC across the boundry |
21:03:12 | FromDiscord | <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:22 | FromDiscord | <Ntsékees> (edit) "initialy" => "initially" |
21:03:22 | FromDiscord | <Elegantbeef> So yes there is no issue, they're two seperate systems |
21:03:31 | FromDiscord | <Elegantbeef> Infact a `ref T` in wasm is just a `int32` on the host |
21:03:45 | FromDiscord | <tfp> well i mean like |
21:03:51 | FromDiscord | <tfp> if i had a ref T in wasm, and i wanted to access it in host world |
21:03:59 | FromDiscord | <tfp> i could just cast it as a pointer and everything would work so long as u have no data race |
21:04:05 | FromDiscord | <tfp> and the binary layout was the same |
21:04:15 | FromDiscord | <Elegantbeef> Yes and since wasm is single threaded there is no issue |
21:04:34 | FromDiscord | <pmp-p> In reply to @Ntsékees "I initially had a": yeah same for python that's why i made pygbag |
21:04:40 | FromDiscord | <tfp> i think wasm has threads now |
21:04:46 | FromDiscord | <tfp> maybe not, not sure |
21:05:05 | FromDiscord | <Elegantbeef> Anyway yea should be fine |
21:05:29 | FromDiscord | <Elegantbeef> I really need to think of some test project that is feasible and fun to write code for |
21:05:37 | FromDiscord | <Elegantbeef> aiarena is a dead end even though it'd be fun in the end |
21:06:05 | FromDiscord | <tfp> ill have to play around with it |
21:06:31 | FromDiscord | <tfp> the sources u linked are helpful |
21:07:12 | FromDiscord | <tfp> what are u using to compile nim to wasm? |
21:07:40 | FromDiscord | <Elegantbeef> emcc but i might consider clang |
21:07:47 | FromDiscord | <pmp-p> and me https://github.com/WebAssembly/wasi-sdk/releases |
21:08:57 | FromDiscord | <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:50 | FromDiscord | <@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:35 | FromDiscord | <Ntsékees> regex.match doesn't implement isSome to check if the match succeeded |
21:22:32 | FromDiscord | <nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnk |
21:23:00 | FromDiscord | <Ntsékees> Apparently I should use doAssert |
21:25:24 | * | PMunch quit (Quit: leaving) |
21:29:22 | FromDiscord | <Elegantbeef> @nqeron\: code? |
21:29:45 | FromDiscord | <Elegantbeef> Do not know if this benefits me personally↵(@pmp-p) |
21:31:21 | FromDiscord | <nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mno |
21:31:38 | FromDiscord | <nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnp |
21:31:45 | FromDiscord | <nqeron> is in a larger code block |
21:32:05 | FromDiscord | <nqeron> that I've recently modified and this bit isn't working anymore |
21:32:41 | FromDiscord | <Elegantbeef> What library? |
21:32:47 | FromDiscord | <nqeron> sent a code paste, see https://play.nim-lang.org/#ix=4mnq |
21:33:18 | FromDiscord | <nqeron> In reply to @Elegantbeef "What library?": I'm using nim-regex |
21:34:09 | FromDiscord | <nqeron> This was all working before I tried coercing Move and Spread to have a generic type that used a static uint |
21:34:27 | FromDiscord | <tfp> anyone know a freetype wrapper for nim that's good |
21:35:24 | FromDiscord | <Elegantbeef> Yea this likely is an issue with generic's plus this macro |
21:35:31 | FromDiscord | <Elegantbeef> Try it with a generic procedure if it fails make an issue |
21:35:39 | FromDiscord | <Elegantbeef> tfp i'd say "just use pixie" but ymmv |
21:35:47 | FromDiscord | <pmp-p> In reply to @tfp "anyone know a freetype": what about sdl_ttf ? |
21:35:47 | FromDiscord | <tfp> i want features like hinting and stuff, i doubt pixie supports it |
21:36:12 | FromDiscord | <tfp> let's see aaa |
21:36:36 | FromDiscord | <pmp-p> In reply to @tfp "i want features like": that's is not freetype alone, it's the combo harfbuzz+freetype |
21:36:48 | FromDiscord | <pmp-p> (edit) "that's" => "that" |
21:37:48 | FromDiscord | <tfp> well hinting is like the cursed TTF feature that requires a bytecode interpreter and stuff |
21:38:09 | FromDiscord | <tfp> it's a FT feature i don't think it's only related to typesetting |
21:38:45 | FromDiscord | <tfp> ah yeah i think kerning is to typesetting as hinting is to rendering |
21:39:20 | FromDiscord | <tfp> unless you mean pixie uses harfbuzz + freetype but to me it looks like a pure nim implementation |
21:41:58 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> I dont think it does hinting |
21:42:25 | FromDiscord | <Elegantbeef> And yes it's pure nim |
21:43:08 | FromDiscord | <tfp> ugh i'll deal with typesetting later |
21:43:18 | FromDiscord | <tfp> for now just focused on glyph rendering with freetype i guess |
22:03:29 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mny |
22:04:09 | FromDiscord | <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:49 | FromDiscord | <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:52 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> Stack based inheritance is limited and icky |
22:07:16 | FromDiscord | <sOkam!> i see |
22:13:05 | FromDiscord | <sOkam!> sent a code paste, see https://paste.rs/3e3 |
22:13:24 | FromDiscord | <Elegantbeef> If you access a ref all the fields are shared of that ref |
22:13:26 | FromDiscord | <Elegantbeef> That's the point of a ref |
22:13:32 | FromDiscord | <Elegantbeef> It's a heap allocated data type |
22:13:53 | FromDiscord | <sOkam!> k so then i don't need the inner data as ref i understand |
22:14:37 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mnC |
22:15:25 | FromDiscord | <Elegantbeef> Refs are pointers |
22:15:36 | FromDiscord | <sOkam!> yep! i get it for standard variables |
22:15:45 | FromDiscord | <Elegantbeef> So it's the same semantics |
22:15:55 | FromDiscord | <sOkam!> the confusing part is from values inside ref objects |
22:17:31 | FromDiscord | <Elegantbeef> There is no difference between that and↵`var a = MyData(a: 100)` |
22:17:33 | FromDiscord | <Elegantbeef> It's the exact same semantics |
22:18:04 | FromDiscord | <sOkam!> kk ✍️ |
22:18:07 | FromDiscord | <Elegantbeef> Like i said there is no difference |
22:18:07 | FromDiscord | <Elegantbeef> A ref points to a block of memory |
22:18:15 | FromDiscord | <Elegantbeef> Just as `ptr` does in the above `MyData(a: 100)` |
22:19:30 | FromDiscord | <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:59 | FromDiscord | <jtv> Not really different from the programmer's perspective, but can have some implications like cache locality |
22:20:00 | FromDiscord | <Elegantbeef> What? |
22:20:19 | FromDiscord | <Elegantbeef> There is no difference between `var a = 100` or `var a = MyData(a: 100)` |
22:20:36 | FromDiscord | <jtv> No, that's not what I'm asking |
22:20:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mnE |
22:20:48 | FromDiscord | <Elegantbeef> a ref object is a pointer |
22:20:57 | FromDiscord | <jtv> Right, and a non-ref isn't |
22:20:58 | FromDiscord | <Elegantbeef> A non ref object is not a pointer |
22:21:02 | FromDiscord | <jtv> So if you have: |
22:21:11 | FromDiscord | <Elegantbeef> Objects are stack allocatable |
22:21:15 | FromDiscord | <Elegantbeef> So they are inline |
22:21:28 | FromDiscord | <Elegantbeef> Refs are not stack allocatable so are just pointers with the object on the heap |
22:21:46 | FromDiscord | <jtv> sent a code paste, see https://play.nim-lang.org/#ix=4mnF |
22:21:50 | FromDiscord | <jtv> I'd expect a to be a pointer |
22:21:59 | FromDiscord | <Elegantbeef> Which it is |
22:21:59 | FromDiscord | <jtv> But if you take off the ref, I would expect it NOT to be |
22:22:07 | FromDiscord | <Elegantbeef> Which it is |
22:22:14 | FromDiscord | <jtv> THAT is what I was saying. |
22:22:33 | FromDiscord | <Elegantbeef> Why are we EMPHASISING words |
22:22:38 | FromDiscord | <jtv> It's semantically not different, but has implications like in the case cache locality |
22:22:49 | FromDiscord | <jtv> Because I roll like that! |
22:22:53 | FromDiscord | <Elegantbeef> Of course |
22:23:01 | FromDiscord | <Elegantbeef> But if you use ref you should know the implications |
22:23:11 | FromDiscord | <Elegantbeef> You should use tools understanding what they do |
22:23:15 | FromDiscord | <jtv> He didn't understand, was trying to help clarify 🙂 |
22:25:05 | FromDiscord | <Elegantbeef> Refs are just easiest understood as pointers that always point to heap allocated data |
22:41:08 | * | ltriant joined #nim |
22:51:46 | FromDiscord | <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:57 | FromDiscord | <Leftbones> What's the use case for Natural vs uint? |
23:14:48 | FromDiscord | <Elegantbeef> Nim's signed integers have under and overflow checks, it's unsigned do not, Natural is a subrange of an integer |
23:15:14 | FromDiscord | <Elegantbeef> This means it has overflow checks, compile time checks, and runtime checks to ensure it doesnt exit `0..high(int)` |
23:24:56 | FromDiscord | <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:38 | FromDiscord | <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:31 | FromDiscord | <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:55 | FromDiscord | <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:29 | FromDiscord | <sOkam!> @voidwalker https://github.com/lihf8515/parseini know of this? might be useful |
23:59:50 | FromDiscord | <sOkam!> its basically parsecfg, but without a lot of its nonsense |