<< 21-10-2024 >>

00:23:20*termer quit (Ping timeout: 260 seconds)
00:23:54*termer joined #nim
00:30:09FromDiscord<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:20FromDiscord<zumi.dxy> at least that's what i got from this https://arxiv.org/abs/2410.05460
00:30:31FromDiscord<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:09FromDiscord<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:34FromDiscord<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:49FromDiscord<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:46FromDiscord<SmaamX> How can I play a frequency by nim (like pygame and ...)?
07:25:27*ntat quit (Quit: Leaving)
07:29:01FromDiscord<odexine> (for those confused, they mean "how do i play audio of a sine wave of a certain frequency")
07:45:11FromDiscord<SmaamX> f(x)=sin([x]) with T inf↵(@odexine)
07:46:03FromDiscord<SmaamX> f(x)=sin([x]) with T (5) r\: inf
07:48:14FromDiscord<SmaamX> f(x)=sin([x]) with T (5pi) r\: inf lol
08:25:48strogon14You 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:54FromDiscord<demotomohiro> If that means sound synthesis, probably you can find audio library in https://forum.nim-lang.org/t/12540
08:26:57strogon14There are libraries, which provide Cross-Platform abstractions. For example Raylib (naylib for Nim), SDL or OpenAL
08:30:16strogon14I 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:19strogon14https://github.com/SpotlightKid/nim-libsoundio
08:31:07strogon14But naylib or SDL is probably easier to get started with.
08:31:46strogon14Sth like libsoundio is only necessary when you have strict real-time requirements.
10:03:01FromDiscord<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:21FromDiscord<frusadev> Thanks in advance
10:14:01*PMunch joined #nim
10:20:45FromDiscord<odexine> iirc yes but they will be turned into RootType
10:21:55FromDiscord<frusadev> Oh! Then all of the properties from the children will be removed?
10:26:38FromDiscord<frusadev> Then can i do something like seq[RootType | ChildOfRootType] ? i guess not right?😅
10:27:09FromDiscord<odexine> no
10:27:34FromDiscord<odexine> In reply to @frusadev "Oh! Then all of": i dont really remember, i dont use OOP in nim, let me test
10:28:07FromDiscord<frusadev> sent a code paste, see https://play.nim-lang.org/#pasty=FNhFhWgg
10:29:23FromDiscord<frusadev> I wanted to avoid OOP but i figured it would make things easier to build
10:29:46FromDiscord<odexine> In reply to @frusadev "Oh! Then all of": theyre not removed
10:29:58FromDiscord<odexine> you can access them by converting back to the child type
10:30:07FromDiscord<odexine> you can check by using `of`
10:30:16FromDiscord<odexine> `obj of TypeA`
10:30:28FromDiscord<frusadev> In reply to @odexine "you can access them": Oh! Then that's great 😋
10:30:31FromDiscord<frusadev> Ty
10:30:34FromDiscord<odexine> basically `if obj of TypeA: # do thing with obj.TypeA`
10:31:10FromDiscord<odexine> https://media.discordapp.net/attachments/371759389889003532/1297869783731277835/image.png?ex=67177eed&is=67162d6d&hm=47849775bed93e007425ac6b2841419fc6587b5267701841e3cb524eda6dd09f&
10:31:22FromDiscord<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:25PMunchHmm, 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:03FromDiscord<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:04FromDiscord<nnsee> same result with -d:debug
12:36:29FromDiscord<nnsee> well, not the _same_ result (it runs about 9x slower), but the difference between the two is the same
12:37:13PMunchInteresting, but hard to know what this means without seeing the code you used..
12:37:37FromDiscord<heysokam> Is it possible to map a C `enum` to a Nim `uint32` when importc?
12:38:15FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=wrjOTyVi
12:38:27FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#pasty=yXOQOOLs" => "https://play.nim-lang.org/#pasty=aWUTvwPE"
12:39:17FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#pasty=vLOVUETG" => "https://play.nim-lang.org/#pasty=gkrOlZXm"
12:41:17PMunch@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:46FromDiscord<nnsee> ah right sorry
12:41:53FromDiscord<nnsee> also i realized i did the benchmark wrong
12:42:07PMunchNo worries, a speed benchmark is of course also very interesting
12:42:17PMunchWas wrong?
12:46:43FromDiscord<nnsee> In reply to @PMunch "Was wrong?": put the hot loop in the wrong place and heavily skewed the data
12:46:54PMunchAh :P
12:47:19PMunch@heysokam, depends on the underlying type of the enum
12:47:23FromDiscord<nnsee> so here are the results https://media.discordapp.net/attachments/371759389889003532/1297904062263726120/image.png?ex=67179eda&is=67164d5a&hm=89948ff678a6141b1a6e663df15e972177d19a5de86c2480426aaebae68be364&
12:47:26FromDiscord<nnsee> and the code...
12:48:01FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#pasty=RWNlkLaX
12:48:19FromDiscord<nnsee> this is with_try, without_try is the same but with the try/finally removed
12:48:25FromDiscord<nnsee> and with -d:debug
12:48:40PMunchOh interesting
12:48:44PMunchSo there is a small penalty
12:49:10FromDiscord<nnsee> with -d:release, the penalty disappears
12:49:24PMunchAh okay
12:49:32FromDiscord<heysokam> In reply to @PMunch "@heysokam, depends on the": wdym?
12:51:14PMunchWell if you compile with GCC and the enum has the attribute __packed__ on it then it is as small as possible
12:51:47PMunchAlso there is the `-fshort-enums` switch which makes them small
12:57:01*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
12:57:08FromDiscord<heysokam> kk
12:59:02FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=zNsGjCyi
13:01:34*Lord_Nightmare joined #nim
13:04:04PMunchI didn't find anything while developing Futhark, so it copies the values over
13:09:01*hastalapasta joined #nim
13:09:10FromDiscord<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:21Amun-Rawhich benchmark module would you recommend?
14:44:43Amun-Raand by module I mean package
14:47:28Amun-Ralet's check benchy
14:58:11*ryuukk quit (Remote host closed the connection)
15:01:40Amun-Ra…and criterion
15:03:00Amun-Racriterion needs undefing nimPreviewSlimSystem in order to compile successfuly
15:25:24*lucasta joined #nim
15:25:38Amun-Rawell, 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:31PMunchBenchy 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:05FromDiscord<spaceshaman> I was surprised to find out that nim isn't fully opt in for nullable types
17:46:43FromDiscord<odexine> well not yet
17:46:55FromDiscord<odexine> https://nim-lang.github.io/Nim/manual_experimental_strictnotnil.html
17:53:44FromDiscord<spaceshaman> Is the nilability monadic with this?
17:54:47FromDiscord<spaceshaman> If you have `ref int nil a = 5` can you do a + 1?
17:56:35FromDiscord<spaceshaman> And is unpacking basically accomplished with flow typing?
17:59:21FromDiscord<odexine> In reply to @spaceshaman "If you have `ref": what is that syntax
17:59:30FromDiscord<odexine> `var a: ref int nil = 5`?
18:01:14FromDiscord<spaceshaman> Oh, woops
18:01:32FromDiscord<spaceshaman> My brain was between languages when typing
18:01:45FromDiscord<odexine> i believe this is meant to work just like now but with not nil annotations
18:01:51FromDiscord<odexine> so i believe a + 1 should still work
18:02:00FromDiscord<odexine> well, defining a `+` for ref int
18:02:00FromDiscord<spaceshaman> Bleh
18:02:23FromDiscord<odexine> and given that `1` here "is a ref int" which is not
18:02:33FromDiscord<spaceshaman> Ah
18:03:08FromDiscord<spaceshaman> I definitely that thats a nasty footgun
18:03:17FromDiscord<spaceshaman> (edit) "that" => "think"
18:03:33FromDiscord<odexine> actually no
18:03:38FromDiscord<odexine> i thought incorrectly
18:03:50FromDiscord<odexine> i can say nothing about how that should work
18:04:03FromDiscord<odexine> i assume its going to fail as long as `+` requires `not nil`
18:04:34FromDiscord<spaceshaman> `var a: int nil = 5` is probably where i should gone with the + example
18:05:37FromDiscord<odexine> i think the document at "nilability state" explains how that would work
18:06:08FromDiscord<odexine> i dont have much experience with this system so i think you should refer to the document
18:06:14FromDiscord<spaceshaman> Have you seen how rust and zig do these things?
18:06:26FromDiscord<odexine> i prolly have but forgotten
18:06:56FromDiscord<odexine> in any case it is still currently experimental so its subject to change or even complete overhaul
18:07:21FromDiscord<spaceshaman> D fucked up their library implementation of this
18:08:25FromDiscord<spaceshaman> Basically their `Nullable(T)` wrapper struct is set up to implicitly unpack the null
18:08:32FromDiscord<spaceshaman> Bad bad bad
19:18:00*xet7 quit (Quit: Leaving)
19:30:13*xet7 joined #nim
19:35:34FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=naujZubw
19:36:36FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#pasty=iKDDweCP" => "https://play.nim-lang.org/#pasty=wrkYqKry"
19:37:48FromDiscord<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:39FromDiscord<Elegantbeef> Isn't it passing a variable named `version`?
20:05:42FromDiscord<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:22Amun-Rais there a way to obtain pragma information is that proc? https://play.nim-lang.org/#pasty=nPmOWQLW
21:15:30FromDiscord<crim4> hi, does nim have aliasing problem? https://media.discordapp.net/attachments/371759389889003532/1298031934756229190/image.png?ex=671815f1&is=6716c471&hm=3801f745ab98acd2bcde7f7dd058f14c3d6c5d35afb3374cc26b70d3c26f3368&
21:15:56FromDiscord<Elegantbeef> Nope you have a use after free and a dangling pointer
21:16:01FromDiscord<Elegantbeef> `addr` is unsafe
21:16:49FromDiscord<Elegantbeef> Amun is there a reason your `check` takes a `NimNode` instead of `auto`?
21:16:52FromDiscord<crim4> and any way to get a safe ref?
21:16:59FromDiscord<Elegantbeef> Nope
21:17:08FromDiscord<Elegantbeef> Store an integer instead then index it after
21:17:20FromDiscord<Elegantbeef> `.add` can reallocate a sequence so you're purposely attempting to get an unsafe pointer
21:26:21Amun-RaElegantbeef: hmm, I've never used auto as a type
21:26:40FromDiscord<Elegantbeef> Or you can do `proc check[T](val: T)`
21:31:42Amun-RaI don't think I'll get pragma info in that case
21:34:14Amun-Rathis 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:42Amun-Rathis is what it looks like now: https://play.nim-lang.org/#pasty=UxHiygRD
21:38:50Amun-Ras/like/right/
21:58:35Amun-Ratested, pragma information is lost
22:16:42FromDiscord<crim4> In reply to @Elegantbeef "`.add` can reallocate a": yes that the point of the aliasing problem
22:17:32FromDiscord<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:53FromDiscord<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:37Amun-Raunsafeaddr is deprecated
22:35:23FromDiscord<zumi.dxy> I'm guessing it's because the sequence was resized
22:35:24*xet7 quit (Quit: Leaving)
22:35:35FromDiscord<zumi.dxy> so vec[0].addr is no longer valid
22:35:48FromDiscord<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:19FromDiscord<Elegantbeef> @crim4 the reason unsafe operations are easily accessible is Nim trusts the programmer
23:07:23FromDiscord<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