00:03:06 | FromDiscord | <guttural666> this cannot possibly be a compile time value right? Nim will fall back to var I guess? https://media.discordapp.net/attachments/371759389889003532/1037879622731317258/image.png |
00:03:33 | FromDiscord | <guttural666> similar to constexpr in cpp |
00:03:37 | FromDiscord | <Elegantbeef> It can be `getHomeDir()` is overloaded for the VM iirc |
00:03:48 | FromDiscord | <Elegantbeef> So it returns your home dir |
00:04:00 | FromDiscord | <Elegantbeef> It's useful for macros, but a bug in disguise |
00:04:08 | FromDiscord | <Elegantbeef> That should be `let` |
00:04:19 | FromDiscord | <guttural666> yeah |
00:05:05 | FromDiscord | <guttural666> works just as well thanks 🙂 |
00:39:57 | * | derpydoo joined #nim |
00:48:42 | * | pyrex left #nim (Leaving) |
02:18:05 | * | alystair joined #nim |
02:18:37 | alystair | I just saw a YT video about NIM, they mentioned it can compile to javascript? where do I read more about this |
02:20:21 | FromDiscord | <Elegantbeef> What do you want to know exactly? |
02:29:38 | alystair | ah nevermind I need to just RTFM :) |
02:52:02 | * | derpydoo quit (Quit: derpydoo) |
02:55:52 | * | disso_peach joined #nim |
03:10:49 | * | arkurious quit (Quit: Leaving) |
03:28:28 | FromDiscord | <tangonov> sent a code paste, see https://play.nim-lang.org/#ix=4eTh |
03:30:36 | FromDiscord | <Bung> maybe try devel build version ? |
03:32:01 | FromDiscord | <tangonov> I am comfortable with my stable install from nixpkgs. If you're saying something upstream may fix this trivial issue, I can just accept it |
03:32:54 | FromDiscord | <tangonov> Stable on nix 1.6.6 if that's of any use in this conversation |
03:37:44 | FromDiscord | <Bung> 1.6.6 is fine, something changes to nimsuggest recent months, but maybe it's not right time try devel |
03:57:34 | FromDiscord | <proton> `/mnt/c/Users/low/nimbus-eth1/nimbus/p2p/validate.nim(247, 21) Error: getBalance(roDB, sender) can raise an unlisted exception: RlpError`↵Nim Compiler Version 1.6.8 [Linux: amd64]↵Compiled at 2022-11-04 |
04:04:40 | * | dtomato4 quit (Ping timeout: 272 seconds) |
04:05:02 | FromDiscord | <Bung> that's probably lib side, add RlpError effect to that proc |
04:07:49 | * | rlr joined #nim |
04:22:04 | * | dtomato4 joined #nim |
04:53:54 | FromDiscord | <Bung> the effect system dont tell you the root cause? `can raise an unlisted exception Exception`, it doesn't tell me what proc call can raise that |
05:12:20 | * | disso_peach quit (Ping timeout: 248 seconds) |
05:22:43 | * | disso_peach joined #nim |
05:47:08 | * | rockcavera quit (Remote host closed the connection) |
06:59:03 | * | kenran joined #nim |
07:02:29 | * | lucerne joined #nim |
07:17:23 | * | arkanoid quit (Ping timeout: 246 seconds) |
07:27:32 | * | lucerne quit (Remote host closed the connection) |
07:38:46 | * | lucerne joined #nim |
07:45:17 | * | lucerne quit (Read error: Connection reset by peer) |
07:50:07 | * | lucerne joined #nim |
07:59:19 | * | jjido joined #nim |
08:02:20 | * | m5zs7k quit (Ping timeout: 252 seconds) |
08:06:49 | * | m5zs7k joined #nim |
08:07:18 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=4eTR |
08:09:14 | FromDiscord | <Girvo> (Ignore that the initial struct is called led_strip_s, thats just some C silliness with forward declarations so it can refer to itself) |
08:12:27 | FromDiscord | <Girvo> I guess what I'm asking is how the heck do I manage to generate `strip->clear()` instead of `(strip).clear()`? |
08:13:40 | FromDiscord | <Rika> Are they not equivalent? |
08:14:56 | FromDiscord | <Elegantbeef> They should be |
08:15:19 | FromDiscord | <Elegantbeef> `ptr->field` is dereference as is `(T)(ptr).field` |
08:15:20 | FromDiscord | <Girvo> ^ you are both correct. I wonder why it's choking then. I think the `importc: clear` that c2nim chucked on there is wrong |
08:15:54 | FromDiscord | <Girvo> Ah yep that's exactly what it was. c2nim was adding `importc` to the internal function pointers on the struct/procs on the object type. Remove them and it compiles! |
08:15:56 | FromDiscord | <Girvo> Now to see if it runs |
08:16:02 | FromDiscord | <Elegantbeef> It's unneeded in this case but you can importc fields iirc |
08:16:05 | FromDiscord | <Rika> Sounds strange |
08:16:14 | FromDiscord | <Rika> I thought it would still work with the import |
08:16:22 | FromDiscord | <Girvo> It was adding this `.ClE_0` stuff for some reason |
08:16:35 | FromDiscord | <Girvo> And removing the import on the `clear` removed it |
08:16:38 | FromDiscord | <Elegantbeef> Closures |
08:16:47 | FromDiscord | <Elegantbeef> `CLE` is closure environment |
08:16:52 | FromDiscord | <Elegantbeef> you needed the proc annotated `{.cdecl.}` or w/e |
08:17:21 | FromDiscord | <Girvo> Ah yeah, I just did that too lol |
08:17:35 | FromDiscord | <Elegantbeef> Remember that Nim assumes all procs in type defs are `closure`, fucks you around with C interop |
08:17:41 | FromDiscord | <Girvo> That's good to know, theres a few other libraries in ESP-IDF that are doing function pointers in structs everywhere |
08:18:19 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=4eTW |
08:18:36 | FromDiscord | <Elegantbeef> No problem |
08:20:18 | * | blackbeard420 quit (Ping timeout: 268 seconds) |
08:22:40 | FromDiscord | <Girvo> Now to wrap all this up in a way nicer interface lol |
08:23:01 | FromDiscord | <Girvo> But it works! I have a LED strip on our daughterboard lighting up through Nim 🙂 |
08:24:53 | FromDiscord | <Elegantbeef> Damn the future is now |
08:26:51 | FromDiscord | <Girvo> It generates the PWM signal by hijacking the Remote Control (infrared) Transceiver hardware, because its the only thing fast enough that can generate a 24-bit 800khz signal for them lol |
08:27:07 | FromDiscord | <Girvo> The RMT driver is way too complicated for me to bother binding fully, but I only needed a couple types and two functions, and then `led_strip` itself. And they're currently blinding me on my desk, hooray |
08:27:07 | FromDiscord | <Elegantbeef> Look at this guy not thinking I know how remote controls used to work |
08:27:07 | FromDiscord | <Elegantbeef> Yes i said used to |
08:27:30 | FromDiscord | <Elegantbeef> Get your bluetooth wifi connected remote control for your forced smart IOT TV and be happy! |
08:27:45 | * | NimBot joined #nim |
08:27:46 | FromDiscord | <Elegantbeef> Do you get danger pay for the blinding |
08:27:57 | FromDiscord | <Elegantbeef> You really should high intensity light is no joke |
08:28:30 | FromDiscord | <Elegantbeef> I knew a guy whose retina had an image burned for a whole 5 minutes, couldnt see properly for 5 minutes, supremely dangerous! |
08:28:54 | FromDiscord | <Girvo> Bare LEDs driven at full power are crazy bright nowadays lol |
08:28:59 | FromDiscord | <Girvo> I have them turned down now |
08:29:19 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=4eTZ |
08:29:38 | FromDiscord | <Elegantbeef> The first step everyone takes when wrapping C, the ugliest stuff ever |
08:30:05 | FromDiscord | <Girvo> Those `_DEFAULT_CONFIG` things are `#define`-s in C land that give you a struct, I've done them as templates for now that just output the object with the default values set rather than a proc. I figure that's closest for now? |
08:30:06 | FromDiscord | <Elegantbeef> I might be wrong but atleast there isnt any resource management here |
08:30:12 | FromDiscord | <Girvo> Oh there absolutely isn't 😄 |
08:30:21 | FromDiscord | <Girvo> Not yet anyway, that's the next step |
08:30:36 | FromDiscord | <Elegantbeef> Consts? |
08:30:45 | FromDiscord | <Elegantbeef> Or do they depend on runtime values? |
08:31:21 | FromDiscord | <Girvo> I know some have -- but these ones don't. But can you then edit the values after? One sec I'll show you what they do, and what I've done |
08:33:57 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=4eU5 |
08:34:13 | FromDiscord | <Elegantbeef> Ah that's just a template constructor yea |
08:34:14 | FromDiscord | <Girvo> Can I assign a `const` object definition to a variable and modify its properties after? |
08:35:13 | FromDiscord | <Elegantbeef> I mean you can of course do `var a = myConst` but that's not what you want here, you want an expression |
08:35:30 | FromDiscord | <Girvo> Yeah sweet |
08:36:00 | FromDiscord | <Girvo> It's what c2nim was outputting and what I'd seen elsewhere and made sense to me as the direct translation of those defines |
08:36:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eU7 |
08:36:34 | FromDiscord | <Girvo> Yeah that's what I also did haha |
08:36:57 | FromDiscord | <Girvo> It seemed to compile the same too yeah, with `-d:release` |
08:37:27 | FromDiscord | <Girvo> But all of this is going to be internal once I put some proper structure around all of it anyway, so I'm not too worried about it |
08:37:27 | FromDiscord | <Elegantbeef> I'd wager even without inline annotation in C it'd inline |
08:37:45 | FromDiscord | <Elegantbeef> This just seems like someone making a CMacro cause they are way way overly concerned |
08:37:47 | FromDiscord | <Girvo> Depends, the compiler they use for the LX7 processer here is... not great, sometimes |
08:38:04 | FromDiscord | <Elegantbeef> Right, i'm too used to gcc/clang |
08:38:07 | FromDiscord | <Girvo> And yep welcome to ESP-IDF lol. They use macros everywhere for this stuff |
08:38:33 | FromDiscord | <Elegantbeef> I guess if you want to not emit a procedure for basic operations C macros are the best you can do there |
08:39:00 | FromDiscord | <Girvo> Yeah. When all you have is text substitution and everything looks like a nail, or something |
08:39:55 | FromDiscord | <Elegantbeef> Metaprogramming was a mistake 😛 |
08:40:10 | FromDiscord | <Girvo> Lispers recoil in horror |
08:42:34 | FromDiscord | <Girvo> Handy to know the `{.cdecl.}` requirement on the functions-in-structs. Will make binding some more of this stuff a lot easier! |
08:42:43 | FromDiscord | <Girvo> It'd tripped me up before and I couldn't work it out lol |
08:45:06 | FromDiscord | <srozb> hey, what is `nim secret` and why it's not in `--fullhelp` ? |
08:45:49 | FromDiscord | <Vindaar> if it were in `--fullhelp` it wouldn't be a secret, would it? |
08:46:05 | FromDiscord | <srozb> absolutely |
08:46:41 | FromDiscord | <Vindaar> it's a REPL for the nim VM. It's pretty limited and hence not really advertised |
08:47:25 | FromDiscord | <srozb> I see, I'm using inim and thought I could stick to the one that's already there (within the compiler) |
08:48:13 | FromDiscord | <ringabout> Does it screw up on Linux? It doesn't work properly on wsl2? |
08:48:31 | FromDiscord | <ringabout> (edit) "wsl2?" => "my wsl2." |
08:49:45 | FromDiscord | <ringabout> https://media.discordapp.net/attachments/371759389889003532/1038012164893573140/image.png |
08:49:47 | FromDiscord | <srozb> ok, thanks, I guess we'll have to wait for this secret to be less secret and more useful |
08:51:33 | FromDiscord | <ringabout> In reply to @flywind "Does it screw up": The prompt shows at the wrong place. It should have been before input not result. |
08:56:55 | FromDiscord | <Elegantbeef> Really i'd argue that inside a `importc`'d type it should infer as `cdecl` but that is likely more confusing |
08:59:17 | * | dnh joined #nim |
09:04:29 | * | alystair quit (Ping timeout: 246 seconds) |
09:19:59 | * | dnh quit (Quit: Textual IRC Client: www.textualapp.com) |
09:22:12 | FromDiscord | <4zv4l> I'm on linux and that does the same thing↵(@ringabout) |
09:24:44 | FromDiscord | <4zv4l> they should also probably add the `readLineFromStdin()` function to allow using the arrow keys to modify the input |
09:28:29 | FromDiscord | <ringabout> It is a regression |
09:28:44 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
09:39:00 | FromDiscord | <Phil> sent a long message, see http://ix.io/4eUn |
09:39:47 | FromDiscord | <Phil> (edit) "http://ix.io/4eUn" => "http://ix.io/4eUo" |
09:40:11 | FromDiscord | <srozb> sure, thanks. That explains a lot |
10:12:28 | * | pro joined #nim |
10:23:22 | * | pro left #nim (#nim) |
10:42:32 | * | wallabra quit (Ping timeout: 276 seconds) |
10:44:20 | * | wallabra joined #nim |
11:51:05 | * | jmdaemon quit (Ping timeout: 246 seconds) |
11:57:13 | FromDiscord | <Cheesy Brik> Where does the name nim come from? |
12:01:33 | madprops | originally it was called Nimrod |
12:01:42 | madprops | but people complained i guess |
12:02:17 | madprops | https://en.wikipedia.org/wiki/Nimrod |
12:05:41 | * | disso_peach quit (Remote host closed the connection) |
12:12:03 | FromDiscord | <Generic> the story I heard was that in the Looney Tunes (idk whether it's a reoccuring thing or only happened ones, I don't know it that well) someone is called Nimrod in ridicule |
12:12:47 | FromDiscord | <Generic> and apparently that had such a lasting impact on American culture that some people to this day think Nimrod means idiot |
12:13:47 | FromDiscord | <Generic> not that I blame them, old cartoons had a lasting effect on me |
12:13:56 | FromDiscord | <Generic> (edit) "not that I blame them, old cartoons had a lasting effect on me ... " added "as well haha" |
12:45:25 | * | derpydoo joined #nim |
12:47:14 | Amun-Ra | there was similar story with Zig language (that reminded someone of "zig heil"…) :| |
12:51:25 | FromDiscord | <Prestige> that's so dumb lol |
12:51:29 | FromDiscord | <Generic> blah now I can't unhear it anymore |
12:51:42 | FromDiscord | <Rika> That is dumber than the Nim one ngl |
12:52:56 | FromDiscord | <Generic> it is, vowel length is afaik contrastive in German and English |
12:53:53 | FromDiscord | <Generic> though I currently can't come up with a minimal pair |
13:06:37 | FromDiscord | <tangonov> Zig as in "zigzag" is how I saw that one. Second to "why would anyone call a great programming language 'Nimrod'?" It took some growing up to realize that Nimrod was re-appropriated. I grew up understanding that Nimrod meant "moron" or baffoon, too. |
13:07:07 | FromDiscord | <tangonov> (edit) "baffoon," => "buffoon," |
13:07:42 | FromDiscord | <tangonov> (edit) "growing up" => "reading" |
13:11:25 | FromDiscord | <jmgomez> converters doesnt work with procs, right? |
13:24:19 | * | jjido joined #nim |
13:38:05 | FromDiscord | <Require Support> anyone have an example of creating a `$` proc for a custom `ref object` ? is there a difference compared to a normal object? |
13:41:10 | * | blackbeard420 joined #nim |
13:43:55 | FromDiscord | <Duskhorn The Eclipsed> Hello, has anyone tried to load a custom shape window using the SDL2 bindings? ↵I had to manually import some functions but now I don't know why my code is not working, even after translating a running C example |
13:44:07 | FromDiscord | <Duskhorn The Eclipsed> And I'm stuck at the window being not opened |
13:52:04 | FromDiscord | <auxym> In reply to @Require Support "anyone have an example": no, there shouldn't be a difference. just define a `$` proc that takes your ref object type and returns a string |
13:52:10 | * | arkurious joined #nim |
13:55:50 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
14:04:47 | * | tinystoat joined #nim |
14:07:16 | * | tinytoast quit (Ping timeout: 248 seconds) |
14:07:58 | * | derpydoo quit (Quit: derpydoo) |
14:10:31 | FromDiscord | <nocturn9x> guys |
14:10:38 | FromDiscord | <nocturn9x> I have an idea that could be the cause of my problem |
14:10:55 | FromDiscord | <nocturn9x> does alloc() return nil when there's not enough memory in the system? |
14:17:31 | FromDiscord | <Rika> alloc() is pretty much equivalent to `malloc` so it should |
14:17:45 | FromDiscord | <Rika> unless you're using zephyrf |
14:17:46 | FromDiscord | <Rika> (edit) "zephyrf" => "zephyr" |
14:17:48 | * | xet7 quit (Ping timeout: 252 seconds) |
14:20:26 | * | derpydoo joined #nim |
14:25:33 | * | xet7 joined #nim |
14:26:30 | FromDiscord | <nocturn9x> I see |
14:33:12 | * | piertoni joined #nim |
14:36:26 | FromDiscord | <ChocolettePalette> What's that?↵(@Rika) |
14:36:38 | FromDiscord | <Rika> embedded rtos |
14:37:46 | FromDiscord | <ChocolettePalette> Uhh I'll google |
14:39:13 | FromDiscord | <ChocolettePalette> Zephyr is kinda cool ngl but there's a programming language called zephyr too |
14:40:11 | FromDiscord | <spoon> theres also fridges and shoes |
14:43:16 | * | kenran quit (Remote host closed the connection) |
14:46:58 | * | rockcavera joined #nim |
14:46:59 | * | rockcavera quit (Changing host) |
14:46:59 | * | rockcavera joined #nim |
14:48:21 | * | nisstyre joined #nim |
15:42:03 | * | piertoni quit (Ping timeout: 260 seconds) |
15:54:05 | * | alystair joined #nim |
16:22:41 | * | derpydoo quit (Ping timeout: 246 seconds) |
16:23:34 | FromDiscord | <jumping_sloth> Hey y'all, just found out about nim and I'm pretty impressed by its capabilities. I wanted to try the cross compilation, but when I try to run this command on windows\: `nim compile --cpu:amd64 --os:linux main.nim` the error `fatal error: sys/mman.h: No such file or directory 10 | #include <sys/mman.h> | ^~~~~~~~~~~~ compilation terminated.` appears. The program itself doesn't do anything special. It just prints some text. |
16:45:58 | * | derpydoo joined #nim |
16:49:10 | Amun-Ra | you have to have some "posixy" env installed |
16:49:49 | FromDiscord | <jumping_sloth> so I have to run the compile command in e.g. mingw? |
16:51:07 | FromDiscord | <auxym> In reply to @jumping_sloth "Hey y'all, just found": Nim uses a C compiler "under the hood". So, if you want to cross compile on windows targetting linux, you'll need a C compiler toolchain that can do that, first. A quick google seems to show that it's not straightforward, but might be possible using cygwin |
16:52:04 | NimEventer | New question by The Modern Gamer: Getting hardware info in nim-lang, see https://stackoverflow.com/questions/74320430/getting-hardware-info-in-nim-lang |
16:53:15 | FromDiscord | <auxym> eg: https://stackoverflow.com/a/4770417/4092334 |
16:54:18 | FromDiscord | <auxym> probably way easier to just use WSL |
16:54:28 | FromDiscord | <ShalokShalom> In reply to @auxym "Nim uses a C": Isnt this somehow possible with the Zig compiler? |
16:54:56 | FromDiscord | <auxym> no idea about zig |
16:55:02 | FromDiscord | <ShalokShalom> And always think about that↵↵https://github.com/jart/cosmopolitan |
16:55:30 | Amun-Ra | zig has all that built-in, nim generate C code for external compiler to compiler |
16:55:37 | Amun-Ra | generates* |
16:55:57 | Amun-Ra | typing is not my strongest perk today |
16:56:09 | FromDiscord | <untoreh> can I iterate over a named tuple? |
16:57:51 | FromDiscord | <ShalokShalom> In reply to @Amun-Ra "zig has all that": Doesnt Zig offer a C compiler, that can do that? |
16:58:19 | Amun-Ra | ShalokShalom: zig can act as standalone C compiler |
17:00:58 | NimEventer | New thread by freeflow: Importing from a parallel directory., see https://forum.nim-lang.org/t/9577 |
17:01:44 | FromDiscord | <UnvaxxedPureBlood> In reply to @auxym "Nim uses a C": Zig can do that |
17:01:47 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4eX3 |
17:02:22 | FromDiscord | <jmgomez> (edit) "https://play.nim-lang.org/#ix=4eX3" => "https://play.nim-lang.org/#ix=4eX4" |
17:02:33 | FromDiscord | <auxym> zig cc indeed seems pretty cool, just had a quick look at the blog post. I wonder if anyone has tried using nim with it. Should be possible with `--cc:clang` and `x64.linux.clang.exe = "zig cc"`, or something like that |
17:02:36 | Amun-Ra | you can generate C code with nim and compile for many platforms, you can compile zig code only for platforms defined in zig |
17:03:02 | FromDiscord | <jmgomez> I guess all that they have is a build script? |
17:06:50 | FromDiscord | <ShalokShalom> In reply to @auxym "zig cc indeed seems": Yes, I know that some people are doing that |
17:06:58 | FromDiscord | <auxym> zig cc is basically a CLI frontend to clang, but it also ships with libc for a ton of platform, and their compiler-rt thing. Or so I understood from a quick skim of the blog post. |
17:07:07 | FromDiscord | <ShalokShalom> But I am more excited about Cosmopolitian. |
17:07:16 | FromDiscord | <ShalokShalom> While I guess you can combine both. |
17:07:40 | FromDiscord | <auxym> In reply to @ShalokShalom "Yes, I know that": cool, would be a neat blog post to https://nim-lang.org/blog.html |
17:08:12 | Amun-Ra | auxym: exactly |
17:08:22 | FromDiscord | <auxym> In reply to @ShalokShalom "But I am more": cosmopolitan is a (very) neat hack, but not something I'd consider using for "real" software |
17:11:42 | FromDiscord | <ShalokShalom> In reply to @auxym "cool, would be a": True |
17:11:47 | FromDiscord | <ShalokShalom> In reply to @auxym "cosmopolitan is a (very)": Why?/ |
17:12:05 | FromDiscord | <ShalokShalom> Does Nim even get used for 'real' software 😋 |
17:18:20 | FromDiscord | <auxym> good point 😉 |
17:19:28 | FromDiscord | <auxym> for one thing, it does not have 100% syscall support, so anything you code which might make a syscall, you have to refer to this table: https://justine.lol/cosmopolitan/functions.html |
17:20:09 | FromDiscord | <auxym> also its dependent on OSes not breaking ABI compability, which is fine for linux apparently, but windows breaks the ABI regularly, and no idea for BSDs and whatnot |
17:20:35 | FromDiscord | <hovsater> How hard would it be to translate the extended BNF grammar (https://nim-lang.org/docs/manual.html#syntax-grammar) to regular BNF? I'm not too familiar with BNF or the extended BNF, but I might want to pursue translating it. |
17:36:46 | FromDiscord | <dlesnoff> In reply to @jmgomez "converters doesnt work with": Do you have a MWE of what you want?↵Do you want to implicitly change a procedure signature? Automatically add effects? Implicitly apply pragmas?↵You probably know but converters are really not appreciated (by Araq I guess?), since it breaks the rule "Explicit is better than implicit". |
17:41:35 | FromDiscord | <jmgomez> In reply to @Jiezron "Do you have a": I just ended up doing it explicitly. Basically I wanted to specify that two signatures were compatible. In particular to go from a regular proc into the same proc but returning a future instead.. |
17:48:40 | alystair | I was going to explore nim as a single language to target both back and frontend effectively but once I saw the generated snake.js code from nim's home page I decided against it, are there no newer build-for-js examples? |
17:49:05 | alystair | I come from a deep vanilla js background so I'm hoping there has been a lot of improvement since that demo was made |
17:49:27 | alystair | as it's between 4-6 years old |
17:51:21 | alystair | I'd need to see more recent generated JS output to get a better understanding if nim is worth my time to pursue for my personal use cases |
18:01:55 | FromDiscord | <dlesnoff> In reply to @alystair "as it's between 4-6": What do you want for your JS output ?↵Do you want it to be easily readable ? small ? Fast ?↵Either way I have seen many compdaints about the JS output in the forum.↵There is yet a dedicated alternative std library for JS or nodeJS https://github.com/juancarlospaco/nodejs |
18:05:30 | FromDiscord | <dlesnoff> https://forum.nim-lang.org/t/8074 |
18:16:34 | FromDiscord | <dlesnoff> https://forum.nim-lang.org/t/9525 |
18:16:45 | FromDiscord | <ShalokShalom> In reply to @alystair "I'd need to see": Nim produces less readable results as Fable, Reason/Rescript and some others. ↵↵Is this important to you? |
18:17:00 | FromDiscord | <ShalokShalom> Or are you unhappy with the performance? ↵↵Security? |
18:17:10 | FromDiscord | <ShalokShalom> What is your pain point? |
18:19:17 | FromDiscord | <hector> What next, people asking for readable assembly code? |
18:19:40 | FromDiscord | <dlesnoff> In reply to @Jiezron "https://forum.nim-lang.org/t/9525": About the readability of the JS output |
18:22:13 | FromDiscord | <dlesnoff> In reply to @hector "What next, people asking": Don't be harsh to Nim newcomers please.↵Assembly and Javascript are complete different things. One is machine-dependent, the other is portable. |
18:22:14 | FromDiscord | <ShalokShalom> In reply to @hector "What next, people asking": JS can be done readable. |
18:22:53 | FromDiscord | <ShalokShalom> Nim doesnt do it. If you drop Nim later on, you depend on unreadable output code |
18:23:20 | FromDiscord | <ShalokShalom> If you do the same thing with Fable, you can drop it later and just succeed working with the produced output. |
18:23:51 | FromDiscord | <ShalokShalom> Particularly for companies, who might not find a Nim or FSharp developer that quick, is this a significant difference |
18:26:05 | FromDiscord | <hector> If it conflicts with performance I'd take performant JS over "readable" JS every time. WASM makes this moot anyway |
18:31:27 | FromDiscord | <dlesnoff> In reply to @hector "If it conflicts with": But readability improves tweaking possibilities and potential performance gains this way.↵It makes also the code reusable in non-Nim contexts. It allows you to extract specific parts of the output code. It helps in analyzing and comparing two code.↵This question is like any black-box vs white-box question: there is no definitive answer. It depends on what you want in the end. |
18:35:05 | FromDiscord | <dlesnoff> In reply to @hovsater "How hard would it": I am not sure what you mean by "regular grammar"?↵If it requires the language to be regular, i.e. specifiable by a regular expression, or equivalently by a finite automaton, I guess it is probably not doable.↵I am no expert in formal languages though. |
18:35:43 | FromDiscord | <hovsater> In reply to @Jiezron "I am not sure": I think you misunderstood me. I want to translate the current extended BNF into BNF. |
18:36:41 | FromDiscord | <hovsater> (edit) "In reply to @Jiezron "I am not sure": I think you misunderstood me. I want to translate the current extended BNF into BNF. ... " added "Since I'm not experienced with BNF I had a hard time understanding if I could express the extended BNF as BNF." |
18:36:57 | FromDiscord | <hovsater> (edit) "me." => "me or perhaps I'm misunderstand you. 😅" |
18:37:24 | * | FromDiscord quit (Remote host closed the connection) |
18:37:37 | * | FromDiscord joined #nim |
18:42:24 | FromDiscord | <dlesnoff> Oh yeah, as you see, I am no expert in formal languages, grammar specification and the likes 😦 |
18:45:51 | FromDiscord | <dlesnoff> Any grammar defined in EBNF can also be represented in BNF, though representations in the latter are generally lengthier |
18:46:04 | * | jjido joined #nim |
18:46:12 | FromDiscord | <dlesnoff> Wikipedia quote |
18:56:59 | * | derpydoo quit (Quit: derpydoo) |
18:58:41 | FromDiscord | <fancy plants> I want to integrate Nim into an existing embedded C++ codebase. Can anyone help me reason with the memory model of the ARC gc? I want to use Nim for generating some JSON string, and so far I'm just passing the generated JSON string back to C as a `cstring` using an exported function. However, how is this cstring ref counted, and how do I safely deallocate the string after the C++ side uses the cstring (and likely copies it to another |
18:59:08 | FromDiscord | <fancy plants> Also hi! I am super new to Nim and I love everything about the language so far, and I decided the best way to learn was to dive right in |
19:01:17 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
19:08:46 | FromDiscord | <demotomohiro> I don't think creating cstring increase ref count.↵Easiest way is create a C function that read cstring but doesn't keep pointer to that string after return.↵Then, in Nim code, create a string and passed it to the C function.↵That string will be freed when the C function returned and the program get out the scope that string is defined. |
19:11:30 | * | wallabra quit (Ping timeout: 268 seconds) |
19:12:47 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4eXy |
19:13:10 | FromDiscord | <Elegantbeef> Correct `cstring` is just the same as `myString[0].addr` so it does nothing for the GC |
19:14:04 | FromDiscord | <Elegantbeef> With refc you can do `GcRef`/`GcUnref` but with arc you need to use `ref string` to keep a reference alive, but it doesnt overly work well with C since you need a string implementation that matches that |
19:15:31 | FromDiscord | <fancy plants> @demotomohiro How would I add the ability for the C side to pass parameters to the JSON-string-making function? I'm essentially using Nim as a C JSON library and I can't just generate it purely from the Nim side |
19:16:33 | FromDiscord | <Elegantbeef> Expose the functions in Nim, and make sure any references are `GCRef`'d |
19:17:45 | * | derpydoo joined #nim |
19:18:28 | FromDiscord | <fancy plants> sent a code paste, see https://play.nim-lang.org/#ix=4eXz |
19:19:02 | * | wallabra joined #nim |
19:20:54 | * | phytolizer joined #nim |
19:21:31 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eXA |
19:21:47 | FromDiscord | <Elegantbeef> Whoops that should be `allocatedStrings[cstring(myStr[])] = myStr` |
19:22:23 | FromDiscord | <Elegantbeef> Due to the fact C strings are not pascal strings you need to do something like this to keep the string alive |
19:22:59 | FromDiscord | <Elegantbeef> Cause you cannot pass a pointer to your string to C and have it work with Cstrings, you either need to have a struct that matches the string in C, or do something like this |
19:23:56 | FromDiscord | <Elegantbeef> The Nim type def for a string in arc/orc is https://github.com/nim-lang/Nim/blob/devel/lib/system/strs_v2.nim#L12-L22 |
19:25:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eXB |
19:30:12 | FromDiscord | <fancy plants> Would I not also need to `exportc` the dealloc function? |
19:33:22 | * | phytolizer quit (Quit: Client closed) |
19:33:35 | FromDiscord | <ShalokShalom> In reply to @hector "If it conflicts with": Performance and readability are usually both possible in JS. ↵↵A lot gets optimized by V8 and that is true for all JS code. |
19:36:26 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/4eXI |
19:57:52 | FromDiscord | <haywireSSC> is there a way I can do something similar to making a sequence of concepts? ↵I could change all my code to use oop and inheritance insted of composition, allowing me to make sequences of the type they inheret from |
19:59:22 | FromDiscord | <Elegantbeef> Yes↵(@fancy plants) |
20:00:08 | FromDiscord | <Elegantbeef> No concepts are only compile time interfaces, to use them for dynamic dispatch you need to either manually or with a macro do that↵(@haywireSSC) |
20:00:37 | FromDiscord | <Elegantbeef> https://github.com/yglukhov/iface↵https://github.com/beef331/traitor↵Are some examples of making runtime interfaces |
20:00:56 | FromDiscord | <Elegantbeef> The latter of which is relatively untested and as it says mostly made cause an idea popped in my head |
20:01:09 | FromDiscord | <haywireSSC> thanks |
20:02:03 | FromDiscord | <jmgomez> you can also use inheritance |
20:03:20 | FromDiscord | <haywireSSC> yeah, I said |
20:06:19 | FromDiscord | <jmgomez> oh I missed it. I did use it for something like IRepository[T] that has multiple implementations but I prefer to stick to static dispatch when possible |
20:06:35 | FromDiscord | <jmgomez> does traitor support generics beef? |
20:07:36 | FromDiscord | <Elegantbeef> Dont recall |
20:07:57 | FromDiscord | <Elegantbeef> It needs a rewrite or two 😄 |
20:22:47 | * | wallabra quit (Ping timeout: 246 seconds) |
20:23:07 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4eY5 |
20:24:25 | * | wallabra joined #nim |
20:24:51 | FromDiscord | <Elegantbeef> You dont `GcRef` the string |
20:25:05 | FromDiscord | <Elegantbeef> Also `GcRef` doesnt work on `seq`/`string` with orc/arc |
20:26:46 | FromDiscord | <Elegantbeef> Ah i misread you make an object and a ref for the destructor |
20:33:22 | FromDiscord | <ShalokShalom> Very nice talk↵↵https://youtu.be/HB5TrK7A4pI |
20:33:39 | * | cyraxjoe quit (Quit: I'm out!) |
20:40:05 | FromDiscord | <fancy plants> In reply to @demotomohiro "Another example to export": This is awesome. Again new to Nim, what is the use of creating the `NimString` and `NimStringObj` in the Nim code? |
20:40:37 | FromDiscord | <Elegantbeef> For the destructor since Nim only allows distincts and objects to have destructors |
20:41:23 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eY9 |
20:43:45 | FromDiscord | <demotomohiro> In reply to @fancy plants "This is awesome. Again": ref object is allocated on heap and managed by Nim and object is allocated on stack.↵I defined object type because destructor is defined to object type but cannot be directly defined to ref object type. |
20:56:28 | * | cyraxjoe joined #nim |
20:57:05 | FromDiscord | <fancy plants> sent a code paste, see https://play.nim-lang.org/#ix=4eYe |
20:58:24 | FromDiscord | <fancy plants> Also thank you both for helping me with this! I'm really enjoying programming in Nim |
20:58:45 | FromDiscord | <fancy plants> Now for the harder challenge: convincing my coworkers this would be a good idea |
21:03:26 | FromDiscord | <Elegantbeef> you're getting the type of the dereferenced heap allocated type |
21:03:26 | FromDiscord | <Elegantbeef> It's how you can get the internal type without doing what demo did |
21:03:46 | FromDiscord | <fancy plants> Also, if there's no need to explicitly run anything or print out the destroyed string, do we need the `=destroy` proc implemented at all? |
21:03:47 | FromDiscord | <Elegantbeef> `[]` is how you dereference in Nim, `Type()` is how you construct an object, type of the dereferenced ref object is the heap allocate struct |
21:03:58 | FromDiscord | <fancy plants> Gotcha |
21:04:29 | FromDiscord | <Elegantbeef> You wouldnt need destroy since the memory management will go "Hey this ref has 0 on it's ref count, destroy on sight" |
21:08:59 | FromDiscord | <fancy plants> sent a code paste, see https://play.nim-lang.org/#ix=4eYn |
21:09:09 | FromDiscord | <fancy plants> Oh wait it'd need to be `ref` right cuz heap |
21:09:52 | FromDiscord | <Elegantbeef> Nim's new string isnt just a pointer so yea demo's is basically best you can do |
21:11:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eYo |
21:11:19 | FromDiscord | <Elegantbeef> Feel free to remove the destroy of course |
21:23:07 | FromDiscord | <fancy plants> Fascinating |
21:26:29 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4eYt |
21:26:59 | FromDiscord | <Elegantbeef> orc/arc use a string that stores the length on the stack |
21:27:08 | FromDiscord | <Elegantbeef> you can see this when you do `sizeof(string)` on refc vs. arc |
21:27:47 | * | jmdaemon joined #nim |
21:28:24 | FromDiscord | <jmgomez> ahh didnt know that! Does it applies to seq too? |
21:28:29 | FromDiscord | <Elegantbeef> Yes |
21:29:13 | FromDiscord | <Elegantbeef> In fact string literals in arc/orc are COW |
21:29:20 | FromDiscord | <jmgomez> Im curious about the reason behind it? |
21:29:51 | FromDiscord | <jmgomez> what's COW? |
21:29:59 | FromDiscord | <Elegantbeef> I'd assume it's cause `len` is often wanted and by storing it on the stack component you can speed up operations |
21:29:59 | FromDiscord | <Elegantbeef> Copy on write |
21:30:37 | FromDiscord | <jmgomez> I see, thanks! |
21:31:11 | FromDiscord | <Elegantbeef> I linked to the definition earlier but here it is again https://github.com/nim-lang/Nim/blob/devel/lib/system/strs_v2.nim#L12-L22 |
21:31:51 | FromDiscord | <demotomohiro> Elegantbeef, you don't need to call `GcRef(result)` in `createStrInNim` proc in your code.↵Otherwise, you need to call `deallocNimString` twice to run destructor. |
21:32:22 | FromDiscord | <Elegantbeef> Right returning the type increments the counter |
21:32:44 | FromDiscord | <fancy plants> In reply to @demotomohiro "Another example to export": Another question. Because Nim would be using `arc` gc here, do I not need `NimMain` at the start of my C code? |
21:33:06 | FromDiscord | <Elegantbeef> Arc/Orc do not require `NimMain` but it's still good style to call it incase there is any top level code you rely on |
21:33:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4eYv |
21:34:24 | FromDiscord | <fancy plants> sent a code paste, see https://play.nim-lang.org/#ix=4eYw |
21:34:40 | FromDiscord | <Elegantbeef> It doesnt have any top level code technicall |
21:39:05 | FromDiscord | <fancy plants> Good to know, thx |
22:01:26 | FromDiscord | <luteva> how can i set the id in norm to be a string/varchar and set the value explicitly? i want to use uuid here. |
22:04:18 | * | derpydoo quit (Ping timeout: 255 seconds) |
22:45:50 | * | jjido joined #nim |
23:42:11 | FromDiscord | <sOkam!> How would you get this type of value in nim? 🤔 https://media.discordapp.net/attachments/371759389889003532/1038236750402834473/unknown.png |
23:43:36 | FromDiscord | <Elegantbeef> `float.high` |
23:46:23 | FromDiscord | <Elegantbeef> Actually sorry that's positive infinity |
23:47:37 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/fenv.html#maximumPositiveValue.t%2Ctypedesc%5Bfloat32%5D |
23:53:04 | FromDiscord | <sOkam!> really handy, ty ✍️ |
23:54:08 | FromDiscord | <sOkam!> what's different, in practical use terms, from `bycopy` to `byref`, and what's the default for Nim types? |
23:54:40 | FromDiscord | <sOkam!> seems like c2nim applies it to almost every type, but trying to understand why its doing that |
23:54:41 | FromDiscord | <Elegantbeef> It depends on the type in Nim |
23:54:53 | FromDiscord | <Elegantbeef> The reason it does that is cause C does that |
23:54:59 | FromDiscord | <Elegantbeef> It doesnt want to use optimisations that Nim applies |
23:55:25 | FromDiscord | <Elegantbeef> C passes by copy everywhere, Nim will pass by ref if the type is larger than 24bytes |
23:55:56 | FromDiscord | <Elegantbeef> Cause it's faster |
23:56:18 | FromDiscord | <sOkam!> Could I just remove the bycopy in the types, or will that create issues? |
23:56:21 | FromDiscord | <Elegantbeef> In C passing by reference is an explicit decision of `T` |
23:56:30 | FromDiscord | <Elegantbeef> That will create issues |
23:56:44 | FromDiscord | <Elegantbeef> If you're calling a procedure that expects a copy and you pass a pointer that's a C gen issue |
23:57:21 | FromDiscord | <sOkam!> so i will need to check each procedure one by one to search for possible problems, right? |
23:57:47 | FromDiscord | <Elegantbeef> Just use bycopy and dont worry |
23:58:11 | FromDiscord | <Elegantbeef> By copy is proper in C cause in C you explicitly do byref |
23:58:43 | FromDiscord | <sOkam!> yeah, this file does a lot of explicit ref passing. but i could adapt it, since im trying to convert it to pure nim |
23:59:02 | FromDiscord | <Elegantbeef> Well if you're making it pure nim you dont need to worry about that annotation |
23:59:08 | FromDiscord | <Elegantbeef> You just write Nim |
23:59:27 | FromDiscord | <sOkam!> yeah, but im starting with a c2nim translation as the base |
23:59:57 | FromDiscord | <sOkam!> so trying to convert it to standard nim, and trying to understand how it could be different |