00:23:20 | * | termer quit (Ping timeout: 260 seconds) |
00:23:54 | * | termer joined #nim |
00:30:09 | FromDiscord | <zumi.dxy> In reply to @Elegantbeef "Not to mention that": benchmarks seem to depend mostly on the quality of the benchmark implementation itself |
00:30:20 | FromDiscord | <zumi.dxy> at least that's what i got from this https://arxiv.org/abs/2410.05460 |
00:30:31 | FromDiscord | <zumi.dxy> https://media.discordapp.net/attachments/371759389889003532/1297718624957763624/image.png?ex=6716f226&is=6715a0a6&hm=e6ff6d5fa43e9b2470f169766d6e68a83bb805498d1b4aa66391b53194b38b6e& |
01:05:47 | * | beholders_eye quit (Ping timeout: 272 seconds) |
01:39:53 | * | SchweinDeBurg quit (Read error: Connection reset by peer) |
01:54:09 | FromDiscord | <Elegantbeef> @zumi.dxy exactly these comparisons only make sense if we're being honest, and it's not honest when people use different implementations |
01:55:34 | FromDiscord | <Elegantbeef> It's like ranking the speed of vehicles by having a race between two points with arbitrary paths to get to the end |
02:16:49 | FromDiscord | <zumi.dxy> they say it's obvious until it's not, and you need a study saying as much |
02:31:51 | * | SchweinDeBurg joined #nim |
03:01:31 | * | rockcavera quit (Remote host closed the connection) |
03:42:27 | * | lucasta joined #nim |
03:44:52 | * | lucasta quit (Client Quit) |
04:37:12 | * | ryuukk quit (Remote host closed the connection) |
06:06:47 | * | ryuukk joined #nim |
06:25:55 | * | ntat joined #nim |
07:17:46 | FromDiscord | <SmaamX> How can I play a frequency by nim (like pygame and ...)? |
07:25:27 | * | ntat quit (Quit: Leaving) |
07:29:01 | FromDiscord | <odexine> (for those confused, they mean "how do i play audio of a sine wave of a certain frequency") |
07:45:11 | FromDiscord | <SmaamX> f(x)=sin([x]) with T inf↵(@odexine) |
07:46:03 | FromDiscord | <SmaamX> f(x)=sin([x]) with T (5) r\: inf |
07:48:14 | FromDiscord | <SmaamX> f(x)=sin([x]) with T (5pi) r\: inf lol |
08:25:48 | strogon14 | You need a library to talk to the OS specific audio frameworks. E.g. CoreAudio on macOS or ALSA or Pipewire / JACK on Linux etc. |
08:26:54 | FromDiscord | <demotomohiro> If that means sound synthesis, probably you can find audio library in https://forum.nim-lang.org/t/12540 |
08:26:57 | strogon14 | There are libraries, which provide Cross-Platform abstractions. For example Raylib (naylib for Nim), SDL or OpenAL |
08:30:16 | strogon14 | I recently created a wrapper for another such Cross-Platform audio I/O library called libsoundio. The C library has an example, which puts out a sine wave. You can translate that directly into Nim with my wrapper. |
08:30:19 | strogon14 | https://github.com/SpotlightKid/nim-libsoundio |
08:31:07 | strogon14 | But naylib or SDL is probably easier to get started with. |
08:31:46 | strogon14 | Sth like libsoundio is only necessary when you have strict real-time requirements. |
10:03:01 | FromDiscord | <frusadev> Hi! let's say i have a type `RootType` and want to create a `seq[RootType]`. Will all objects that inherit from `RootType` be able to get into the sequence? |
10:03:21 | FromDiscord | <frusadev> Thanks in advance |
10:14:01 | * | PMunch joined #nim |
10:20:45 | FromDiscord | <odexine> iirc yes but they will be turned into RootType |
10:21:55 | FromDiscord | <frusadev> Oh! Then all of the properties from the children will be removed? |
10:26:38 | FromDiscord | <frusadev> Then can i do something like seq[RootType | ChildOfRootType] ? i guess not right?😅 |
10:27:09 | FromDiscord | <odexine> no |
10:27:34 | FromDiscord | <odexine> In reply to @frusadev "Oh! Then all of": i dont really remember, i dont use OOP in nim, let me test |
10:28:07 | FromDiscord | <frusadev> sent a code paste, see https://play.nim-lang.org/#pasty=FNhFhWgg |
10:29:23 | FromDiscord | <frusadev> I wanted to avoid OOP but i figured it would make things easier to build |
10:29:46 | FromDiscord | <odexine> In reply to @frusadev "Oh! Then all of": theyre not removed |
10:29:58 | FromDiscord | <odexine> you can access them by converting back to the child type |
10:30:07 | FromDiscord | <odexine> you can check by using `of` |
10:30:16 | FromDiscord | <odexine> `obj of TypeA` |
10:30:28 | FromDiscord | <frusadev> In reply to @odexine "you can access them": Oh! Then that's great 😋 |
10:30:31 | FromDiscord | <frusadev> Ty |
10:30:34 | FromDiscord | <odexine> basically `if obj of TypeA: # do thing with obj.TypeA` |
10:31:10 | FromDiscord | <odexine> https://media.discordapp.net/attachments/371759389889003532/1297869783731277835/image.png?ex=67177eed&is=67162d6d&hm=47849775bed93e007425ac6b2841419fc6587b5267701841e3cb524eda6dd09f& |
10:31:22 | FromDiscord | <frusadev> Yeah i see! Then nim considers all children as the type itself and conserves all of their props |
11:11:53 | * | beholders_eye joined #nim |
11:47:17 | * | def- quit (Quit: -) |
11:47:28 | * | def- joined #nim |
12:21:25 | PMunch | Hmm, does `try/finally` in code that doesn't have any exceptions add any overhead? |
12:30:34 | * | beholders_eye quit (Ping timeout: 265 seconds) |
12:31:30 | * | beholders_eye joined #nim |
12:35:03 | FromDiscord | <nnsee> In reply to @PMunch "Hmm, does `try/finally` in": from a crude benchmark, doesn't look like it https://media.discordapp.net/attachments/371759389889003532/1297900961343340620/image.png?ex=67179bf7&is=67164a77&hm=1041ffa1f6ef780082cb2a407f45bc5cbe5cb0d3f9048a2b7336ca08d25a37bc& |
12:36:04 | FromDiscord | <nnsee> same result with -d:debug |
12:36:29 | FromDiscord | <nnsee> well, not the _same_ result (it runs about 9x slower), but the difference between the two is the same |
12:37:13 | PMunch | Interesting, but hard to know what this means without seeing the code you used.. |
12:37:37 | FromDiscord | <heysokam> Is it possible to map a C `enum` to a Nim `uint32` when importc? |
12:38:15 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=wrjOTyVi |
12:38:27 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#pasty=yXOQOOLs" => "https://play.nim-lang.org/#pasty=aWUTvwPE" |
12:39:17 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#pasty=vLOVUETG" => "https://play.nim-lang.org/#pasty=gkrOlZXm" |
12:41:17 | PMunch | @nnsee, I was actually thinking of code size though, and a very simple test seems to indicate that there is no difference between https://pasty.ee/ccDqvoDn and https://pasty.ee/FOsbWvwn |
12:41:46 | FromDiscord | <nnsee> ah right sorry |
12:41:53 | FromDiscord | <nnsee> also i realized i did the benchmark wrong |
12:42:07 | PMunch | No worries, a speed benchmark is of course also very interesting |
12:42:17 | PMunch | Was wrong? |
12:46:43 | FromDiscord | <nnsee> In reply to @PMunch "Was wrong?": put the hot loop in the wrong place and heavily skewed the data |
12:46:54 | PMunch | Ah :P |
12:47:19 | PMunch | @heysokam, depends on the underlying type of the enum |
12:47:23 | FromDiscord | <nnsee> so here are the results https://media.discordapp.net/attachments/371759389889003532/1297904062263726120/image.png?ex=67179eda&is=67164d5a&hm=89948ff678a6141b1a6e663df15e972177d19a5de86c2480426aaebae68be364& |
12:47:26 | FromDiscord | <nnsee> and the code... |
12:48:01 | FromDiscord | <nnsee> sent a code paste, see https://play.nim-lang.org/#pasty=RWNlkLaX |
12:48:19 | FromDiscord | <nnsee> this is with_try, without_try is the same but with the try/finally removed |
12:48:25 | FromDiscord | <nnsee> and with -d:debug |
12:48:40 | PMunch | Oh interesting |
12:48:44 | PMunch | So there is a small penalty |
12:49:10 | FromDiscord | <nnsee> with -d:release, the penalty disappears |
12:49:24 | PMunch | Ah okay |
12:49:32 | FromDiscord | <heysokam> In reply to @PMunch "@heysokam, depends on the": wdym? |
12:51:14 | PMunch | Well if you compile with GCC and the enum has the attribute __packed__ on it then it is as small as possible |
12:51:47 | PMunch | Also there is the `-fshort-enums` switch which makes them small |
12:57:01 | * | Lord_Nightmare quit (Quit: ZNC - http://znc.in) |
12:57:08 | FromDiscord | <heysokam> kk |
12:59:02 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=zNsGjCyi |
13:01:34 | * | Lord_Nightmare joined #nim |
13:04:04 | PMunch | I didn't find anything while developing Futhark, so it copies the values over |
13:09:01 | * | hastalapasta joined #nim |
13:09:10 | FromDiscord | <heysokam> ty pmunch |
13:10:34 | * | hastalapasta left #nim (#nim) |
13:26:09 | * | beholders_eye quit (Ping timeout: 248 seconds) |
13:53:07 | * | ntat joined #nim |
14:44:21 | Amun-Ra | which benchmark module would you recommend? |
14:44:43 | Amun-Ra | and by module I mean package |
14:47:28 | Amun-Ra | let's check benchy |
14:58:11 | * | ryuukk quit (Remote host closed the connection) |
15:01:40 | Amun-Ra | …and criterion |
15:03:00 | Amun-Ra | criterion needs undefing nimPreviewSlimSystem in order to compile successfuly |
15:25:24 | * | lucasta joined #nim |
15:25:38 | Amun-Ra | well, criterion is very nice, except one thing - it outputs nothing… ;) |
15:28:15 | * | Amun-Ra picks benchy |
15:43:54 | * | beholders_eye joined #nim |
15:52:40 | * | ryuukk joined #nim |
16:04:31 | PMunch | Benchy is very nice |
16:22:10 | * | PMunch quit (Quit: Leaving) |
16:42:14 | * | lucasta quit (Remote host closed the connection) |
17:18:43 | * | beholders_eye quit (Ping timeout: 264 seconds) |
17:32:12 | * | beholders_eye joined #nim |
17:46:05 | FromDiscord | <spaceshaman> I was surprised to find out that nim isn't fully opt in for nullable types |
17:46:43 | FromDiscord | <odexine> well not yet |
17:46:55 | FromDiscord | <odexine> https://nim-lang.github.io/Nim/manual_experimental_strictnotnil.html |
17:53:44 | FromDiscord | <spaceshaman> Is the nilability monadic with this? |
17:54:47 | FromDiscord | <spaceshaman> If you have `ref int nil a = 5` can you do a + 1? |
17:56:35 | FromDiscord | <spaceshaman> And is unpacking basically accomplished with flow typing? |
17:59:21 | FromDiscord | <odexine> In reply to @spaceshaman "If you have `ref": what is that syntax |
17:59:30 | FromDiscord | <odexine> `var a: ref int nil = 5`? |
18:01:14 | FromDiscord | <spaceshaman> Oh, woops |
18:01:32 | FromDiscord | <spaceshaman> My brain was between languages when typing |
18:01:45 | FromDiscord | <odexine> i believe this is meant to work just like now but with not nil annotations |
18:01:51 | FromDiscord | <odexine> so i believe a + 1 should still work |
18:02:00 | FromDiscord | <odexine> well, defining a `+` for ref int |
18:02:00 | FromDiscord | <spaceshaman> Bleh |
18:02:23 | FromDiscord | <odexine> and given that `1` here "is a ref int" which is not |
18:02:33 | FromDiscord | <spaceshaman> Ah |
18:03:08 | FromDiscord | <spaceshaman> I definitely that thats a nasty footgun |
18:03:17 | FromDiscord | <spaceshaman> (edit) "that" => "think" |
18:03:33 | FromDiscord | <odexine> actually no |
18:03:38 | FromDiscord | <odexine> i thought incorrectly |
18:03:50 | FromDiscord | <odexine> i can say nothing about how that should work |
18:04:03 | FromDiscord | <odexine> i assume its going to fail as long as `+` requires `not nil` |
18:04:34 | FromDiscord | <spaceshaman> `var a: int nil = 5` is probably where i should gone with the + example |
18:05:37 | FromDiscord | <odexine> i think the document at "nilability state" explains how that would work |
18:06:08 | FromDiscord | <odexine> i dont have much experience with this system so i think you should refer to the document |
18:06:14 | FromDiscord | <spaceshaman> Have you seen how rust and zig do these things? |
18:06:26 | FromDiscord | <odexine> i prolly have but forgotten |
18:06:56 | FromDiscord | <odexine> in any case it is still currently experimental so its subject to change or even complete overhaul |
18:07:21 | FromDiscord | <spaceshaman> D fucked up their library implementation of this |
18:08:25 | FromDiscord | <spaceshaman> Basically their `Nullable(T)` wrapper struct is set up to implicitly unpack the null |
18:08:32 | FromDiscord | <spaceshaman> Bad bad bad |
19:18:00 | * | xet7 quit (Quit: Leaving) |
19:30:13 | * | xet7 joined #nim |
19:35:34 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=naujZubw |
19:36:36 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#pasty=iKDDweCP" => "https://play.nim-lang.org/#pasty=wrkYqKry" |
19:37:48 | FromDiscord | <heysokam> oh wait, it might be an exported variable somewhere, hmmm |
19:51:12 | * | coldfeet joined #nim |
19:57:50 | * | ntat quit (Quit: Leaving) |
20:05:39 | FromDiscord | <Elegantbeef> Isn't it passing a variable named `version`? |
20:05:42 | FromDiscord | <Elegantbeef> It's typed to `Version` |
20:22:27 | * | coldfeet quit (Remote host closed the connection) |
20:39:18 | * | beholders_eye quit (Ping timeout: 246 seconds) |
20:48:39 | * | rockcavera joined #nim |
21:12:22 | Amun-Ra | is there a way to obtain pragma information is that proc? https://play.nim-lang.org/#pasty=nPmOWQLW |
21:15:30 | FromDiscord | <crim4> hi, does nim have aliasing problem? https://media.discordapp.net/attachments/371759389889003532/1298031934756229190/image.png?ex=671815f1&is=6716c471&hm=3801f745ab98acd2bcde7f7dd058f14c3d6c5d35afb3374cc26b70d3c26f3368& |
21:15:56 | FromDiscord | <Elegantbeef> Nope you have a use after free and a dangling pointer |
21:16:01 | FromDiscord | <Elegantbeef> `addr` is unsafe |
21:16:49 | FromDiscord | <Elegantbeef> Amun is there a reason your `check` takes a `NimNode` instead of `auto`? |
21:16:52 | FromDiscord | <crim4> and any way to get a safe ref? |
21:16:59 | FromDiscord | <Elegantbeef> Nope |
21:17:08 | FromDiscord | <Elegantbeef> Store an integer instead then index it after |
21:17:20 | FromDiscord | <Elegantbeef> `.add` can reallocate a sequence so you're purposely attempting to get an unsafe pointer |
21:26:21 | Amun-Ra | Elegantbeef: hmm, I've never used auto as a type |
21:26:40 | FromDiscord | <Elegantbeef> Or you can do `proc check[T](val: T)` |
21:31:42 | Amun-Ra | I don't think I'll get pragma info in that case |
21:34:14 | Amun-Ra | this is a part of larger project, that proc returns NimNode, I wanted to automagically read big/little-endian object fields based on custom pragma; right now I have two separate functions for that |
21:38:42 | Amun-Ra | this is what it looks like now: https://play.nim-lang.org/#pasty=UxHiygRD |
21:38:50 | Amun-Ra | s/like/right/ |
21:58:35 | Amun-Ra | tested, pragma information is lost |
22:16:42 | FromDiscord | <crim4> In reply to @Elegantbeef "`.add` can reallocate a": yes that the point of the aliasing problem |
22:17:32 | FromDiscord | <crim4> bu why is the addr function so easily accessible if ita unsafe and at this point what's the difference with unsafeAddr? |
22:17:53 | FromDiscord | <jay.herry77> I'M HUMBLE😉😉 trustworthy🤠🤠 real and legit 💯💵💸💰💶💷💳am not a scammer ⚠️🚫 all deals we do here is real and legit just tapin guys https://t.me/+ioqje81ziAYyYTc0 now and invest your money with the real plug |
22:22:37 | Amun-Ra | unsafeaddr is deprecated |
22:35:23 | FromDiscord | <zumi.dxy> I'm guessing it's because the sequence was resized |
22:35:24 | * | xet7 quit (Quit: Leaving) |
22:35:35 | FromDiscord | <zumi.dxy> so vec[0].addr is no longer valid |
22:35:48 | FromDiscord | <zumi.dxy> In reply to @Elegantbeef "`.add` can reallocate a": oh yeah that |
22:36:45 | * | xet7 joined #nim |
22:38:14 | * | lucerne quit (Ping timeout: 252 seconds) |
23:06:19 | FromDiscord | <Elegantbeef> @crim4 the reason unsafe operations are easily accessible is Nim trusts the programmer |
23:07:23 | FromDiscord | <crim4> In reply to @zumi.dxy "I'm guessing it's because": yes is a famous example the alias problem for testing automatic memory management in languages |