<< 08-06-2024 >>

00:09:34FromDiscord<morgan> is there anything that handles converting nim variadic arguments to a c va_list?
00:16:07FromDiscord<morgan> im not sure i need to implement it yet
00:16:19FromDiscord<morgan> it's in two debug functions in bgfx
00:18:18FromDiscord<riku5543> Hi there. I seem to be having some memory issues with Nim when trying to work with the cstring type. The code should output the same thing twice, but the second time around, the immutable variable gets messed up somehow. Here's the code. https://play.nim-lang.org/#pasty=sWYjnUCJ
00:19:41FromDiscord<ElegantBeef> You are making a dangling pointer
00:19:55FromDiscord<ElegantBeef> `bleh.cstring` does not extend the lifetime of `bleh`
00:20:43FromDiscord<riku5543> Would I have to return like a brand new cstring somehow?
00:20:55FromDiscord<ElegantBeef> You would have to return a manually managed cstring
00:20:59*krux02 quit (Remote host closed the connection)
00:20:59FromDiscord<ElegantBeef> Why are you using cstring is my question
00:21:28FromDiscord<riku5543> I was interfacing with some C code (raygui) and the parameter for comboboxes requires a cstring
00:21:40FromDiscord<ElegantBeef> So use a string and pass `myString.cstring`
00:21:46FromDiscord<ElegantBeef> Do not attempt to have a cstring outlive your `string`
00:22:04FromDiscord<riku5543> Alright haha, thanks
00:23:03FromDiscord<ElegantBeef> Do you have any reference material for the combo box procedure?
00:23:08FromDiscord<ElegantBeef> I cannot find any documentation for it
00:24:15FromDiscord<riku5543> Not exactly haha, but here's the header file for it↵https://github.com/raysan5/raygui/blob/master/src/raygui.h↵↵RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char text, bool checked);
00:24:40FromDiscord<riku5543> (edit) "Not exactly haha, but here's the header file for it↵https://github.com/raysan5/raygui/blob/master/src/raygui.h↵↵RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char text, bool checked);" => "sent a code paste, see https://play.nim-lang.org/#pasty=GZTaYJpP"
00:25:40FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=PlQNVYxh
00:26:00FromDiscord<ElegantBeef> Right so that likely should be an `array[entries, cstring]`
00:26:24FromDiscord<ElegantBeef> Or is text supposed to be new line seperated
00:26:30FromDiscord<ElegantBeef> That's an awful api 😄
00:26:37FromDiscord<riku5543> Ah my bad, in the widget gallery example, it's formatted as "OptionA;OptionB" etc
00:27:13FromDiscord<ElegantBeef> Ah then yea just use a Nim string and explicitly do `cstring myString` ensuring `myString` outlives `guiComboBox` call
00:28:11FromDiscord<riku5543> Alright \:P
00:29:25FromDiscord<ElegantBeef> You have fallen into the trap in thinking that `cstring` keeps `string` alive, but due to how `string` works it does not
00:30:22FromDiscord<riku5543> I'm surprised that the data isn't just copied and behaves like a pointer. But I guess since it's basically a pointer to a char array it would make sense that it doesn't create a whole new variable
00:30:32FromDiscord<ElegantBeef> Well this is the point of how Nim does it's strings
00:30:40FromDiscord<ElegantBeef> You can use all of the stdlib and not have to copy to send it to C
00:30:56FromDiscord<riku5543> That sounds pretty efficient honestly
00:31:10FromDiscord<ElegantBeef> Almost every modern string implementation is a pascal string that is also a cstring internally
00:31:36FromDiscord<ElegantBeef> Except those that treat `string` as a sequence of runes
00:32:35FromDiscord<ElegantBeef> In reply to @riku5543 "That sounds pretty efficient": Some might say it's a 0-cost abstraction
00:32:45FromDiscord<ElegantBeef> It's not 0-cost cause it takes an extra byte!
00:33:21FromDiscord<riku5543> Haha
00:34:41FromDiscord<riku5543> Thanks to you I can dream of having my own desktop environment haha https://media.discordapp.net/attachments/371759389889003532/1248797313254690896/image.png?ex=6664f8a1&is=6663a721&hm=359d577d757f879568c7288be0b61a73cfb4256000f5422b8dc992d3ebb4bee2&
00:34:56FromDiscord<ElegantBeef> Using raygui as a GUI toolkit is a choice
00:35:03FromDiscord<ElegantBeef> No sure I'd do it, but to each their own
00:35:47FromDiscord<riku5543> I made something similar using web tech a long time ago \:P Having nim do everything is a whole lot nicer at the very least
00:37:05FromDiscord<ElegantBeef> How accessible is raygui? Curious how much control the programmer has
00:39:24FromDiscord<riku5543> It's pretty similar to imgui, it's immediate mode and everything so you gotta keep track of state yourself. You can also mix it with regular ol raylib so you could make your own controls if you wanted to
00:39:44FromDiscord<ElegantBeef> Ah that's to say it's not
00:40:39FromDiscord<riku5543> I guess infinite control isn't accessible lol
00:41:12FromDiscord<morgan> so raylib uses like ui widgets and shapes and such?
00:42:25FromDiscord<riku5543> raygui has all the ui widgets, raylib is a general-purpose graphics library that can do whatever (draw rectangles, text, control framerate, get input, etc)
00:42:35FromDiscord<riku5543> (edit) "graphics" => "game engine(?)"
00:42:59FromDiscord<ElegantBeef> I'd calle it a framework more than an engine not that those terms mean anything
00:43:34FromDiscord<morgan> ah ok
00:44:21FromDiscord<morgan> it seemed a bit more focused on that sorta abstraction so i didn't look much into it
00:44:52FromDiscord<ElegantBeef> It's meant for education, but you can use it as a full game dev library
00:45:03FromDiscord<morgan> In reply to @morganalyssa "it seemed a bit": (as opposed to just papering over the differences between opengl and directx etc but still based on meshes and shaders)
00:45:15FromDiscord<ElegantBeef> It just uses opengl of course
00:45:20FromDiscord<riku5543> I used it instead of sdl2 to make an emulator \:D (It handled some things a little better)
00:45:39FromDiscord<ElegantBeef> I'm too deep into opengl + sdl2 to think raylib can do any better 😄
00:46:03FromDiscord<riku5543> Fair \:P I kinda gave up on sdl2 through nim cause the library is just way too c-heavy if you know what I mean
00:46:11FromDiscord<morgan> i think sokol can do better than those tho
00:46:17FromDiscord<ElegantBeef> To each their own
00:46:33FromDiscord<ElegantBeef> Opengl works well enough for me
00:46:42FromDiscord<ElegantBeef> Plus runs on all platforms I care about
00:46:56FromDiscord<morgan> yea and sokol can use opengl
00:47:08FromDiscord<morgan> or use vulkan, or metal, or two directx options
00:47:15FromDiscord<morgan> and webgpu
00:47:16FromDiscord<ElegantBeef> Yea I know what it does
00:47:29FromDiscord<morgan> ah ok
00:48:06FromDiscord<morgan> i had been using plain opengl before and it was a complete mess and i had errors i just could not fix
00:48:13FromDiscord<ElegantBeef> User error
00:48:14FromDiscord<ElegantBeef> 😛
00:48:20FromDiscord<morgan> yea
00:48:31FromDiscord<morgan> but it's also bad api design lol
00:48:40FromDiscord<riku5543> Try using vulkan 💀
00:48:44FromDiscord<ElegantBeef> I truthfully think it's fine if you use opengl 4.5+
00:48:51FromDiscord<ElegantBeef> Most people stick to like opengl3.3 and whine about the API
00:49:01FromDiscord<ElegantBeef> DSA makes life way less silly
00:49:40FromDiscord<ElegantBeef> You no longer need to do `glBind(GlTexture, myTextureHandle); glSomeOperation(GlTexture, ...)`
00:49:40FromDiscord<morgan> i was targetting some 3 version because juce only allowed targetting specific versions and the 4 version they had was newer than apple's latest version (yea i know it's part apple's fault not continuing to update their opengl support)
00:49:54FromDiscord<ElegantBeef> you just do `glNamedOperation(myTextureHandle, ...)`
00:50:03FromDiscord<ElegantBeef> It removes a lot of the global state management
00:50:13FromDiscord<riku5543> Whaat I wanna try that
00:50:40FromDiscord<morgan> that was actually the thing that pushed me to switch from juce and write plugins in nim (yea i traded pain for different pain lol)
00:51:02FromDiscord<ElegantBeef> I havent fully moved to DSA but I do try to use it in all of my new code 😄
00:51:16FromDiscord<ElegantBeef> I heavily use SSBOs aswell so I remove a lot of uniforms
00:52:01FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=tvatEDMe
00:52:16FromDiscord<ElegantBeef> Only set uniforms for the entire batch renderer
00:52:18FromDiscord<ElegantBeef> So lovely
00:52:28FromDiscord<morgan> nice
00:52:30FromDiscord<riku5543> Spicy
00:52:46FromDiscord<riku5543> Does that mean you can use opengl 4.5 in nim then?
00:52:55FromDiscord<ElegantBeef> Of course
00:53:03*SchweinDeBurg quit (Quit: WeeChat 4.4.0-dev)
00:53:16FromDiscord<ElegantBeef> <https://github.com/beef331/truss3d/> My shitty framework is here if you want to investigate
00:53:28*SchweinDeBurg joined #nim
00:54:36FromDiscord<riku5543> Hm wait a second, since I'm wrapping raygui manually, does that mean I could let the user pass in a regular string and just convert it to a cstring before calling the C code? \:o
00:54:43FromDiscord<ElegantBeef> Yes
00:55:03FromDiscord<riku5543> My library wrappers just got so much better
00:55:05*beholders_eye quit (Read error: Connection reset by peer)
00:55:27FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=AHLXkphe
00:55:38FromDiscord<ElegantBeef> (edit) "https://play.nim-lang.org/#pasty=vHzSzlGW" => "https://play.nim-lang.org/#pasty=PXYVAxEB"
00:55:42FromDiscord<ElegantBeef> Will work just fine
00:55:55FromDiscord<ElegantBeef> Also you do know about naylib right?
00:56:43FromDiscord<riku5543> Yeah \:D It doesn't wrap raygui though last I checked
00:57:06FromDiscord<riku5543> (So I just use my wrapper and naylib together)
00:58:19FromDiscord<riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=BJNdhxMA
01:01:05*beholders_eye joined #nim
01:01:08FromDiscord<ElegantBeef> No it's not
01:01:15FromDiscord<ElegantBeef> That's not even close
01:01:42FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#pasty=IHiJQBHA
01:01:44FromDiscord<ElegantBeef> There we go
01:01:47FromDiscord<ElegantBeef> We're now Nimming
01:02:21FromDiscord<riku5543> Whoa you turned it into a bool
01:02:25FromDiscord<riku5543> Like automatically
01:02:56FromDiscord<ElegantBeef> What did you think `== 0` was doing?
01:03:19FromDiscord<ElegantBeef> `guiDropdownBoxOrig(bounds, text.cstring, active, editMode).bool` is also valid
01:03:41FromDiscord<ElegantBeef> Actually that should've been `!= 0` originally
02:02:30*rockcavera quit (Remote host closed the connection)
02:07:03*beholders_eye quit (Read error: Connection reset by peer)
02:12:30*beholders_eye joined #nim
02:43:00*beholders_eye quit (Read error: Connection reset by peer)
02:49:20*beholders_eye joined #nim
03:01:56*beholders_eye quit (Read error: Connection reset by peer)
03:07:54*beholders_eye joined #nim
03:11:18*beholders_eye quit (Read error: Connection reset by peer)
03:17:17*beholders_eye joined #nim
04:03:41FromDiscord<xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=ybyStKDw
04:04:26FromDiscord<ElegantBeef> It's fine as is
04:05:37*beholders_eye quit (Read error: Connection reset by peer)
04:10:12FromDiscord<xkonti> I can't seem to find a compile-time implementation of the `myAppend` that will actually be compile-time 😦
04:10:49FromDiscord<ElegantBeef> `add`
04:11:27*beholders_eye joined #nim
04:14:19FromDiscord<ElegantBeef> `const` forces compile time evaluation
04:14:46FromDiscord<xkonti> Oh. That works! I guess I went through so many weird issues that I lost the clarity 😅
04:49:47*beholders_eye quit (Ping timeout: 264 seconds)
05:37:11FromDiscord<Phil> sent a long message, see https://pasty.ee/NaOueTMm
05:37:50FromDiscord<Phil> You can, in fact, combine the above with whatever SQL query you do against the DB for authentication
05:38:27FromDiscord<Phil> So it wouldn't even be an extra SQL query, assuming you're not doing token based auth.
05:39:43FromDiscord<Phil> If you are doing JWT based auth, you could play around with the thought of storing the boolean whether the user is past their limit or not inside the token, which circumvents the db trip all together the same way JWT based auth avoids DB trips for permission checks more generally
05:42:35FromDiscord<Phil> However, the above assumes you plan a rate limiting scheme that can be expressed with that kind of DB setup. It all depends on business logic.↵If its sufficiently more complex, you might need to write an entry into the DB per request and then aggregate over that.
05:43:41FromDiscord<Phil> In that case to avoid needing to aggregate every time you can write yourself a materialized view aka just a second table that is basically derived from the first table and just contains the data in a simple format to answer your question whether the user can have access to the API or not.
05:44:03FromDiscord<Phil> The options for this kind of stuff are myriad and it can range from medium complex to really tricky depending on business needs
05:59:30FromDiscord<xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=cxdPrDPp
06:01:46FromDiscord<xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=lwaaQrpy
06:05:02FromDiscord<ElegantBeef> Why even use a template
06:08:06FromDiscord<xkonti> In reply to @elegantbeef "Why even use a": My brain hurts when dealing with macros... At least for now. Should I make a macro that defines macros instead?
06:08:21FromDiscord<ElegantBeef> No you should stop what you're doing 😄
06:10:41FromDiscord<xkonti> Still... I need to solve this somehow.
06:15:01FromDiscord<ElegantBeef> should be `bodyNode & node.repr` to build a string
06:17:16FromDiscord<xkonti> In reply to @elegantbeef "should be `bodyNode &": Not sure if I understand in the context of my code...
06:17:51FromDiscord<ElegantBeef> sorry your `bodyNode` should just be a string
06:18:52FromDiscord<ElegantBeef> Actually i'm wrong
06:29:55FromDiscord<ElegantBeef> @xkonti https://play.nim-lang.org/#pasty=tJPgsfNL does work
06:29:57FromDiscord<ElegantBeef> But yea idk
06:30:10FromDiscord<basilajith> When I call `now()` from `std/times` I get a value like this: "2024-06-08 06:21:04+00"↵↵However, how I can I get a value like this "2024-06-04 11:05:48.791403+00" with milliseconds?
06:30:51FromDiscord<ElegantBeef> format time
06:33:07FromDiscord<xkonti> @ElegantBeef Whoah! That's awesome! I was trying to make a macro define other macros, but then the backtick values stop working from the internal macro...
06:33:21FromDiscord<ElegantBeef> templates + macros
06:33:51FromDiscord<xkonti> sent a code paste, see https://play.nim-lang.org/#pasty=wqkvrORQ
06:34:39FromDiscord<ElegantBeef> there is a html dsl
06:35:41*ntat joined #nim
06:36:06FromDiscord<ElegantBeef> Think there is htmlgen or whatever in nimble you can refer to
06:50:21FromDiscord<xkonti> Niml: https://nimble.directory/pkg/niml↵Thank you for your help @ElegantBeef !
08:53:35*coldfeet joined #nim
11:00:41*beholders_eye joined #nim
12:24:26*casaca quit (Read error: Connection reset by peer)
12:24:27*ursa-major quit (Write error: Connection reset by peer)
12:24:27*adigitoleo quit (Read error: Connection reset by peer)
12:24:27*noeontheend quit (Write error: Broken pipe)
12:24:27*johuck quit (Write error: Connection reset by peer)
12:24:28*mronetwo quit (Remote host closed the connection)
12:24:28*robertmeta quit (Remote host closed the connection)
12:24:36*mronetwo joined #nim
12:24:39*robertmeta joined #nim
12:24:40*johuck joined #nim
12:24:42*noeontheend joined #nim
12:24:43*ursa-major joined #nim
12:24:51*adigitoleo joined #nim
12:37:30*deadmarshal_ quit (Ping timeout: 256 seconds)
12:39:32FromDiscord<Robyn [She/Her]> In reply to @isofruit "The options for this": Thanks for explaining, Phil!
13:04:23ehmryare there tools for processing the JSON format for Nim docs?
13:05:41FromDiscord<sOkam! 🫐> there are at least 3-4 html dsl libraries
13:05:56FromDiscord<sOkam! 🫐> best is probably treeform's
13:06:13FromDiscord<sOkam! 🫐> `taggy` I believe it was called
13:17:59*ntat quit (Quit: Leaving)
13:53:46FromDiscord<user2m> In reply to @xkonti "Niml: https://nimble.directory/pkg/niml Thank you": theres also dekao
14:27:47*lucasta joined #nim
14:30:37FromDiscord<fabric.input_output> just make your own like everyone else :P
14:33:25*coldfeet quit (Remote host closed the connection)
14:46:22FromDiscord<user2m> In reply to @fabric.input_output "just make your own": lol yeah we need to settle on one main one. taggy looks great
15:21:56FromDiscord<double_spiral> Is there a way to rename imported symbols? Im using bindings for a c library so for whatever reason `const renamed_func = funcToRename` doesnt work
15:45:06FromDiscord<double_spiral> Ok nvm nim is aparently the collest language ever invented and automatically translates snake case with camel case
15:45:15FromDiscord<double_spiral> awesome
15:49:27*coldfeet joined #nim
16:25:02FromDiscord<sOkam! 🫐> In reply to @double_spiral "Ok nvm nim is": only the first character matters. the rest you are free to do whatev
16:25:11FromDiscord<sOkam! 🫐> one of the best features of nim, agreed
16:47:14*lucasta quit (Remote host closed the connection)
16:47:59*ntat joined #nim
17:42:13*ntat quit (Ping timeout: 268 seconds)
19:18:53*ntat joined #nim
19:51:47*ntat quit (Quit: Leaving)
20:01:29*krux02 joined #nim
20:54:46*coldfeet quit (Remote host closed the connection)
22:01:44*deadmarshal_ joined #nim
22:16:28*beholders_eye quit (Read error: Connection reset by peer)
22:22:08*beholders_eye joined #nim
22:28:41*beholders_eye quit (Read error: Connection reset by peer)
22:34:35*beholders_eye joined #nim