00:14:16 | NimEventer | New thread by tcheran: How to properly init a Table of seq, see https://forum.nim-lang.org/t/9515 |
00:23:56 | FromDiscord | <Elegantbeef> @Patitotective\: so i got a little bored https://github.com/beef331/recyclable/blob/master/src/recyclable/unicode.nim |
00:24:13 | FromDiscord | <Elegantbeef> Parseutils is next but it uses magic so it's' a bit of a pain |
00:25:38 | FromDiscord | <konradmb> @albassort\: there is `parallel for` in stdlib https://nim-lang.org/docs/system.html#%7C%7C.i%2CS%2CT%2Cstaticstring |
00:44:57 | * | fallback joined #nim |
02:08:50 | * | arkurious quit (Quit: Leaving) |
03:01:19 | * | rockcavera joined #nim |
03:01:19 | * | rockcavera quit (Changing host) |
03:01:19 | * | rockcavera joined #nim |
03:11:32 | FromDiscord | <Mr.Ender> So I noticed something about links if you type "steam:(something)" it will take you to that page on the steam desktop app. How could I have links with my own custom thing: that would redirect to my app and send the url data to it? |
03:11:41 | FromDiscord | <Mr.Ender> (edit) "it?" => "it?↵↵(Please ping in reply)" |
03:24:54 | FromDiscord | <Rika> In reply to @Mr.Ender "So I noticed something": https://stackoverflow.com/questions/796748/how-can-i-add-a-custom-url-handler-on-windows-like-itunes-itms |
03:36:48 | FromDiscord | <Mr.Ender> In reply to @Rika "https://stackoverflow.com/questions/796748/how-can-": Thank you |
03:37:05 | FromDiscord | <Rika> It won’t really work for Linux , would prolly need a different solution |
03:37:11 | FromDiscord | <Rika> Probably also easily searchable |
03:46:26 | FromDiscord | <huantian> with linux you have to register a mime type |
05:35:21 | FromDiscord | <Not Saucx> Hi, How come when i try printing to console, terminal is blank unless i input something? |
05:37:12 | FromDiscord | <JustADigimon (she/her)> In reply to @Not Saucx "Hi, How come when": show code |
05:38:28 | FromDiscord | <Not Saucx> sent a code paste, see https://play.nim-lang.org/#ix=4cDO |
05:38:47 | FromDiscord | <Elegantbeef> You might need to do `stdoud.flushFile` |
05:38:52 | FromDiscord | <Elegantbeef> `stdout` rather |
05:39:34 | FromDiscord | <Not Saucx> In reply to @Elegantbeef "You might need to": where? |
05:39:45 | FromDiscord | <Elegantbeef> After you writeline |
05:41:11 | FromDiscord | <Not Saucx> In reply to @Elegantbeef "After you writeline": I still have to input |
05:41:17 | FromDiscord | <Not Saucx> b/4 it shows anything |
05:41:25 | FromDiscord | <Not Saucx> like why is it blank |
05:41:33 | FromDiscord | <Elegantbeef> Cause you dont flush the file |
05:41:44 | FromDiscord | <Elegantbeef> Your order is wrong |
05:41:53 | FromDiscord | <Not Saucx> what do I do? |
05:41:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4cDS |
05:41:58 | FromDiscord | <Elegantbeef> swap those two lines |
05:42:31 | FromDiscord | <Not Saucx> yup |
05:42:32 | FromDiscord | <Not Saucx> haha |
05:42:33 | FromDiscord | <Not Saucx> ok |
05:49:05 | * | CyberTailor joined #nim |
06:43:34 | * | CyberTailor quit (Remote host closed the connection) |
06:46:16 | * | CyberTailor joined #nim |
06:54:05 | * | CyberTailor quit (Remote host closed the connection) |
06:56:33 | * | CyberTailor joined #nim |
07:03:37 | FromDiscord | <oswaltmalcolmbtc> sent a long message, see http://ix.io/4cE1 |
07:04:57 | * | CyberTailor left #nim (Konversation terminated!) |
07:09:39 | FromDiscord | <Phil> <@&371760044473319454> The scum has invaded! |
07:16:15 | FromDiscord | <Elegantbeef> I've always been here |
07:30:29 | strogon14 | When I set a cleanup proc with setControlCHook my program still exits with a return code of 130 and prints a traceback when I press Control-C to end it. How can I exit cleanly with Control-C? |
07:33:11 | FromDiscord | <Elegantbeef> `quit QuitSuccess` iirc |
07:41:21 | strogon14 | No, that doesn't seem to have any effect (I had 'quit 0' before too) |
08:28:46 | * | Jjp137 quit (Ping timeout: 246 seconds) |
08:29:06 | * | Jjp137 joined #nim |
08:37:26 | * | pro joined #nim |
09:34:22 | FromDiscord | <qb> Hey I got issues to create a wrapper for a c library with nimterop. Two conditions I would like to have is just exporting symbols with `Ex` in it and also this library uses a lot of custom type definitions which I would like to have as standard nim types (https://github.com/rdbo/libmem/blob/master/libmem/libmem.h#L504). Could someone help out? I want to mention that this is the first time I'm using nimterop. |
09:34:58 | FromDiscord | <qb> Not sure if the type definition issue is doable |
09:52:09 | * | kenran joined #nim |
10:11:48 | FromDiscord | <skiddie99> hello alllll |
10:11:54 | FromDiscord | <skiddie99> I'm excited to be here:DD |
10:12:03 | FromDiscord | <skiddie99> may I ask you if anyone has used nim for making rest apis? |
10:14:15 | FromDiscord | <Bung> https://github.com/search?q=language%3Anim+rest |
10:15:40 | FromDiscord | <Phil> In reply to @skiddie99 "may I ask you": I have a medium large-ish rest api in production for a private website |
10:16:11 | FromDiscord | <skiddie99> In reply to @Isofruit "I have a medium": wow! Interesting! Is it running smoothly? |
10:16:12 | FromDiscord | <Phil> I am surprised it only shows up on page 2 of bungs search |
10:17:03 | FromDiscord | <Phil> In reply to @skiddie99 "wow! Interesting! Is it": Once it compiles it pretty much runs no issue. Did what I could to basically crash either during compilation or during start-up if anything is incorrect. |
10:17:05 | FromDiscord | <skiddie99> also, is there any possible way to connect it postgres? How nim handles json serialization? |
10:17:46 | FromDiscord | <Phil> there is db_postgres if you don't want to use an ORM and interact directly with the database.↵If you want an ORM there's norm. There are also other ORMs, but I don't use them so I can't say much about them. |
10:18:05 | FromDiscord | <skiddie99> I'm making rest apis with fastapi and other python frameworks, but found this fast http server library and I'm hooked:↵↵https://github.com/marcospereirampj/python-keycloak |
10:18:08 | FromDiscord | <Phil> And for json Serialization just look at jsony for direct JSON-string --> object instance conversion |
10:18:12 | FromDiscord | <skiddie99> I hate orms |
10:18:32 | FromDiscord | <skiddie99> does the db_postgres have pooling methods? |
10:18:33 | FromDiscord | <Phil> In reply to @skiddie99 "I hate orms": Personally I prefer them vastly over writing INSERT INTO statements manually. |
10:18:48 | FromDiscord | <skiddie99> raw sql is good for complex queries |
10:19:09 | FromDiscord | <skiddie99> I've seen huge performance improvement by using asyncpg in python and making sql queries directly |
10:19:14 | FromDiscord | <Phil> In reply to @skiddie99 "raw sql is good": Which is why norm has recently added support for raw SQL queries and converts them into object instances for you as long as you supply the correct type |
10:19:56 | FromDiscord | <skiddie99> okay but there is connection pooling with this db_postgres library, for many async connections, right? |
10:20:01 | FromDiscord | <Phil> Connection pooling you have to supply yourself.↵I did write a connection pooling lib out there that should work, but I work with sqlite in my spare time, not postgres so never bothered to in-depth test if it works flawlessly |
10:21:18 | FromDiscord | <Phil> Though you might also want to take a look at gatabase |
10:22:05 | FromDiscord | <Phil> Back when I went searching for ORMs I stumbled over it but dismissed it due to no sqlite support back then IIRC↵If I remember that correctly it comes with connection pooling built in |
10:22:30 | FromDiscord | <skiddie99> https://github.com/juancarlospaco/nim-gatabase |
10:22:32 | FromDiscord | <skiddie99> oh it's cool! |
10:22:52 | FromDiscord | <skiddie99> I appreciate it! |
10:22:56 | FromDiscord | <skiddie99> which http server are you using? |
10:23:28 | FromDiscord | <skiddie99> I've seen this one |
10:23:28 | FromDiscord | <skiddie99> https://github.com/dom96/httpbeast |
10:23:31 | FromDiscord | <skiddie99> seems top |
10:24:05 | FromDiscord | <Phil> I use the http server bundled with my webframework, that is prologue so I use httpx (a fork of httpbeast with windows compatibility. Not that I use windows but I have no reason to use async-http) |
10:24:25 | FromDiscord | <Phil> (edit) "async-http)" => "async-http, which is the alternative httpserver)" |
10:25:08 | FromDiscord | <skiddie99> what about httpbeast? |
10:25:10 | FromDiscord | <Phil> Jester, the more popular framework IIRC and Sinatra inspired (whatever that means) also comes with httpbeast |
10:25:22 | FromDiscord | <skiddie99> I mean would it be good for rest apis? |
10:25:57 | FromDiscord | <skiddie99> (edit) "I mean would it be good for rest apis? ... " added "(the httpbeast)" |
10:26:28 | FromDiscord | <Phil> Define good↵I'd choose Jester or prologue to build a rest api any day for the convenience procs that they provide |
10:26:44 | FromDiscord | <Phil> And they're both using httpbeast (or a fork of it) under the hood either way |
10:27:53 | * | kenran quit (Remote host closed the connection) |
10:27:57 | FromDiscord | <skiddie99> That's perfect! I really appreciate your help |
10:28:02 | FromDiscord | <skiddie99> One last dumb question |
10:32:06 | FromDiscord | <skiddie99> sent a long message, see http://ix.io/4cEx |
10:32:22 | FromDiscord | <skiddie99> dumbest question ever, ik |
10:33:04 | FromDiscord | <skiddie99> (edit) "http://ix.io/4cEx" => "http://ix.io/4cEy" |
10:33:07 | FromDiscord | <skiddie99> (edit) "http://ix.io/4cEy" => "https://paste.rs/d4R" |
10:33:33 | FromDiscord | <Phil> In reply to @skiddie99 "I want to use": Basically you want to use nim code in python or the other way around?↵nimpy |
10:34:13 | FromDiscord | <Phil> Though keep in mind that does not pull the python code into your binary. Which means to get your application running you'll need to have a python interpreter and the necessary libs installed |
10:35:25 | FromDiscord | <skiddie99> In reply to @Isofruit "Basically you want to": I mean to use nim code inside python |
10:36:15 | FromDiscord | <Phil> Though you could also look into a split service architecture, where you have one python server that deals with auth and provides a token that can be validated in the nim-server that deals with the majority of the actual request |
10:37:07 | FromDiscord | <skiddie99> yes! |
10:37:13 | FromDiscord | <Phil> containerize it all into 3 separate containers (reverse proxy, python-auth-server, nim-server) and bring it up via docker-compose |
10:37:31 | FromDiscord | <skiddie99> I have no idea with nim though, at first I thought it was a pythonic alternative, but no |
10:37:31 | FromDiscord | <Phil> or whatever other container-solution you want to use |
10:37:35 | FromDiscord | <skiddie99> and that's impressive |
10:37:59 | FromDiscord | <Phil> I mean, the syntax is reminiscent, and to me felt very familiar |
10:38:02 | FromDiscord | <skiddie99> I have never used containers.. aren't they slowing down in production? |
10:38:10 | FromDiscord | <Phil> But my god do I love the type safety |
10:39:31 | FromDiscord | <Phil> In reply to @skiddie99 "I have never used": Not really. For reference, I do containerize, my JSON responses take, on the server, somewhere between 12-70ms.↵The network latency of 30ms from my browser to the server and from the server to my browser is often way longer than the request takes to be processed on the server |
10:40:02 | FromDiscord | <skiddie99> what container do you use? |
10:40:04 | FromDiscord | <Phil> And that is with simple token auth, so I do hit the database always at least twice, once for auth, once to perform whatever query is required |
10:40:09 | FromDiscord | <skiddie99> (edit) "what" => "which" |
10:40:21 | FromDiscord | <Phil> (edit) "for auth," => "to check if the token is in my database," |
10:40:29 | FromDiscord | <Phil> just simple docker containers |
10:40:37 | FromDiscord | <skiddie99> oh okay |
10:40:42 | FromDiscord | <skiddie99> do you think nim is faster than golang? |
10:41:42 | FromDiscord | <Phil> both are compiled languages. I don't know how much low-level optimization golang allows, in nim you can literally go as low as C and control when a particular piece of memory gets copied, when it gets moved etc.↵That allows for pretty fine-grained optimization |
10:42:35 | FromDiscord | <Phil> I also don't know how fast requests get processed in go typically, but I'd assume in either case the server will be well fast enough to deal with whatever you throw at it |
10:42:48 | FromDiscord | <Phil> (edit) "server" => "server/application" |
10:43:21 | FromDiscord | <Phil> And when it isn't that's 99% of the time a hint that you need tweak your algorithm and refactor some inefficient part instead of a language issue |
10:43:32 | FromDiscord | <Phil> (edit) "And when it isn't that's 99% of the time a hint that you need tweak your algorithm and refactor some inefficient part instead of a language ... issue" added "speed" |
10:43:40 | FromDiscord | <skiddie99> indeed |
10:43:52 | FromDiscord | <skiddie99> on python, FastAPI is fast only on development |
10:44:03 | FromDiscord | <skiddie99> well okay, it performs better than most of the python frameworks |
10:44:13 | FromDiscord | <skiddie99> but a great bottleneck is the json serialization |
10:44:32 | FromDiscord | <skiddie99> https://www.techempower.com/benchmarks/#section=data-r21&test=json |
10:44:43 | FromDiscord | <Phil> I'm surprised that it is, I'd have assumed somebody would have written some ridiculously fast serializer in CPP by now |
10:45:13 | FromDiscord | <skiddie99> Japronto is the first python framework on json serialization and when I combined it it performed better than fastapi or other frameworks |
10:45:25 | FromDiscord | <skiddie99> https://github.com/squeaky-pl/japronto |
10:45:31 | FromDiscord | <skiddie99> japronto is 50% C |
10:46:18 | FromDiscord | <Phil> Keep in mind that synthetic benchmarks are to be enjoyed with a planetary load of salt |
10:46:19 | FromDiscord | <skiddie99> but httpbeast is higher on that list |
10:47:25 | FromDiscord | <Phil> httpbeast is just a webserver. A ridonculously fast webserver, but it itself doesn't do json serialization (unless dom hid that somewhere in there).↵Things that (de)serialize are either std/json or jsony (which is considerably faster at that job than std/json) |
10:47:26 | FromDiscord | <skiddie99> they do provide the code though |
10:47:26 | FromDiscord | <skiddie99> https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Nim/httpbeast/techempower.nim |
10:48:29 | FromDiscord | <Phil> That's not really measuring serialization though |
10:48:56 | FromDiscord | <Phil> That measures how quickly you can turn a predefined string into a json object and server that back (which converts the json object into a string again) |
10:50:19 | FromDiscord | <Phil> A measure for JSON de(serialization) performance would be to receive 10.000.000 different json-strings of the same shape but with different values and turn them all into objects.↵Or have 10.000.000 different objects and turn them into json strings and serve them |
10:50:41 | FromDiscord | <skiddie99> That is true |
10:51:01 | FromDiscord | <skiddie99> is there any chance that you have a sample code of a get request where I could test versus golang? |
10:51:10 | FromDiscord | <Phil> Basically, what you can for sure believe, is that general code in python will always be slow. |
10:51:33 | FromDiscord | <Phil> The only exception is once a C/C++ wrapper gets involved (numpy) |
10:52:08 | FromDiscord | <Phil> That's just by virtue of how python works. Everything else is... mostly a matter of how much time you spent on optimizing the crap out of every facet of your code |
10:52:51 | FromDiscord | <Phil> In reply to @skiddie99 "is there any chance": I mean, for what? A static HTML response? |
10:53:25 | FromDiscord | <skiddie99> In reply to @Isofruit "I mean, for what?": I would really appreciate a connection pooling to postgres, so I could compare it with golang and other frameworks |
10:53:43 | FromDiscord | <skiddie99> I'm afraid that if I do it by myself I'll break the code from the first few lines |
10:54:00 | FromDiscord | <skiddie99> like as simple as possible with minimal effort |
10:54:24 | FromDiscord | <skiddie99> like a get request "SELECT id, text, timestamp FROM table WHERE id = $1", id |
10:54:28 | FromDiscord | <Phil> In reply to @skiddie99 "I would really appreciate": I mean, that you can look into building yourself with gatabase 😛↵Given I'd need to set up postgres and all I'm a tad too lazy to do so |
10:54:48 | FromDiscord | <skiddie99> no I'll provide the postgres credits |
10:55:00 | FromDiscord | <Phil> Particularly given that the bottlenecks you'll run into are everywhere but your webserver |
10:55:03 | FromDiscord | <skiddie99> like the server and the rest |
10:55:15 | FromDiscord | <Phil> That is one of the reasons udemy can get away with using Django in prod even though its (comparatively) slow as molasses |
10:56:18 | FromDiscord | <skiddie99> I see.. could you please make me this basic skeleton in nim? I would really appreciate it and I'll send you db credits for the table |
10:57:15 | FromDiscord | <Phil> Basic examples for setting up a prologue application can be found in the prologue repository.↵From there you can basically just use db_postgres for raw database interaction without connection pooling (or see how to write it up in gatabase) |
10:58:04 | FromDiscord | <skiddie99> what if I buy you a beer? xD |
10:58:54 | FromDiscord | <Phil> Not going to happen either way, just look into it, it's really not the world |
11:01:08 | FromDiscord | <skiddie99> okay I'll give it a try. So the code junks (xD) I need are gatabase and Jester ? |
11:03:39 | FromDiscord | <Phil> In reply to @skiddie99 "okay I'll give it": a running postgres instance, jester/prologue (I use prologue, for jester there's a decent chunk of other folks around afaik... like, I'm one of 2 people by now that I'm aware are actively using prologue in this discord), gatabase (or db_postgres if you want to try without connection pooling) and jsony for the serialization from object to JSON |
11:05:03 | * | pro quit (Quit: pro) |
11:05:14 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cEJ |
11:05:24 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4cEJ" => "https://play.nim-lang.org/#ix=4cEK" |
11:06:11 | FromDiscord | <Phil> The setup for the pragma should be completely correct, norm set up its own fk pragma similarly and that one works flawlessly:↵`template fk(val: typed) {.pragma.}` |
11:06:26 | FromDiscord | <skiddie99> jsony seems to handle datetime, where other libs in python failed (besides orjson). Thank you very much, I appreciate it!↵↵I gotta give it a try! Never used nim before |
11:06:36 | FromDiscord | <skiddie99> I'm super excitedxD |
11:06:43 | FromDiscord | <Phil> In reply to @skiddie99 "jsony seems to handle": Jsony can also trivially be expanded to deal with any custom datatype |
11:07:46 | FromDiscord | <Phil> I used that when I migrated from django to prologue.↵Django provided me with some seriously bad Datetime strings in the db, so I had to do my own date-time type that would seamlessly convert these strings to DateTime and back |
11:08:35 | FromDiscord | <Phil> (edit) "I used that when I migrated from django to prologue.↵Django provided me with some seriously bad Datetime strings in the db, so I had to do my own date-time type that would seamlessly convert these strings ... to" added "(when received via JSON)" |
11:09:19 | FromDiscord | <skiddie99> 2 questions,↵1. Which is faster overall (performance, productivity), jester or prologue?↵2. What's your take on NIM versus Julia? Can nim be used for machine learning in the future or Julia is better than NIM for data science etc? |
11:11:03 | FromDiscord | <Phil> In reply to @skiddie99 "2 questions, 1. Which": I haven't seen benchmarks, but either way I'd say it doesn't matter.↵We're talking about sub millisecond differences at that point.↵I'd say pick whatever jives with you more. If you coded with a sinatra-like framework before, I'd assume jester will feel familiar.↵To me, coming from Django, Prologue felt more at home so I used that. |
11:11:04 | FromDiscord | <Rika> Nim isn’t an acronym so just capitalise it like normal |
11:11:44 | FromDiscord | <Rika> A Sinatra like framework by the way is akin to a “microframework” which might be more familiar of a term for you |
11:11:55 | FromDiscord | <Phil> Ohhhhh that makes so much more sense |
11:12:12 | FromDiscord | <Rika> Haha |
11:12:19 | FromDiscord | <Rika> Sinatra is a Ruby library by the way |
11:12:23 | FromDiscord | <Phil> Due to my lack of using Jester I just had to go with what it self-described as |
11:12:32 | FromDiscord | <Rika> So jester is to Sinatra while prologue is to rails I guess |
11:13:08 | FromDiscord | <Phil> Though I wouldn't call prologue overly feature rich either, it basically simplifies configs a bit for you and deals with routing, both of which I'd assume jester does as well, no? |
11:13:32 | FromDiscord | <Phil> The main difference I've seen so far is that prologue comes with middlewares and allows you to swap out http server |
11:13:59 | FromDiscord | <Rika> That’s pretty much the main differences |
11:14:00 | FromDiscord | <Phil> Either way you're still wiring up everything yourself once a controller proc comes into play |
11:14:01 | FromDiscord | <Rika> I believe |
11:15:04 | FromDiscord | <skiddie99> I think I'll try the jester/gatabase and jsony |
11:15:16 | FromDiscord | <skiddie99> is there any faster alternative to jsony btw? I'm trying to overoptimize things xd |
11:15:33 | FromDiscord | <skiddie99> (edit) "I think I'll try the jester/gatabase and jsony ... " added "combo" |
11:15:42 | FromDiscord | <skiddie99> (edit) "combo" => "combo. What do you think?" |
11:15:50 | FromDiscord | <Rika> No |
11:16:00 | FromDiscord | <Rika> Faster alternative is not to use JSON I guess |
11:16:20 | FromDiscord | <Rika> JSON is just slow for computers because it’s human readable first |
11:16:31 | FromDiscord | <skiddie99> I'm trying to make a rest api |
11:16:32 | FromDiscord | <ngangngong> ok, so what's good? |
11:16:35 | FromDiscord | <Phil> I'd be hard pressed tbh.↵If there were, it'd need to be significantly faster than JSONY for me to even consider it due to how easily useable jsony is |
11:16:49 | FromDiscord | <ngangngong> CSV ftw Rika? |
11:16:50 | FromDiscord | <Phil> In reply to @skiddie99 "I'm trying to make": REST doesn't mean much, you can also do a REST api with XML |
11:16:58 | FromDiscord | <Phil> In reply to @ngangngong "CSV ftw Rika?": Binary formats |
11:17:02 | FromDiscord | <Rika> CBOR |
11:17:05 | FromDiscord | <Rika> I’d use CBOR |
11:17:22 | FromDiscord | <skiddie99> now that's crazy |
11:17:37 | FromDiscord | <Rika> I mean you do you really |
11:17:48 | FromDiscord | <Rika> If you wanna over optimise then there’s a strategy |
11:18:04 | FromDiscord | <Phil> Allow me to point out |
11:18:12 | FromDiscord | <Phil> We're talking about saving maybe 2ms |
11:18:26 | FromDiscord | <Phil> Unless you're sending/receiving gigantic amounts of JSON |
11:18:42 | FromDiscord | <Rika> In reply to @Isofruit "Unless you're sending/receiving gigantic": If you were you would probably not be looking at Nim really |
11:19:12 | FromDiscord | <skiddie99> In reply to @Isofruit "We're talking about saving": no not at all. Is there async support for jester? |
11:19:17 | FromDiscord | <Rika> Yes |
11:19:37 | FromDiscord | <Phil> In reply to @Rika "If you were you": I mean, at that scale I'd assume you just store it in a file and have a separate process crunch through the file |
11:19:44 | FromDiscord | <skiddie99> Awesome. I can't thank you enough guys for out chat, I really appreciate it! |
11:19:47 | FromDiscord | <Phil> (edit) "In reply to @Rika "If you were you": I mean, at that scale I'd assume you just store it in a file ... and" added "via a reverse-proxy like nginx" |
11:20:17 | FromDiscord | <skiddie99> you pointed out some great ideas |
11:20:23 | FromDiscord | <skiddie99> I'll try the coding part |
11:20:48 | FromDiscord | <Rika> I’d say weigh the effort to benefit before doing over optimisation lol |
11:20:59 | FromDiscord | <Rika> Done it before, feels so wasteful |
11:21:30 | FromDiscord | <Phil> ~~Mine didn't, and all I did was crunch down from 200ms-500ms to 40ms-100ms |
11:21:34 | FromDiscord | <Phil> (edit) "40ms-100ms" => "40ms-100ms~~" |
11:21:47 | FromDiscord | <Rika> Well that’s just optimisation if you’re reducing tens of milliseconds |
11:22:07 | FromDiscord | <skiddie99> I'm basically interested in making an api that can handle many concurrent users without failing |
11:22:21 | FromDiscord | <skiddie99> json serialization was the biggest bottleneck in python |
11:22:27 | FromDiscord | <skiddie99> along with the web server itself |
11:22:29 | FromDiscord | <Phil> Ah, you meant over-optimisation so that you can technically see the difference, not just that he user can feel a difference.↵Because my users certainly didn't notice one ^^' |
11:22:34 | FromDiscord | <skiddie99> besides the code |
11:23:21 | FromDiscord | <Phil> Anyway, any experience with writing your own pragmas Rika? |
11:23:25 | FromDiscord | <Rika> Yes |
11:24:32 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cEN |
11:25:21 | FromDiscord | <Phil> Argh, wait, no, I think I've got it, the 3rd time copy pasting revealed it I think |
11:25:23 | FromDiscord | <ngangngong> Which exactly (45, 23) is? |
11:25:26 | FromDiscord | <Rika> Lol |
11:25:59 | FromDiscord | <Phil> In reply to @ngangngong "Which exactly (45, 23)": It was the line with description |
11:26:27 | FromDiscord | <Phil> I was so overly focussed to make sure that the pragma declaration itself was correct my eyes just glossed over the fact that the pragma must be put before the type annotation |
11:26:28 | FromDiscord | <ngangngong> I think, i've never seen pragma like that? {.async.} or {.gcsafe.} |
11:27:01 | FromDiscord | <ngangngong> In reply to @Isofruit "I was so overly": so, {.pragma.} T |
11:27:17 | FromDiscord | <Phil> In reply to @ngangngong "I think, i've never": Its a custom pragma, down the line I need to annotate norm-model fields with it to specify whether a file should be stored directly in a configured media directory or a subdirectory of it |
11:27:50 | FromDiscord | <Phil> Like image fields, when an image is uploaded, store it in the subdirectory defined by the pragma within the root media directory |
11:28:23 | FromDiscord | <ngangngong> So correct one is {.pragma.} T over T {.pragma.} ? |
11:28:48 | FromDiscord | <Rika> Yes |
11:28:51 | FromDiscord | <ngangngong> Nice, gave me insight about custom pragma, even idk when to use. |
11:28:58 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cEO |
11:29:02 | FromDiscord | <Rika> Wait I misread |
11:29:06 | FromDiscord | <Rika> Me dumb lo |
11:29:16 | FromDiscord | <Phil> Don't forget the column after the pragma |
11:29:24 | FromDiscord | <Phil> colon? |
11:29:24 | FromDiscord | <Rika> Yeah it’s kind of strange, since it doesn’t apply to proc pragmas |
11:29:28 | FromDiscord | <Phil> Double point I mean |
11:29:39 | FromDiscord | <ngangngong> yeah it's colon |
11:29:39 | FromDiscord | <Rika> : is called colon indeed |
11:30:00 | FromDiscord | <Phil> Its one of those words I forget on a weekly basis |
11:30:07 | FromDiscord | <Rika> Not daily! |
11:30:08 | FromDiscord | <Phil> Because the german one is just that different |
11:30:08 | FromDiscord | <Rika> ? |
11:30:14 | FromDiscord | <Rika> Cologne |
11:30:24 | FromDiscord | <ngangngong> siblings of `;` the semi. |
11:30:33 | FromDiscord | <Phil> Word memory resets on Sunday 23:00 stat. We're efficient that way |
11:31:02 | FromDiscord | <Phil> In reply to @Rika "Cologne": That's the city.↵In german its "Doppelpunkt" - double point |
11:31:09 | FromDiscord | <Rika> It’s a joke |
11:31:12 | FromDiscord | <Phil> (edit) "its" => "it's" |
11:31:16 | FromDiscord | <Phil> Ahhh wooshed right over me |
11:31:39 | FromDiscord | <Phil> Ironically, the semicolon is called similar in german so that one I never forget |
11:35:43 | FromDiscord | <Rika> Semi cologne |
11:38:04 | FromDiscord | <Phil> Half a city or half fragrant water, that is the question |
11:44:57 | FromDiscord | <Phil> Alright, custom pragma works |
11:55:01 | FromDiscord | <skiddie99> how am I supposed to install the packages? |
11:55:18 | FromDiscord | <skiddie99> it's weird but I'm hooked, can't find it though lol |
11:56:02 | FromDiscord | <skiddie99> nimble install |
11:56:04 | FromDiscord | <skiddie99> ok got it |
12:21:09 | FromDiscord | <skiddie99> what are your thoughts about this one?↵https://github.com/treeform/pg |
12:23:14 | FromDiscord | <Rika> Looks fine to me |
12:25:19 | FromDiscord | <skiddie99> may I ask you how I can make pass a parameter to the query given by user in nim? |
12:26:15 | FromDiscord | <skiddie99> I don't know how to make the connection between jsony and the query basically |
12:41:35 | FromDiscord | <skiddie99> anyone? I'm stuck😅 |
12:42:00 | * | derpydoo quit (Quit: derpydoo) |
12:45:33 | FromDiscord | <Patitotective> In reply to @Elegantbeef "<@762008715162419261>\: so i got": :]]]]]]]]]] |
12:47:58 | * | arkurious joined #nim |
12:50:02 | FromDiscord | <auxym> In reply to @skiddie99 "may I ask you": Like this? https://nimdocs.com/treeform/pg/pg.html#examples-inserting-data |
12:50:59 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028650784050663424/unknown.png |
12:51:13 | FromDiscord | <skiddie99> that's my dumb code |
12:52:02 | FromDiscord | <skiddie99> I know it's bad |
12:52:03 | FromDiscord | <skiddie99> too bad |
12:52:40 | FromDiscord | <skiddie99> can't cope with nim language, I need help |
12:54:00 | FromDiscord | <auxym> well for one thing you can't name your `pg` variable with the same name as a module |
12:54:35 | FromDiscord | <skiddie99> it's totally crap the code, I know |
12:54:39 | FromDiscord | <auxym> I'm not familiar with jester otherwise, but compile, and fix errors one by one. if you can't figure out a specific error post the message here |
12:54:44 | FromDiscord | <skiddie99> hasn't anyone implemented rest apis in nim? |
12:56:16 | FromDiscord | <auxym> I haven't, I'm sure people have. Notably https://github.com/nim-lang/nimforum and possibly https://github.com/zedeus/nitter. you can try asking in #webdev tool |
12:56:20 | FromDiscord | <auxym> (edit) "tool" => "too" |
13:00:00 | FromDiscord | <skiddie99> oh okay, thank you mate |
13:03:12 | * | sagax joined #nim |
13:10:03 | FromDiscord | <Phil> Generally, posting the error message you receive during compilation also does help 😛 |
13:14:49 | FromDiscord | <skiddie99> I have no idea how to struct code |
13:14:51 | FromDiscord | <skiddie99> it's day 0 |
13:15:00 | FromDiscord | <skiddie99> so I would really appreciate any help |
13:16:16 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028657146247778364/unknown.png |
13:16:17 | FromDiscord | <skiddie99> nim is weird |
13:16:28 | FromDiscord | <skiddie99> I beg for some help |
13:17:30 | FromDiscord | <auxym> your first error is `let id`, let is a constant/immutable variable so it needs to be assigned to something. if you want a mutable use `var` (and specify the type) |
13:17:56 | FromDiscord | <auxym> Have you read the nim tutorials at all? I'd recommend doing that first |
13:18:33 | FromDiscord | <skiddie99> I don't even know if "let id" is the problem at this point |
13:18:45 | om3ga | Hi there! What I'm missing here: I have 2d sequence, declared like that: let seq = newSeqWith(len(spectrogram), newSeq[float64](255)), and I want to see it's element length: ... let len = high(seq[i]), it should work right? |
13:18:50 | FromDiscord | <skiddie99> I don't have any blueprint of how rest apis are made in nim |
13:19:22 | FromDiscord | <auxym> In reply to @skiddie99 "I don't even know": it's 100% one of your problems. like I said, fix problems one at a time... |
13:19:46 | FromDiscord | <vestel> In reply to @om3ga "Hi there! What I'm": You wanna see row or column len? |
13:19:52 | om3ga | clarification, that's just example, actually length of seq[i] is not known |
13:20:10 | om3ga | vestel, the number of elements of row |
13:20:16 | FromDiscord | <Rika> High is not length of sequence |
13:20:40 | FromDiscord | <skiddie99> In reply to @auxym "it's 100% *one* of": but as I said, I'm not even sure if the structure of the code is correct, it would be pointless to fix the syntax if the struct is wrong be default |
13:20:44 | om3ga | sorry, not length, but for loop |
13:20:55 | om3ga | element count minus 1 |
13:21:10 | FromDiscord | <Rika> In reply to @skiddie99 "but as I said,": As said before, your let id is wrong |
13:21:35 | FromDiscord | <auxym> In reply to @skiddie99 "but as I said,": fixing the syntax isn't pointless , it's required for the program to work... |
13:21:46 | FromDiscord | <skiddie99> In reply to @Rika "As said before, your": what about the db? is this even the correct way to make async apis? |
13:21:59 | FromDiscord | <Rika> Probably |
13:22:04 | FromDiscord | <Rika> Looks fine to me other than mentioned |
13:22:48 | FromDiscord | <Rika> I don’t remember how jester works anymore so I might be wrong |
13:23:13 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028658895310307498/unknown.png |
13:23:26 | FromDiscord | <Rika> Ah |
13:23:28 | FromDiscord | <Rika> I didn’t notice |
13:23:37 | FromDiscord | <Rika> The database variable isn’t global |
13:23:42 | FromDiscord | <Rika> So you can’t access it in the route |
13:24:06 | FromDiscord | <skiddie99> just give me a chunk of code that works pleaase |
13:24:37 | FromDiscord | <skiddie99> I've no idea on how to do it in nim |
13:25:43 | FromDiscord | <Horizon [She/Her]> What's the most sensible way to see if an object type is in a sequence? |
13:26:42 | FromDiscord | <Horizon [She/Her]> I have an array of components and i want to be able to check if a certain component type is in an array |
13:27:08 | FromDiscord | <Horizon [She/Her]> Should i just add a `ComponentType` field? |
13:28:53 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028660324938825878/unknown.png |
13:29:21 | FromDiscord | <skiddie99> 😕 |
13:31:05 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFc |
13:31:21 | FromDiscord | <skiddie99> In reply to @Isofruit "what's pg? The gatabase": https://github.com/treeform/pg |
13:32:00 | FromDiscord | <skiddie99> "Very simple PostgreSQL async api for nim." |
13:32:14 | FromDiscord | <skiddie99> issue here is the global variable |
13:32:49 | FromDiscord | <skiddie99> I have no idea how to struct the nim code, I'm trying to fix it the pythonic way though I'm not even sure what I'm doing at this point |
13:36:17 | FromDiscord | <Horizon [She/Her]> Does Nim have an alternative to interfaces in Java? |
13:37:19 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFh |
13:37:46 | FromDiscord | <Phil> Given that you do not need any sql-arguments, you can just throw in an empty seq (seq = list in python) |
13:37:53 | FromDiscord | <Phil> A list you can instantiate via `@[]` |
13:38:19 | FromDiscord | <Phil> Like so: `let x: seq[string] = @[]` |
13:39:11 | FromDiscord | <Phil> the entire `let db` line I'd move out of the main proc and into general execution space, simply since that's the scope in which it'll be available anyway |
13:39:32 | FromDiscord | <Phil> If you do that you can also save yourself the global pragma |
13:40:50 | * | oisota quit (Quit: Ping timeout (120 seconds)) |
13:40:59 | FromDiscord | <skiddie99> I don't even understand how I connect the get from the get route to the sql |
13:41:14 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028663434042146817/unknown.png |
13:41:18 | FromDiscord | <skiddie99> I feel too dumb at this point |
13:42:05 | FromDiscord | <Phil> sent a long message, see http://ix.io/4cFi |
13:42:17 | FromDiscord | <skiddie99> sent a long message, see http://ix.io/4cFj |
13:42:22 | FromDiscord | <Phil> Backticks, ma dude |
13:42:27 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028663736963182623/main.nim |
13:43:00 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFj |
13:43:24 | FromDiscord | <Phil> sent a long message, see http://ix.io/4cFk |
13:43:36 | FromDiscord | <Phil> (edit) "long message," => "code paste," | "http://ix.io/4cFk" => "https://play.nim-lang.org/#ix=4cFl" |
13:43:48 | FromDiscord | <auxym> yeah I have no idea how jester's macros works, but your `db` variable probably isn't accessible in that routes block. `{.global.}` doesn't make the variable accessible from the global scope, it just means that it's stored globally, like `static` in C, so it persists across function calls (non re-entrancy or somehting like that) |
13:43:57 | * | oisota joined #nim |
13:44:21 | FromDiscord | <skiddie99> I can change jester to anything else if somebody could guide me on that😅 |
13:45:29 | FromDiscord | <Phil> Also your global pragma is borked↵you wrote `{.global}`, it must be `{.global.}` |
13:45:40 | FromDiscord | <Phil> Dots on both sides of the pragma name |
13:46:09 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFp |
13:46:27 | FromDiscord | <skiddie99> how am I supposed to get it work without getting drained? |
13:48:37 | FromDiscord | <auxym> In reply to @Isofruit "Also your global pragma": I'm pretty sure that the global pragma doesn't make a variable visible from the global scope, it just persists across function calls |
13:48:53 | FromDiscord | <skiddie99> so I gotta change the pg library? |
13:49:28 | FromDiscord | <auxym> you'd need to actually declare `db` in the top level scope. but I'm not sure if that's the best pattern, like I said I'm not familiar with jester and webdev in general |
13:50:29 | FromDiscord | <Patitotective> In reply to @Elegantbeef "<@762008715162419261>\: so i got": huh, it just fails now https://github.com/Patitotective/kdl-nim/actions/runs/3214356710/jobs/5254690133 |
13:51:25 | FromDiscord | <skiddie99> https://github.com/treeform/pg/issues/3 |
13:51:29 | FromDiscord | <Phil> In reply to @auxym "you'd need to actually": Its sometimes unavoidable. Particularly for connection pools I'd be okay with this. |
13:53:36 | FromDiscord | <Rika> In reply to @Isofruit "Also your global pragma": By the way single dot is actually valid syntax iirc |
13:55:06 | FromDiscord | <skiddie99> should this be supposed to work? |
13:55:07 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFu |
13:56:16 | FromDiscord | <skiddie99> taken from: https://github.com/treeform/pg/issues/3 |
13:58:22 | FromDiscord | <skiddie99> I'll try db_postgres |
13:59:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFv |
13:59:20 | FromDiscord | <Phil> db_postgres isn't going to let you escape from that as you need to also define all the stuff that newAsyncPool asks you to define, other than the number of connections |
13:59:46 | FromDiscord | <skiddie99> In reply to @Isofruit "First things first, do": I have my own database, the above code chunk was from a dude on issues of that lib |
14:00:04 | FromDiscord | <skiddie99> it seems that pg uses db_postgres internally |
14:00:17 | FromDiscord | <Phil> In reply to @skiddie99 "I have my own": That's fine, does that mean you know username, password and database-name to connect to? |
14:00:26 | FromDiscord | <skiddie99> In reply to @Isofruit "That's fine, does that": yes? |
14:00:28 | FromDiscord | <skiddie99> ofc |
14:00:34 | FromDiscord | <skiddie99> do you want me to send you access maybe? |
14:00:52 | FromDiscord | <Phil> No, that thing is on your machine, I couldn't access it anyway assuming its running local |
14:01:04 | FromDiscord | <skiddie99> I have a server running |
14:01:21 | FromDiscord | <skiddie99> so it's not on my machine, it's just on a machine |
14:01:44 | FromDiscord | <Phil> So I can assume you've accurately replaced "remote.host.domain", "user", "password", "dbname" in your actual code that you're compiling? |
14:02:06 | FromDiscord | <skiddie99> I didn't even compile the code |
14:02:28 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028668771533066352/unknown.png |
14:02:32 | FromDiscord | <skiddie99> because of those errors |
14:03:07 | FromDiscord | <Phil> Remember what I wrote earlier about the missing third parameter? |
14:03:20 | FromDiscord | <skiddie99> yes.. |
14:03:23 | FromDiscord | <Phil> That'd get you rid of one of the errors |
14:04:06 | FromDiscord | <skiddie99> you mean:↵↵WHERE id = ?", @[id] |
14:04:06 | FromDiscord | <Phil> I'm almost certain that's the only error actually |
14:04:35 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFy |
14:04:39 | FromDiscord | <skiddie99> how do I connect it with the get endpoint? |
14:04:59 | FromDiscord | <Phil> connect as in fire an http request to it to look at the generated HTML? |
14:05:25 | FromDiscord | <skiddie99> I mean is the code now correct? |
14:05:44 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028669597974536192/unknown.png |
14:05:46 | FromDiscord | <Phil> Try to compile it and look at the error if one props up |
14:06:02 | FromDiscord | <Phil> Ah, one sec, you want a path parameter id |
14:06:08 | FromDiscord | <Phil> correct? |
14:06:08 | FromDiscord | <skiddie99> yes |
14:06:38 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFz |
14:06:48 | FromDiscord | <Phil> Jesters way of declaring routes and everything looks pretty wild I'm not gonna lie |
14:07:27 | FromDiscord | <Phil> So you need to first add that parameter to your route string, aka `"/@id"` |
14:08:19 | FromDiscord | <Phil> And then you can access it via @"id" ... I assume it'll be recognized as a string, so if you want it as number you'll have to parse it into a number first.↵The procs for that are in std/strutils, should be called parseInt |
14:08:42 | FromDiscord | <Phil> (edit) "@"id"" => "`@"id"`" |
14:11:07 | FromDiscord | <skiddie99> or .format(id) I guess? |
14:12:05 | FromDiscord | <Horizon [She/Her]> In reply to @Isofruit "Dots on both sides": That doesn't matter |
14:12:11 | FromDiscord | <Horizon [She/Her]> From what ik at least |
14:12:19 | FromDiscord | <Phil> In reply to @Event Horizon "That doesn't matter": It does when the formatting looks unreadable |
14:12:24 | FromDiscord | <skiddie99> wait |
14:12:32 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFC |
14:12:34 | FromDiscord | <skiddie99> this stopped the errors |
14:12:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFD |
14:13:33 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFE |
14:13:57 | FromDiscord | <skiddie99> let me test it please |
14:14:01 | FromDiscord | <Horizon [She/Her]> In reply to @Isofruit "It does when the": Ah fair |
14:15:19 | FromDiscord | <Horizon [She/Her]> Does Nim have a way to add another value to an enum at compile time? |
14:15:22 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFG |
14:16:53 | FromDiscord | <auxym> macro? |
14:17:01 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFI |
14:17:24 | FromDiscord | <Horizon [She/Her]> In reply to @auxym "macro?": I would have to be able to ectend it from another file, not in the same block |
14:17:59 | FromDiscord | <Horizon [She/Her]> So `enumName.addEnumField(ComponentName)` |
14:18:22 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFJ |
14:18:47 | FromDiscord | <auxym> In reply to @Event Horizon "I would have to": I'm not a huge macro expert, but I don't think that's possible. I think however with a `typed` macro you should be able to create a new enum typedef that extends the first |
14:18:51 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cFK |
14:18:56 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFL |
14:19:31 | FromDiscord | <Phil> In reply to @Event Horizon "I would have to": Best I can suggest is have that thing in the other file be a seq[string], fill that across files and finally turn that seq[string] into an enum latter |
14:19:34 | FromDiscord | <Phil> (edit) "latter" => "later" |
14:19:49 | FromDiscord | <Phil> Though even that I'm not fully sure how that'd work |
14:19:52 | FromDiscord | <Horizon [She/Her]> Hm |
14:20:00 | FromDiscord | <Horizon [She/Her]> Probably with a lot of macro hell haha |
14:20:12 | FromDiscord | <Horizon [She/Her]> I'd need to do this at compile time i'd imagine |
14:20:15 | FromDiscord | <skiddie99> I just want a json response with jsony of that data of the table |
14:20:28 | FromDiscord | <Phil> In reply to @Event Horizon "I'd need to do": You want to generate a type, that's forcibly at compiletime |
14:20:45 | FromDiscord | <Horizon [She/Her]> Yeah i mean in the way that, afaik, seqs aren't compile time |
14:20:52 | FromDiscord | <skiddie99> I don't get why there should be for row in rows: ? I guess it takes data from than 1 row only? |
14:21:23 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFN |
14:22:00 | FromDiscord | <auxym> In reply to @Event Horizon "Yeah i mean in": seqs can be used in the vm, sure |
14:22:11 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFO |
14:22:34 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4cFP |
14:22:37 | FromDiscord | <Horizon [She/Her]> In reply to @auxym "seqs can be used": With the `static` block? |
14:22:39 | FromDiscord | <Phil> In reply to @Event Horizon "Yeah i mean in": They can be used that way ^^ |
14:22:48 | FromDiscord | <Phil> Since you can have `const a = @[1,2,3,4]` |
14:22:58 | FromDiscord | <skiddie99> that's all I see |
14:23:01 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028673946679251014/unknown.png |
14:23:02 | FromDiscord | <Phil> That means you can have compile-time seqs |
14:23:18 | FromDiscord | <auxym> In reply to @Event Horizon "With the `static` block?": or in a macro, a const def, a compiletime proc, anything that runs at compile time... |
14:23:32 | FromDiscord | <Horizon [She/Her]> Ah fair |
14:23:41 | FromDiscord | <Phil> In reply to @skiddie99 "that's all I see": Does that message pop up actively when you try to compile or is that just your IDE pre-emptively warning you? |
14:23:49 | FromDiscord | <Phil> Because chances are your IDE is wrong in this case |
14:24:04 | FromDiscord | <Horizon [She/Her]> In reply to @skiddie99 "": Are you using the Nimsaem extension? |
14:24:15 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFR |
14:24:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFS |
14:25:05 | FromDiscord | <Phil> Treeform may have forgotten a dependency in his nimble file |
14:25:29 | FromDiscord | <skiddie99> you're god |
14:26:35 | FromDiscord | <Phil> Could you do me a favor, open your vscode on the pg nim file and copy paste me the first 10 lines?↵SOmething feels very wrong |
14:26:38 | FromDiscord | <Phil> (edit) "lines?↵SOmething" => "lines?↵Something" |
14:27:37 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFT |
14:28:26 | FromDiscord | <skiddie99> oh you mean that you cannot see any print on the lines of https://github.com/treeform/pg/blob/master/src/pg.nim ? |
14:28:52 | FromDiscord | <Phil> Yeah |
14:29:06 | FromDiscord | <Phil> Wait... god damnit if db_postgres imports print |
14:29:46 | FromDiscord | <skiddie99> I don't get it.. what should I do? |
14:30:53 | FromDiscord | <Phil> Alright, first things first, what data type do you think is `@["id"]`? |
14:31:01 | FromDiscord | <skiddie99> it's integer |
14:31:05 | FromDiscord | <skiddie99> on the postgres db |
14:31:07 | FromDiscord | <Phil> nope, that's seq[string] |
14:31:30 | FromDiscord | <Phil> "id" is the string "id"↵@"id" is likely the path parameter value, but still in string form |
14:32:17 | FromDiscord | <Phil> And what's happening is that db_postgres is taking your "id" parameter and put that into the select query placeholder and failing since it expects an integer there (see error) |
14:32:35 | FromDiscord | <skiddie99> yup I've faced it with python before |
14:32:45 | FromDiscord | <skiddie99> I need to declare it as integer like let id L int ? |
14:32:51 | FromDiscord | <skiddie99> (edit) "L" => ":" |
14:32:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cFW |
14:33:22 | FromDiscord | <Phil> You can of course do more at once, but this is the sort of thing where writing down every type is beneficial |
14:33:50 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4cFW" => "https://play.nim-lang.org/#ix=4cFX" |
14:34:01 | FromDiscord | <Phil> Try to get into the habit of going in small steps at first and always writing out the types you expect to see |
14:34:44 | FromDiscord | <Phil> Helps catch errors faster as soon as the compiler says that variable "X" is of type "Y" but you said its of type "Z" |
14:35:05 | FromDiscord | <skiddie99> https://media.discordapp.net/attachments/371759389889003532/1028676981115592816/unknown.png |
14:35:19 | FromDiscord | <Phil> The star was a typo |
14:36:07 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cFY |
14:36:30 | FromDiscord | <Phil> Looks like it compiled |
14:36:44 | FromDiscord | <Phil> So no syntax errors |
14:37:53 | FromDiscord | <Phil> Sidenote btw., for now keep compiling as you are.↵Once you compile for production you want to add the flag `-d:release` in order for gcc to do all proper optimizations, gives you roughly a 10x speed up |
14:38:10 | FromDiscord | <skiddie99> sent a code paste, see https://paste.rs/eNA |
14:38:16 | FromDiscord | <skiddie99> sent a code paste, see https://paste.rs/ptt |
14:40:07 | FromDiscord | <skiddie99> is this how it should be? |
14:40:08 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cG0 |
14:40:49 | FromDiscord | <Phil> Just checked the proc again, it eats a seq string... I'm not sure why the heck it would, but apparently it does.↵Try to do `@[idStr]` |
14:41:17 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cG1 |
14:41:40 | FromDiscord | <Phil> I've been to spoiled by ndb which handles these types properly I guess |
14:42:12 | FromDiscord | <skiddie99> it run but 2 issues |
14:42:14 | FromDiscord | <skiddie99> 1. |
14:42:33 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cG2 |
14:43:22 | FromDiscord | <skiddie99> 2. https://media.discordapp.net/attachments/371759389889003532/1028679067689566318/unknown.png |
14:43:30 | FromDiscord | <skiddie99> it doesn't look like json |
14:44:23 | FromDiscord | <skiddie99> I mean in the api format |
14:44:51 | * | jmdaemon quit (Ping timeout: 248 seconds) |
14:45:25 | FromDiscord | <skiddie99> it seems that the favicon thing happens only at the beginning |
14:45:37 | FromDiscord | <skiddie99> and then for the json that's because of DEBUG 200 OK {"content-type": @["text/html;charset=utf-8"]} |
14:45:43 | FromDiscord | <skiddie99> content type |
14:46:33 | FromDiscord | <Phil> In reply to @skiddie99 "2.": That's a perfect JSON representation of what you gathered out of the database.↵You fire a query and receive a `Row`.↵Row is just another name for `seq[string]`.↵If you want some sort of key-value thing, you need to first parse the `Row` into an object, that's what ORMs in nim are for |
14:46:56 | FromDiscord | <Phil> An absolutely minimal one that is solely for converting Row into object and does nothing else would be nisane |
14:47:03 | strogon14 | To answer my question from this morning "How can I exit cleanly with Control-C?". The traceback and exit code I was seeing was actually from the compiler (nim compile -r), not my program. That got me confised :-( |
14:49:01 | FromDiscord | <skiddie99> In reply to @Isofruit "That's a perfect JSON": can I please have a content type response: json ? |
14:51:22 | FromDiscord | <skiddie99> In reply to @Isofruit "That's a perfect JSON": I think it's the response that should be returned as json to get key-value result, not the orm itself. In python I can have this json content headers without using orm at all |
14:52:29 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGa |
14:52:58 | FromDiscord | <skiddie99> (edit) "https://play.nim-lang.org/#ix=4cGa" => "https://play.nim-lang.org/#ix=4cGb" |
14:55:58 | FromDiscord | <Horizon [She/Her]> Trying to make a macro that does a check for if a certain component exists but idk how i'm supposed to implement that really |
14:56:18 | FromDiscord | <Horizon [She/Her]> Also, is it possible to define a custom pragma? |
14:56:53 | FromDiscord | <skiddie99> found it |
14:56:57 | FromDiscord | <skiddie99> I added , "application/json" |
14:57:01 | FromDiscord | <Horizon [She/Her]> I wanna make an `ensureComponents` pragma, so you'd do `{.ensureComponents: BaseComponent, InfoComponent.)` |
14:58:47 | FromDiscord | <auxym> pragma macros are a thing IIRC, never used them. that might be possible if you pass your enum type as a `typed` argument to the macro, so it can introspect it |
14:59:16 | FromDiscord | <auxym> I think |
14:59:20 | FromDiscord | <Horizon [She/Her]> Alright, thanks! |
14:59:29 | FromDiscord | <Horizon [She/Her]> So would a pragma macro just be a macro definition? |
14:59:38 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cGe |
14:59:58 | FromDiscord | <Horizon [She/Her]> In reply to @Event Horizon "So would a pragma": I'd imagine it'd pass the proc as the first param |
15:00:40 | FromDiscord | <Phil> Also solves the favicon issue.↵Favicon is the icon it shows on the top left in your tab. Typically its served on `<DOMAIN>/favicon.ico`.↵Due to the pattern you set up (`<DOMAIN>/<Anything as String>`) it also tried to resolve that request for the favicon |
15:01:58 | FromDiscord | <Phil> Note that with nisane it is mandatory that the order of fields in your Object-type and the order of columns in your SQL query match perfectly.↵So if you have an "id" column first, your first field on the object type must be called "id" |
15:03:33 | * | derpydoo joined #nim |
15:04:07 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGm |
15:09:20 | FromDiscord | <Rika> In reply to @Event Horizon "I'd imagine it'd pass": last param i believe |
15:09:52 | FromDiscord | <Horizon [She/Her]> Aah, thanks! |
15:10:07 | FromDiscord | <skiddie99> @Phil what about the |
15:10:14 | FromDiscord | <skiddie99> ? |
15:10:19 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGp |
15:10:21 | FromDiscord | <Phil> sent a long message, see https://paste.rs/an6 |
15:10:45 | FromDiscord | <skiddie99> which would be the most performant way to do it? |
15:10:49 | FromDiscord | <Phil> (edit) "http://ix.io/4cGr" => "http://ix.io/4cGq" |
15:10:52 | FromDiscord | <skiddie99> is my approach bad? |
15:11:22 | FromDiscord | <Phil> Ah, no I just didn't see that particular resp definition |
15:11:24 | FromDiscord | <Phil> Should be fine |
15:11:29 | FromDiscord | <Phil> It's more explicit that way |
15:11:55 | FromDiscord | <Phil> ~~jester really could use some better docs~~ |
15:12:54 | FromDiscord | <skiddie99> @Phil , I have no words to thank you enough for your support! |
15:13:03 | FromDiscord | <skiddie99> this is our final result I guess? |
15:13:11 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGs |
15:13:24 | FromDiscord | <skiddie99> (edit) "https://play.nim-lang.org/#ix=4cGs" => "https://play.nim-lang.org/#ix=4cGt" |
15:15:46 | FromDiscord | <Phil> pretty much.↵↵Sidenote: I'll admit prologue is more verbose than this, but given that I can more easily split out associating procs with routes, I know my preference. |
15:16:37 | FromDiscord | <Phil> Also a lot less magic |
15:16:41 | FromDiscord | <Phil> (edit) "magic" => "magic, which I prefer" |
15:17:13 | FromDiscord | <skiddie99> less magic in prologue or jester? |
15:17:40 | FromDiscord | <Phil> prologue |
15:17:47 | FromDiscord | <skiddie99> oh okay |
15:18:04 | FromDiscord | <skiddie99> I'd like to see a prologue version as well, to be honest |
15:18:42 | FromDiscord | <skiddie99> compared to python, I was expecting to write a lot more lines of code |
15:18:51 | FromDiscord | <skiddie99> those 9 lines? wow |
15:19:19 | FromDiscord | <Horizon [She/Her]> Is there a generic type for `proc` i should use for macros? |
15:19:25 | FromDiscord | <Phil> Prologue would've been easily double that I think |
15:19:38 | FromDiscord | <Horizon [She/Her]> Since the pragma could be used on a method with any amount of arguments |
15:19:48 | FromDiscord | <Horizon [She/Her]> And return value |
15:19:49 | FromDiscord | <skiddie99> In reply to @Isofruit "Prologue would've been easily": yeah I don't mind, I'd like to see that.. By the way, isn't the 9 lines better than making classes? |
15:19:50 | FromDiscord | <Phil> In reply to @Event Horizon "Is there a generic": You can write generic proc types, I use generic proc types all the time |
15:19:58 | FromDiscord | <Horizon [She/Her]> How do i do them? |
15:20:31 | FromDiscord | <Horizon [She/Her]> Also need a way to check if it should be executed lol |
15:20:31 | FromDiscord | <Phil> In reply to @Event Horizon "How do i do": Like anything else. Here an example proc type:↵type ReadProc[REQUESTPARAMS: object, ENTRY: Model] = proc(connection: DbConn, params: REQUESTPARAMS): ENTRY |
15:20:41 | FromDiscord | <Phil> (edit) "type:↵type" => "type:↵`type" | "ENTRY" => "ENTRY`" |
15:20:46 | FromDiscord | <Horizon [She/Her]> Yeah but that isn't generic? |
15:20:57 | FromDiscord | <Horizon [She/Her]> Since it'd require at least two params |
15:21:08 | FromDiscord | <Horizon [She/Her]> and a return type |
15:21:12 | FromDiscord | <Phil> That is a generic proc type with the 2 generic parameters REUQESTPARAMS and ENTRY.↵Or do you mean variable number of parameter of varying types? |
15:21:15 | FromDiscord | <Horizon [She/Her]> I'm using the macro as a pragma |
15:21:25 | FromDiscord | <Horizon [She/Her]> In reply to @Isofruit "That is a generic": Yeah |
15:21:40 | FromDiscord | <Horizon [She/Her]> I'm making a macro that ensures that X components exist |
15:22:04 | FromDiscord | <Horizon [She/Her]> Maybe i'd be better off modifying the nodes directly or something? |
15:22:18 | FromDiscord | <Phil> That one I'm fairly sure is only possible via macros, if at all.↵You can pass pointers to procs around no problem, but if you want to use them you need to unsafely typecast them back to their original proc type and that one you just have to know |
15:22:26 | FromDiscord | <Phil> (edit) "That one I'm fairly sure is only possible via macros, if at all.↵You can pass pointers to procs around no problem, but if you want to use them you need to unsafely typecast them back to their original proc type and that one you just have to know ... " added "in the place where you're executing the proc" |
15:23:10 | FromDiscord | <Horizon [She/Her]> Yeah i'm using a macro for that |
15:23:24 | FromDiscord | <Rika> In reply to @Isofruit "prologue": why would prologue be less magic? |
15:23:27 | FromDiscord | <Rika> id say it is more |
15:23:37 | FromDiscord | <Rika> or roughly the same actually, not more |
15:23:43 | FromDiscord | <Horizon [She/Her]> I don't need to call it, simply need to modify it to add an `if` check to it |
15:24:28 | FromDiscord | <Phil> In reply to @Rika "why would prologue be": You explicitly need to extract your path parameters via an explicit proc from a context and don't have to just "know" that the `@` symbol allows you to access the path parameter in string form. |
15:25:00 | FromDiscord | <Rika> okay, anything else? |
15:25:12 | FromDiscord | <Phil> You also have a single proc to create a response with defaults instead of 10 resp templates |
15:25:25 | FromDiscord | <Rika> okay |
15:25:35 | FromDiscord | <Phil> Wait no, damnit flywind made extensions around that proc with "jsonResponse" |
15:25:42 | FromDiscord | <Phil> (edit) "Wait no, damnit flywind made extensions around that proc with ... "jsonResponse"" added "stuff like" |
15:26:10 | FromDiscord | <Phil> Further, you get to explicitly add the route to an explicit variable that represents your server |
15:26:37 | FromDiscord | <Phil> Here a server magically starts up though it was never explicitly coded, and magically gets a corresponding route attached which was never explicitly done either |
15:27:22 | FromDiscord | <Phil> You can't read that that happens out of the context of the code itself, you have to know jester to know that this happens automatically |
15:28:02 | FromDiscord | <Phil> Similarly you just get magically access to a request object in the context of your route even though it was never explicitly stated anywhere that that even exists |
15:28:23 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cGx |
15:28:45 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cGy |
15:29:08 | FromDiscord | <Phil> In reply to @Event Horizon "`/home/raees/projects/Nim/TextAdventureGame/src/ent": What's componentType? |
15:29:14 | FromDiscord | <skiddie99> oh guys sorry to interrupt |
15:29:23 | FromDiscord | <Horizon [She/Her]> In reply to @Isofruit "What's componentType?": It's an enum |
15:29:31 | FromDiscord | <skiddie99> how do I specify the host on the above script / jester? |
15:29:41 | FromDiscord | <Horizon [She/Her]> Well, a list of enums |
15:30:01 | FromDiscord | <Phil> In reply to @skiddie99 "how do I specify": Define specifying host. Do you mean setting up your domain? |
15:30:09 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGz |
15:30:11 | FromDiscord | <Phil> Or do you mean port? |
15:30:12 | FromDiscord | <skiddie99> I want to access that ip |
15:30:17 | FromDiscord | <skiddie99> from my browser |
15:30:24 | FromDiscord | <Phil> localhost:5000 |
15:30:24 | FromDiscord | <Rika> localhost:5000 |
15:30:25 | FromDiscord | <skiddie99> that's running on a linux server |
15:30:26 | FromDiscord | <Rika> fuck you |
15:30:28 | FromDiscord | <Phil> HAH! Faster |
15:30:31 | FromDiscord | <Phil> Bite me! |
15:30:33 | FromDiscord | <Rika> ok |
15:30:35 | FromDiscord | <Rika> how hard |
15:30:46 | FromDiscord | <skiddie99> In reply to @skiddie99 "that's running on a": -.-" 😛 |
15:30:56 | FromDiscord | <Rika> whats the ip of your server |
15:30:57 | FromDiscord | <Rika> use that |
15:31:07 | FromDiscord | <skiddie99> I mean on terminal command? |
15:31:25 | FromDiscord | <skiddie99> I'm running it as:↵↵nim c -r app.nim -d:release |
15:31:45 | FromDiscord | <Rika> what? |
15:32:01 | FromDiscord | <skiddie99> on python you type the host on the command, is it possible in nim? |
15:32:03 | FromDiscord | <Phil> In reply to @Rika "how hard": Take the strength of like you're about to draw blood and multiply by 0.25 |
15:32:13 | FromDiscord | <Rika> also put `-d:release` before `app.nim` |
15:32:24 | FromDiscord | <skiddie99> oh okay |
15:32:28 | FromDiscord | <skiddie99> but what about the host? |
15:32:57 | FromDiscord | <Phil> For the most part you just need to change the port to 443...was 443 the http one? |
15:33:08 | FromDiscord | <Horizon [She/Her]> In reply to @Event Horizon "Well, a list of": Nvmthat was unrelated |
15:33:13 | FromDiscord | <Phil> Nah, port 80 |
15:33:46 | FromDiscord | <skiddie99> In reply to @Isofruit "For the most part": how? |
15:35:10 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4cGA |
15:35:15 | FromDiscord | <Rika> `let settings = newSettings(port=Port(<port number here>), bindAddr="<address here>")` |
15:36:15 | * | def- quit (Quit: -) |
15:36:25 | * | def- joined #nim |
15:37:05 | FromDiscord | <skiddie99> thank you very much guys |
15:37:06 | FromDiscord | <skiddie99> one last thing please |
15:37:19 | FromDiscord | <skiddie99> is this useful in my case? |
15:37:28 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGE |
15:37:36 | FromDiscord | <skiddie99> I mean the way he uses main and jester.serve() ? |
15:38:01 | FromDiscord | <Phil> Personally I love the main-proc-pattern, stole that from python as well |
15:38:13 | FromDiscord | <Phil> The entire "isMainModule" doesn't make a difference for you |
15:38:27 | FromDiscord | <Phil> Could basically leave out the when check and always call main() |
15:39:06 | FromDiscord | <Phil> And the entire thing of you swapping out your router is also not useful for you yet |
15:39:09 | FromDiscord | <dom96> sent a code paste, see https://play.nim-lang.org/#ix=4cGF |
15:39:16 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cGG |
15:39:22 | FromDiscord | <Horizon [She/Her]> It looks like it should work, but it doesn't |
15:39:50 | FromDiscord | <Rika> components should be made into whatever the field's type is |
15:40:08 | FromDiscord | <Rika> ...i think that should be done |
15:41:17 | FromDiscord | <Horizon [She/Her]> In reply to @Rika "components should be made": It's an openarray which is why I'm confused |
15:41:37 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://paste.rs/38F |
15:42:56 | FromDiscord | <skiddie99> thank you very much guys |
15:42:59 | FromDiscord | <skiddie99> I highly appreciate it |
15:43:08 | FromDiscord | <skiddie99> let's make some benchmarks now |
15:43:22 | FromDiscord | <skiddie99> https://tenor.com/view/hehe-raccoon-ornery-gif-10625001 |
15:46:23 | FromDiscord | <Phil> Note that your windows binary is unlikely to run on a linux server. So better compile the binary on linux. |
15:46:49 | FromDiscord | <Phil> At least from what I gather from this channel there should be compat issues |
15:47:14 | FromDiscord | <JustADigimon (she/her)> open wsl, and compile it from here |
15:47:40 | FromDiscord | <Phil> Ah, right, windows has that, yeah wsl compile |
15:48:29 | FromDiscord | <skiddie99> sent a code paste, see https://play.nim-lang.org/#ix=4cGI |
15:49:05 | FromDiscord | <skiddie99> 🤦♂️ |
15:49:22 | FromDiscord | <Phil> Not enough connections in the async pool? |
15:49:30 | * | kenran joined #nim |
15:50:05 | FromDiscord | <skiddie99> I let it 50.000 |
15:50:15 | FromDiscord | <skiddie99> I really hope that it closes the connections afterwards |
15:50:45 | FromDiscord | <skiddie99> I cannot connect to the db now |
15:50:47 | FromDiscord | <skiddie99> wtf |
15:50:58 | FromDiscord | <skiddie99> I mean from the script |
15:52:57 | * | Alecui joined #nim |
15:53:01 | FromDiscord | <Horizon [She/Her]> Is there a way for me to append this node: https://hastebin.com/ogecekunus.nginx↵to the start of my proc? (So this is executed when the proc is called) |
16:10:21 | * | kenran quit (Remote host closed the connection) |
16:16:43 | FromDiscord | <JustADigimon (she/her)> what the hell is that- |
16:40:51 | FromDiscord | <Patitotective> In reply to @Event Horizon "Is there a way": https://github.com/Patitotective/kdl-nim/blob/main/src/kdl/lexer.nim#L95 |
16:44:26 | * | derpydoo quit (Ping timeout: 268 seconds) |
16:47:14 | FromDiscord | <Patitotective> you just insert your statements at the start of the procedure's body (which is the last children `body[^1]`) |
17:00:45 | * | Alecui left #nim (ERC 5.4.1 (IRC client for GNU Emacs 29.0.50)) |
17:20:19 | FromDiscord | <!!sharpcdf!!> sent a code paste, see https://play.nim-lang.org/#ix=4cHg |
17:20:52 | FromDiscord | <Horizon [She/Her]> Ah thanks :) |
17:29:52 | FromDiscord | <Horizon [She/Her]> In reply to @JustADigimon (she/her) "what the hell is": Nim AST formatted into a tree |
17:29:58 | * | wallabra_ joined #nim |
17:30:00 | FromDiscord | <Horizon [She/Her]> It's just macro stuff |
17:30:29 | FromDiscord | <Horizon [She/Her]> In reply to @Event Horizon "Why is this code": Anyone know the issue? Still haven't figured it out |
17:31:36 | * | wallabra quit (Ping timeout: 264 seconds) |
17:32:09 | * | wallabra_ is now known as wallabra |
17:32:43 | * | derpydoo joined #nim |
17:34:24 | * | rockcavera quit (Remote host closed the connection) |
17:35:08 | FromDiscord | <Rika> I don’t remember being able to put open arrays as a field, do you have any experimental flags on |
17:36:40 | * | rockcavera joined #nim |
17:36:41 | * | rockcavera quit (Changing host) |
17:36:41 | * | rockcavera joined #nim |
17:37:09 | * | xet7 quit (Remote host closed the connection) |
17:40:10 | * | def- quit (Quit: -) |
17:40:20 | * | def- joined #nim |
17:40:51 | FromDiscord | <Horizon [She/Her]> Ah, no i don't, that'd make sense |
17:42:16 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cHl |
17:50:06 | FromDiscord | <Horizon [She/Her]> Figured it out |
18:07:25 | * | PMunch joined #nim |
18:31:05 | * | derpydoo quit (Read error: Connection reset by peer) |
18:54:40 | FromDiscord | <Goel> Isn't possible to use `&` to concatenate two already defined `cstring`? |
19:02:00 | FromDiscord | <Patitotective> In reply to @Goel "Isn't possible to use": i think you need to convert them to strings to do that |
19:02:13 | FromDiscord | <Patitotective> or you could define your own procedure 🤷 |
19:03:33 | strogon14 | yes, you can use $ |
19:10:54 | FromDiscord | <Goel> Uhm, the thing is they are expecting to be put to a proc that needs cstring, so the Objects i created have cstring, and 90% of the time is fine, but in some cases i need to concatenate two of them, as i usually do but since they are cstring i can't do as they are normal strings. So even if now i change back their type to normal strings, i'll still need to conver them to .cstring when needed and that will even be more annoying |
19:11:00 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cHM |
19:11:24 | FromDiscord | <Horizon [She/Her]> In reply to @Goel "Uhm, the thing is": You could just make a proc to concat them? |
19:12:23 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4cHO |
19:12:57 | FromDiscord | <Horizon [She/Her]> It converts `a` and `b` to a Nim string, then joins them, and then returns a `cstring` of the concatted string |
19:13:05 | FromDiscord | <Horizon [She/Her]> Probably a better way to do it though |
19:13:27 | FromDiscord | <Horizon [She/Her]> In reply to @Event Horizon "Anyone know why this": Also yeah, idk why this happens at all, it's confusing |
19:16:01 | FromDiscord | <Horizon [She/Her]> It's for a basic ECS system that feels clean to use in general |
19:17:18 | FromDiscord | <Goel> sent a code paste, see https://play.nim-lang.org/#ix=4cHT |
19:17:23 | * | PMunch quit (Quit: leaving) |
19:17:28 | FromDiscord | <Horizon [She/Her]> 👍 |
19:23:23 | FromDiscord | <Patitotective> In reply to @Goel "Oh wait actually this": you may get a `CStringConv` warning tho |
19:27:42 | FromDiscord | <Goel> In reply to @Patitotective "you may get a": Yes i noticed, i just made the convCString proc and i hope its the end of the story |
19:30:20 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4cHW |
20:02:16 | * | xet7 joined #nim |
20:10:05 | FromDiscord | <Goel> @Patitotective doesn't work like that |
20:35:07 | FromDiscord | <FireLite> Is there a class? Or is there any way to simulate a c++ vtable in nim? |
20:38:05 | FromDiscord | <Phil> I have no idea what a vtable is, but given you're mentioning class, is this going into the direction of dynamic dispatch? |
20:38:13 | FromDiscord | <Phil> Because the concept of methods exists in nim |
20:39:43 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4cI7 |
20:40:22 | FromDiscord | <Phil> In reply to @FireLite "Is there a class?": https://nim-lang.org/docs/tut2.html#object-oriented-programming-dynamic-dispatch↵Does this maybe answer the question? ↵I'm still assuming this is overall about the mechanisms of dynamic dispatch for polymorphisms |
20:40:38 | FromDiscord | <Phil> > Performance note: Nim does not produce a virtual method table, but generates dispatch trees. This avoids the expensive indirect branch for method calls and enables inlining. However, other optimizations like compile time evaluation or dead code elimination do not work with methods. |
21:00:39 | FromDiscord | <Elegantbeef> A vtable is an array of procedures bound to a type for dynamic dispatch so yes↵(@Phil) |
21:00:58 | FromDiscord | <Elegantbeef> Each type gets a array of procedures so when you call methods you just look them up |
21:01:20 | FromDiscord | <Elegantbeef> This is somewhat better than what Nim does with a bunch of case statements on a method call |
21:03:40 | FromDiscord | <Horizon [She/Her]> In reply to @Event Horizon "Anyone know why this": Anyone? :P |
21:05:18 | FromDiscord | <jos> is there any way to have a nim macro (or something like a nim macro) accept the block as a string instead of having nim parse it first |
21:05:54 | FromDiscord | <jos> i wanna have a macro that reads in s-expressions for emitting webassembly and parsing it as a string seems easier/simpler |
21:06:12 | FromDiscord | <jos> worst case scenario i guess i can just accept literally a string, but i dont want the quotes aha |
21:07:42 | FromDiscord | <Patitotective> In reply to @jos "is there any way": accept it as a block and do `repr body` |
21:08:55 | FromDiscord | <jos> i don't know enough about nim to understand what you said really |
21:09:16 | FromDiscord | <jos> do u mean like `macro xyz(input: block): let blockAsString = repr block` |
21:09:39 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4cIc |
21:09:40 | FromDiscord | <jos> ah ok |
21:09:53 | FromDiscord | <jos> ok so FWIU the body would still have to be parseable nim |
21:10:08 | FromDiscord | <jos> is there any way to avoid that |
21:10:51 | FromDiscord | <Patitotective> i dont think there is way to do that, you should instead just use a multiline string |
21:11:03 | FromDiscord | <jos> fair enough, thanks |
21:11:13 | FromDiscord | <jos> if anyone knows that would be great though |
21:13:09 | FromDiscord | <jos> also if anybody knows of an s-expression macro implementation in nim that would be cool, i couldn't find one |
21:16:04 | FromDiscord | <matkuki> Hey, @treeform can you tell me what is the status of Fidget? Is it still developed? It's an excellent library.↵I asked this in the github issues already some time ago, but there's still no reply. |
21:16:54 | FromDiscord | <Patitotective> In reply to @matkuki "Hey, <@107140179025735680> can you": i dont know if treeform is still developing it but, elcritch shares updates about his fork of fidget in the forum https://forum.nim-lang.org/t/9476 |
21:18:33 | FromDiscord | <matkuki> Thanks, does that mean it shouldn't be used for new projects? Better to use elctritch's `Fidgetty`? |
21:19:44 | FromDiscord | <Patitotective> i would say yes https://media.discordapp.net/attachments/371759389889003532/1028778819756241007/unknown.png |
21:30:50 | FromDiscord | <Patitotective> is there something like python's keyword arguments `kargs` in nim? something like `kargargs[int]` |
21:37:00 | FromDiscord | <Elegantbeef> Eh just use a `static string` and triple quote↵(@jos) |
21:37:20 | FromDiscord | <jos> yeah that's what I'm doing now |
21:37:34 | FromDiscord | <jos> it kind of sucks because the keyword highlighting would be nice |
21:37:49 | FromDiscord | <Elegantbeef> then write it in another file and staticRead it in |
21:37:55 | FromDiscord | <jos> eh |
21:38:07 | FromDiscord | <jos> its way nicer inline |
21:38:29 | FromDiscord | <jos> I'm just trying to do something like quasi quote s expressions |
21:38:43 | FromDiscord | <Elegantbeef> Sure but arbitrary code inside macros is different syntax which is sketchy |
21:39:00 | FromDiscord | <Elegantbeef> What are you doing exactly? |
21:39:07 | FromDiscord | <jos> I mean if ultra opinionated rust supports arbitrary token streams |
21:39:32 | FromDiscord | <jos> I want to emit s expressions for wasm with a macro |
21:40:07 | FromDiscord | <jos> but whitespace rules make reasonably formatted sexprs not valid n |
21:40:14 | FromDiscord | <jos> not valid nim |
21:40:36 | FromDiscord | <jos> oh maybe I can escape the newline? |
21:40:39 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4cIe |
21:40:46 | FromDiscord | <Elegantbeef> Hardly an argument given that their procedural are a mess↵(@jos) |
21:41:25 | FromDiscord | <Elegantbeef> `varargs[untyped]` does that↵(@Patitotective) |
21:42:04 | FromDiscord | <Elegantbeef> QED |
21:42:05 | FromDiscord | <Patitotective> but im not going to be able to accept a last body block :[ |
21:42:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4cIf |
21:42:13 | FromDiscord | <Elegantbeef> Yea you are |
21:43:50 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4cIg |
21:45:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4cIi |
21:48:26 | FromDiscord | <Patitotective> :] |
21:50:59 | FromDiscord | <Elegantbeef> Can even error after the first `nnkExprEqExpr` if you dont get a stmtlist or another nnkexpreqexpr |
21:57:06 | FromDiscord | <treeform> In reply to @matkuki "Hey, <@107140179025735680> can you": Its currently kind of limbo, I am trying to get the underlaying libraries right, windy/pixie/boxy. Once that is done i'll be back to fidget. |
22:08:25 | FromDiscord | <ChocolettePalette> > nnkexpreqexpr |
22:08:42 | FromDiscord | <Elegantbeef> Yes |
23:11:30 | FromDiscord | <Patitotective> In reply to @Patitotective "is there way to": any workarounds beef? |
23:15:07 | FromDiscord | <SYN_ACK_SICARI0🐍> Good evening everyone hope you are all enjoying your weekend, does anyone know where I can find the original Pascal source for the first Nim compiler? |
23:16:49 | * | jmdaemon joined #nim |
23:25:50 | FromDiscord | <Elegantbeef> No↵(@Patitotective) |
23:28:56 | FromDiscord | <auxym> In reply to @SYN_ACK_SICARI0🐍 "Good evening everyone hope": https://github.com/nim-lang/Nim/tree/ea1f1ec6d4d6c776eb0f81c2bebdd4cb4c817ebe/nim |
23:29:15 | FromDiscord | <auxym> found that linked on wikipedia |
23:29:49 | FromDiscord | <SYN_ACK_SICARI0🐍> In reply to @auxym "found that linked on": Oh sweet, thank so much! |
23:32:22 | * | xet7 quit (Remote host closed the connection) |
23:53:22 | FromDiscord | <jos> when i get an error like this: |
23:53:23 | FromDiscord | <jos> https://media.discordapp.net/attachments/371759389889003532/1028817483047637013/unknown.png |
23:53:25 | FromDiscord | <jos> is there any way to know why? |
23:53:31 | FromDiscord | <jos> like what feature am i using that isn't supported |
23:53:56 | FromDiscord | <Elegantbeef> compile the code |
23:54:01 | FromDiscord | <jos> i do, nothing helpful comes up |
23:54:04 | FromDiscord | <jos> it's the same error from nimble build |
23:54:09 | FromDiscord | <jos> barring that, can macros even return static values? |
23:54:28 | FromDiscord | <Elegantbeef> you dont need `static` for a macro |
23:54:34 | FromDiscord | <Elegantbeef> macros are inherently static |
23:54:45 | FromDiscord | <Elegantbeef> `block:` |
23:54:48 | FromDiscord | <jos> i changed it into a static proc btw |
23:54:56 | FromDiscord | <jos> i still get the same error, cannot evaluate at compile time: parser |
23:54:59 | FromDiscord | <jos> but i'm not sure how to get more |
23:57:21 | FromDiscord | <jos> it might be because i'm using patty |
23:57:34 | FromDiscord | <jos> it might use some feature under the hood that isn't compatible with compile time eval |
23:57:49 | FromDiscord | <huantian> is parser a ref obj? i don't think those work at compile time |
23:58:05 | FromDiscord | <Elegantbeef> `ref obj` work at compile time, they dont work as constants |
23:58:09 | FromDiscord | <huantian> ah |
23:58:32 | FromDiscord | <Elegantbeef> So if SexprNode is a ref object there's the issue |
23:58:49 | FromDiscord | <huantian> sex pr node |
23:58:58 | FromDiscord | <jos> it is a ref object |
23:59:13 | FromDiscord | <jos> ok |
23:59:18 | FromDiscord | <jos> i think distinct will work fine here |
23:59:25 | FromDiscord | <jos> i think!! 🙂 |
23:59:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/fPU |
23:59:54 | FromDiscord | <Elegantbeef> But that obviously doesnt work if your sexpr object has references |