<< 16-05-2025 >>

01:35:19*GnuYawk1 quit (Quit: The Lounge - https://thelounge.chat)
01:58:45*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
02:08:03*GnuYawk1 joined #nim
02:14:35*GnuYawk1 quit (Quit: The Lounge - https://thelounge.chat)
02:18:30*GnuYawk1 joined #nim
03:02:44*rockcavera quit (Remote host closed the connection)
03:43:54FromDiscord<heysokam> In reply to @aintea "thanks past me for": I love self documented code. As in, I document my code to save my own ass 🙈
03:53:18*nils` quit (Ping timeout: 265 seconds)
04:26:21*SchweinDeBurg joined #nim
04:47:05*nils` joined #nim
04:53:08*ntat joined #nim
06:36:40*skippy8 joined #nim
06:46:38*Guest61 joined #nim
06:52:46*Guest61 quit (Quit: Client closed)
07:19:45*jjido joined #nim
07:43:25*redj quit (Quit: No Ping reply in 180 seconds.)
07:44:57*redj joined #nim
07:45:21*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
08:04:15*ntat quit (Quit: leaving)
08:08:50*ehmry quit (Read error: Connection reset by peer)
08:09:09*ehmry joined #nim
08:17:34*andy-turner joined #nim
08:23:48FromDiscord<aintea> Also I finally used AI for the first time to find the bug in my code because my stupid ass put `none()` for the project to compile and then after trying to fill in `some(something)` where it made sense and forgot to replace one
08:24:12FromDiscord<nnsee> you've held off from using AI for so long? commendable
08:24:22FromDiscord<nnsee> (edit) removed "from"
08:24:26FromDiscord<aintea> It's not that I held off, it's that I didn't see any use
08:24:35FromDiscord<aintea> I never had a codebase this big
08:24:55FromDiscord<aintea> It is pretty small but that's my biggest project so
08:52:27*jjido joined #nim
09:04:31FromDiscord<tekk1661> In reply to @nnsee "you've held off using": you use ai?
09:09:46*ntat joined #nim
09:17:35*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
09:18:36FromDiscord<Phil> In reply to @tekk1661 "you use ai?": It's a really good autocomplete
09:19:39FromDiscord<nnsee> In reply to @tekk1661 "you use ai?": not very often - mostly to get feedback on something i've written myself
09:20:06FromDiscord<tekk1661> In reply to @nnsee "not very often -": that's actually a good way to use ai
09:20:42FromDiscord<tekk1661> In reply to @isofruit "It's a *really* good": hmm... you may have a point
09:20:54FromDiscord<flashjaysan> I don't get it. Are nim files compiled to C then the C files are compiled to machine code or are nim files compiled to machine code ?
09:21:20FromDiscord<nnsee> Nim is first compiled to C and then a C compiler is leveraged to compile to machine code
09:21:22FromDiscord<Phil> Should be noted I mean that in the sense of "You have the code you want in your head and the AI does its best to guess what that is based on your coding patterns"
09:21:49FromDiscord<nnsee> In nim world, the Nim->C step is referred to as _codegen_ for... obvious reasons
09:21:52FromDiscord<Phil> (edit) "patterns"" => "patterns".↵And if it gets it right you just use it."
09:22:05FromDiscord<flashjaysan> So nim compiler is a transpiler, like haxe.
09:22:07FromDiscord<Phil> You can pass flags to the underlying C compiler directly as well btw
09:22:25FromDiscord<Phil> In reply to @flashjaysan "So nim compiler is": Sorta kinda, there are also direct-compilation experiments here and there and keep in mind that there's also a JS backend
09:22:34FromDiscord<nnsee> In reply to @flashjaysan "So nim compiler is": it's not a transpiler, since information is lost and C code cannot be transpiled back to Nim code
09:22:40FromDiscord<nnsee> you can think of the C code as IR
09:22:50FromDiscord<flashjaysan> Yes JS, exactly.
09:23:21FromDiscord<nnsee> if you take a look at the generated code, it's not something you generally want to work with anymore
09:23:22FromDiscord<flashjaysan> Is there a way to look at C code generated ?
09:23:26FromDiscord<Phil> So its nim => some IR in nim => whatever other language, which typically is C
09:23:37FromDiscord<nnsee> In reply to @flashjaysan "Is there a way": take a look inside your nim cache directory
09:24:22FromDiscord<Phil> (edit) "So its nim => some IR in nim => whatever other language, which typically is ... C=>" added "C↵(and if it's C, then" | "C↵(and if it's C, thenC ... " added "=> machine code via gcc/llcm)"
09:24:26FromDiscord<Phil> (edit) "gcc/llcm)" => "gcc/llvm)"
09:24:26FromDiscord<flashjaysan> I thought that nim should be viewed as a better C but since it goes through C compiling, it's not.
09:24:30FromDiscord<Phil> (edit) "gcc/llvm)" => "gcc/clang)"
09:24:48FromDiscord<nnsee> In reply to @flashjaysan "I thought that nim": I don't follow this logic
09:25:02FromDiscord<nnsee> the generated C code is unlike any C code you'd write by hand
09:25:14FromDiscord<nnsee> in that sense, it absolutely is "better"
09:25:20FromDiscord<flashjaysan> I mean, if it goes through C, we can't bé sure it's memory safe.
09:25:34FromDiscord<Phil> In reply to @flashjaysan "I mean, if it": That ... logic doesn't track
09:25:46FromDiscord<Phil> You can't be sure with any language in anything that it's memory safe
09:25:55FromDiscord<nnsee> In reply to @flashjaysan "I mean, if it": that logic doesn't hold water. Rust goes through llvm so it can't be memory safe either?
09:25:58FromDiscord<Phil> Before it gets in: That also counts for rust
09:26:02FromDiscord<Phil> (edit) "in:" => "written:"
09:26:28FromDiscord<nnsee> The Nim compiler runs before any C compiler. The Nim compiler is responsible for memory access
09:26:53FromDiscord<Phil> The assurance of sth being memory safe or not stems from logic checks you did ahead of time that states that this should be so.↵ ↵Which language you pass through along the way is pretty immaterial
09:27:34FromDiscord<flashjaysan> Well, I hear some news about us governments asking to use rust or other "safe" languages instead of C and C++ to avoid memory leaks and so.
09:27:48FromDiscord<Phil> In reply to @flashjaysan "Well, I hear some": C is not memory unsafe because it's C
09:27:56FromDiscord<nnsee> Rust doesn't protect you from memory leaks...
09:27:56FromDiscord<Phil> Rust is not memory safe just because it's Rust
09:28:10FromDiscord<flashjaysan> I was wondering if nim was considered safe in those regards.
09:28:31FromDiscord<flashjaysan> OK I see your point.
09:29:13FromDiscord<Phil> The memory safety stems from logic checks, always. Nim and rust do those both at compile time.↵Rust's are stricter than nim's by default, but you can write your own in nim as well so that has a very big asterisk attached
09:29:31FromDiscord<nnsee> Nim doesn't prevent you from corrupting your memory if you deliberately wish to do so, but it's also fairly hard to do by accident (unlike C)
09:29:53FromDiscord<flashjaysan> As a newcomer to all these languages, I felt it much more easier to create memory leaks in C/C++ than in rust or nim.
09:29:56*ntat quit (Read error: Connection reset by peer)
09:30:46FromDiscord<flashjaysan> But I wondered if going through C compilation phase would be considered unsafe.
09:32:00FromDiscord<Phil> Not really. The memory safety checks that there are happen during the Nim => C step (in Rust they happen during Rust => Rust IR I would guess and then whatever happens in LLVM is black magic to me).
09:32:53FromDiscord<Phil> After those step anything goes and you trust that the people that implemented the underlying steps did their job correctly and that the underlying compilers don't transform your code in a manner that breaks the safety assurances.
09:32:53FromDiscord<flashjaysan> I see. So it's not harmful to pass through C steps.
09:33:03FromDiscord<Phil> (edit) "step" => "steps"
09:33:27FromDiscord<nnsee> not intrinsically any more harmful than Rust passing through llvm steps
09:33:46FromDiscord<Phil> ~~C is not a programming language I swear, it's a compilation target~~
09:33:54FromDiscord<nnsee> by the way, there's also a version of the nim compiler that targets llvm directly, but it's not as battle-tested
09:33:55FromDiscord<flashjaysan> OK thanks for explaining that.
09:34:08*beholders_eye joined #nim
09:34:59FromDiscord<nnsee> (edit) "version" => "fork"
09:35:45*ntat joined #nim
09:39:59*ntat quit (Read error: Connection reset by peer)
09:43:24FromDiscord<litlighilit> how to detect if a template/macro is called at top level scope?
09:48:03Amun-Raby inspecting the result of instantiationInfo
09:56:34*redj quit (Read error: Connection reset by peer)
09:57:07*redj joined #nim
09:59:51FromDiscord<lainlaylie> machine code is not memory safe, and since everything compiles to machine code, nothing can ever be memory safe. we are doomed
10:02:19*jjido joined #nim
10:03:24Amun-Ralet's invent new machine code, in rust naturally and in colors
10:04:17*ntat joined #nim
10:14:10FromDiscord<nnsee> colours, you say? colour me intrigued
10:45:25FromDiscord<Phil> Boooooooo
10:45:28*ntat quit (Read error: Connection reset by peer)
10:45:30FromDiscord<Phil> Mooooods do something!
10:56:15*andy-turner_ joined #nim
10:56:57FromDiscord<odexine> you are mods
10:58:13FromDiscord<Phil> Lies
10:58:56FromDiscord<Phil> If I were I'd be in a position to abuse my power unjustifiably is opposed to telling others to abuse their power unjustifiably and take the fall!
10:59:01*andy-turner quit (Ping timeout: 248 seconds)
11:07:47*ntat joined #nim
11:14:31*ntat quit (Read error: Connection reset by peer)
11:15:01FromDiscord<aintea> In reply to @flashjaysan "I don't get it.": a Nim compiler is being written for Nim 3 that directly compiles to machine code, at least from what I heard
11:16:19*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
11:22:31*krux02 joined #nim
11:32:26*ntat joined #nim
11:32:26*ntat quit (Client Quit)
11:37:44*xtr00 quit (Read error: Connection reset by peer)
11:48:22*xtr00 joined #nim
11:51:34FromDiscord<zumi.dxy> "portable" "assembly" :p
11:51:39FromDiscord<zumi.dxy> (edit)
11:51:48FromDiscord<zumi.dxy> (edit) "isn't C ... "portable"" added ""kind of""
11:56:16*skippy8 quit (Ping timeout: 276 seconds)
11:58:35*xtr00 quit (Ping timeout: 252 seconds)
12:04:24*xtr00 joined #nim
12:06:45FromDiscord<shiloh0363> Hai
12:07:26*xtr00 quit (Read error: Connection reset by peer)
12:09:52FromDiscord<nnsee> hello
12:12:15FromDiscord<tapeda> I don't think so, it's just a mote portable intermediate representation so llvm _could_ be simpler but it's still very much based on C, and I think the new compiler plugin system is very much meant to be used like llvms iterative passes, just now something you can write personally, and not limited by a nimscript interpreter like current macros
12:12:28FromDiscord<tapeda> In reply to @aintea "a Nim compiler is": Is what I meant to reply to
12:18:57*xtr00 joined #nim
12:23:32*xtr00 quit (Ping timeout: 252 seconds)
12:24:50*xtr00 joined #nim
12:26:45krux02C is is portable in the sense, that it is supported by more than one compiler. LLVM intermediate representation only works in the LLVM toolchain.
12:50:11FromDiscord<tapeda> In reply to @krux02 "C is is portable": More so doesn't this imply it's quite hard for llvm to catch up to optimizations from decades of c compiler inter-mingling? Like sure it's probs not impossible and llvms architecture makes it easier to create optimization passes generally but isn't what you want really the enlightened in-lining of macros to remove the idea of passes from your IR and bring it to AST
12:50:49FromDiscord<tapeda> (As much as possible, and other caveats)
12:54:41*ntat joined #nim
13:13:06FromDiscord<0xfab_10> can you plug your codegen to the new compiler?
13:39:35FromDiscord<tapeda> nah course not but the plugins help you get to where you can. And the plugins themselves are no longer interpreted through nimscript but incrementally compiled
13:42:39FromDiscord<tapeda> but if u just mean make a backend, then ye ofc, but take for example that recent Vindaar nim-ast-to-optimized-cuda translator or even just a trivial example like the recent forum post on jill where at compile time all inputs and outptus to `withJack:` are run through a macro to generate what might as well be in-line assembly though currently according to the readme not necessarily that optimized. Runtime is overrated.
13:50:40FromDiscord<litlighilit> Great, except for failing to handle `when`↵(<@709044657232936960_=41mun-=52a=5b=49=52=43=5d>)
14:38:15*krux02 quit (Remote host closed the connection)
15:46:27*skippy8 joined #nim
16:36:02*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
17:20:21*ntat quit (Quit: leaving)
17:21:16*ntat joined #nim
18:13:29FromDiscord<spotlightkid> Hey ho, for anyone interested in audio development in Nim, I created this curated list of projects\: https://codeberg.org/SpotlightKid/nim-audio-dev
18:28:35*xet7 joined #nim
18:35:23*SchweinDeBurg joined #nim
18:51:24*xet7 quit (Remote host closed the connection)
18:55:17*skippy8 quit (Ping timeout: 248 seconds)
18:55:42*skippy8 joined #nim
19:00:30*xet7 joined #nim
19:28:40*beholders_eye quit (Ping timeout: 276 seconds)
19:59:30*ntat quit (Quit: leaving)
20:51:54*beholders_eye joined #nim
21:11:10*end quit (Ping timeout: 252 seconds)
21:11:10*bcksl quit (Ping timeout: 252 seconds)
21:18:29*beholders_eye quit (Ping timeout: 252 seconds)
21:37:42*skippy8 quit (Quit: WeeChat 4.5.2)
21:42:25FromDiscord<mr_rowboto> In reply to @flashjaysan "But I wondered if": It's not.↵Any and every language goes through "an unsafe compilation phase".↵↵In the end it's all assembly code, and assembly is always unsafe.
21:42:47*bcksl joined #nim
21:42:58FromDiscord<mr_rowboto> Even if you're running on top of a vm or interpreter, those could have (and usually have) bugs, exploits, etc.
21:47:26*end joined #nim
21:48:56*jjido joined #nim
21:49:26FromDiscord<Elegantbeef> Safe also depends what you're talking about
21:49:53FromDiscord<Elegantbeef> There is no single definition of safe, there is memory safe which Nim is mostly
21:50:33FromDiscord<mr_rowboto> Safe is what people started talking about when they finally realized that everyone meant different things when they said "strong typing"
21:50:39FromDiscord<mr_rowboto> (edit) "Safe" => ""Safe""
21:51:07FromDiscord<mr_rowboto> Now everyone means different things when they say "safe".
21:51:29FromDiscord<Elegantbeef> lol
21:51:37FromDiscord<mr_rowboto> You can't unbabel this shit.
21:51:41FromDiscord<mr_rowboto> (edit) "unbabel" => "un-babel"
21:52:07FromDiscord<Elegantbeef> Well Rust promotes safe code, but they mean memory safe
21:52:23FromDiscord<mr_rowboto> _but they're not_
21:52:45FromDiscord<Elegantbeef> Well code without `unsafe` is supposed to be memory safe
21:53:22FromDiscord<mr_rowboto> In reply to @Elegantbeef "Well code without `unsafe`": Have you seen that repo that completely destroys this narrative?
21:53:51FromDiscord<Elegantbeef> Yes the open hole in the Rust type system
21:54:06FromDiscord<mr_rowboto> It had lots of examples, real fun.
21:54:42FromDiscord<Elegantbeef> It's quite easy in Nim to do unsafe code that is supposed to be safe
21:55:01FromDiscord<mr_rowboto> Yeah, I've already bashed my face against segfaults.
21:55:38FromDiscord<mr_rowboto> But it's ok. It's not like I'm doing regular-stuff, I'm integrating a huge graphics library.
21:56:29*andy-turner_ quit (Quit: Leaving)
21:57:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=TpsEFNAd
21:57:38FromDiscord<Elegantbeef> @mr_rowboto Well I was talking about using safe mechanisms in Nim to do unsafe operations
21:58:33FromDiscord<Elegantbeef> No pointer or cast in sight, yet this is incorrect
22:00:58FromDiscord<dawidek.2137> sent a code paste, see https://play.nim-lang.org/#pasty=zhEmwdsg
22:02:49FromDiscord<Elegantbeef> We use an iterator to reference memory that incorrectly allows mutation to `s` whilst `x` is active
22:02:58FromDiscord<Elegantbeef> This is a typical "borrow checking would've caught this"
22:03:06FromDiscord<mr_rowboto> oh I see
22:03:15FromDiscord<mr_rowboto> is the problem in the `var T`?
22:03:20FromDiscord<mr_rowboto> (edit) "T`?" => "T` on alias?"
22:04:08FromDiscord<Elegantbeef> Cause `x` is a `var T` it really is a pointer to the first element. When you mutate `s` it causes a reallocation of the sequence, which makes `x` dangle. Allocating a new sequence of the same size of the original reuses the memory and then `x` points to its first element. Eh voila a simple dangling pointer
22:04:29FromDiscord<mr_rowboto> ohhhh
22:04:31FromDiscord<mr_rowboto> got it
22:04:50FromDiscord<mr_rowboto> it's a combination of var T with how seq works with reallocations
22:05:08FromDiscord<Elegantbeef> No it's just `var T`
22:05:39FromDiscord<mr_rowboto> I see
22:05:49FromDiscord<Elegantbeef> It also can work with `ref T`
22:06:02FromDiscord<mr_rowboto> anything that tosses around that pointer I suppose
22:07:16FromDiscord<Elegantbeef> Anything that causes a reallocation whilst `x` is active
22:07:34FromDiscord<mr_rowboto> right
22:07:43FromDiscord<Elegantbeef> This is what a borrow checker stops. It'd go "s is not mutable as long as x is active, so this `var seq[T]` is an error"
22:07:59FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=yAjKyWgP
22:08:00FromDiscord<Elegantbeef> Works just the same
22:10:21FromDiscord<tapeda> sent a code paste, see https://play.nim-lang.org/#pasty=cnEpmRHN
22:10:40FromDiscord<tapeda> (edit) "https://play.nim-lang.org/#pasty=hVkTULkk" => "https://play.nim-lang.org/#pasty=fhACOPqf"
22:10:48FromDiscord<mr_rowboto> In reply to @tapeda "Only kind of related": modifying a seq while looping?
22:10:51FromDiscord<mr_rowboto> naughty!
22:16:19FromDiscord<tapeda> Because who wants to work on copies?
22:17:06FromDiscord<mr_rowboto> Not performance-obsessed people? 😛
22:18:32FromDiscord<tapeda> I just like my globals in my .data ok
22:18:38FromDiscord<mr_rowboto> hehe
22:19:03FromDiscord<tapeda> (edit) "I" => "i"
22:37:04*Guest74 joined #nim
22:37:35*Guest74 quit (Client Quit)
23:25:38FromDiscord<aintea> How do I drop a identifier ?
23:26:10FromDiscord<aintea> sent a code paste, see https://play.nim-lang.org/#pasty=efGfydvR
23:36:52FromDiscord<demotomohiro> In reply to @aintea "How do I drop": https://nim-lang.org/docs/manual.html#statements-and-expressions-block-statement
23:37:28FromDiscord<aintea> not exactly what I was searching for but I guess that does the trick, thanks!
23:38:02FromDiscord<aintea> I love writing unit tests for my library (please help me)
23:42:22FromDiscord<aintea> sent a code paste, see https://play.nim-lang.org/#pasty=fJVUHcax
23:42:38FromDiscord<aintea> (edit) "https://play.nim-lang.org/#pasty=GfzIIYCs" => "https://play.nim-lang.org/#pasty=DxHHrWGA"
23:43:12FromDiscord<mr_rowboto> Are you testing command line args?
23:43:40FromDiscord<dawidek.2137> since strings are never nil, does it mean every time i create an object with an unused string field it also allocates something for that field?
23:44:13FromDiscord<aintea> No I'm making a CLI args parser, but the `addFlag` has consecutive booleans and imagine someone that doesn't know exactly what `true` and what `false` are in each args
23:44:46FromDiscord<aintea> In reply to @dawidek.2137 "since strings are never": I highly doubt it, the nim compiler is pretty smart, if something is unused it most likely won't be allocated or even put in the final binary
23:44:58FromDiscord<mr_rowboto> you can use `required = false` when calling the function
23:45:04FromDiscord<mr_rowboto> named arguments are a thing in nim
23:45:33FromDiscord<aintea> yes I know but would there be a way to "enforce" a more explicit way to give arguments
23:45:44FromDiscord<aintea> I have no idea how nor what I would want it to look like
23:45:48FromDiscord<mr_rowboto> oh, so you can't jsut pass the value
23:45:51FromDiscord<mr_rowboto> (edit) "jsut" => "just"
23:46:07FromDiscord<mr_rowboto> I'd say you're trying too hard.
23:46:13FromDiscord<mr_rowboto> And just don't.
23:46:18FromDiscord<aintea> good idea
23:46:21FromDiscord<aintea> less work for me
23:46:24FromDiscord<mr_rowboto> yah
23:46:30FromDiscord<aintea> 😎
23:46:36FromDiscord<aintea> sometimes less is more
23:46:37FromDiscord<mr_rowboto> mm I mean
23:46:38FromDiscord<aintea> (I'm lazy)
23:46:43FromDiscord<mr_rowboto> I get where you come from but
23:46:50FromDiscord<mr_rowboto> If you end up complicating the interface
23:47:08FromDiscord<mr_rowboto> Chances are whoever uses your lib will get even more frustrated
23:47:09FromDiscord<mr_rowboto> air?
23:47:24FromDiscord<aintea> In reply to @mr_rowboto "Chances are whoever uses": good remark, thanks for the help
23:47:27FromDiscord<aintea> In reply to @mr_rowboto "air?": what ?
23:47:30FromDiscord<mr_rowboto> am i right
23:47:33FromDiscord<mr_rowboto> (edit) "am" => "_am" | "right" => "right_"
23:47:38FromDiscord<aintea> oh yeah
23:47:40FromDiscord<aintea> you're right
23:47:42FromDiscord<aintea> thanks
23:48:03FromDiscord<mr_rowboto> Don't take my word for granted tho, I tend to end up in the very same places.
23:48:17FromDiscord<mr_rowboto> _and_ I'm no nim expert
23:56:31FromDiscord<Elegantbeef> @dawidek.2137 No it just means it has a `(0, nil)` where the string is