<< 24-01-2025 >>

00:04:26*tiorock joined #nim
00:04:26*rockcavera is now known as Guest4925
00:04:26*tiorock is now known as rockcavera
00:07:28*Guest4925 quit (Ping timeout: 252 seconds)
00:10:13*tiorock joined #nim
00:10:13*rockcavera quit (Killed (zirconium.libera.chat (Nickname regained by services)))
00:10:13*tiorock is now known as rockcavera
00:37:52FromDiscord<summarity> sent a code paste, see https://play.nim-lang.org/#pasty=aevhiABe
00:39:59FromDiscord<Elegantbeef> `setutils`
00:40:03FromDiscord<Elegantbeef> `s.toSet Digits == {}`
01:32:04*beholders_eye quit (Ping timeout: 245 seconds)
02:04:50FromDiscord<albassort> is it possible to generate a smaller js output?
02:05:21FromDiscord<albassort> currently my js output is about 200k
02:05:26FromDiscord<albassort> i would like for it to be smaller
02:05:34FromDiscord<albassort> i think i saw an alternative js implementation somewhere?
02:07:55FromDiscord<albassort> using google-closure-compiler i am able to get it to 108k
02:08:51FromDiscord<albassort> woah 52l
02:08:55FromDiscord<albassort> (edit) "52l" => "52k with --compilation_level=advanced"
02:08:57FromDiscord<albassort> eh thats good enough
02:48:45FromDiscord<Robyn [She/Her]> In reply to @albassort "is it possible to": try `-d:danger`?
02:49:04FromDiscord<Robyn [She/Her]> also maybe there's some intelligent JS minimisers
02:49:28FromDiscord<Robyn [She/Her]> alternatively you could compile the code to WASM and have JS glue to call functions
02:59:33FromDiscord<janakali> @albassort `-d:nimPreviewSlimSystem`
03:00:10FromDiscord<albassort> In reply to @battery.acid.bubblegum "try `-d:danger`?": I've been using nim since before you went to highschool, i know -d:danger exists
03:00:31FromDiscord<albassort> In reply to @janakali "<@217459674700578816> `-d:nimPreviewSlimSystem`": slim system?
03:00:39FromDiscord<Robyn [She/Her]> In reply to @albassort "I've been using nim": ...we're the same age
03:00:44FromDiscord<albassort> yes :)
03:01:05FromDiscord<Robyn [She/Her]> and it's not like you sent flags 🙃
03:01:10FromDiscord<Robyn [She/Her]> ig trim it down by hand
03:01:57FromDiscord<Robyn [She/Her]> In reply to @albassort "yes :)": you've been using Nim before 2022? jesus
03:02:09FromDiscord<albassort> we are not tyhe same age
03:02:11FromDiscord<albassort> im 21
03:02:18FromDiscord<albassort> (edit) "tyhe" => "the"
03:02:20FromDiscord<albassort> and yes
03:02:28FromDiscord<Robyn [She/Her]> In reply to @albassort "im 21": differs by a year, p minor
03:02:42FromDiscord<albassort> think the difference is uk and us middleschool then
03:03:26FromDiscord<albassort> -d:nimPreviewSlimSystem doesn't cover
03:03:29FromDiscord<albassort> (edit) "-d:nimPreviewSlimSystem doesn't cover ... " added "the functions i have"
03:04:14FromDiscord<Robyn [She/Her]> In reply to @albassort "think the difference is": 🤷‍♀️
03:04:29FromDiscord<janakali> import them explicitly
03:05:02FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=ayYGiMDa
03:05:14FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=TSldowAH
03:05:51FromDiscord<albassort> isn't $float in system?
03:06:01FromDiscord<Elegantbeef> slim system desn't effect code gen size
03:06:40FromDiscord<janakali> in my experience it does (for js backend)
03:07:45FromDiscord<janakali> In reply to @albassort "isn't $float in system?": it's in std/dollars
03:08:18FromDiscord<janakali> (edit) "std/dollars" => "system/dollars"
03:09:29FromDiscord<lainlaylie> under slim system you need std/formatfloat, isn't it
03:27:36*rockcavera quit (Remote host closed the connection)
03:53:05*alexdaguy joined #nim
03:59:19*SchweinDeBurg quit (Quit: WeeChat 4.6.0-dev)
04:13:19*SchweinDeBurg joined #nim
04:30:21FromDiscord<blackmius> how good nim OOP is? i want some sort of interfaces to implement strategy pattern but statically dont think it is possible or at least with generics it will have parasitic effect (all parent structures will have to also pass type of strategy)
04:30:46FromDiscord<Elegantbeef> It's basic single parent inheritance
04:31:29FromDiscord<Elegantbeef> You can likely just use pointer procs for the strategy pattern
04:36:36FromDiscord<albassort> its good enough
04:36:53FromDiscord<demotomohiro> In reply to @janakali "<@288750616510201856> koch uses one": Thank you!↵https://github.com/termux/termux-packages/actions/runs/12938847873↵That fixed the error and Nim has been built successfully.
04:36:57FromDiscord<albassort> to allows you to do enough OOP that it works when OOP is good and useful
04:37:07FromDiscord<Elegantbeef> Cmon now OOP is never good 😄
04:37:24FromDiscord<albassort> but as far as a lot of the abstract concepts of Java, they arne't there. You would need to do some C-like mangaling get them to work
04:37:38FromDiscord<albassort> (edit) "arne't" => "aren't"
04:38:01FromDiscord<albassort> You know beef, if you generalize OOP enough, JS has OOP
04:38:04FromDiscord<albassort> C has OOP
04:38:05FromDiscord<gigglyingallo> what nim coding language actually used for ?
04:38:17FromDiscord<albassort> its used for making programs :)
04:38:27FromDiscord<Elegantbeef> If you generalise anything you can lie about it all
04:38:39FromDiscord<gigglyingallo> interesting is it similar to python? ↵(@albassort)
04:38:44FromDiscord<Elegantbeef> No
04:38:45FromDiscord<albassort> no
04:38:57FromDiscord<gigglyingallo> ok
04:39:19FromDiscord<albassort> It looks vaguely similar in form, but in content its very different
04:39:26FromDiscord<blackmius> sent a long message, see https://pasty.ee/JUnqQysC
04:39:40FromDiscord<gigglyingallo> I am curious what stuff can I make with it? ↵(@albassort)
04:39:52FromDiscord<gigglyingallo> I know C++ python an html javascript
04:39:58FromDiscord<gigglyingallo> I know C++ python an html javascript css
04:40:04FromDiscord<Elegantbeef> Who cares what patterns you can do with OOP, the patterns aren't needed
04:40:24FromDiscord<Elegantbeef> Most of those patterns are to work around OOP and not work due to OOP
04:40:28FromDiscord<albassort> almost all of these OOP patterns are bad and shouldn't have been written or given names
04:40:47FromDiscord<Elegantbeef> `singleton` oh so you mean a global variable
04:41:03FromDiscord<albassort> You can implement all of these tho it would be a bit of work and nobody would use your library
04:41:10FromDiscord<Elegantbeef> You only need a singleton cause your system requires wrapping everything in an object and you're too lazy to pass a variable around
04:41:24FromDiscord<Elegantbeef> Or too lazy to do dependency injection
04:41:38FromDiscord<Elegantbeef> The fact singleton is here but not dependency injection is funny
04:42:07FromDiscord<albassort> fuck dependency injection idek what it means
04:42:13FromDiscord<Elegantbeef> Builder is not an OOP pattern
04:42:27FromDiscord<Elegantbeef> You write a constructor that takes in an object you want the object to interact with
04:42:35FromDiscord<blackmius> i havent seen a good dependency injection in nim yet
04:42:51FromDiscord<Elegantbeef> Cause you don't need it
04:43:11FromDiscord<Elegantbeef> You just make an object and pass it to another
04:43:13FromDiscord<Elegantbeef> We did DI
04:43:19FromDiscord<albassort> In reply to @Elegantbeef "You write a constructor": this is DI?
04:43:25FromDiscord<Elegantbeef> Yes
04:43:34FromDiscord<blackmius> how can i make mockups tests if i cant pass different type?
04:43:44FromDiscord<Elegantbeef> > In software engineering, dependency injection is a programming technique in which an object or function receives other objects or functions that it requires, as opposed to creating them internally.
04:44:06FromDiscord<albassort> thats just like, called programming
04:44:08FromDiscord<albassort> :|
04:44:20FromDiscord<Elegantbeef> Yes but it's OOP land so you need a fancy term else it gets axed
04:44:28FromDiscord<Elegantbeef> So write the code to test the public interface
04:44:34FromDiscord<Elegantbeef> I'm not one for supporting mock testing
04:44:46FromDiscord<Elegantbeef> When you are not testing a true API what are you truly testing?
04:45:09FromDiscord<blackmius> how my code reacts on responses
04:45:16FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=HPWNRswU
04:45:27FromDiscord<Elegantbeef> Nah that's not DI
04:45:31FromDiscord<albassort> (edit) "https://play.nim-lang.org/#pasty=bVCHbcKk" => "https://play.nim-lang.org/#pasty=hkmEmdUx"
04:45:44FromDiscord<albassort> In reply to @blackmius "how my code reacts": idk what this means
04:46:00FromDiscord<Elegantbeef> Now we're doing DI
04:46:00FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=JvNCvKzl
04:46:07FromDiscord<muddmaker> DI is used all over the place in C#/Java land
04:46:11FromDiscord<Elegantbeef> They want to ensure their code reacts as they expect on specific server responses
04:46:31FromDiscord<blackmius> In reply to @muddmaker "DI is used all": i am using it in python
04:46:54*xet7 joined #nim
04:47:10FromDiscord<Elegantbeef> It's used a lot, but it's only special cause people reach for singletons instead in OOPland
04:47:49FromDiscord<Elegantbeef> Tightly coupling the class to a singleton in a cyclical hell
04:48:26FromDiscord<albassort> In reply to @blackmius "i am using it": well then why are you here
04:49:17FromDiscord<albassort> Singletons are cool ig but why not jsut have a object in globally shared memory?
04:49:30FromDiscord<albassort> well, if you wanna store local date to it ig
04:49:40FromDiscord<Elegantbeef> Cause like in Unity people want to have a inspector 😛
04:49:41FromDiscord<albassort> these cocepts come from bad roots tho
04:49:53FromDiscord<Elegantbeef> Singletons are more common in game engines due to that inspector
04:50:08FromDiscord<Elegantbeef> So you get dumb classes like "GameManager"
04:50:16FromDiscord<Elegantbeef> What's it do "It manages the game"
04:50:19FromDiscord<albassort> I just think the idea of programming a game engine or interacting with a game engine in C# is like the worst idea i can imagine
04:50:35FromDiscord<muddmaker> It's common in enterprise web frameworks
04:50:36FromDiscord<Elegantbeef> Programming a game engine is hunky dory
04:50:43FromDiscord<Elegantbeef> Now using C#.... 😄
04:50:45FromDiscord<muddmaker> Like ASP.net Core
04:50:57FromDiscord<albassort> yeah Ik at my old job aspnet core and swagger
04:51:02FromDiscord<albassort> linq
04:51:04FromDiscord<albassort> its all nonsense tho
04:51:24FromDiscord<muddmaker> Everything Microsoft touches is overarchitected to death
04:51:32FromDiscord<albassort> overengineered solutions to overcomplicated problems
04:51:59FromDiscord<Elegantbeef> Atleast MS doesn't have the naming issues Oracle has
04:52:12FromDiscord<albassort> like the sheer human labor pored into LINQ, a project that doesn't need to exist
04:52:23FromDiscord<albassort> (edit) "pored" => "poured"
04:52:55FromDiscord<albassort> my ORM is like 100 lines of code, runs faster, and has less bugs
04:53:08FromDiscord<albassort> (edit) "bugs" => "bugs, and is easier to use"
04:53:27FromDiscord<muddmaker> Linq isn't the ORM, though, that's EntityFramework
04:53:39FromDiscord<albassort> they go hand in hand
04:53:42FromDiscord<albassort> but yes linq is fine ig
04:53:44FromDiscord<albassort> EF is the issue
04:53:53FromDiscord<albassort> (edit) "EF is the issue ... " added "i meant to say"
04:53:54FromDiscord<muddmaker> Fuck EF with a cactus
04:54:19FromDiscord<albassort> 10,000+ hours of cumulative human effort in its creation
04:54:41FromDiscord<muddmaker> Took until the past couple years to add UpdateWhere
04:55:36FromDiscord<Elegantbeef> I'm so happy i'm pretty much over here playing with wooden blocks going "What's a database"
04:56:19FromDiscord<albassort> In reply to @muddmaker "Took until the past": they dont have Match in their sqlite bindings
04:56:30FromDiscord<albassort> tbf nim's bind() doesn't work with it either
04:56:55FromDiscord<blackmius> In reply to @Elegantbeef "It's basic single parent": how vtable is implemented? every inherited ref object having vtable inself or how dispatch function knows which realisation to use?
04:57:16FromDiscord<Elegantbeef> Nim doesn't have vtables withotu a flag
04:57:24FromDiscord<Elegantbeef> It's a large switch statement without that flagh
04:57:42FromDiscord<Elegantbeef> With that flag you have to declare all your types in the same file iirc
04:58:09FromDiscord<Elegantbeef> Ah nvm that's not true
04:58:10FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual_experimental.html#vtable-for-methods
04:59:19FromDiscord<albassort> should i even ask
04:59:43FromDiscord<Elegantbeef> If you want to
05:00:17FromDiscord<blackmius> In reply to @Elegantbeef "https://nim-lang.org/docs/manual_experimental.html#": is typeinfo accessable?
05:00:18FromDiscord<albassort> oh i undrstand
05:00:50FromDiscord<Elegantbeef> Sure but it's really limited
05:01:02FromDiscord<blackmius> can i monkeypatch it for specific object?
05:01:39FromDiscord<Elegantbeef> Probably
05:01:42FromDiscord<Elegantbeef> Would have to ask ringabout
05:02:25FromDiscord<albassort> ok look, heres the deal.↵Nim is not a OOP first class language. We CAN do it, kinda. But nobody programs, very few people would be able to help you or give you support if you need it.↵↵As they say, "When in Rome, do as the Romans do". Perhaps it would benefit you to learn a new style of programming?
05:06:01FromDiscord<blackmius> In reply to @albassort "ok look, heres the": write duplicate code or mangle with proc pointers this your alternative
05:06:30FromDiscord<albassort> Probably more foundational, where you wouldn't be writing methods and such
05:06:41FromDiscord<Elegantbeef> Why do you have to duplicate code?
05:07:10FromDiscord<albassort> my http dispatcher uses str-:> pointer tables but, thats really the only time i've ever needed this
05:07:30FromDiscord<albassort> and this is over a very long time
05:08:04FromDiscord<blackmius> In reply to @Elegantbeef "Why do you have": without runtime dispatch it is hard to write less code and pass multiple realisations
05:08:45FromDiscord<Elegantbeef> Can you provide a code example?
05:11:29FromDiscord<blackmius> std/streams status-im/asyncstreams boringssl↵↵mangle with creating runtime vtable
05:11:51FromDiscord<blackmius> i dont want to write code compiler have to
05:12:18FromDiscord<Elegantbeef> Ah right
05:12:22FromDiscord<Elegantbeef> https://github.com/beef331/traitor my counter point
05:13:00FromDiscord<Elegantbeef> Does suck that it relies on macros
05:13:06FromDiscord<Elegantbeef> Better than relying on inheritance tree for 'interfaces'
05:13:50FromDiscord<lainlaylie> isnt std/streams an example of why trying to do runtime dispatch is a bad idea?
05:14:26FromDiscord<Elegantbeef> It shows an alternative to using methods really
05:15:08FromDiscord<Elegantbeef> A vast majority of the time you'd want to have the static variations, but it pollutes the entire system with runtime dispatch
05:15:12FromDiscord<blackmius> so i am wishing something like go's interfaces
05:15:49FromDiscord<Elegantbeef> This is why I have `StaticTraitor` so I can force traits without having to corrupt the entire api with static dispatch 😄
05:15:56FromDiscord<Elegantbeef> runtime dispatch\
05:15:56FromDiscord<blackmius> maybe i need to change chat and asking go channel how can i create macros
05:16:20FromDiscord<albassort> beef why would you make this
05:16:44FromDiscord<Elegantbeef> There is also iface which is another interface API
05:16:51FromDiscord<lainlaylie> i thought we were talking about alternatives to oop, not trying to reimplement oop without methods
05:16:52FromDiscord<Elegantbeef> > A trait library made from bordem.
05:16:55FromDiscord<Elegantbeef> I like my constrained generics so why wouldn't I makei t
05:18:05FromDiscord<albassort> i respect it beef but this is dumnb
05:18:07FromDiscord<albassort> (edit) "dumnb" => "dumb"
05:18:30FromDiscord<albassort> bravo
05:18:31FromDiscord<Elegantbeef> It's really not
05:18:31FromDiscord<Elegantbeef> I actively use it where I need it
05:18:58FromDiscord<Elegantbeef> Why would I want to introduce inheritance trees
05:20:02FromDiscord<Elegantbeef> Be afraid, be very afraid
05:20:04FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1332218339648475256/image.png?ex=67947483&is=67932303&hm=e4caf39e5ba08836075f234b049e7a0dab7c18264359dd248edce3be3e0abf17&
05:20:23FromDiscord<albassort> its kinda cool that .onClick() just didn't exist and now it does
05:21:50FromDiscord<albassort> hey beef what does "gameState" do :-)
05:22:03FromDiscord<Elegantbeef> On top of it you can do `StaticTrait[Clickable]` which just ensures it compiles
05:22:06FromDiscord<Elegantbeef> Or whatever the name is
05:22:19FromDiscord<Elegantbeef> It unironically just holds gamestate
05:22:39FromDiscord<albassort> it holds the game state
05:22:55FromDiscord<Elegantbeef> Pass it around to get data from the game state and do not have global variables
05:25:28FromDiscord<albassort> i need to make a macro that adds "export" to js functions
05:25:32FromDiscord<albassort> "exportjs"
05:26:01FromDiscord<Elegantbeef> Just `{.push exportjs.}`
05:27:03FromDiscord<muddmaker> In reply to @albassort "tbf nim's bind() doesn't": The best pattern I've seen for databases now is to have write raw sql for each query, and at build time to have that query run against the DB in a way that generates the necessary types for it
05:27:26FromDiscord<muddmaker> This is what go's sqlc and rusts sqlx do
05:27:59FromDiscord<muddmaker> (edit) "rusts" => "rust's"
05:28:05FromDiscord<albassort> i might write something to scaffold a postgres databse for nim
05:28:18FromDiscord<albassort> mine does this
05:28:58FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=NSHDBGlT
05:29:05FromDiscord<albassort> where typdesc is a manually written type
05:29:31FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=ZKZpQNkq
05:29:40FromDiscord<albassort> that has to be ordered according to the rows you want to get
05:30:05FromDiscord<albassort> (edit) "https://play.nim-lang.org/#pasty=RgFKfHgy" => "https://play.nim-lang.org/#pasty=vuCmaRGQ"
05:30:07FromDiscord<muddmaker> Yeah... the main thing that sqlc would do differently is auto generate that type
05:30:34FromDiscord<muddmaker> Which is useful in the event that the schema changes and you want to see what breaks at compile time
05:31:22FromDiscord<albassort> how do you get the data from it if its not generated pre-compile time
05:31:29FromDiscord<albassort> is it not static?
05:33:14FromDiscord<muddmaker> Here's their marketing: <https://sqlc.dev/>
05:33:53FromDiscord<muddmaker> It's just a command that is run to generate the necessary code
05:34:03FromDiscord<albassort> you would need to get the stuff before the lexer for nim
05:34:13FromDiscord<albassort> idk how you would implement this
05:34:15FromDiscord<albassort> macro amgic
05:34:16FromDiscord<albassort> (edit) "amgic" => "magic"
05:35:42FromDiscord<muddmaker> For sqlc, I think the queries are just written in a different file. Rust's sqlx will actually run it within rust's macro system, but it's still recommended to put the queries in another file for the sake of syntax highlighting and other tooling
05:36:06FromDiscord<albassort> they i bet this can be written in 500 lines of nim
05:36:37FromDiscord<muddmaker> So your project would just be structured to have a `queries/` directory, and it would make a `src/queries.nim` that you could include and call with
05:41:36FromDiscord<albassort> i cant find a way to get the types and names without at least a sample query...
05:42:26FromDiscord<Elegantbeef> I imagine in Nim you'd do like `type MyType = queryType(sqlHere)`
05:43:00FromDiscord<albassort> nah im just thinking about writing a scaffolder
05:47:27FromDiscord<albassort> i was feeling burned out so i will do this today instead of being productive
05:47:53FromDiscord<albassort> (edit) "burned" => "burnt"
05:50:52FromDiscord<albassort> also im programming a groupBy proc
05:51:07FromDiscord<albassort> be very afraid beef, i am sequtil-ing
05:51:18FromDiscord<albassort> although my code will probably be less of a dumpsterfire
05:51:46*coldfeet joined #nim
05:53:47*coldfeet quit (Client Quit)
06:42:11FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=ecccToGZ
06:45:59FromDiscord<albassort> beef would it be possible to make a macro that, you stable to a type, that, at compile times runs this code, generates an object, and compares it to the reference type, and if it failes the compilation fails and it spits the typedef out
06:47:12FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=JHDKtIuo
06:50:15FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=crfhJMnZ
07:13:42FromDiscord<yummy_licorice> is there a way to transfer data between threads?
07:13:51FromDiscord<albassort> In reply to @yummy_licorice "is there a way": many
07:13:57FromDiscord<albassort> depends what you're trying to do which is best
07:14:20FromDiscord<albassort> Channels, shared ptrs, and atomics come to mind
07:15:06FromDiscord<albassort> channels communicate between threads, shared ptrs are globally alloced, and so are atomics but they're different lol
07:15:29FromDiscord<yummy_licorice> i see
07:15:42FromDiscord<yummy_licorice> thanks
07:18:06FromDiscord<luteva> In reply to @nnsee "so instead of `import": first of all: Thyx a lot! That worked fine!↵What is the preferred way/process to handle these lib-verison-issues? ↵- Create a PR for the exitisting project? (Which won't work for nim version 1.x) OR↵- Create a fork or a new project of the (old) project to work with the current nim version?
07:19:41FromDiscord<luteva> maybe there even is a doc of how to handle these version issues?
07:19:57FromDiscord<nnsee> worth making a PR but if this is Ormin then that hasn't been updated in years
07:20:08FromDiscord<nnsee> and you're probably better off just rolling your own fork
07:20:53FromDiscord<nnsee> I doubt many people are still using 1.6.x, and if they are, they can pin the dependency to a specific version or commit
07:21:21FromDiscord<yummy_licorice> sent a code paste, see https://play.nim-lang.org/#pasty=aJlWztlh
07:21:55FromDiscord<lainlaylie> In reply to @luteva "first of all: Thyx": why wouldn't this fix work for nim 1.x.x?
07:22:15FromDiscord<nnsee> oh yeah good point
07:22:43FromDiscord<nnsee> the db_connector module doesn't have a hard dependency on 2.x and can also be installed for 1.x
07:27:59FromDiscord<lainlaylie> i wonder if stuff like `when NimMajor < 2: requires "..."` works in nimble files
07:28:09FromDiscord<Elegantbeef> Yesn't
07:29:26FromDiscord<albassort> In reply to @yummy_licorice "i also had a": im unsure, but fair warning, async in nim can be buggy and i avoid it
07:30:25FromDiscord<yummy_licorice> In reply to @albassort "im unsure, but fair": would it be easier to have the ipc server and the window manager update loop on different threads
07:30:34FromDiscord<albassort> no
07:30:47FromDiscord<albassort> although thats how i programmed by http server lol
07:31:10FromDiscord<yummy_licorice> should i rewrite the update loop for the window loop to also poll for socket events?
07:31:18FromDiscord<yummy_licorice> that may be a bit easier
07:31:39FromDiscord<albassort> yeah, at the very least it will help with debugging whatever is going wrong with async
07:31:44FromDiscord<Elegantbeef> Here I am almost always using selectors over async as I find there less to faff with 😄
07:31:45FromDiscord<albassort> also make sure your nim is up to date
07:32:03FromDiscord<albassort> beef is a thread hater
07:32:11FromDiscord<yummy_licorice> In reply to @albassort "also make sure your": im on 2.2.0
07:32:21FromDiscord<Elegantbeef> I mean threads aren't needed for basic IO
07:32:59FromDiscord<albassort> my scaffolder works now i just need to... do something...
07:35:42*ntat joined #nim
07:37:52FromDiscord<albassort> i should have wrote this 2 months ago
07:37:55FromDiscord<nnsee> In reply to @Elegantbeef "I mean threads aren't": i always write my code to use all of my cores. unused cores are wasted cores. i also write my code to consume as many cycles as possible
07:38:12FromDiscord<Elegantbeef> What about ram?
07:38:28FromDiscord<nnsee> obviously all of the ram
07:38:35FromDiscord<albassort> wasted cycles is wasted frequency
07:38:44FromDiscord<Elegantbeef> I always do `discard alloc(int32.high)` just so the user knows I mean business
07:39:02FromDiscord<albassort> you know, some Taiwanese workers owrked really hard to make your cpu 4ghz, and you're gonna waste it by optimizing your code
07:39:35FromDiscord<albassort> (edit) "owrked" => "worked"
07:40:42FromDiscord<Elegantbeef> Wirth is rolling
07:42:09FromDiscord<mrgaturus> In reply to @albassort "you know, some Taiwanese": you need also understand the OS needs schedule hundred of processes just for 4/8 cores
07:42:53FromDiscord<nnsee> this is why we invented scheduling like 80 years ago
07:43:42FromDiscord<Elegantbeef> What's the airspeed of a fully laden 8 thread processor?
07:46:14Amun-RaElegantbeef: what do you mean, european or african one?
07:49:38FromDiscord<Elegantbeef> I have to imagine there is no difference
07:49:58FromDiscord<yummy_licorice> In reply to @yummy_licorice "that may be a": ok now i feel dumb ass hell 😭 there is no loop function, i wrote the loop myself then forgot i wrote the loop
07:50:03FromDiscord<yummy_licorice> (edit) "ass" => "as"
08:07:13*tokyovigilante quit (Read error: Connection reset by peer)
08:07:28*tokyovigilante joined #nim
09:26:44*beholders_eye joined #nim
09:30:42FromDiscord<spotlightkid> Is there a way to mark a proc, which I imported from somewhere else, as `discardable`? Without creating a wrapper proc?↵Templates apparently do not support the `discardable` pragma.
09:41:47FromDiscord<firasuke> What's a good fast hashing algorithm implemented in pure Nim (for file checksums, preferrably cryptographic)?
09:57:10FromDiscord<spotlightkid> @firasuke\: is it a problem of finding or of choosing? because there are tons of hashing libraries here\: https://nimpkgs.dayl.in/?query=hash#/search
10:47:16*oisota quit (Quit: Ping timeout (120 seconds))
10:47:35*oisota joined #nim
11:05:43FromDiscord<firasuke> In reply to @spotlightkid "<@248208053952970752>\: is it a": I'd say it's the latter, I found BLAKE3 from `hashlib` but it turns out it's using the C implementation underneath
11:06:57FromDiscord<firasuke> In reply to @spotlightkid "<@248208053952970752>\: is it a": also wait, since when did we have a cool website for searching for available nim libraries? I recall nimble directory, but that's pretty much about it
11:10:23FromDiscord<nnsee> In reply to @firasuke "I'd say it's the": check out Constantine and its SHA256 impl https://github.com/mratsim/constantine?tab=readme-ov-file#general-cryptography
11:11:10FromDiscord<nnsee> iirc it takes advantage of hw acceleration where possible
11:11:25FromDiscord<nnsee> @mratsim can probably say more about this
11:11:43FromDiscord<firasuke> Cool, thanks
11:13:17FromDiscord<nnsee> the impl itself is here https://github.com/mratsim/constantine/tree/master/constantine/hashes
11:18:08*SchweinDeBurg quit (Ping timeout: 264 seconds)
11:19:38*SchweinDeBurg joined #nim
11:47:44*SchweinDeBurg quit (Ping timeout: 244 seconds)
11:49:39FromDiscord<albassort> having an issue where socket.send() is getting trapped in there
11:49:55*SchweinDeBurg joined #nim
11:50:34FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#pasty=JTgWVdZg
11:51:26FromDiscord<Phil> (edit) "https://play.nim-lang.org/#pasty=SSDEDgOz" => "https://play.nim-lang.org/#pasty=LZBmLwdU"
11:54:13FromDiscord<albassort> In reply to @albassort "having an issue where": its probably a bug in the src, im trying to fix it :)\
11:57:54FromDiscord<albassort> net.nim:1764 is failing to raise
11:58:05FromDiscord<albassort> (edit) "net.nim:1764 is failing to raise ... " added "socketError"
11:59:00FromDiscord<albassort> seems they're missing a break
12:00:51FromDiscord<albassort> socketError(socket, lastError = lastError, flags = flags)
12:01:00FromDiscord<albassort> https://github.com/nim-lang/Nim/blob/8fe518ed47163e4fdcad1f17eab589283585ad3f/lib/pure/net.nim#L1763
12:01:12FromDiscord<albassort> add a break after this line
12:01:40FromDiscord<albassort> can someone else double check this to make sure im not crazy
12:03:57FromDiscord<albassort> > ## If `flags` contains `SafeDisconn`, no exception will be raised↵> ## when the error was caused by a peer disconnection.
12:04:31FromDiscord<albassort> yeah so it seems nobody considered the case where, SockerError wont be raised and data can no longer b written?
12:26:34FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=zqGECYHM
13:23:18FromDiscord<firasuke> sent a code paste, see https://play.nim-lang.org/#pasty=VzkZIdsZ
13:26:50FromDiscord<firasuke> Or do I have to duplicate the file handle of `fd1`?
13:31:56FromDiscord<nnsee> yep, you need to `dup2` it
13:35:13FromDiscord<nasuray> In reply to @firasuke "also wait, since when": Since I was bored one weekend and annoyed that looking at my own packages was broken because of faulty tag handling by nimble.directory
13:35:46FromDiscord<spotlightkid> @firasuke\: you can also just do `stdout.write("blah")`, of course.
13:48:30FromDiscord<firasuke> In reply to @nasuray "Since I was bored": thanks for your work
13:49:17FromDiscord<firasuke> In reply to @spotlightkid "<@248208053952970752>\: you can also": that is equivalent to `echo` without flushing, but what I want is a redirect
13:50:13FromDiscord<firasuke> sent a code paste, see https://play.nim-lang.org/#pasty=xBqvzGdq
13:55:58FromDiscord<firasuke> In reply to @firasuke "this version works as": Is this correct? or should I use `dup2` instead?
13:56:49FromDiscord<nnsee> i meant the dup2 syscall
13:56:55FromDiscord<nnsee> if you're doing it this way it should be fine
14:00:10FromDiscord<firasuke> In reply to @nnsee "if you're doing it": oh ok, you mean the version above correct?
14:00:34FromDiscord<nnsee> In reply to @firasuke "oh ok, you mean": if it works as intended then probably
14:01:04FromDiscord<firasuke> In reply to @nnsee "if it works as": Alright, I also found this: https://forum.nim-lang.org/t/6909
14:02:21FromDiscord<nnsee> In reply to @firasuke "Alright, I also found": that link says you should probably be using dup2
15:07:54*alexdaguy quit (Quit: w)
15:17:04*arkanoid joined #nim
15:17:30arkanoidhello! how can I remove -lrt from linking pass?
15:23:46arkanoidI am trying with switch("clang.options.linker", "") but it keeps adding -lm -lrt and so on
15:24:40Amun-Rawhat os?
15:25:29arkanoidlinux
15:25:40Amun-Rawhen cross-compiling for windows I added -Wl,-Bstatic
15:25:55arkanoidI am trying to solve this problem, but forum post is 10 years old https://forum.nim-lang.org/t/1729
15:26:08arkanoidI have to remove, not add
15:26:23Amun-Rayes, that removes -ldl
15:26:57Amun-Ramy first method was dynliboverride
15:27:06arkanoidI have "switch("passl", "-target x86_64-macos -fno-sanitize=undefined")" but linkers errors out "error: unable to find dynamic system library 'rt' using strategy 'paths_first'. searched paths: none" because "-pthread -pthread -lm -lm -lrt -target x86_64-macos -fno-sanitize=undefined -ldl"
15:27:44Amun-Raif you can build static binary add -static
15:28:18arkanoidalready tried, same error. "-pthread -pthread -lm -lm -lrt -target x86_64-macos -fno-sanitize=undefined -static -ldl"
15:29:42Amun-Rayou can override gcc.options.linker in nim.cfg
15:29:43arkanoidyou see I have duplicated entries possibly because nim is adding options that the linker is automatically using (I'm using zigcc to cross compile)
15:30:22Amun-Raduplicated libs make no difference
15:30:23arkanoidI already set switch("clang.options.linker", "") and switch("gcc.options.linker", ""), it still adds flags
15:31:21Amun-RaI suspect switch-ing clang.options.linker in config.nims does not work
15:31:35Amun-Ratry to change it in nim.cfg
15:32:07Amun-Ragcc.options.linker = ""
15:32:16Amun-Raor clang if that's the cc
15:35:54*coldfeet joined #nim
15:51:08arkanoidAmun-Ra: seems not working
15:53:20Amun-Ra:/
15:53:42arkanoidI don't see where -lrt is added to linking args https://github.com/nim-lang/Nim/blob/devel/config/nim.cfg
15:53:45Amun-Rawhat the output of --listcmd looks like?
15:56:23arkanoidhttps://termbin.com/l6iw
15:56:50arkanoidthe last 2 are the ones I am playing with. The first 2 are unchanged from nim 2.2.0 tarball
15:57:22arkanoidI'm building with nimble build --verbose and it shows cfg files are being used
15:58:01arkanoidbut I get same result using nim c src/foo.nim
16:02:04Amun-RaI mean add --listcmd to the build args
16:03:23*coldfeet quit (Quit: Lost terminal)
16:04:44FromDiscord<luteva> In reply to @lainlaylie "why wouldn't this fix": Because in nim 1.x.x the libs are part of the stdlib
16:07:21arkanoidAmun-Ra: solved. Linking options are controlled by --os switch. I have to use switch("os", "MacOSX")
16:07:49arkanoidI was trying with "MacOS" and it was not working
16:08:17FromDiscord<luteva> Oh yeah you are right! Should work for nim 1.x.x , too!
16:10:32Amun-Raah
17:46:06FromDiscord<threefour> Anyone familiar with NimYAML? I'm trying to figure out how to load a YAML field into a differently-named object field. The field name is `type`, but I can't put that field on the object because it's a reserved keyword.
17:48:10FromDiscord<flyx> yeah, I've written it. easiest way is to put the name in backticks like so\: ``type``↵(@threefour)
17:50:21FromDiscord<threefour> Duh. I don't know why I didn't try that. Works great, thanks. Do you by chance know how to do the other approach, which would be mapping the original field onto a differently-named object field? In case I ever want to do that.
17:53:33FromDiscord<flyx> you'd need to write a custom constructor for the type containing the field (and possibly a representer if you want to write the data out again). that would be rather tedious since you'd need to recreate the logic that comes for free with the default generic object constructor (i.e. checking each field name, calling the appropriate child constructors, checking whether all required values are present and so on)↵(@threefour)
17:54:53FromDiscord<flyx> the third approach would be to create an issue „please implement an annotation to let the YAML have a key different from the field name in Nim“. I never implemented that yet because no-one asked ;)↵(@threefour)
17:58:57*ntat quit (Remote host closed the connection)
17:59:16*ntat joined #nim
18:01:38arkanoidis there a non gc-ed string in nim? I want a global variable string with pre-allocated max length to be shared between threads (using locks). At the moment I get "'mythread' is not GC-safe as it accesses 'config' which is a global using GC'ed memory"
18:02:38FromDiscord<threefour> Oh I just realized you meant _you_ built the thing. Yeah, it's something I use semi frequently when loading YAML in Go. Maybe I'll create an issue. I can't be the only one that does that.
18:02:44FromDiscord<threefour> Thanks for the quick response
18:05:48FromDiscord<demotomohiro> @arkanoid array[char, Len] with cstring is.
18:08:12FromDiscord<pointystick> arkanoid, is this useful for you? https://github.com/termermc/nim-stack-strings I've not used it myself, I just remember seeing it in mentioned a while ago
18:10:00arkanoidpointystick: thanks!
18:10:34arkanoiddemotomohiro, interesting, I'll try with cstring too
18:21:53arkanoidpointystick it works!
18:23:17Amun-Rahmm, I wrote something similar
18:41:35FromDiscord<Phil> Can nimcall capture variables from the procs environment?
18:41:43FromDiscord<Phil> (edit) "Can nimcall ... capture" added "procs"
18:42:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#pasty=dKQJtaGT
18:46:06FromDiscord<threefour> @flyx probably a dumb question, but how do I access the object field now? Trying to do `<object>.\`type\`` gives me the actual object type, not the value for the field.
18:46:14FromDiscord<threefour> (edit) "`<object>.\`type\``" => "<object>.\`type\`"
18:53:28FromDiscord<demotomohiro> In reply to @isofruit "I'm slightly confused that": https://internet-of-tomohiro.pages.dev/nim/faq.en#coding-what-is-the-difference-between-variables-inside-procedures-and-outside-proceduresqmark↵Variables inside procedures and outside procedures are different.
18:54:11FromDiscord<flyx> not sure what happens here, I don't regularly write Nim these days. someone else might have an idea. this thread implies it should work https://forum.nim-lang.org/t/7191↵(@threefour)
18:54:53FromDiscord<demotomohiro> You need to use closure proc when you capture variables inside procedures.↵Any procs can access variables outside procedures.
19:02:28FromDiscord<Phil> In reply to @demotomohiro "You need to use": Check, that explains why I'm running into issues with norm >_>
19:06:08FromDiscord<solitudesf> In reply to @threefour "@flyx probably a dumb": is your `type` field exported?
19:06:13FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#pasty=sKiACsEv
19:06:43FromDiscord<threefour> Yeah looks like my deserialization setup is wrong, not the backticks.
19:08:56FromDiscord<threefour> My object model
19:18:52FromDiscord<threefour> sent a code paste, see https://play.nim-lang.org/#pasty=LatgkudA
19:19:16FromDiscord<threefour> Where the unknown keys I obviously don't the name of ahead of time.
19:20:31FromDiscord<threefour> sent a code paste, see https://play.nim-lang.org/#pasty=YYcToXZS
19:21:35FromDiscord<threefour> Okay nevermind scratch absolutely all of what I said. I got it working. Sorry for spam.
20:08:31*xet7 quit (Remote host closed the connection)
20:31:36*xet7 joined #nim
22:28:00*beholders_eye quit (Ping timeout: 252 seconds)
22:30:58*beholders_eye joined #nim
22:48:08*FromDiscord quit (Remote host closed the connection)
22:48:21*FromDiscord joined #nim
23:00:03*ntat quit (Quit: Leaving)