00:06:48 | * | jmdaemon joined #nim |
00:35:23 | FromDiscord | <auxym> can closure procs be exportc'd and called from C? Or is the calling convention incompatible? |
00:36:29 | FromDiscord | <Elegantbeef> They can be called from C if you pass the environment |
00:38:37 | FromDiscord | <auxym> hm. I'd have to have a look at the codegen. but I'll try to use something else I think |
00:39:10 | FromDiscord | <Elegantbeef> Yea it's not really designed for it but it can 😄 |
00:39:33 | FromDiscord | <Elegantbeef> Remember that closure generation turns the procedure into a `(env, proc)` internally |
00:54:51 | * | jmdaemon quit (Ping timeout: 252 seconds) |
00:58:25 | * | jmdaemon joined #nim |
01:20:07 | * | jmdaemon quit (Ping timeout: 252 seconds) |
01:39:15 | * | jmdaemon joined #nim |
01:44:48 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
02:40:15 | FromDiscord | <0xʎ> anyone know if there are updated llvm bindings for nim? |
02:40:19 | FromDiscord | <nqeron> if I have a generic type like `Bitmap[N: static uint] = distinct uint64` - how do I create a function that can modify that type, e.g. ` proc set[N](bitmap: var Bitmap[N], x: uint, y: uint) =↵ assert(x < N)↵ assert(y < N)↵ bitmap = bitmap bitor(1'u64 shl ((N - 1 - x) + y N)) ` |
02:42:33 | * | argonica joined #nim |
02:43:59 | * | argonica quit (Remote host closed the connection) |
02:47:37 | * | argonica joined #nim |
02:51:12 | * | argonica quit (Remote host closed the connection) |
02:51:51 | * | argonica joined #nim |
02:59:45 | FromDiscord | <ringabout> In reply to @Isofruit "On that sidenote, anyone": The warning is supposed to be removed from recent Nim devel version. |
03:00:41 | FromDiscord | <0xʎ> how can I use LLVM with nim? I wass looking online but can't find any updated bindings |
03:01:02 | FromDiscord | <0xʎ> if not, is there any binding generator I can use ? |
03:02:01 | FromDiscord | <Elegantbeef> https://github.com/arnetheduck/nlvm/tree/master/llvm |
03:02:31 | FromDiscord | <0xʎ> oh I see |
03:02:45 | FromDiscord | <0xʎ> I was looking at that repo but dismissed it thinking it was just an LLVM-based compiler impl for nim |
03:02:56 | FromDiscord | <0xʎ> but it turns out they obviously need to use LLVM bindings themselves, genius |
03:03:13 | FromDiscord | <0xʎ> I can see they're generated via `c2nim`. Thanks, that's all I needed to know |
03:56:17 | * | azimut quit (Ping timeout: 255 seconds) |
03:57:18 | * | azimut joined #nim |
04:11:05 | * | argonica quit (Quit: Leaving) |
04:24:15 | * | krux02 quit (Remote host closed the connection) |
04:35:10 | * | arkurious quit (Quit: Leaving) |
05:01:31 | * | jmdaemon joined #nim |
05:05:11 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4m8C |
05:10:55 | * | argonica joined #nim |
05:45:55 | FromDiscord | <kots> passing `handles = @[]` to `dump` removes the "%TAG..." line, and `tagStyle = tsNone` removes the "!n!system:seq..." stuff |
06:09:49 | FromDiscord | <sOkam!> tysm! i found the handles one, but i didn't see the tagstyle. tyty 🙏 |
06:53:10 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=4m8N |
07:11:50 | FromDiscord | <Elegantbeef> `result = newSeqOfCap[float](amount)` |
07:11:54 | FromDiscord | <Elegantbeef> We did it we're faster now! |
07:14:49 | FromDiscord | <Elegantbeef> @that_dude guess i should do this given it was 20 minutes old 😄 |
07:16:54 | FromDiscord | <that_dude> That didn't actually change the speed |
07:17:12 | FromDiscord | <Elegantbeef> Are you not running -d\:release? |
07:17:16 | FromDiscord | <that_dude> I am |
07:17:35 | FromDiscord | <that_dude> What can I give you that would help? |
07:17:50 | FromDiscord | <Elegantbeef> The full benchmark code |
07:18:10 | FromDiscord | <Elegantbeef> Or are we really just calling `random` procs and adding to a seq |
07:18:34 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=4m8Q |
07:18:39 | FromDiscord | <that_dude> sorry for the dumps |
07:18:52 | FromDiscord | <Elegantbeef> bleh useless output |
07:18:53 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=4m8R |
07:19:40 | FromDiscord | <that_dude> Now that I look at it, nimprof seems to only log calls, not time spent |
07:21:07 | FromDiscord | <Rika> Yes |
07:21:10 | FromDiscord | <Rika> That is correct |
07:21:13 | FromDiscord | <that_dude> I just wanted to compare this to their python and julia counterparts that I was given in class |
07:21:33 | FromDiscord | <Elegantbeef> 1.53s vs 1.55s by changing that to `newSeqOfCap` |
07:21:39 | FromDiscord | <Elegantbeef> So that's not the expensive overhead |
07:21:57 | FromDiscord | <Elegantbeef> `sum(mapIt())` |
07:23:11 | FromDiscord | <that_dude> Upon seeing my mistake with nimprof, that's kinda what I thought next, but I'm not sure what I could do other than make it more verbose |
07:23:23 | FromDiscord | <ShalokShalom> You know how it will perform on his device? |
07:23:25 | FromDiscord | <Elegantbeef> "more verbose" |
07:23:28 | FromDiscord | <Elegantbeef> You mean faster |
07:23:45 | FromDiscord | <that_dude> Well doesn't manually mapping it in a loop make it faster? |
07:23:52 | FromDiscord | <Elegantbeef> Yes |
07:24:02 | FromDiscord | <that_dude> My first goal was to try to keep it as close as possible to the original source |
07:24:03 | FromDiscord | <Elegantbeef> You arent allocating a second sequence |
07:24:39 | FromDiscord | <that_dude> I guess that makes sense |
07:24:49 | FromDiscord | <Elegantbeef> you should be using `applyIt(copySign(1.0, it))` |
07:24:53 | FromDiscord | <Elegantbeef> then just `sum` on that |
07:26:10 | FromDiscord | <Elegantbeef> That drops around 50ms on my machine |
07:26:17 | FromDiscord | <Elegantbeef> So now whatelse can we fix |
07:26:37 | FromDiscord | <Elegantbeef> Dont really see anything |
07:26:39 | FromDiscord | <Elegantbeef> Damn |
07:26:45 | * | argonica quit (Remote host closed the connection) |
07:26:50 | FromDiscord | <Rika> Or combine them by using fold |
07:27:06 | * | argonica joined #nim |
07:27:30 | FromDiscord | <Elegantbeef> Dont see how fold helps, though i dont use sequtils |
07:27:46 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=4m8T |
07:27:47 | * | byanka joined #nim |
07:27:47 | FromDiscord | <that_dude> it actually became slower |
07:27:59 | FromDiscord | <Elegantbeef> It certainly did not |
07:28:28 | FromDiscord | <that_dude> nevermind that was just some randomness |
07:28:32 | FromDiscord | <that_dude> but it's not faster |
07:28:51 | FromDiscord | <Elegantbeef> Are you using `-d:lto --mm:orc`? |
07:28:54 | FromDiscord | <Elegantbeef> If not you should |
07:29:15 | * | byanka__ quit (Ping timeout: 248 seconds) |
07:29:16 | FromDiscord | <that_dude> I'm using nim v1.9.1 I thought that already has orc by default |
07:29:19 | FromDiscord | <that_dude> I'll try lto tho |
07:29:25 | FromDiscord | <Elegantbeef> It does use orc by default |
07:30:11 | FromDiscord | <Rika> In reply to @Elegantbeef "Dont see how fold": Can combine the apply and the sum into one |
07:30:35 | FromDiscord | <that_dude> Lto worked and made it as fast as python/numpy now. 1.8s -> 1.5s |
07:30:47 | FromDiscord | <Rika> Can you show the command you use to compile |
07:30:55 | FromDiscord | <Elegantbeef> Can even do `-d:danger` if you want it faster |
07:30:59 | FromDiscord | <that_dude> I haven't used fold yet, looking into it |
07:31:13 | FromDiscord | <Rika> foldl specifically |
07:31:19 | FromDiscord | <Elegantbeef> Now aside from changing how this program operates we're near the limit of what i can say |
07:31:29 | FromDiscord | <that_dude> `nim c -d:release -d:lto test_random_walk.nim` |
07:31:55 | FromDiscord | <that_dude> Danger actually didn't actually change the speed back when I tested it |
07:34:02 | FromDiscord | <Elegantbeef> Without any funky tricks this is basically the best you can do |
07:34:03 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4m8U |
07:34:12 | FromDiscord | <Elegantbeef> But this changes how the code was written to something that makes sense |
07:39:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4m8V |
07:40:01 | FromDiscord | <that_dude> Just queued into game, I'll mess with golfing later |
07:40:06 | FromDiscord | <that_dude> thanks for the help guys |
08:36:11 | * | azimut quit (Ping timeout: 255 seconds) |
08:46:25 | * | argonica quit (Quit: Leaving) |
09:50:16 | * | kenran joined #nim |
09:51:02 | FromDiscord | <New> Hiho! Is here some way for catching console input from program and do smthg like "echo" with our variable to it? |
10:01:58 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m9v |
10:03:40 | FromDiscord | <Phil> (this is for the choosenim image of nim, trying to slim it down, already got rid of manually compiling openssl that was there before and removed like 3 packages, as well as removed unnecessary tmp files) |
10:05:09 | FromDiscord | <leetnewb> Is it possible that minideb is missing an expected dep that gets pulled in? |
10:06:43 | FromDiscord | <Phil> I mean, a lot of dependencies get pulled in for gcc, but that's unavoidable |
10:06:53 | FromDiscord | <Phil> The image is pointless without gcc so eh |
10:09:00 | FromDiscord | <leetnewb> 200MB for gcc alone. ca-certificates is probably another 80-100. I dunno, 500 seems not out of the ballpark. |
10:09:25 | FromDiscord | <Phil> May have underestimated gcc then, because dang |
10:10:12 | FromDiscord | <Phil> the only way ca-certificates is in there so that curl with https works, I wonder if I can slim that down somehow |
10:11:37 | FromDiscord | <leetnewb> +200MB from a fresh debian bullseye adding those packages |
10:12:09 | FromDiscord | <Phil> bullseye? Wut? |
10:12:52 | FromDiscord | <leetnewb> I spun up an lxc container to check the size of adding openssl curl xz-utils ca-certificates gcc |
10:16:18 | FromDiscord | <Phil> Yeah I don't think I can dump ca-certificates =/ |
10:17:40 | FromDiscord | <leetnewb> fwiw, the entire container is 420M before, so figure 620M after adding gcc openssl etc. I don't think there's much/anything to shave from the 500MB you had originally. |
10:18:44 | FromDiscord | <Phil> Wait, 420M?↵I'm seeing 78MB and 500MB respectively https://media.discordapp.net/attachments/371759389889003532/1067750362745937940/image.png |
10:19:33 | FromDiscord | <leetnewb> I built an lxd container from canonical's image repo. It isn't 1:1. |
10:19:39 | FromDiscord | <leetnewb> Used it as a proxy |
10:20:01 | FromDiscord | <Phil> Alrighty, the vast discrepancy for starting points just confused me |
10:20:17 | FromDiscord | <Phil> I guess the GCC install pulls in so much extra shit that the endpoints lead up not differing too much |
10:20:30 | FromDiscord | <Phil> (edit) "lead" => "end" | "endup not differing too much ... " added "in size" |
10:21:59 | FromDiscord | <Phil> In reply to @New "Hiho! Is here some": Best I can do you is getting the return-code.↵Though I think one of the execCmd thingies also grabs all strings, though no guarantees for that.↵But then again, if you're executing stuff from the shell, you can just pipe the output into a file as normal |
10:25:11 | FromDiscord | <Phil> In reply to @New "Hiho! Is here some": https://nim-lang.org/docs/osproc.html#execProcess%2Cstring%2Cstring%2CopenArray%5Bstring%5D%2CStringTableRef%2Cset%5BProcessOption%5D↵There that might work |
10:42:01 | FromDiscord | <Phil> So I wanted to try out compiling in the container |
10:42:29 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m9D |
10:43:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m9E |
11:14:58 | * | xet7 quit (Quit: Leaving) |
11:24:33 | Zevv | you seem to be missing your libc header files |
11:31:04 | * | jmdaemon quit (Ping timeout: 260 seconds) |
11:42:35 | FromDiscord | <Require Support> noob question, im trying to create a DLL that will be loaded by me exe. The function that is defined in the DLL takes in a parameter of an `object`. Do I define this `object` in both the exe and the DLL ? 🤔 |
11:49:03 | FromDiscord | <demotomohiro> You can do `type FooObj = object ..` in foo.nim and `import foo` in both dll and exe. |
11:51:34 | FromDiscord | <Require Support> nice, was just making sure before I actually tried it |
11:59:44 | * | argonica joined #nim |
12:37:23 | * | kenran quit (Remote host closed the connection) |
12:42:14 | PMunch | Hmm, anyone know what would be the best way to compare an object between two runs of my code? I'm trying to figure out why nimlsp and nimsuggest are giving different results for the same file. |
12:45:54 | FromDiscord | <Phil> Write it to a json file and compare the json |
12:46:12 | FromDiscord | <Phil> Assuming you care for the data content mostly |
12:51:04 | PMunch | Hmm, I guess I might be able to convert to json |
12:52:42 | FromDiscord | <Phil> I wonder how you'd async stuff with sqlite |
12:53:47 | PMunch | https://www.sqlite.org/asyncvfs.html |
12:57:24 | FromDiscord | <Phil> sent a long message, see http://ix.io/4ma7 |
12:57:32 | FromDiscord | <jmgomez> Can the compiler API be used to generate a string (at comp time) with the fields that a type may have? |
12:57:51 | FromDiscord | <Phil> a type may have? |
12:58:00 | FromDiscord | <Phil> Like, that's every character combination possible |
12:58:19 | FromDiscord | <jmgomez> the C/C++ that it would generate |
12:58:59 | FromDiscord | <Phil> Ah, so the scenario is basically you do have an explicit type, you just want all the fields on it and that should also separate all permutations of an object variant? |
12:59:05 | PMunch | @Phil, it seems basically like you just tell SQLite to load the async stuff, then run their event loop in a background thread and go about using SQLite as normal |
12:59:33 | FromDiscord | <Phil> In reply to @PMunch "<@180601887916163073>, it seems basically": So using sqlite normally with extra steps!:... shouldn't that be returning promises or sth? |
12:59:46 | FromDiscord | <Phil> Well, Futures in nim |
13:00:17 | PMunch | Hmm, good point |
13:00:28 | FromDiscord | <jmgomez> sent a code paste, see https://paste.rs/wjd |
13:01:13 | FromDiscord | <jmgomez> In reply to @Isofruit "Ah, so the scenario": Im doing an implementing of virtual functions and dont want to rewrite a generator for the fields |
13:01:20 | FromDiscord | <Rika> `With asynchronous I/O, write requests are handled by a separate thread running in the background. This means that the thread that initiates a database write does not have to wait for (sometimes slow) disk I/O to occur. The write seems to happen very quickly, though in reality it is happening at its usual slow pace in the background.` |
13:01:23 | FromDiscord | <jmgomez> (edit) "implementing" => "implementation" |
13:01:24 | FromDiscord | <Phil> Oh, you want the field names how they'll be declared in the generated code because they have these weird NII prefixes |
13:01:42 | FromDiscord | <Rika> you technically dont need a future for a write |
13:02:00 | FromDiscord | <Rika> since theres usually no (important) result |
13:02:15 | FromDiscord | <jmgomez> In reply to @Isofruit "Oh, you want the": I dont really care about the names, I dont want to generate all of it myself (specially because they are a lot of cases) |
13:03:05 | FromDiscord | <Phil> In reply to @Rika "since theres usually no": So basically you're just establishing an earlier step where you hand the task off and then return from there, sort of |
13:03:29 | FromDiscord | <Phil> While the tasks you handed off then proceeds in the background |
13:03:56 | FromDiscord | <jmgomez> (edit) "they" => "there" |
13:10:46 | PMunch | No async reads though? |
13:11:00 | FromDiscord | <Phil> Pretty much, and even then that module is deprecated |
13:11:42 | FromDiscord | <Phil> What SQLITE suggests instead is using their "write ahead log" (WAL) mode, which means you're still doing the same code as before, but now it works slightly different |
13:12:08 | FromDiscord | <Phil> sent a long message, see http://ix.io/4maa |
13:14:15 | FromDiscord | <Rika> yeah |
13:15:11 | FromDiscord | <Phil> But basically you're still writing synchronous code and you're not writing any "Execute when value is there later" procs, you're just changing the way you use sqlite |
13:16:34 | FromDiscord | <Rika> i believe you just dont generally use "traditional" async with sqlite |
13:16:42 | FromDiscord | <Rika> you prolly really have to use a different thread |
13:17:42 | FromDiscord | <Nerve> Is there any way to store columns of unequal length in a DataMancer dataframe? |
13:17:47 | FromDiscord | <Nerve> (edit) "DataMancer" => "datamancer" |
13:22:08 | FromDiscord | <albassort> In reply to @Rika "i believe you just": Do it in a coroutine like an adult |
13:22:32 | FromDiscord | <albassort> Not in nim though, I still need to wrap libAco |
13:22:34 | FromDiscord | <albassort> One Day |
13:25:37 | FromDiscord | <Rika> In reply to @albassort "Do it in a": ~~i barely use nim nowadays~~ |
13:28:50 | FromDiscord | <Phil> Hmm so assuming I have 3 super expensive SQL queries to separate sqlite files in a row, the way to deal with them is basically maintaining my own threadpool to do this stuff async? |
13:28:59 | FromDiscord | <Phil> Not that I have any idea how that'd even look like |
13:30:13 | FromDiscord | <Phil> Wait, treeform's implementation looks almost trivial |
13:49:37 | * | xet7 joined #nim |
13:50:52 | FromDiscord | <Phil> You innocently want to run your nimforum installation with the nim 1.6.10 compiler |
13:51:14 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mah |
13:51:23 | FromDiscord | <Phil> (edit) "run" => "compile" |
13:57:29 | FromDiscord | <albassort> In reply to @Rika "~~i barely use nim": :( same |
13:57:54 | FromDiscord | <albassort> At my job I'm in C sharp and SQL and JS |
13:58:01 | FromDiscord | <albassort> The second I get home I'm in C |
13:58:04 | FromDiscord | <albassort> Pain |
13:58:07 | FromDiscord | <civbag> In reply to @Rika "~~i barely use nim": why? |
13:58:12 | FromDiscord | <Rika> moving on to elixir |
13:58:19 | FromDiscord | <albassort> But elixir isn't even that cool |
13:58:38 | FromDiscord | <Rika> ? does it seem like i care about what you think |
13:59:09 | FromDiscord | <albassort> Is it bad that I'm unironically crying |
13:59:20 | FromDiscord | <civbag> In reply to @Rika "moving on to elixir": i see |
13:59:36 | FromDiscord | <Rika> sorry to put it so bluntly |
13:59:47 | FromDiscord | <albassort> I was joking lol |
13:59:57 | FromDiscord | <civbag> In reply to @albassort "Is it bad that": pat pat |
14:00:02 | FromDiscord | <albassort> I was trying to maybe hint you to tell me some things you might like about it |
14:00:46 | FromDiscord | <Rika> ive found the philosophy interesting |
14:00:55 | FromDiscord | <Rika> you already most likely have heard of it |
14:01:42 | FromDiscord | <albassort> I've seen it, and I've looked at the code. It's functional but I don't know if it has any killer features over say Haskell |
14:01:47 | FromDiscord | <civbag> elixir actually has a good track record in business |
14:02:44 | FromDiscord | <albassort> Oh yeah I remember elixir |
14:02:52 | FromDiscord | <albassort> I actually suggested something related to elixir to my company, I feel like it would be a good fit for some things we do |
14:03:06 | FromDiscord | <albassort> Obviously, not really practical nobody Is there very much a serious software developer besides a few people |
14:03:21 | FromDiscord | <Rika> i mean a good amount of people would probably say that the use of BEAM is a killer feature |
14:03:24 | FromDiscord | <albassort> (edit) "there" => "here is" |
14:09:28 | Zevv | I also moved to elixir for some time, mostly for the beam |
14:10:09 | Zevv | but i found interfacing with the rest of my ecosystem too cumbersome. the beam is like a different OS, I'm no longer 'on linux' |
14:36:44 | FromDiscord | <ShalokShalom> In reply to @albassort "I've seen it, and": The runtime and OTP is what makes it so special |
14:37:07 | FromDiscord | <ShalokShalom> You barely see that on the language level, at least as someone who is new to the language ☺️ |
14:38:31 | FromDiscord | <ShalokShalom> In reply to @albassort "At my job I'm": You could theoretically convince them, that they allow you to use fsharp instead 😉 |
14:40:02 | FromDiscord | <albassort> Nah |
14:40:11 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/4mat |
14:40:15 | FromDiscord | <Phil> I am fascinated you guys appear to have such liberal language environments. Over here its basically "For tech stack adoption the entire team must speak it and the benefit must be massive" |
14:40:36 | FromDiscord | <Phil> (edit) "massive"" => "massive. Otherwise not worth the effort"" |
14:40:44 | FromDiscord | <albassort> That's exactly how it is here |
14:40:48 | FromDiscord | <albassort> There is no liberalness |
14:40:48 | FromDiscord | <ShalokShalom> Most tech spaces are as you describe |
14:41:16 | FromDiscord | <albassort> You can't write your code in cobol because you then become a liability |
14:42:39 | FromDiscord | <Rika> im still having difficulty not programming defensively lmao |
14:42:41 | FromDiscord | <ShalokShalom> I was half way joking and half way playing to the fact, that most dotnet shops are so desperate for programmer, that they actually accept F# devs as well |
14:42:41 | FromDiscord | <ShalokShalom> Startups are basically the only place, at which adventures are allowed. |
14:42:43 | FromDiscord | <ShalokShalom> Jet.com is one of them. Fully build on FSharp and got to be the quickest unicorn in the history |
14:42:43 | FromDiscord | <Rika> hard habit to break |
14:43:16 | FromDiscord | <ShalokShalom> In reply to @Rika "hard habit to break": I think its a wonderful opportunity for you 😊 |
14:43:26 | FromDiscord | <Rika> yeah |
14:43:28 | FromDiscord | <Rika> something new |
14:43:46 | FromDiscord | <ShalokShalom> Particularly as someone who comes from a language, that does a lot of things not as bad as the traditional languages |
14:43:57 | FromDiscord | <Rika> wdym |
14:44:16 | FromDiscord | <ShalokShalom> Its not so simple for you, to find something that is really making a difference positively |
14:44:24 | FromDiscord | <ShalokShalom> Since Nim is already a sane language |
14:44:50 | FromDiscord | <Gumbercules> In reply to @ShalokShalom "As Rika already mentioned": Yes you do |
14:44:56 | FromDiscord | <ShalokShalom> From someone's else perspective, a lot of languages and even just changed paradigms would make a big difference |
14:45:00 | FromDiscord | <Tanguy> This project brings BEAM like features to languages that can target WASM: https://lunatic.solutions/ for now only rust & assemblyscript, but someone could do nim bindings for instance (I started to do it but didn't finish) |
14:45:30 | FromDiscord | <ShalokShalom> I know a similar project |
14:45:37 | FromDiscord | <Gumbercules> Just because the VM has a way to restart your processes doesn't mean you stop coding defensively |
14:46:06 | FromDiscord | <ShalokShalom> https://eigr.io/ |
14:46:13 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "Just because the VM": Read again 😄 |
14:46:19 | FromDiscord | <ShalokShalom> Its the standard library |
14:46:22 | FromDiscord | <ShalokShalom> OTP |
14:46:33 | FromDiscord | <Gumbercules> Okay I'm not even going to start |
14:46:44 | FromDiscord | <Gumbercules> I work in Elixir and Erlang professionally |
14:46:54 | FromDiscord | <ShalokShalom> Idiomatic Erlang and Elixir play into your hands |
14:47:00 | FromDiscord | <Tanguy> In reply to @ShalokShalom "https://eigr.io/": Interesting thanks, I'll take a look |
14:47:01 | FromDiscord | <Gumbercules> If you think any of the OTP functionality would work without the VN |
14:47:07 | FromDiscord | <Gumbercules> vm |
14:47:16 | FromDiscord | <Gumbercules> Go ahead and believe that |
14:47:24 | FromDiscord | <ShalokShalom> In reply to @Tanguy "Interesting thanks, I'll take": On a first look, lunatic seems a bit more approachable |
14:47:30 | FromDiscord | <ShalokShalom> But have to look deeper |
14:47:40 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "If you think any": I dont say that |
14:47:50 | FromDiscord | <ShalokShalom> I said from the start its BEAM plus OTP |
14:48:07 | FromDiscord | <Gumbercules> Okay then why do you nitpick my statement? |
14:48:08 | FromDiscord | <Rika> haiya another argument between you two |
14:48:11 | FromDiscord | <ShalokShalom> You came and said |
14:48:19 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "Just because the VM": This |
14:48:21 | FromDiscord | <Gumbercules> Because what you were saying is wrong |
14:48:28 | FromDiscord | <ShalokShalom> Nobody said that 😅 |
14:48:49 | FromDiscord | <Gumbercules> You don't just throw away defensive programming because you're using OTP or a language on beam |
14:49:42 | FromDiscord | <Tanguy> Though the lower you are in the hierarchy, the less you can care |
14:49:45 | FromDiscord | <ShalokShalom> But the architecture and the tools and how you typically write code, aids to that |
14:50:04 | FromDiscord | <Gumbercules> No it leads to recoverability and fault tolerance |
14:50:17 | FromDiscord | <Tanguy> It's not like in nim where any of the 500k+ LoC of your code / compiler can crash the entire thing |
14:50:18 | FromDiscord | <ShalokShalom> Which avoids defensive programming |
14:50:23 | FromDiscord | <ShalokShalom> Or makes it useless |
14:50:30 | FromDiscord | <Tanguy> (nim or any other langage, not attacking nim specifically) |
14:50:41 | FromDiscord | <Gumbercules> It doesn't make your code any safer and a NPE will still crash your process over and over until you do something about it |
14:50:49 | FromDiscord | <Gumbercules> No it doesn't make it uses ugh |
14:50:52 | FromDiscord | <ShalokShalom> In reply to @Tanguy "Though the lower you": In which hierarchy you mean? 🙂 |
14:50:57 | FromDiscord | <Rika> In reply to @Tanguy "It's not like in": i mean if nim actually went into the defect route.... |
14:51:02 | FromDiscord | <Gumbercules> Useless even |
14:51:34 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "It doesn't make your": Who said it automated deals with crashes |
14:51:42 | FromDiscord | <Gumbercules> well it does |
14:51:44 | FromDiscord | <Rika> In reply to @Gumbercules "It doesn't make your": NPE? |
14:51:48 | FromDiscord | <Gumbercules> null pointer exception |
14:51:58 | FromDiscord | <ShalokShalom> If you connect to a host, and loose connection, it will try again |
14:51:59 | FromDiscord | <Gumbercules> that's the point of the supervisors / supervision hierarchy |
14:51:59 | FromDiscord | <Tanguy> In reply to @ShalokShalom "In which hierarchy you": The OTP process tree: https://user-images.githubusercontent.com/4210829/80588480-063c0b00-8a4b-11ea-9df3-48705ea2914f.gif (random example) |
14:52:09 | FromDiscord | <ShalokShalom> In most of the cases, this solves the problem |
14:52:11 | FromDiscord | <Gumbercules> no it won't |
14:52:28 | FromDiscord | <ShalokShalom> Sure, since most connection issues are temporary |
14:52:30 | FromDiscord | <Rika> you can have pointers in elixir? or do you mean in nifs? |
14:52:35 | FromDiscord | <ShalokShalom> And those who are, obviously have to be handled |
14:52:45 | FromDiscord | <ShalokShalom> (edit) "are," => "are not," |
14:53:06 | FromDiscord | <Gumbercules> @Rika if I try to access a field on an object and that object is `nil` - NPE |
14:53:08 | FromDiscord | <Tanguy> In reply to @Rika "i mean if nim": What do you mean? Defects are just one of the way that can happen. Even rust can "panic" in a lot of different ways |
14:53:19 | FromDiscord | <Rika> In reply to @Gumbercules "<@259277943275126785> if I try": oh in that sense |
14:53:29 | FromDiscord | <Gumbercules> @ShalokShalom and OTP / the VM do none of this for you |
14:53:32 | FromDiscord | <Gumbercules> you're talking out of your ass I'm sorry |
14:53:33 | FromDiscord | <Rika> In reply to @Tanguy "What do you mean?": i meant that it would have been worse |
14:53:55 | FromDiscord | <Gumbercules> the VM will allow me to say - supervise this process and have this process responsible for supervising this other process / processes |
14:54:07 | FromDiscord | <Gumbercules> I can set up restart strategies along with that process supervision |
14:54:32 | FromDiscord | <ShalokShalom> @Tanguy I think the platform kinda misses a statically typed language. Yes, there is Gleam and its neat. I would still like to write in something like Elm or F# ↵↵Sadly, the wasm implementation makes GC needed |
14:54:38 | FromDiscord | <Gumbercules> but there is nothing in OTP / BEAM which is going to retry making a DB connection or whatever you're talking about |
14:54:45 | FromDiscord | <ShalokShalom> And that means shipping a runtime |
14:54:58 | FromDiscord | <Gumbercules> I can set up a supervision hierarchy so that if my process trying to make a DB connection crashes, it will be restarted in some way |
14:55:02 | FromDiscord | <Tanguy> In reply to @Gumbercules "<@259277943275126785> if I try": The point isn't that BEAM prevents every bug, it's that "just restarting a small process" can solve a non-negligible percent of the bugs automatically (there was some studies, can't remember the numbers), instead of having to restart the entire program everytime |
14:55:19 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "I can set up": And that's how its implemented usually |
14:55:19 | FromDiscord | <Gumbercules> I believe the statement made was - defensive programming is worthless |
14:55:34 | FromDiscord | <Gumbercules> no it's not, usually people have code that explicitly retries failed connections |
14:55:38 | FromDiscord | <ShalokShalom> In this environment I consider it pointless most of the time |
14:55:43 | FromDiscord | <Gumbercules> because they don't want their client trying to endlessly reconnect to whatever endpoint |
14:55:46 | FromDiscord | <ShalokShalom> And that's kinda the point |
14:55:50 | FromDiscord | <Rika> damn |
14:55:50 | FromDiscord | <Gumbercules> whatever |
14:56:16 | FromDiscord | <Rika> im able to follow the conversation but this is a lot of back and forth so |
14:56:18 | FromDiscord | <Gumbercules> @Rika you still need to program defensively in any programming language |
14:56:25 | FromDiscord | <Gumbercules> Elixir and Erlang are no exception |
14:56:27 | FromDiscord | <Rika> sure its just much reduced |
14:56:30 | FromDiscord | <Gumbercules> not really |
14:56:37 | FromDiscord | <Gumbercules> you are more recoverable |
14:56:41 | FromDiscord | <ShalokShalom> 😅 |
14:56:42 | FromDiscord | <Gumbercules> the language doesn't make you any safer |
14:56:47 | FromDiscord | <Rika> of course |
14:57:18 | FromDiscord | <ShalokShalom> I would say, defensive programming is also different |
14:57:31 | FromDiscord | <Gumbercules> you don't need to worry about getting out of bad state X because the runtime will get you back to state Y |
14:57:31 | FromDiscord | <ShalokShalom> Its not like you would usually do it. |
14:57:40 | FromDiscord | <Gumbercules> but if something in your application state is going to cause you to get back to state X again |
14:57:44 | FromDiscord | <Gumbercules> you're still fucked |
14:57:52 | FromDiscord | <Rika> i understood that from the conversation |
14:58:18 | FromDiscord | <ShalokShalom> And that's a logic error |
14:58:29 | FromDiscord | <Gumbercules> noooo |
14:58:30 | FromDiscord | <ShalokShalom> And nobody said, they shouldn't be handled |
14:58:35 | FromDiscord | <Gumbercules> let's say I parse a file in my process |
14:58:42 | FromDiscord | <Gumbercules> and it returns a deeply nested map of data |
14:58:50 | FromDiscord | <Rika> the thought i have about that is that at least in elixir that wouldnt end my whole webserver unlike maybe nim where i have to make sure i catch it somewhere |
14:58:54 | FromDiscord | <ShalokShalom> In reply to @Tanguy "Though the lower you": And why is that, would you say? |
14:58:55 | FromDiscord | <Gumbercules> and I access a field in that deeply nested object and the parent object of the field is nil |
14:59:09 | FromDiscord | <Gumbercules> it doesn't matter how many times erlang / elixir restarts my process |
14:59:14 | FromDiscord | <Gumbercules> it will crash over and over and over again |
14:59:18 | FromDiscord | <Rika> you'd get stuck in a sort of kinda not really livelock there |
14:59:33 | FromDiscord | <Gumbercules> or once and then stop - it depends on what my supervision strategy is |
14:59:50 | FromDiscord | <Gumbercules> now if I'm coding defensively (which I should be) I'd check to make sure that field doesn't belong to a `nil` object |
15:00:27 | FromDiscord | <Tanguy> In reply to @ShalokShalom "And why is that,": you can care less↵Because of the hierarchy, if something "high up" crashes, every child dies, vs if one child dies, doesn't matter as much |
15:00:47 | FromDiscord | <Gumbercules> this isn't accurate either |
15:01:02 | FromDiscord | <Gumbercules> I mean yes the statement was correct |
15:01:09 | FromDiscord | <Gumbercules> but the level of care depends much more on what the process is actually doing |
15:01:29 | FromDiscord | <Gumbercules> vs where in the hierarchy it finds itself |
15:01:35 | FromDiscord | <Rika> i mean ig i still program defensively in some sense (i'm using typecheck for my program so far) |
15:01:37 | FromDiscord | <Gumbercules> generally root level supervisors do nothing but supervise |
15:02:23 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/4maA |
15:02:45 | FromDiscord | <Rika> ill have to go now |
15:03:52 | FromDiscord | <Gumbercules> In reply to @ShalokShalom "My case is, that": if you set up your supervision hierarchy correctly and architect your application correctly then yes you could make your application automatically recover from this situation gracefully |
15:03:58 | FromDiscord | <Gumbercules> but that's a far cry from saying "defensive programming is useless" |
15:04:16 | FromDiscord | <Gumbercules> I hear this get thrown around way too much in reference to Erlang and Elixir and it's just factually incorrect |
15:05:26 | FromDiscord | <Gumbercules> defensive programming isn't just about handling crashes, it's about trying to avoid them in the first place and not every situation is going to be a recoverable one and in some cases (a lot of cases) you don't want to just let things fail, you want to do something else that you can't model in a supervision tree |
15:05:35 | FromDiscord | <ShalokShalom> @Tanguy they two know each other and there seems to be some integration work going on |
15:06:28 | FromDiscord | <ShalokShalom> In reply to @Gumbercules "defensive programming isn't just": Well, the point is that the founders think very different from you, about how often which mistake happens |
15:06:29 | FromDiscord | <ShalokShalom> https://media.discordapp.net/attachments/371759389889003532/1067822777563893780/image0.png |
15:07:04 | FromDiscord | <Gumbercules> huh? |
15:07:15 | FromDiscord | <Gumbercules> that screenshot doesn't tell me anything |
15:07:42 | FromDiscord | <ShalokShalom> That is in the Eigr Discord, if you happen to be interested |
15:07:54 | FromDiscord | <ShalokShalom> @Gumbercules Its not for you, sorry |
15:08:14 | FromDiscord | <Gumbercules> In reply to @ShalokShalom "Well, the point is": the founders of what? |
15:08:18 | FromDiscord | <ShalokShalom> Erlang |
15:08:24 | FromDiscord | <Gumbercules> source? |
15:08:24 | FromDiscord | <Tanguy> Ok, good to know 🙂 |
15:08:39 | FromDiscord | <ShalokShalom> Joe said, that the most issues happen in a way, that is recoverable |
15:08:45 | FromDiscord | <ShalokShalom> Some of his talks, sorry |
15:09:00 | FromDiscord | <Gumbercules> we can use our logic to figure this out we don't need to cite heresay |
15:09:07 | FromDiscord | <Gumbercules> I already laid out an example |
15:09:11 | FromDiscord | <Gumbercules> which is quite common - parsing a file |
15:09:20 | FromDiscord | <Gumbercules> how are you going to recover from this with restarting a process? |
15:09:56 | FromDiscord | <Gumbercules> if I try to parse an empty file, my process is going to crash and it will continue to crash no matter how many times it is restarted |
15:10:08 | FromDiscord | <Gumbercules> I should probably check to see if the file is empty before parsing it, no? |
15:10:43 | FromDiscord | <Gumbercules> assuming I want to recover.... |
15:13:12 | FromDiscord | <pmp-p> In reply to @Gumbercules "I should probably check": if it's a job queue most likely you would want to notify job sender to either resend (if not using checksum bad!) or notify job submiter etc ... |
15:13:30 | FromDiscord | <Gumbercules> you're assuming a lot of things about my application there |
15:14:16 | FromDiscord | <Gumbercules> but even if that were the case - having the VM restart my process or terminate it isn't going to handle that |
15:14:43 | FromDiscord | <pmp-p> yes it can |
15:15:18 | FromDiscord | <Gumbercules> it could via telemetry... |
15:15:24 | FromDiscord | <Gumbercules> which would be horrible |
15:15:50 | FromDiscord | <pmp-p> error can be a one time condition, that may not repeat itself on relaunch ( eg network or other io error ), terminate is a way to signal an unsolvable condition to notify |
15:16:07 | FromDiscord | <Gumbercules> this is missing my point... |
15:16:45 | FromDiscord | <Gumbercules> if I have a process which is going to parse a file and do something with its content and the file it's trying to parse is unparseable - it doesn't matter how many times my process is started, the file will remain unparseable |
15:17:32 | FromDiscord | <Gumbercules> so I can't just rely on the VM / whatever to fix that situation for me - I need to understand that the file is not parseable and do something about that - I either need to check to see if I can parse the file and then if not have some sort of fallback |
15:17:58 | * | PMunch quit (Quit: Leaving) |
15:18:05 | FromDiscord | <pmp-p> In reply to @Gumbercules "if I have a": usually i augment the time beetween retries, and then failed the job for good |
15:18:20 | FromDiscord | <pmp-p> (edit) "failed" => "fails" |
15:18:25 | FromDiscord | <Gumbercules> yes but I'm not even talking about a distributed application here |
15:18:58 | FromDiscord | <Gumbercules> you could write a simple elixir application that just parses a file and saves some other representation to disk |
15:19:40 | FromDiscord | <Gumbercules> all of the OTP / BEAM magic isn't going to solve the root problem for you, or provide you with a solution for doing anything other than failing and restarting the failed process or terminating it |
15:20:49 | FromDiscord | <Gumbercules> an explicit check to determine whether or not the file is able to be parsed however, will allow you to do something about it other than fail / retry |
15:21:26 | FromDiscord | <Gumbercules> and thus the need for some defensive program if you want your JSON parsing application to be able to do anything when it encounters an empty file other than crash / crash over and over again |
15:21:34 | FromDiscord | <Gumbercules> (edit) "program" => "programming" |
15:23:01 | FromDiscord | <pmp-p> i don't think most people are coding everyday like if they were on some automotive industrial project |
15:23:13 | FromDiscord | <Gumbercules> you need to handle non-exceptional errors |
15:23:17 | FromDiscord | <pmp-p> they don't sanitize their input, deal with it |
15:23:47 | FromDiscord | <Gumbercules> right, you need to deal with it |
15:24:09 | FromDiscord | <Rika> In reply to @Gumbercules "you need to handle": i always thought this was true |
15:24:46 | FromDiscord | <Gumbercules> well that's good |
15:24:51 | FromDiscord | <Rika> when i said its hard to get used to not defensively program, i meant in the sense that i had to deal with every single imaginable issue to just have my program work in some way |
15:25:09 | FromDiscord | <Rika> with elixir, now i can just focus on the errors that matter, i think |
15:25:13 | FromDiscord | <Gumbercules> that wasn't what set me off it was the - defensive programming is useless comment |
15:25:18 | FromDiscord | <Rika> yeah |
15:25:31 | FromDiscord | <Gumbercules> well you still need to think about exceptional failures but you can leverage the VM to help you handle them |
15:25:35 | FromDiscord | <Rika> elixir has :ok/:error for a reason |
15:25:41 | FromDiscord | <Gumbercules> right |
15:25:57 | FromDiscord | <Rika> In reply to @Gumbercules "well you still need": yeah its not just a massive try catch thing |
15:26:10 | FromDiscord | <Gumbercules> what @pmp-p said is a good example or @ShalokShalom - you have some connection you want to attempt to reestablish N number of times |
15:26:25 | FromDiscord | <Gumbercules> you set up a supervisor and supervisor strategy to monitor your process attempting the connection |
15:26:33 | FromDiscord | <Rika> im reading some stuff now and what you said is coming up in them like in here https://devdecks.io/2021-let-it-crash-explained |
15:27:03 | FromDiscord | <Gumbercules> yeah |
15:27:18 | FromDiscord | <Rika> and i dont think ive disagreed before i read it |
15:27:19 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4maP |
15:27:22 | FromDiscord | <Rika> (edit) "and i dont think ive disagreed ... before" added "with it" |
15:27:58 | FromDiscord | <Rika> in what i said above, its the thing where one error in one dude's web request doesnt murder my whole server as an example |
15:28:06 | FromDiscord | <Gumbercules> I'd be remiss if someone came in here and read that about the language and then started writing code that way |
15:28:21 | FromDiscord | <ShalokShalom> We simply disagree about how often such cases do happen |
15:28:23 | FromDiscord | <Gumbercules> In reply to @Rika "in what i said": sure, this is definitely a nice thing |
15:29:21 | FromDiscord | <Gumbercules> In reply to @ShalokShalom "We simply disagree about": well based on my experience at work, recoverable runtime errors that need to be explicitly handled happen quite a bit |
15:29:36 | FromDiscord | <Rika> In reply to @Gumbercules "well based on my": quite a bit feels like a massive understatement |
15:29:40 | FromDiscord | <Gumbercules> more than a bad connection to a database / http server / whatever |
15:29:43 | FromDiscord | <Gumbercules> I mean it is |
15:29:54 | FromDiscord | <Gumbercules> those are the majority of the errors I encounter by far |
15:30:04 | FromDiscord | <Gumbercules> the exceptional stuff which the beam vm can help me with is much rarer |
15:30:20 | FromDiscord | <Rika> its still hard for me to identify when i should handle an error or not, personally |
15:30:31 | FromDiscord | <Gumbercules> I just go with - can I predict this happening |
15:30:40 | FromDiscord | <Gumbercules> can I predict that someone will send me an empty file - certainly |
15:30:49 | FromDiscord | <Gumbercules> can I predict that the database will be down when I make this call or it will time out? nope! |
15:31:19 | FromDiscord | <Rika> im not sure whether its good to keep on having `{:ok, val} = ...` or `case expr do ... {:ok, val } -> ... {:error, reason} -> ...` |
15:31:36 | FromDiscord | <Gumbercules> `case` is the way to go if you can |
15:31:41 | FromDiscord | <Gumbercules> `with` expressions help a lot here too |
15:31:48 | FromDiscord | <Rika> yeah ive used them both |
15:31:59 | FromDiscord | <Rika> idk though, with kinda feels wrong to me |
15:32:18 | FromDiscord | <Rika> since it kinda feels like mixing errors from different functions |
15:32:22 | FromDiscord | <Rika> feels really wrong to me for some reaosn |
15:32:26 | FromDiscord | <Gumbercules> well, generally I use `with` to cache a bunch of values I want to use in a `case` |
15:32:47 | FromDiscord | <Gumbercules> yeah, you can certainly encounter errors using `with` and then not have a great way to handle them |
15:33:04 | FromDiscord | <Gumbercules> but at least the error will be cached in the result, so you can do what you want with it in the body of the `with` |
15:33:17 | * | jmdaemon joined #nim |
15:33:17 | FromDiscord | <Gumbercules> it is pretty dirty though, but sometimes very necessary |
15:34:07 | FromDiscord | <Gumbercules> mostly when you run into limits regarding what invocations you can make in a conditional |
15:34:54 | FromDiscord | <Rika> might be getting into territory where i cant understand here |
15:34:56 | FromDiscord | <Rika> lol |
15:39:16 | FromDiscord | <Gumbercules> probably not - generally most of this stuff is introduced by dependencies, like Ecto, where certain expressions cannot be evaluated in certain contexts |
15:40:05 | FromDiscord | <Phil> Elixir runs on the erlang VM? |
15:40:14 | FromDiscord | <Gumbercules> well the BEAM virtual machine |
15:40:22 | FromDiscord | <Phil> (I have no clue about the entire ecosystem as a disclaimer) |
15:40:32 | FromDiscord | <Phil> (Not even naming of anything) |
15:40:32 | FromDiscord | <Gumbercules> but Erlang was the original language implemented for that VM when Erikson created it |
15:40:42 | FromDiscord | <Gumbercules> the US telecom industry runs on Erlang |
15:40:59 | FromDiscord | <Gumbercules> OTP stands for - open telecom platform |
15:41:00 | FromDiscord | <Phil> The most I know about Erlang is that its very fault tolerant and is very message based |
15:41:23 | FromDiscord | <Gumbercules> yeah it implements the actor model |
15:41:38 | FromDiscord | <Gumbercules> fault tolerance mostly comes from the VM which allows for processes to be supervised |
15:42:16 | FromDiscord | <Gumbercules> OTP provides a bunch of abstractions like https://www.erlang.org/doc/man/gen_server.html |
15:42:33 | FromDiscord | <Gumbercules> https://learnyousomeerlang.com/ is a good place to start if you want to explore more 🙂 |
15:51:31 | FromDiscord | <Rika> ~~be careful the erlang syntax is very funky~~ |
15:52:25 | * | arkurious joined #nim |
15:52:50 | Amun-Ra | hmm, calling proc that was forward declared adds raises: Exception to the callee |
15:53:01 | FromDiscord | <0xʎ> why doesn't nim lsp at least warn me about uninitialized variables? https://media.discordapp.net/attachments/371759389889003532/1067834484860407938/image.png |
15:53:17 | FromDiscord | <0xʎ> when I compile it doesn't warn either, it goes to segfault |
15:53:44 | FromDiscord | <0xʎ> or does it implicitly initialize it to nil ? |
15:53:44 | Amun-Ra | it is initialized, ref are initialized to nil |
15:53:49 | FromDiscord | <0xʎ> I see |
15:54:10 | FromDiscord | <0xʎ> so everything is implicitly initialized including primitives? |
15:54:18 | FromDiscord | <0xʎ> I assume numbers 0, strings "", etc. ? |
15:54:18 | Amun-Ra | unless you add {.noinit.} |
15:54:22 | Amun-Ra | yes |
15:54:23 | FromDiscord | <0xʎ> epic |
15:54:24 | Amun-Ra | all |
15:54:30 | FromDiscord | <pyolyokh> <https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement> |
15:54:31 | FromDiscord | <0xʎ> k I got scared for a sec |
15:54:35 | FromDiscord | <0xʎ> got C vibes for a sec |
15:54:35 | FromDiscord | <0xʎ> lol |
15:54:38 | Amun-Ra | ;> |
15:54:56 | Amun-Ra | var x {.noinit.} x: ModuleRed # C vibes \o/. |
15:54:58 | Amun-Ra | :> |
15:57:13 | * | jmdaemon quit (Ping timeout: 252 seconds) |
15:57:48 | FromDiscord | <Phil> One of the reasons I almost never use var |
15:57:58 | FromDiscord | <Phil> Compiler shouts at you if you try to do that stuff with let |
15:58:32 | FromDiscord | <Rika> Of course because it makes no sense |
15:59:17 | FromDiscord | <rutenl> sent a code paste, see https://play.nim-lang.org/#ix=4mb4 |
15:59:40 | FromDiscord | <Rika> I forgot but I think that’s supposed to work |
15:59:44 | FromDiscord | <Rika> What’s the issue exactly |
15:59:49 | FromDiscord | <huantian> you need a `[]=` proc right? |
16:00:06 | FromDiscord | <Rika> He just says access |
16:00:19 | FromDiscord | <huantian> > so that I can write to it with such syntax |
16:00:19 | FromDiscord | <rutenl> when i try to write an int to it now it says type mismatch |
16:00:30 | FromDiscord | <rutenl> https://media.discordapp.net/attachments/371759389889003532/1067836369042411661/image.png |
16:01:01 | FromDiscord | <Rika> Ah I didn’t read it properly, yeah |
16:01:23 | FromDiscord | <rutenl> so i need a []= proc here? |
16:01:29 | Amun-Ra | rutenl: how about https://play.nim-lang.org/#ix=4mb6 |
16:01:53 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4mb7 |
16:02:37 | FromDiscord | <rutenl> ok i'll try now |
16:02:39 | FromDiscord | <Nerve> How is one supposed to use tables and JSON objects in `nimf`source filters? It seems like they don't allow `[]` dereferencing at all, especially with string keys. |
16:03:29 | FromDiscord | <rutenl> sent a code paste, see https://play.nim-lang.org/#ix=4mbb |
16:03:35 | FromDiscord | <Nerve> If I drop a `$some_table"some"key"]` in a source filter, it just pretty prints the entire table. |
16:03:46 | FromDiscord | <Nerve> (edit) "table." => "table with copious newlines." |
16:03:54 | FromDiscord | <Nerve> (edit) "`$some_table"some"key"]`" => "`$some_table["some"key"]`" |
16:04:02 | FromDiscord | <Nerve> (edit) "`$some_table["some"key"]`" => "`$some_table["some_key"]`" |
16:10:26 | FromDiscord | <Nerve> Think I figured it out, any complex expression like a table access should be in a `${}` container. |
16:32:35 | FromDiscord | <Nerve> However, it does leave quotes around everything. That's annoying. |
17:20:33 | * | azimut joined #nim |
17:27:42 | FromDiscord | <rutenl> I've got a grid type that's just a ref array[16, int], how do I initialize this? a normal non-ref array initialized on its own but i cant figure it out for this `type Grid = ref array[ArrSize, int]` |
17:29:29 | FromDiscord | <rutenl> i had the type as non-ref array[16, int] before, but then I needed var in function parameters and i hear i should just put ref in the original type instead |
17:35:00 | FromDiscord | <Phil> `new(Grid)` |
17:35:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mby |
17:35:43 | FromDiscord | <Phil> Kinda surprised it didn't echo a memory location |
17:36:03 | FromDiscord | <Phil> (edit) "Kinda surprised it didn't echo a memory location ... " added "as well with the "ref" mention of the array" |
17:38:48 | FromDiscord | <rutenl> Nice thanks, couldn't find it in the docs but guess I was searching wrong |
17:39:01 | FromDiscord | <Phil> `new` is generally the keyword to get something allocated on the heap |
17:39:14 | FromDiscord | <Phil> Same as java for example |
17:40:30 | * | azimut quit (Remote host closed the connection) |
17:41:05 | * | azimut joined #nim |
17:50:44 | Zevv | what happened to nimble; my packages go to ~/.nimble/pkg2 but nim can't find my imports |
17:51:36 | Zevv | also, `nimble develop` no longer makes a link for me |
17:54:51 | FromDiscord | <Leftbones> Is there a good way to get something made with nim-ncurses to work on Windows? |
17:55:18 | FromDiscord | <Leftbones> Haven't played with it much yet, I used to use ncurses-windows with Python but even that wasn't always a drop-in solution. |
17:56:50 | Zevv | i have some reasonable okayis experience with a win32 curses compatible lib, let me find that |
17:57:20 | * | azimut quit (Ping timeout: 255 seconds) |
17:57:31 | Zevv | "pdcurses" |
17:57:50 | Zevv | https://pdcurses.org/ |
18:00:23 | * | azimut joined #nim |
18:02:38 | FromDiscord | <Leftbones> Hm okay, so I'd probably have to go about wrapping that myself, I assume |
18:03:00 | FromDiscord | <Leftbones> There's a deprecated nim-pdcurses on GitHub already which could be a good starting point |
18:03:11 | FromDiscord | <Leftbones> I miss the days when I didn't care if something worked on Windows or not lol |
18:04:00 | Zevv | pdcurses api is just a drop in for normal unix curses |
18:04:11 | Zevv | so you should be able to get any wrapper running without too much pain |
18:10:05 | FromDiscord | <Leftbones> Cool. Thanks. |
18:10:39 | FromDiscord | <Leftbones> Still considering forking Illwill and shoe-horning in true color support since the maintainer doesn't seem to have an interest |
18:10:44 | FromDiscord | <Leftbones> That would probably be easier lol |
18:16:31 | Amun-Ra | rutenl: you can always initialize it in any moment via .reset |
18:23:53 | FromDiscord | <Nerve> Does anyone know how to use format specifiers NOT in the `fmt` or `&` macros? I'd like a simple damn proc that transforms some value into another, one that can be called in nimja templates or elsewhere, which crap out on `fmt` and `&` usage. |
18:24:04 | FromDiscord | <Nerve> (edit) "NOT in" => "WITHOUT using" |
18:24:25 | FromDiscord | <Nerve> (edit) "elsewhere, which crap" => "elsewhere; every solution I try craps" |
18:24:43 | FromDiscord | <Nerve> (edit) "another," => "a formatted string," |
18:26:33 | FromDiscord | <Nerve> Ideally I could just do something like `format(3.14159, ".2f") |
18:26:36 | FromDiscord | <Nerve> (edit) "".2f")" => "".2f")`" |
18:26:55 | FromDiscord | <Nerve> (edit) "`format(3.14159," => "`let two_sig_digits = format(3.14159," |
18:27:26 | FromDiscord | <Nerve> (edit) "two_sig_digits" => "two_sig_digits: string" |
18:28:58 | FromDiscord | <Nerve> Does `$` contain this functionality for types that can use specifiers? |
18:34:08 | FromDiscord | <rutenl> In reply to @Amun-Ra "<@298182739289702400>: you can always": nice to know, thx |
18:39:03 | FromDiscord | <Nerve> In reply to @Nerve "Ideally I could just": In fact since DateTime objects do exactly this, why not other values? |
18:44:27 | FromDiscord | <demotomohiro> @Nerve I think `formatValue` procs in strformat module is what you are looking for: https://nim-lang.org/docs/strformat.html#implementation-details↵https://nim-lang.org/docs/strformat.html#formatValue%2Cstring%2CSomeFloat%2Cstring |
18:49:42 | FromDiscord | <nqeron> sent a long message, see http://ix.io/4mbL |
18:50:22 | FromDiscord | <nqeron> (edit) "long message," => "code paste," | "http://ix.io/4mbL" => "https://play.nim-lang.org/#ix=4mbM" |
18:51:11 | FromDiscord | <nqeron> (edit) "https://play.nim-lang.org/#ix=4mbM" => "https://play.nim-lang.org/#ix=4mbN" |
18:52:08 | FromDiscord | <demotomohiro> @nqeron How about to explicity specify unsigned int like`Bitmap[5'u]`? |
18:54:47 | FromDiscord | <demotomohiro> Or define `groups` generic proc with type class like `proc groups(bitmap: Bitmap): GroupIter =`. |
18:57:27 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4mbO |
19:01:19 | FromDiscord | <Nerve> sent a code paste, see https://play.nim-lang.org/#ix=4mbS |
19:01:44 | FromDiscord | <Nerve> Could probably make it a `func` |
19:01:53 | FromDiscord | <Nerve> (edit) "https://play.nim-lang.org/#ix=4mbS" => "https://play.nim-lang.org/#ix=4mbT" |
19:02:20 | FromDiscord | <Nerve> (edit) "https://play.nim-lang.org/#ix=4mbT" => "https://play.nim-lang.org/#ix=4mbU" |
19:03:07 | FromDiscord | <0xʎ> why was the `result` variable quirk chosen to be part of Nim? |
19:03:17 | FromDiscord | <Leftbones> In reply to @michaelb.eth "I’ve been making progress": Nice, I’ll check it out. I’ve never used notcurses but I’ve known about it for a few years. |
19:03:45 | FromDiscord | <0xʎ> In other words, are there any specific benefits that it provides that made the developers decide to add it to the language? |
19:04:13 | FromDiscord | <michaelb.eth> `result` certainly has some pitfalls |
19:04:33 | FromDiscord | <michaelb.eth> https://status-im.github.io/nim-style-guide/language.result.html |
19:06:32 | FromDiscord | <0xʎ> hm |
19:06:39 | Amun-Ra | and some pros, too |
19:06:49 | FromDiscord | <michaelb.eth> true |
19:07:08 | FromDiscord | <0xʎ> are there any pros. apart from the ones outlined there? |
19:10:18 | Amun-Ra | 0xʎ: 'https://play.nim-lang.org/#ix=4mbW' |
19:20:13 | * | genpaku quit (Read error: Connection reset by peer) |
19:21:00 | * | genpaku joined #nim |
19:24:50 | FromDiscord | <demotomohiro> In reply to @Nerve "Here's a function that": But it seems `formatValue` procs exists to just implement `fmt` and `&` macros. |
19:25:19 | * | Jjp137 quit (Ping timeout: 260 seconds) |
19:27:19 | FromDiscord | <jtv> Hmm, speaking of which, strformat needs to tell me when I have a string that is NOT an f string, yet, if it WERE one, would be accessing valid variables (i.e., a warning when I'm probably forgetting fmt). I notice people make this mistake a ton |
19:27:56 | FromDiscord | <Nerve> Why can't `formatValue` also be used for this? Seems to work well, and my func would only add two lines of code to `std/strformat`. |
19:28:48 | FromDiscord | <Nerve> Anyways I made an issue, let's see what the team thinks and if they want to implement it another way or not at all |
19:28:49 | FromDiscord | <Nerve> https://github.com/nim-lang/Nim/issues/21300 |
19:55:15 | FromDiscord | <Elegantbeef> @Nerve\: people generally just use `%` from strutils |
19:57:03 | FromDiscord | <Elegantbeef> You also can just use `formatFloat` with your value |
19:57:26 | FromDiscord | <Nerve> How do you use specifiers with `%`? It's unclear from the documentation. |
19:57:53 | FromDiscord | <Elegantbeef> `"My string $#" % formatFloat(myFloat, ...)` |
19:58:01 | FromDiscord | <Elegantbeef> You dont use specifiers in the string |
19:58:09 | FromDiscord | <Nerve> Ah, I see |
19:58:53 | FromDiscord | <Elegantbeef> I'd say it's more readable cause you can do `percision = 4` or whatever you want |
19:58:53 | FromDiscord | <Elegantbeef> Or even spelled properly 😄 |
19:59:08 | FromDiscord | <Nerve> Okay, I did not stumble across this whole selection of functions, and they're deep in `strutils` |
19:59:19 | FromDiscord | <Nerve> That decision is a head-scratcher |
20:01:03 | FromDiscord | <Elegantbeef> What's a headscratcher? |
20:03:14 | FromDiscord | <Elegantbeef> `strformat` implements the `fmt` and `&` macros only |
20:04:44 | FromDiscord | <Nerve> But no other utilities for formatting strings |
20:05:36 | FromDiscord | <Nerve> Anyways, I think my function is still useful for cases where the "g" specifier is needed, unless there's a proc/function for that. |
20:06:04 | FromDiscord | <Nerve> (edit) "strings" => "strings, many of which are in `strutils`" |
20:06:20 | FromDiscord | <Nerve> (edit) "the "g"" => "the`g`" |
20:06:28 | FromDiscord | <Elegantbeef> `formatFloat` has another argument |
20:06:50 | FromDiscord | <Elegantbeef> It does decimal or scientific notation depending on size |
20:08:21 | FromDiscord | <Nerve> I want to display the 2 or 3 most significant digits in an engineering case where they might be left or right of the decimal, and not in scientific notation |
20:08:28 | FromDiscord | <Nerve> does `formatEng` have what I need? |
20:08:51 | FromDiscord | <sOkam!> is it possible to create a reference to an already existing value, such that when you modify the first value all references are modified with it?↵Is that default behavior, or does creating a ref starts a new separate value instead? |
20:08:54 | FromDiscord | <Elegantbeef> Perhaps |
20:09:12 | FromDiscord | <Elegantbeef> You cannot do that sokam |
20:09:39 | FromDiscord | <Elegantbeef> A reference is heap allocated data, turning a stack value into a reference cannot be done. The only way you can get that semantic is by taking the address of that stack value |
20:10:31 | FromDiscord | <sOkam!> i guess the issue is not using ref in every variable related, then 🤔 |
20:10:40 | FromDiscord | <Hourglass [She/Her]> In reply to @jtv "Hmm, speaking of which,": That sounds weird to implement tbh |
20:10:43 | FromDiscord | <sOkam!> I thought non-ref would be better, but true it should be ref instead |
20:11:32 | FromDiscord | <Elegantbeef> term rewriting macros to the rescue↵(@Hourglass [She/Her]) |
20:12:27 | FromDiscord | <Elegantbeef> I only slightly joke, they could detect a string that would be a valid `fmt` or `&` string, and warning/hint |
20:12:30 | FromDiscord | <demotomohiro> Or use variables outside of procs. When you modify them, other procs see modified values. |
20:12:32 | FromDiscord | <Elegantbeef> But that is quite tedious |
20:13:26 | FromDiscord | <Hourglass [She/Her]> In reply to @Elegantbeef "term rewriting macros to": Hm that sounds annoying but also interesting |
20:15:38 | FromDiscord | <sOkam!> Const don't need to be references, right? |
20:18:51 | FromDiscord | <demotomohiro> Does Nim have something like `memset_explicit`, `memset_s` or `SecureZeroMemory` to clear secret data on memory?↵https://en.cppreference.com/w/c/string/byte/memset |
20:20:25 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#zeroMem%2Cpointer%2CNatural |
20:22:42 | * | PMunch joined #nim |
20:26:14 | FromDiscord | <demotomohiro> @ElegantBeef It seems it calls `memset` in C stdlib that is not securely clear secret on memory as `memset` can be optimized out. |
20:31:11 | FromDiscord | <demotomohiro> It seems I can use `memset_s` as long as backend C compiler supports C11. |
20:54:11 | Amun-Ra | you can also play with emited memset wrapped in -O0 function, attribute __used__ etc. |
20:54:41 | Amun-Ra | and volatile |
20:55:27 | Amun-Ra | btw. there's also explicit_bzero on freebsd |
20:58:47 | FromDiscord | <demotomohiro> @Amun-Ra thank you. It seems currently no portable simple secure memory clear functions. |
20:59:56 | Amun-Ra | yes, there's no portable way |
21:00:39 | FromDiscord | <demotomohiro> `memset_s` is actually not avaliable on my GCC.↵`memset_explicit` might become portable way as it is in C23, but require new C compiler.↵https://www.open-std.org/JTC1/SC22/WG14/www/docs/n2897.htm |
21:01:53 | Amun-Ra | IIRC musl has it |
21:04:23 | Amun-Ra | perhaps I'll make a module for that |
21:05:35 | FromDiscord | <Elegantbeef> It needs to be called 'TheHero' |
21:06:33 | * | argonica quit (Quit: Leaving) |
21:07:17 | FromDiscord | <sOkam!> Can variables inside objects be made immutable? 🤔 |
21:07:27 | FromDiscord | <Elegantbeef> No |
21:07:39 | FromDiscord | <demotomohiro> If you make a module for that, here is secure memory clear C function implementation from argon2 code:↵https://github.com/P-H-C/phc-winner-argon2/blob/master/src/core.c#L134 |
21:07:41 | FromDiscord | <Elegantbeef> If you want that use properties |
21:08:38 | FromDiscord | <sOkam!> ah good idea ✍️ |
21:09:03 | Amun-Ra | I've seen that volatile pointer trick somewhere |
21:10:02 | FromDiscord | <Elegantbeef> Since it's in the same module |
21:10:04 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mce |
21:10:19 | FromDiscord | <Elegantbeef> But if you export `MyType` and import this module you cannot mutate `myType.data` |
21:19:31 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mcf |
21:20:49 | FromDiscord | <Phil> Basically the procs a,b and c are blocking despite being annotated with the async pragma and I don't get why |
21:21:16 | FromDiscord | <michaelb.eth> I’m aware that historically that was a big difference between std and the design of nim-chronos |
21:21:26 | FromDiscord | <michaelb.eth> I guess maybe it’s still a thing? |
21:21:52 | FromDiscord | <Phil> Never used nim chronos |
21:21:58 | FromDiscord | <Phil> Just trying to wrap my head around async here |
21:22:02 | FromDiscord | <Phil> (edit) "async" => "std/async" |
21:22:30 | FromDiscord | <michaelb.eth> https://github.com/status-im/nim-chronos/wiki/AsyncDispatch-comparison |
21:23:05 | FromDiscord | <michaelb.eth> > The order of Future[T] completion callbacks:↵↵Current version of asyncdispatch processes Future[T] completion callbacks in reverse order, but Chronos schedules callbacks in forward order: https://github.com/nim-lang/Nim/issues/7197 |
21:23:22 | FromDiscord | <michaelb.eth> (edit) "callbacks:↵↵Current" => "callbacks:↵>↵> Current" |
21:23:36 | FromDiscord | <michaelb.eth> (edit) "callbacks:↵>↵>" => "callbacks:↵> ↵>" |
21:25:07 | FromDiscord | <Elegantbeef> phil you're using `sleep` |
21:25:17 | FromDiscord | <Elegantbeef> not `waitfor asyncSleep` |
21:25:42 | FromDiscord | <Elegantbeef> Not that it changes the overall behaviour you're using a blocking sleep 😄 |
21:28:38 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mci |
21:28:49 | FromDiscord | <wiga> im not quite sure of what the doc says about importc pragma. Can anyone explains me how this works?(i want to includes windows.h in my proc) |
21:28:56 | FromDiscord | <Phil> This doesn't block now, which is nice.↵But it also doesn't ever execute the callbcaks, which is dumb |
21:29:00 | FromDiscord | <Elegantbeef> I mean you also are discarding the futures |
21:29:07 | FromDiscord | <Phil> Not anymore I'm not |
21:29:30 | FromDiscord | <Phil> I was originally discarding it because the callbacks ran through regardless, now the callbacks aren't even running with it |
21:31:12 | FromDiscord | <Elegantbeef> I mean you are discarding the asyncs afaik |
21:31:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mcj |
21:33:59 | FromDiscord | <Phil> Uuuuugh, so every future must ultimately be waitfor'd |
21:34:20 | FromDiscord | <Phil> And only if you write the code with that in mind does it actually behave as you'd expect |
21:34:43 | FromDiscord | <Phil> If you don't explicitly wait for a future to complete it'll just get GC'd |
21:35:28 | FromDiscord | <Elegantbeef> It's more like if you dont tell the async dispatcher you care about a future it's not scheduled |
21:35:51 | Amun-Ra | wiga: you don't need to include C header in order for importc to work |
21:35:56 | FromDiscord | <Elegantbeef> Also works |
21:35:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mck |
21:36:41 | FromDiscord | <wiga> In reply to @Amun-Ra "<@795785229699645491>: you don't need": cuz yeah uh, it kinda doesnt really work https://media.discordapp.net/attachments/371759389889003532/1067920970049916958/image.png |
21:37:02 | FromDiscord | <wiga> (its not the full proc) |
21:37:03 | FromDiscord | <System64 ~ Flandre Scarlet> Is it possible to define compilation flags directly in a Nim file? |
21:37:19 | FromDiscord | <wiga> In reply to @System64 "Is it possible to": create a config.nims |
21:37:25 | FromDiscord | <Elegantbeef> ImportC isnt c2nim or futhark, it just says "Import this procedure by this name" |
21:37:45 | FromDiscord | <wiga> sent a code paste, see https://play.nim-lang.org/#ix=4mcl |
21:38:06 | Amun-Ra | wiga: you need to import these types |
21:38:08 | FromDiscord | <wiga> In reply to @Elegantbeef "ImportC isnt c2nim or": so i have to use c2nim |
21:38:27 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mcm |
21:38:48 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @wiga "and write in it": Ah alright, thanks↵I want to do some tests with Emscripten↵Is emcc included with Nim or I have to set it up? |
21:38:52 | Amun-Ra | wiga: also, you don't use imoprt that way; you are using importc the wrong way; emit works that way |
21:39:01 | FromDiscord | <auxym> In reply to @wiga "so i have to": you don't have to, you can create the bindings manually if you want to |
21:39:17 | FromDiscord | <Elegantbeef> emcc is not included with Nim |
21:39:22 | FromDiscord | <auxym> c2nim (and furthark) are tools that automate the creation of bindings |
21:39:31 | FromDiscord | <wiga> In reply to @Amun-Ra "<@795785229699645491>: also, you don't": then how do i import ? |
21:39:34 | FromDiscord | <Phil> So in the end it's still just all a chain of futures that end up depending on the final waitFor |
21:39:42 | FromDiscord | <wiga> doc is confusing |
21:39:58 | Amun-Ra | wiga: 'https://play.nim-lang.org/#ix=4mcn' |
21:40:34 | Amun-Ra | importc works like forward function declaraction in C |
21:40:52 | FromDiscord | <wiga> so in my context |
21:40:57 | FromDiscord | <Elegantbeef> You have to import the entire API you want to use in Nim language |
21:41:01 | FromDiscord | <wiga> how do i use the importc correctly |
21:41:07 | FromDiscord | <Elegantbeef> `takeScreenShot` is not a procedure in gdi |
21:41:11 | FromDiscord | <Elegantbeef> So you do not import c that |
21:41:18 | FromDiscord | <wiga> oh wait ok |
21:41:18 | FromDiscord | <Elegantbeef> You import c all the types and procedures you use |
21:41:27 | FromDiscord | <wiga> i just fucking realized |
21:41:42 | FromDiscord | <wiga> the proc name is the actual function from the dll in the prgma |
21:41:44 | FromDiscord | <wiga> (edit) "prgma" => "pragma" |
21:41:59 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/master/src/wasm3/wasm3c.nim here is how one imports |
21:43:01 | FromDiscord | <Elegantbeef> so you'd do `proc takeScreenShot(name: cstring){.importc, dynlib: "gdi32.dll".}` |
21:43:12 | FromDiscord | <Elegantbeef> Assuming gdi32 had that procedure |
21:43:16 | FromDiscord | <Elegantbeef> But given your code i doubt it does |
21:43:26 | FromDiscord | <wiga> no the thing is |
21:43:33 | FromDiscord | <wiga> i want to make a takeScreenshot function |
21:43:36 | FromDiscord | <wiga> i do not have a dll |
21:43:41 | FromDiscord | <Elegantbeef> https://github.com/khchen/winim/blob/a485708a243e2f2acbce783027b8cf8582536414/winim/inc/wingdi.nim but like i said |
21:44:04 | FromDiscord | <wiga> i just want functions from C in the proc |
21:44:19 | FromDiscord | <Elegantbeef> Yes use winim |
21:44:27 | FromDiscord | <Elegantbeef> you do not need to annotate that procedure with anything |
21:44:33 | FromDiscord | <wiga> aight ty |
21:44:37 | FromDiscord | <Elegantbeef> It's a nim procedure, it's not imported |
21:44:49 | FromDiscord | <wiga> which module in winim |
21:44:56 | FromDiscord | <wiga> lean, com or the other? |
21:44:58 | FromDiscord | <Elegantbeef> Perhaps the one i linked |
21:45:07 | FromDiscord | <wiga> ah yes indeed |
21:45:26 | FromDiscord | <Elegantbeef> I dont have a windows PC so i have no clue the windows API |
21:45:38 | FromDiscord | <Elegantbeef> I can only say read winim's manual and the windows manual |
21:45:50 | FromDiscord | <wiga> yes |
21:46:36 | * | Jjp137 joined #nim |
21:47:37 | FromDiscord | <michaelb.eth> In reply to @System64 "Is it possible to": yes, you can put e.g. `{.passC:"...".}` and `{.passL:"...".}` directly into a .nim module |
21:48:37 | FromDiscord | <Elegantbeef> Personallg for compiling to wasm i use https://github.com/beef331/wasm3/blob/master/wasmsources/config.nims which is based off of https://github.com/treeform/nim_emscripten_tutorial |
21:49:09 | FromDiscord | <Elegantbeef> My version is more for wasm3 modules that are not stand alone programs but 'scripts' |
21:49:33 | FromDiscord | <michaelb.eth> In reply to @System64 "Ah alright, thanks I": here's an example: https://github.com/status-im/nim-nat-traversal/blob/master/nat_traversal/miniupnpc.nim#L18-L20 |
21:51:20 | FromDiscord | <michaelb.eth> In reply to @System64 "Is it possible to": here's an example: https://github.com/status-im/nim-nat-traversal/blob/master/nat_traversal/miniupnpc.nim#L18-L20 |
21:56:51 | FromDiscord | <wiga> In reply to @Elegantbeef "My version is more": that sucks there's no windows.h in the winim |
21:57:43 | FromDiscord | <Elegantbeef> Why does it matter? |
21:58:26 | FromDiscord | <wiga> cuz i need this header for the screenshot function |
21:58:29 | FromDiscord | <Elegantbeef> I'm like 90% certain all the procedures you use are wrapped inside winim |
21:58:33 | FromDiscord | <Elegantbeef> ...? |
21:58:43 | FromDiscord | <wiga> i have a program in C |
21:58:46 | FromDiscord | <wiga> that takes a screenshot |
21:58:50 | FromDiscord | <wiga> and it uses windows.h |
21:59:00 | FromDiscord | <wiga> and i dont seem to find it in winim |
21:59:20 | FromDiscord | <Elegantbeef> I'm so confused |
21:59:30 | FromDiscord | <Elegantbeef> Isnt the program what you wrote in Nim |
21:59:38 | FromDiscord | <Elegantbeef> Why do you need windows.h |
21:59:50 | FromDiscord | <wiga> to take a screenshot 😐 |
22:00:01 | FromDiscord | <Elegantbeef> .... |
22:00:06 | FromDiscord | <Elegantbeef> You clearly call specific procedures from windows.h |
22:00:22 | FromDiscord | <wiga> on god |
22:00:29 | FromDiscord | <wiga> thats why i kinda need it |
22:00:50 | FromDiscord | <Elegantbeef> What procedures do you call that are not inside winim? |
22:01:00 | FromDiscord | <wiga> ZeroMemory |
22:01:13 | FromDiscord | <wiga> hBitmap type |
22:01:17 | FromDiscord | <Elegantbeef> Alternatively compile the C code into an object and link it |
22:01:23 | FromDiscord | <Elegantbeef> https://github.com/khchen/winim/blob/a485708a243e2f2acbce783027b8cf8582536414/winim/inc/winbase.nim#L2779 |
22:01:50 | FromDiscord | <Elegantbeef> https://github.com/khchen/winim/search?q=HBitmap |
22:01:52 | FromDiscord | <Elegantbeef> It's clearly there |
22:02:39 | FromDiscord | <wiga> ok nvm im just retard |
22:03:04 | FromDiscord | <wiga> i literally imported winim/inc/wingdi instead of the whole library 🗿 |
22:03:24 | FromDiscord | <Elegantbeef> On god |
22:03:56 | FromDiscord | <Elegantbeef> I really should make a rule that if i have to pull teeth to help, you have to make a PR to Nim |
22:05:03 | FromDiscord | <wiga> lmfao |
22:05:13 | FromDiscord | <wiga> 💀 https://media.discordapp.net/attachments/371759389889003532/1067928151193305158/image.png |
22:06:06 | * | PMunch quit (Quit: Leaving) |
22:13:03 | FromDiscord | <Gumbercules> In reply to @Elegantbeef "I really should make": Not sure we'd want some of those PRs... |
22:13:31 | FromDiscord | <wiga> homemade garbage collector |
22:16:43 | FromDiscord | <Elegantbeef> Hey fixing a typo is a PR |
22:23:54 | Amun-Ra | :> |
22:24:11 | Amun-Ra | homemade garbo (AU) |
22:31:17 | FromDiscord | <jmgomez> In reply to @jmgomez "Can the compiler API": Hey beef, do you happen to have an answer for this? |
22:31:36 | FromDiscord | <Elegantbeef> Nope |
22:34:12 | FromDiscord | <jmgomez> Ok, took a look at cgtypes.nim but didnt see anything that I could use (not even sure if it can be used outside the compiler) |
22:51:06 | * | cm quit (Quit: Bye.) |
22:56:57 | FromDiscord | <JOHN William> Do you need financial support? Are you tired living from paycheck to paycheck… wanna say goodbye to 9to5? Wanna make $2000 daily $5000 weekly before your next pay check arrives?THEN ASK HOW....📥↵https://t.me/+KuOs8q7WfH8zZGZk↵(@jmgomez) |
22:58:32 | FromDiscord | <Nilts> In reply to @JOHN William "Do you need financial": wtf is this |
22:58:58 | * | cm joined #nim |
22:59:16 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @michaelb.eth "here's an example: https://github.com/status-im/nim": Sounds interesting! |
22:59:33 | * | FromDiscord quit (Remote host closed the connection) |
22:59:46 | * | FromDiscord joined #nim |
23:01:14 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mcD |
23:03:22 | FromDiscord | <Gumbercules> In reply to @not logged in "is this allowed?": no it's not... <@&371760044473319454> |
23:07:30 | FromDiscord | <Hourglass [She/Her]> In reply to @Elegantbeef "I really should make": Lmao that would be horrid but funny |
23:08:25 | FromDiscord | <Hourglass [She/Her]> In reply to @Gumbercules "no it's not... <@&371760044473319454>": What was it if I can ask? |
23:09:10 | FromDiscord | <Nilts> In reply to @Hourglass, When the Hour Strikes "What was it if": this stuff: https://discord.com/channels/371759389889003530/706542664643772436/1067941376043536567 |
23:09:19 | FromDiscord | <Hourglass [She/Her]> In reply to @not logged in "<@1046486398850576494> how would": Obviously I'm not the person you're asking, but maybe something that stores the identifier of the function, the parameter types and return types? |
23:09:25 | FromDiscord | <Hourglass [She/Her]> In reply to @not logged in "this stuff: https://discord.com/channels/3717593898": Aaah |
23:09:52 | FromDiscord | <Nilts> In reply to @Hourglass, When the Hour Strikes "Obviously I'm not the": Nahh, i would need to store the address of the code more likely |
23:10:08 | FromDiscord | <Hourglass [She/Her]> In reply to @Hourglass, When the Hour Strikes "Obviously I'm not the": (I'm using the generalised assumption that it's somewhat like JVM bytecode but that's probably wrong) |
23:10:21 | FromDiscord | <Nilts> (edit) "likely" => "likely, and then store that function object under the ident" |
23:10:53 | FromDiscord | <Hourglass [She/Her]> In reply to @not logged in "Nahh, i would need": Oh so no global function table or something? That's fair |
23:12:09 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mcE |
23:13:19 | FromDiscord | <Hourglass [She/Her]> Fair! |
23:13:29 | FromDiscord | <Hourglass [She/Her]> I'm clueless then haha |
23:13:44 | FromDiscord | <Nilts> we were all clueless once ¯\_(ツ)_/¯ |
23:16:14 | FromDiscord | <Hourglass [She/Her]> True! |
23:16:29 | FromDiscord | <Elegantbeef> A function is practically a jump with a psuh |
23:16:32 | FromDiscord | <Elegantbeef> push\ |
23:16:41 | FromDiscord | <Elegantbeef> You push your parameters on the stack, then jump to the procedure |
23:16:52 | FromDiscord | <Elegantbeef> Which grabs the elements off the stack and carries on |
23:18:28 | FromDiscord | <Hourglass [She/Her]> Yeah that makes sense, JVM bytecode used a bytecode instruction for calling a method instead of jumping to a block though when I was looking through it |
23:24:15 | FromDiscord | <Nilts> In reply to @Elegantbeef "You push your parameters": is the stack the ident table or the seq that the PUSH command sends data to |
23:25:58 | FromDiscord | <Hourglass [She/Her]> The latter |
23:26:18 | FromDiscord | <Hourglass [She/Her]> 'Stack' of data used by the program is a good way to remember it imo |
23:31:47 | FromDiscord | <Nilts> In reply to @Elegantbeef "A function is practically": wait, but would i need a skip or jump to jump to the end of the func? |
23:32:59 | FromDiscord | <Hourglass [She/Her]> It'd be jumping to the start of the function, no? Since you wanna run the function's code |
23:33:15 | FromDiscord | <Hourglass [She/Her]> Wdym by skip? |
23:33:42 | FromDiscord | <Nilts> In reply to @Hourglass, When the Hour Strikes "Wdym by skip?": well, you don't run a function the first time around, only when called |
23:34:27 | FromDiscord | <Hourglass [She/Her]> Yep, so when you encounter a function call in the bytecode you'd jump to the function- |
23:34:41 | FromDiscord | <Hourglass [She/Her]> Unless I'm missing something |
23:35:03 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mcF |
23:36:32 | FromDiscord | <Elegantbeef> Pretty much |
23:38:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mcG |
23:38:14 | FromDiscord | <Elegantbeef> This is actually how some C calling conventions handle it |