00:03:39 | * | dtomato4 quit (Quit: Ping timeout (120 seconds)) |
00:03:56 | * | dtomato4 joined #nim |
00:57:01 | FromDiscord | <exelotl> I guess it's about preserving the good ergonomics of having 1 string type that everyone agrees on |
00:57:08 | * | neceve joined #nim |
00:58:24 | FromDiscord | <Elegantbeef> Think it was more that "no one needs strutils to be fast" |
00:58:36 | FromDiscord | <Elegantbeef> But i dont know |
01:00:57 | FromDiscord | <Elegantbeef> I dont see how it impedes though↵(@exelotl) |
01:01:04 | FromDiscord | <Elegantbeef> `openarray[char]` accepts `string` |
01:02:44 | FromDiscord | <Elegantbeef> The simple fact is that `openarray[char]` works on `array[char]` `seq[char]` `cstring` and `string` means it's just the best |
01:03:12 | FromDiscord | <Yepoleb> is string something different than just a renamed seq[char] internally? |
01:03:47 | FromDiscord | <Elegantbeef> Yes |
01:03:51 | FromDiscord | <Elegantbeef> It's a null terminated `seq[char]` |
01:24:53 | FromDiscord | <Goat> I completely forgot NimScript was a standalone thing that I could use instead of compiling these very small programs |
01:28:10 | FromDiscord | <Goat> sent a code paste, see https://play.nim-lang.org/#ix=4hVU |
01:34:30 | FromDiscord | <Elegantbeef> The compile times arent much for these small one-offs in my experience |
01:37:47 | FromDiscord | <exelotl> yeah nim is generally preferable to nimscript even for quick and dirty scripts (just as easy to use, and you don't have to worry about nimscript's limitations) |
01:43:02 | FromDiscord | <exelotl> I use nimscript as a task runner for my library, to read user config, set compiler options, and run certain tools pre-and-post build, all in a single invocation of the compiler (well actually I guess there's 2 invocations because `selfExec` works like that...) |
01:43:24 | FromDiscord | <exelotl> but even for this purpose it's kind of annoying because it has no facilities to check when a file was last modified |
01:49:08 | FromDiscord | <Elegantbeef> Maybe one day all the wanted procedures will be properly interoped 😄 |
01:49:37 | FromDiscord | <Elegantbeef> Or we just use libffi |
01:55:19 | FromDiscord | <Yepoleb> is it hard to implement? |
01:59:58 | * | sagax joined #nim |
02:04:04 | FromDiscord | <Girvo> Are there any good references/libraries/implementations for high-perf vectorisation instruction usage in Nim? |
02:08:06 | FromDiscord | <auxym> simd stuff? mratsim is probably the local expert, you can have a look at his libs. also treeform shared this recently, looks like they are using SIMD in the latest pixie version: https://www.youtube.com/watch?v=Did21OYIrGI |
02:08:33 | FromDiscord | <auxym> not aware of good references though, I still have no idea how this black magic works |
02:08:35 | FromDiscord | <Girvo> Yeah 🙂 Though in this case its the weird Tensilica Instruction Extension SIMD instructions, but they're pretty similar |
02:09:23 | FromDiscord | <Girvo> The LX6/LX7 GCC fork doesn't really do auto-vectorisation very well, and the ESP32-S3 has a tonne of useful instructions I want to take advantage of. I'll check out their stuff, cheers! |
02:54:32 | FromDiscord | <Girvo> https://github.com/guzba/nimsimd is what Treeform seems to use in Pixie, interesting |
02:54:57 | FromDiscord | <Girvo> I could add support for the TIE set to it, neat |
03:11:05 | FromDiscord | <Yepoleb> In reply to @Girvo "https://github.com/guzba/nimsimd is what Treeform": Guzba is also a pixie dev |
03:20:41 | * | arkurious quit (Quit: Leaving) |
03:28:58 | FromDiscord | <voidwalker> https://nim-lang.org/docs/asyncdispatch.html#withTimeout%2CFuture%5BT%5D%2Cint |
03:31:58 | FromDiscord | <voidwalker> calling withTimeout will get you a Future[bool] (owned, not sure what that is). How would I get the value of the Future then ? Like this ? https://github.com/waku-org/nwaku/blob/6811af328cfae8b23755faaf3a30dae5df15880e/tests/v1/test_waku_mail.nim#L49 |
03:32:11 | * | ensyde joined #nim |
03:33:14 | FromDiscord | <voidwalker> Wouldn't be nicer if `withTimeout` wrapped the called Future's return value as well ? |
03:45:24 | FromDiscord | <Yepoleb> Just get the value from the future you wrapped |
03:45:55 | FromDiscord | <Yepoleb> At least i assume that's how it's intended to be used |
03:46:45 | FromDiscord | <voidwalker> yeah well I first have to assign it to another variable so that I can later read its value |
04:25:55 | FromDiscord | <Elegantbeef> It's for erroring |
04:36:55 | FromDiscord | <demotomohiro> @Girvo If there are no Nim libraries for simd instructions you want to use, I think you can import intrinsic functions in the same way as C functions if your C compiler provides intrinsic functions for simd. |
04:39:38 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hWs |
04:55:43 | FromDiscord | <Girvo> In reply to @demotomohiro "<@823468778704076810> If there are": Yeah that's basically what I'm digging in to, it seems thats mostly what nimsimd does |
04:57:27 | FromDiscord | <Girvo> Though it seems the PIE instructions don't use intrinsics, more-so just straight assembly instructions! |
05:00:01 | FromDiscord | <Girvo> Whats the easiest way to find what intrinsics exist in a given GCC install? |
05:01:41 | FromDiscord | <Girvo> https://gcc.gnu.org/onlinedocs/gcc/Target-Builtins.html annoyingly the Xtensa stuff dosen't appear to be in here lol |
05:03:34 | FromDiscord | <Girvo> Oooh `-mdensity` will be useful. Unrelated to what I'm searching for, but useful |
05:03:52 | FromDiscord | <Girvo> To adjust my question then: are there any existing resources for handling assembly in Nim I should look at? |
05:48:38 | * | rockcavera quit (Remote host closed the connection) |
05:54:09 | FromDiscord | <Cheeseinator> i just found a really weird bug in nimpretty, every time it saves it doubles every indent, like it goes from 2 spaces to 4 and so on |
05:55:39 | FromDiscord | <ringabout> In reply to @Cheeseinator "i just found a": You mean like https://github.com/nim-lang/Nim/issues/21018 |
05:56:14 | FromDiscord | <Cheeseinator> yeah |
05:57:05 | FromDiscord | <ringabout> You can add you case to the issue, |
05:57:09 | FromDiscord | <ringabout> (edit) "you" => "your" |
06:04:03 | FromDiscord | <Gumbercules> I don't think nimsimd uses the correct calling conventions in certain situations |
06:04:24 | * | ltriant quit (Ping timeout: 264 seconds) |
06:04:34 | FromDiscord | <Gumbercules> This is why I'm rolling my own simd linear algebra libt |
06:04:42 | FromDiscord | <Gumbercules> (edit) "libt" => "lib" |
06:05:28 | FromDiscord | <Gumbercules> Well, that among other reasons |
06:19:08 | FromDiscord | <Gumbercules> I guess `vmath` doesn't use `simd` which is another reason... |
06:42:57 | * | kenran joined #nim |
06:44:35 | * | kenran quit (Remote host closed the connection) |
07:18:09 | FromDiscord | <Gumbercules> seems that we're being increasingly forced into relying on exceptions |
07:18:30 | FromDiscord | <Gumbercules> looking at `std/json` there isn't a `parseJson` proc that doesn't raise.... |
07:20:30 | FromDiscord | <Gumbercules> I guess I have to add another dependency to my project now... |
07:24:21 | FromDiscord | <voidwalker> speaking of exceptions, I haver never used them before. What is a good read about this subject ? I need to handle socket timeout in my code and no idea how to design it |
07:25:51 | FromDiscord | <Gumbercules> I only use exceptions when I am trying to deal with exceptional situations |
07:26:03 | FromDiscord | <Gumbercules> something I can expect to happen in my code that I am in control of - is not exceptional |
07:26:11 | FromDiscord | <voidwalker> I have this code to initialize connection `var (socket, connection_id) = await udpTrackerHello(tracker) ` - returns the connected socket with protocol initalization sent, and the connection_id |
07:26:27 | FromDiscord | <Gumbercules> if I'm dealing with an external service - like making HTTP requests to a server - I can't predict how the server will behave |
07:26:33 | FromDiscord | <Gumbercules> so in these situations exceptions make sense |
07:26:42 | FromDiscord | <Gumbercules> I don't need to use exceptions to handle errors from parsing JSON though.... |
07:27:10 | FromDiscord | <voidwalker> Do I need to add a 3rd var to the tuple to handle the timeout ? Or do I use a magic value ? Or what kind of socket var to message it's not valid, as this is udp, so no .connected ? |
07:27:44 | FromDiscord | <voidwalker> Do I use the Option type (which I also never used) ? Or is there some special mehcanism to send exceptions between procs ? |
07:27:56 | FromDiscord | <Gumbercules> you can re-raise an exception |
07:28:14 | FromDiscord | <Gumbercules> maybe check out the tagged union library |
07:28:19 | FromDiscord | <Gumbercules> I find this a very nice way to deal with errors |
07:28:26 | FromDiscord | <Gumbercules> sorry the anonymous union lib I mean |
07:28:36 | FromDiscord | <Gumbercules> https://github.com/alaviss/union |
07:30:19 | FromDiscord | <voidwalker> but unions are already in nim, no ? |
07:31:44 | FromDiscord | <Gumbercules> tagged / discriminated unions / object variants are, and C-style unions are |
07:32:00 | FromDiscord | <voidwalker> welp, no idea about unions, never touched them |
07:32:24 | FromDiscord | <Gumbercules> anonymous unions are not and they can serve well for acting as an easy way to represent an error or lack of one |
07:33:05 | FromDiscord | <voidwalker> ok, so with exceptions, I have to do try: some code.. if bad condition: raise newException("blah blah"), and then except it ? |
07:33:21 | FromDiscord | <voidwalker> if I don't do except for it, I get a crash, right ? |
07:35:19 | FromDiscord | <Gumbercules> generally you will wrap some code that raises in a `try / except` |
07:35:29 | FromDiscord | <Gumbercules> in the `try` block you invoke whatever code potentially raises |
07:35:41 | FromDiscord | <Gumbercules> in the `except` block you deal with any exceptions which were raised |
07:36:03 | FromDiscord | <Gumbercules> there's an option `finally` block where you can do whatever else you might need to (closing file handles, etc...) |
07:37:49 | FromDiscord | <voidwalker> well the code I have does not raise anything. I use `withTimeout` proc to set a timeout to network event, and I want to "do something" when it times out |
07:38:06 | FromDiscord | <Gumbercules> sure you could raise there |
07:38:39 | FromDiscord | <voidwalker> simplest thing I could do, is just return an empty seq as result. Ideally I'd want the timeout signal to be passed along, for precision's sake, even though atm I have no use for this info |
07:39:08 | FromDiscord | <voidwalker> so I manually raise, and catch my raise.. that's funny |
07:41:02 | FromDiscord | <voidwalker> uhm, so then I do a `try myHelloProc` and `except` , in the proc that calls the timeout-able connection ? |
07:41:27 | FromDiscord | <Gumbercules> have you checked to see if the network call you're making doesn't already raise in the case of a timeout? |
07:41:47 | FromDiscord | <voidwalker> of course I did, sync sockets have built in timeout, async ones don't |
07:42:06 | FromDiscord | <voidwalker> withTimeout merely returns a bool |
07:43:09 | FromDiscord | <voidwalker> ok, let me give it a try and see what happens |
07:43:51 | FromDiscord | <voidwalker> I hope there's maybe a shorter solution with this.. otherwise all of my code will be full of try raise except:/ |
07:45:01 | FromDiscord | <Gumbercules> don't use exceptions 🙂 |
07:45:15 | FromDiscord | <voidwalker> use what then ? |
07:46:06 | FromDiscord | <Gumbercules> I'd have to see some code |
07:46:07 | FromDiscord | <voidwalker> maybe a macro can handle this timeout case in an uniform and shortened manner |
07:46:33 | FromDiscord | <Gumbercules> or at least have a better understanding of what procedures you're invoking and when |
07:46:39 | FromDiscord | <voidwalker> https://github.com/sgmihai/torrentim/blob/main/udp_tracker2.nim#L47 |
07:46:58 | FromDiscord | <voidwalker> this is the state of the code now, no withTimeout, no error handling |
07:48:01 | FromDiscord | <Gumbercules> `withTimeout` says it returns a `Future[bool]` indicating whether it timed out or not |
07:48:03 | FromDiscord | <Gumbercules> isn't that enough? |
07:52:37 | FromDiscord | <voidwalker> well, I need to: 1. stop executing the rest of the proc as it's pointless. 2. return something to the caller proc to let it know we failed, and it should stop executing the rest of the code, and at least return @[] if not the fail itself |
07:53:51 | FromDiscord | <Gumbercules> so use an option type or anonymous union |
07:54:04 | FromDiscord | <Gumbercules> and then have an error enum or something |
07:54:09 | FromDiscord | <voidwalker> what would jesus (Araq) do ? : D |
07:54:22 | FromDiscord | <Gumbercules> Araq would probably use exceptions |
07:54:51 | FromDiscord | <voidwalker> I've no idea about the exception vs union consequences down the road |
07:56:05 | FromDiscord | <Gumbercules> https://flylib.com/books/en/2.254.1/stack_unwinding.html#:~:text=When%20an%20exception%20is%20thrown%20but%20not%20caught,to%20the%20statement%20that%20originally%20invoked%20that%20method. |
07:57:05 | FromDiscord | <Gumbercules> https://mattwarren.org/2016/12/20/Why-Exceptions-should-be-Exceptional/#:~:text=So%20we%20clearly%20see%20there%20is%20an%20extra,stack%2C%20the%20more%20work%20it%20has%20to%20do. |
07:57:13 | FromDiscord | <voidwalker> When an exception is thrown but not caught in a particular scope, the method-call stack is "unwound," and an attempt is made to catch the exception in the next outer try block. This |
07:57:14 | FromDiscord | <voidwalker> Ohhhhh |
07:57:16 | FromDiscord | <Gumbercules> Nim doesn't follow this advice - it uses exceptions everywhere |
07:57:27 | FromDiscord | <voidwalker> So I don't need to catch in the innermost proc.. otherwise it would not go further up |
07:57:30 | FromDiscord | <Gumbercules> well, in the stdlib anyawy |
07:57:34 | FromDiscord | <Gumbercules> (edit) "anyawy" => "anway" |
07:57:38 | FromDiscord | <Gumbercules> (edit) "anway" => "anyway" |
07:57:50 | FromDiscord | <Gumbercules> yeah but I mean - this doesn't always happen |
07:58:43 | FromDiscord | <voidwalker> so I guess a tracker has like a ~10+% chance of timeout or so, considering many torrents have trackers that have died, but their url is kept in the metadata for eternity |
07:58:52 | FromDiscord | <voidwalker> so not very exceptional |
07:59:15 | FromDiscord | <Gumbercules> it's more about the unpredictability of a certain error |
07:59:20 | FromDiscord | <Gumbercules> and how much control you have over what you're calling into |
07:59:28 | FromDiscord | <Gumbercules> timeouts are a good case for exceptions |
07:59:46 | FromDiscord | <Gumbercules> when it comes to something like calling out to a web server that you don't own |
07:59:55 | FromDiscord | <Gumbercules> or making a socket request to a server you don't control |
08:00:11 | FromDiscord | <Gumbercules> you have no idea how that external service is going to behave or what it will do, so the behavior you encounter may indeed be excpetional |
08:00:24 | FromDiscord | <Gumbercules> opening a file on your local filesystem - well you can pretty much guess every single error you might run into here |
08:00:41 | FromDiscord | <Gumbercules> these are not exceptional errors but instead very predictable ones and using exceptions is probably overkill |
08:02:12 | FromDiscord | <Gumbercules> same with parsing JSON which is what I originally made the comment about - I'd much prefer a `parseJson` overload that returns `nil` to being forced into exceptions (even though there are much better ways than to return `nil`) |
08:02:31 | FromDiscord | <voidwalker> timeout for torrent peers and torrent trackers is pretty common. I'd guess that at least 20% |
08:03:26 | FromDiscord | <Gumbercules> if you're already planning on blocking till the request times out or completes, I'd just inspect the returned future and then reuturn a value or an error |
08:03:27 | FromDiscord | <voidwalker> So if that article you linked has good advice, maybe exception is not the best idea |
08:04:05 | FromDiscord | <voidwalker> I wonder why "error" is not a built in return type for any proc |
08:04:38 | FromDiscord | <voidwalker> not sure how other languages do it.. as I don't have experience |
08:04:57 | FromDiscord | <Gumbercules> C lacks exceptions all together |
08:05:29 | FromDiscord | <Gumbercules> languages don't really dictate error handling patterns - they leave it up to the user |
08:05:41 | FromDiscord | <Gumbercules> most languages higher level than C feature exceptions |
08:05:54 | FromDiscord | <Gumbercules> but there's no reason you have to use them - it's not like it's forced on the programmer |
08:06:10 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hX3 |
08:06:17 | FromDiscord | <Gumbercules> `error` is not a built-in return type because not every call will produce an error |
08:06:28 | FromDiscord | <Gumbercules> pure functions cannot produce an error by definition |
08:06:55 | FromDiscord | <Gumbercules> I honestly don't think this is a bad place for exceptions |
08:07:13 | FromDiscord | <Gumbercules> even if the timeouts occur 20% of the time - you're still making a network request to a server you don't own |
08:07:32 | FromDiscord | <Gumbercules> the request might timeout - but you don't know why it timed out or the true reason for the failure, you just know your request timed out |
08:08:54 | FromDiscord | <Gumbercules> you shouldn't even need `withTimeout` |
08:09:05 | FromDiscord | <Gumbercules> according to async socket.sendTo - `If an error occurs an OSError exception will be raised.` |
08:10:23 | FromDiscord | <voidwalker> well, for sendTo udp, it's hard to get an error, maybe an OS error if there is no network at all or something |
08:10:33 | FromDiscord | <voidwalker> maybe fail to resolve |
08:10:54 | FromDiscord | <voidwalker> you get no error just sending data to a dead host |
08:11:25 | FromDiscord | <voidwalker> I think failing to resolve host will block it forever if I don't put timeout |
08:11:58 | FromDiscord | <Gumbercules> yeah - I've never used Nim's socket modules in the stdlib because tmk they're lacking |
08:12:00 | FromDiscord | <albassort> alright im back and asking for some assistance |
08:12:10 | FromDiscord | <albassort> how do i iterate over a carray |
08:12:26 | FromDiscord | <voidwalker> @Gumbercules what socket modules did you use then ? |
08:12:31 | FromDiscord | <albassort> ie a pointer to a single type which is actually an unchecked array of an unknown amount |
08:12:34 | FromDiscord | <Gumbercules> Enet |
08:12:57 | FromDiscord | <voidwalker> https://github.com/fowlmouth/nimrod-enet/ ? |
08:13:10 | FromDiscord | <Gumbercules> I wrapped it myself most likely but yeah |
08:13:26 | FromDiscord | <Gumbercules> I think treeform wrote a reliable upd socket lib but I can't speak to its correctness |
08:13:50 | FromDiscord | <voidwalker> yeah but with this "reliable" over udp, you expect both hots to use it, otherwise it's meaningless |
08:13:59 | FromDiscord | <albassort> because i have a ptr to an array of culong |
08:14:00 | FromDiscord | <Gumbercules> In reply to @albassort "ie a pointer to": cast it to a `ptr UncheckedAray[T]`? |
08:14:02 | FromDiscord | <voidwalker> so good for game server/client, useless otherwise |
08:14:29 | FromDiscord | <albassort> like that? |
08:14:31 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hX4 |
08:15:40 | FromDiscord | <Gumbercules> if it's a C array of unsigned longs then yes |
08:16:10 | FromDiscord | <albassort> alright so how do i convert it to a seq |
08:16:16 | FromDiscord | <albassort> i know the size |
08:16:25 | FromDiscord | <albassort> therapeutically... it is c |
08:16:32 | FromDiscord | <Gumbercules> @voidwalker pretty sure ENet's reliability feature is optional |
08:16:39 | FromDiscord | <albassort> (edit) "therapeutically..." => "theoretically c..." |
08:16:51 | FromDiscord | <albassort> beef said i need to alloc the size of the type |
08:17:03 | FromDiscord | <albassort> unless i misunderstood him |
08:17:06 | FromDiscord | <Gumbercules> `toOpenArray` |
08:17:12 | FromDiscord | <Gumbercules> then `toSeq` |
08:17:28 | FromDiscord | <Gumbercules> unless `toSeq` will accept a `ptr UncheckedArray[T]` but I dobut it |
08:17:33 | FromDiscord | <Gumbercules> (edit) "dobut" => "doubt" |
08:18:05 | FromDiscord | <albassort> ah |
08:18:10 | FromDiscord | <albassort> yep |
08:18:14 | FromDiscord | <albassort> thank you@! |
08:18:16 | FromDiscord | <albassort> (edit) "you@!" => "you!" |
08:18:17 | FromDiscord | <Gumbercules> np |
08:18:23 | FromDiscord | <Gumbercules> @voidwalker asyncnet doesn't work on windows either |
08:18:29 | FromDiscord | <voidwalker> what ? :\ |
08:18:44 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hX5 |
08:19:09 | FromDiscord | <Gumbercules> pretty sure on windows they're blocking |
08:20:41 | FromDiscord | <voidwalker> I understood that on windows you can't work with all the "layers" of the asyncnet lib on windows |
08:20:49 | FromDiscord | <voidwalker> meaning you only get the higher level one ? |
08:20:57 | FromDiscord | <Gumbercules> no |
08:21:05 | FromDiscord | <EchoPouet> In reply to @starch "how do i use": The sunset of Atom is very closed, use VSCode -> https://github.blog/2022-06-08-sunsetting-atom/ |
08:21:12 | FromDiscord | <Gumbercules> Nim has no non-blocking sockets for Windows |
08:21:15 | FromDiscord | <Gumbercules> it's been like this for quite some time |
08:22:00 | FromDiscord | <voidwalker> oh :\ |
08:22:16 | FromDiscord | <voidwalker> That is quite unfortunate... they gonna fix, no ? |
08:22:37 | * | pro joined #nim |
08:22:44 | FromDiscord | <voidwalker> hm actually, I don't believe this |
08:22:47 | FromDiscord | <Gumbercules> I believe you could get away with using - https://nim-lang.org/docs/nativesockets.html |
08:22:49 | FromDiscord | <voidwalker> proof : P |
08:23:02 | FromDiscord | <Gumbercules> but you're not going to be able to use anything in the net / async net packages |
08:23:45 | FromDiscord | <Gumbercules> fine if you don't want to believe me |
08:23:46 | * | pro left #nim (#nim) |
08:23:51 | FromDiscord | <Gumbercules> (edit) |
08:23:56 | FromDiscord | <voidwalker> I am pretty sure I would have read it somewhere by now, it's a pretty big thing |
08:24:11 | FromDiscord | <Gumbercules> well you didn't know about unions so... |
08:24:24 | FromDiscord | <Gumbercules> and you didn't know about stack unwinding and exceptions |
08:24:34 | FromDiscord | <Gumbercules> I've been using Nim since 2015 |
08:24:46 | FromDiscord | <Gumbercules> I might know a thing or two about the stdlib... |
08:24:49 | FromDiscord | <voidwalker> i just googled and there is nothing about this :\ |
08:24:52 | FromDiscord | <Rika> gumberbacca is right |
08:25:08 | FromDiscord | <Rika> at least from my own memory, i believe it is right |
08:25:21 | FromDiscord | <Gumbercules> In reply to @voidwalker "i just googled and": yeah well google doesn't hold all the answers all of the time |
08:25:31 | FromDiscord | <Rika> especially with nim stuff lol |
08:25:43 | FromDiscord | <Rika> most of the stuff is here in this discord server and that doesnt get indexed by google |
08:25:47 | FromDiscord | <voidwalker> I mean, araq uses windows afaik, surely he'd not allow such an important feature to not work on windows |
08:25:52 | FromDiscord | <Rika> and discord search is ass |
08:26:14 | FromDiscord | <Gumbercules> maybe stop comparing him to Jesus and you'll be less surprised when things don't work 🙂 |
08:26:35 | FromDiscord | <Gumbercules> I believe core devs have been fine with - go out and roll your own socket solution / bind to some C lib |
08:26:42 | FromDiscord | <Gumbercules> which is what most folks have done |
08:27:39 | FromDiscord | <Gumbercules> https://gitter.im/nim-lang/Nim?at=5b8e432cf5402f32aad6233e |
08:27:44 | FromDiscord | <Gumbercules> I was able to find an old gitter convo pretty quick |
08:30:55 | FromDiscord | <Elegantbeef> Also araq uses mac |
08:33:03 | FromDiscord | <voidwalker> why didn't anyone help him install linux ? :\ |
08:33:14 | FromDiscord | <Elegantbeef> It's an m1 mac |
08:33:34 | FromDiscord | <voidwalker> asahi linux |
08:35:29 | FromDiscord | <Elegantbeef> Until recently you had 0 gpu acceleration |
08:37:40 | FromDiscord | <Gumbercules> If I remember, fowl wrote some pretty nice macros for working with enet |
08:38:27 | FromDiscord | <Elegantbeef> \I just wish we could get optionals with semantics of exceptions |
08:38:30 | FromDiscord | <Gumbercules> https://github.com/fowlmouth/nimrod-enet/blob/master/pkt_tools.nim |
08:39:28 | FromDiscord | <Gumbercules> gd that repo has a `.babel` file |
08:39:31 | FromDiscord | <Gumbercules> I forgot about that shit.... |
08:39:59 | FromDiscord | <Gumbercules> back when nim was all biblican |
08:40:03 | FromDiscord | <Gumbercules> (edit) "biblican" => "biblical" |
08:40:14 | FromDiscord | <Gumbercules> (edit) "biblical" => "biblican" |
08:40:16 | FromDiscord | <Gumbercules> (edit) "biblican" => "biblical" |
08:40:27 | FromDiscord | <Gumbercules> alright I can't type anymore, type for bed 😄 |
08:40:40 | FromDiscord | <Elegantbeef> type for bed? |
08:40:48 | FromDiscord | <Gumbercules> see??? |
08:40:51 | FromDiscord | <Elegantbeef> What is this a shitty text adventure game |
08:40:53 | FromDiscord | <Gumbercules> ugh |
08:41:06 | FromDiscord | <Gumbercules> pretty much describes my life |
08:41:08 | FromDiscord | <Gumbercules> shitty text adventure game |
08:41:21 | FromDiscord | <Rika> luk 0 |
08:53:29 | FromDiscord | <voidwalker> so what is your opinion Elegantbeef, on handling socket timeouts ? Use exceptions ? |
08:53:58 | FromDiscord | <Elegantbeef> I personally like exceptions but it's likely not the 'correct' way of handling it |
08:54:47 | FromDiscord | <voidwalker> ah wait, status has an articole on it, ima read it first https://status-im.github.io/nim-style-guide/errors.html |
08:56:14 | FromDiscord | <albassort> whats the best way of taking someones code, chopping it up, and putting it in your code |
08:56:17 | FromDiscord | <albassort> on a git level |
08:56:20 | FromDiscord | <albassort> do i fork it? |
08:56:23 | FromDiscord | <albassort> do i just copy it and credit? |
08:56:40 | FromDiscord | <albassort> i usually copy it and credit |
08:57:07 | FromDiscord | <Elegantbeef> I generally say fork |
09:04:27 | FromDiscord | <voidwalker> status seems to like using this lib : https://github.com/arnetheduck/nim-result |
09:04:57 | FromDiscord | <Gumbercules> that's because `arnetheduck` works at status |
09:05:13 | FromDiscord | <Gumbercules> but I mean - it's probably good |
09:05:23 | FromDiscord | <Gumbercules> just have no experience using it |
09:05:25 | FromDiscord | <Elegantbeef> I still dislike results, so invasive |
09:07:43 | FromDiscord | <albassort> actually |
09:07:59 | FromDiscord | <albassort> im just gonna extract the guts and leave |
09:08:09 | FromDiscord | <albassort> HORIZON |
09:08:10 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "back when nim was": Biblical? How so? |
09:08:13 | FromDiscord | <albassort> HOW |
09:08:15 | FromDiscord | <albassort> HEWO |
09:08:23 | FromDiscord | <Gumbercules> the language was named Nimrod |
09:08:23 | FromDiscord | <albassort> they means it was old (?) |
09:08:26 | FromDiscord | <Elegantbeef> The name of the language was named nimrod the packagemanger babel |
09:08:30 | FromDiscord | <Gumbercules> the package manager was named babel |
09:08:41 | FromDiscord | <Elegantbeef> nimrod is the name of the 'first' king in the bible |
09:08:42 | FromDiscord | <albassort> i thought nimrod was a different thing |
09:08:46 | FromDiscord | <Horizon [She/Her]> In reply to @albassort "HEWO": Hi xD |
09:08:50 | FromDiscord | <albassort> HI XD |
09:09:12 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "the language was named": Aah i remember hearing that ages ago, didn't it need to ge tchanged cuz people got angry? |
09:09:19 | FromDiscord | <voidwalker> they should have kept it nimrom.. nim is so hard to search for on youtube |
09:09:21 | FromDiscord | <Horizon [She/Her]> get changed |
09:09:22 | FromDiscord | <Gumbercules> no |
09:09:26 | FromDiscord | <voidwalker> (edit) "nimrom.." => "nimrod.." |
09:09:42 | FromDiscord | <Gumbercules> well maybe - I don't know, if people were offended by the name of a biblical king I think they have bigger issues than the naming of a programming language |
09:10:02 | FromDiscord | <Gumbercules> I believe it was probably the connotation that nimrod means stupid person in the West |
09:10:16 | FromDiscord | <Horizon [She/Her]> Ah |
09:10:37 | FromDiscord | <Gumbercules> not because people were offended about the biblical references |
09:10:41 | FromDiscord | <Elegantbeef> I'm relatively anti-religion, and I just find it inane 😄 |
09:10:45 | FromDiscord | <voidwalker> what's wrong with stupid ? |
09:11:00 | FromDiscord | <Gumbercules> well the old testament predates religion |
09:11:08 | FromDiscord | <Horizon [She/Her]> I don't really follow religion, keep it away from me and y'all are gucci 👍 |
09:11:10 | FromDiscord | <Gumbercules> but it's neither here nor there really |
09:11:21 | * | disso_peach quit (Quit: Leaving) |
09:11:27 | FromDiscord | <Elegantbeef> "predates religion" |
09:11:31 | FromDiscord | <Gumbercules> I mean - it works both ways |
09:11:32 | FromDiscord | <Elegantbeef> Yea we're going to leave that there |
09:11:51 | FromDiscord | <Gumbercules> I mean there were no organized religions when the old testament was authored, there were cults |
09:12:05 | FromDiscord | <Gumbercules> but the concept of religion emerged later |
09:12:18 | FromDiscord | <Gumbercules> or at least organized religions |
09:12:43 | FromDiscord | <Gumbercules> what one thinks of when they think of modern day Christianity / Judaism / Islam etc |
09:13:32 | FromDiscord | <Gumbercules> tower of babel dates back to Mesopotamia |
09:13:46 | FromDiscord | <Horizon [She/Her]> I wonder how hard it'll be to implement a basic python interpreter in Nim ngl |
09:14:12 | FromDiscord | <Horizon [She/Her]> Shouldn't be too hard in theory? (Famous last words) |
09:14:18 | FromDiscord | <Gumbercules> and the Babylonian kings so yeah - very much a different thing |
09:14:59 | FromDiscord | <Gumbercules> probably as hard as it would be in any other language |
09:15:00 | FromDiscord | <Elegantbeef> Sure but i consider many thousands of people believing in a belief system a religious organisation |
09:15:09 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "probably as hard as": True |
09:15:23 | FromDiscord | <Elegantbeef> The old testament was only written in around 1000bce which isnt that far ago |
09:15:23 | FromDiscord | <Gumbercules> well it wasn't really a belief system then |
09:15:46 | FromDiscord | <Gumbercules> at least not according to theologians and historians |
09:16:06 | FromDiscord | <Gumbercules> Christianity had so many sects / cults back then |
09:16:29 | FromDiscord | <Elegantbeef> So many given it didnt even exist yet |
09:16:32 | FromDiscord | <Gumbercules> take the Gnostics for instance which is what I would classify my beliefs as being most closely aligned with |
09:16:48 | FromDiscord | <Gumbercules> well no one was running around calling it Christianity |
09:17:17 | FromDiscord | <Gumbercules> and many of the sects were persecuted by other sects that wanted their dogma to prevail |
09:18:36 | FromDiscord | <Gumbercules> the Gnostics were essentially snuffed out by the Christians who rose to power and founded the church |
09:19:08 | FromDiscord | <Gumbercules> and take the movie The Matrix for instance - it's steeped in Gnosticism but most wouldn't associate Christianity and religion with The Matrix |
09:20:46 | * | ltriant joined #nim |
09:20:50 | FromDiscord | <Elegantbeef> Sure but Ancient Greeks, Egyptians and Hinduism were established before or around the time Hebrews were also writing their book |
09:20:58 | FromDiscord | <Elegantbeef> So there was establish organised religion |
09:21:02 | FromDiscord | <Elegantbeef> But anyway this isnt Nim |
09:21:05 | FromDiscord | <Gumbercules> yeah |
09:21:34 | FromDiscord | <arkanoid> Nim is not religion? Sounds new to me |
09:21:40 | FromDiscord | <Gumbercules> I was a religious studies minor so I enjoy talking about it |
09:22:07 | FromDiscord | <Elegantbeef> It clearly is a religion a bunch of diluted individuals follow it's teachings and use it. |
09:22:22 | FromDiscord | <Gumbercules> when's the next crusade again? |
09:22:35 | FromDiscord | <Elegantbeef> I misplaced my chainmail you go on without me |
09:22:55 | FromDiscord | <Gumbercules> bout to burn some heathens |
09:23:10 | FromDiscord | <Elegantbeef> Nah keep them alive, can turn them into contributors |
09:23:13 | FromDiscord | <arkanoid> Writing AST in the heavens |
09:28:45 | FromDiscord | <Horizon [She/Her]> Used GitHub Actions to compile my Nim code for my website |
09:29:48 | FromDiscord | <Rika> wtf gumberbacca why tf you still awake |
09:29:53 | FromDiscord | <Rika> didnt you say it was type for bed |
09:29:57 | FromDiscord | <Gumbercules> yeah this is a good question |
09:30:02 | FromDiscord | <Gumbercules> it was and then it wasn't 😦 |
09:30:10 | FromDiscord | <Rika> story of everyone's life |
09:30:15 | FromDiscord | <Rika> "im gonna sleep in a bit" |
09:30:19 | FromDiscord | <Rika> "just one more" |
09:30:28 | FromDiscord | <Rika> "itll be quick i promise" |
09:30:37 | FromDiscord | <Rika> and other lies we tell ourselves |
09:30:41 | FromDiscord | <Gumbercules> seriously closing the laptop now though, baby is probably going to wake up any minute and I am woefully unprepared |
09:30:46 | FromDiscord | <Gumbercules> cya all later |
09:30:56 | FromDiscord | <Rika> yes the baby will force you to know when to sleep |
09:31:00 | FromDiscord | <Rika> because otherwise you will never sleep |
09:31:04 | FromDiscord | <voidwalker> eek, added `try: ` block to handle shitty timeouts.. variables declared there are not visible outside the block :\ |
09:31:08 | FromDiscord | <voidwalker> this is going to totally ruin my linecount |
09:31:13 | FromDiscord | <Rika> actually what am i saying you're never gonna sleep even if you wanted to |
09:32:55 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "eek, added `try: `": Can't you just define them before the try block? |
09:33:04 | FromDiscord | <voidwalker> yeah +1 lines of code 😦 |
09:33:15 | FromDiscord | <Horizon [She/Her]> Do they need to be visible outside the block? |
09:33:21 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "yeah +1 lines of": Not that bad |
09:33:31 | * | ltriant quit (Ping timeout: 248 seconds) |
09:33:38 | FromDiscord | <Horizon [She/Her]> Could be worse |
09:33:43 | FromDiscord | <Horizon [She/Her]> ~~Like being JS~~ |
09:33:54 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXm |
09:33:58 | FromDiscord | <voidwalker> yeah but it totally defeats the purpose of using nim : P |
09:34:20 | FromDiscord | <voidwalker> could they not make a try variant that did not create a new scope ? |
09:35:25 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "could they not make": Iirc i think defer did that? But is being removed because of the issues it causes |
09:36:43 | FromDiscord | <voidwalker> ok so I raise the exception in the `updTrackerHello` proce. I thought I did not need to catch it there, so that it gets pushed up the stack to the caller proc |
09:36:57 | FromDiscord | <voidwalker> where I have the try except.. but program just closes with the exception ? |
09:37:16 | FromDiscord | <voidwalker> Do I need to use that pragma for exceptions , raises? |
09:37:16 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4hXn |
09:37:18 | FromDiscord | <Horizon [She/Her]> Looks more readable imo |
09:37:31 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "Do I need to": Nope but it's good for documentation |
09:37:42 | FromDiscord | <voidwalker> then what am I doing wrong ? :\ |
09:37:46 | FromDiscord | <Horizon [She/Her]> I think so, at least (but it isn't needed) |
09:38:02 | FromDiscord | <voidwalker> do I need to catch it in all places so it does not crash the program? |
09:38:05 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "where I have the": Maybe because the connection isn't handled properly? |
09:38:35 | * | anddam quit (Quit: WeeChat 3.7.1) |
09:38:38 | FromDiscord | <Horizon [She/Her]> In reply to @voidwalker "do I need to": Any places it may raise an error probably, but shouldn't be needed if it should be running without issue |
09:38:42 | FromDiscord | <voidwalker> well yeah, that's the whole idea, I am using an unresponsive host to test the timeout case |
09:38:50 | FromDiscord | <Horizon [She/Her]> Ah |
09:39:21 | FromDiscord | <voidwalker> which will happen a lot in a p2p program.. |
09:41:48 | FromDiscord | <voidwalker> well, what do you know.. if I catch inside the inner/called proc, then there is no exception when it returns |
09:42:45 | FromDiscord | <voidwalker> ah nvm, I was writing the code in the wrong proc ;\ |
09:57:19 | FromDiscord | <voidwalker> uhm, it seems that if I do `return` in the except block, the exception is not passed up. without return, it is. But if I don't return, the proc continues executing, encountering a real exception this time. |
09:58:16 | * | GreaseMonkey quit (Remote host closed the connection) |
09:59:54 | * | greaser|q joined #nim |
10:00:21 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix= |
10:04:07 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXu |
10:06:55 | FromDiscord | <voidwalker> I shortened it to this, since I don't really need an except block if I'm only going to raise it again ? |
10:07:02 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXv |
10:07:43 | FromDiscord | <voidwalker> but like this, it doesn't trigger the except in the calling proc. Unless I add a `raise` before return. But I have no except here, what is consuming it ? :\ |
10:23:26 | FromDiscord | <Rika> thats fucked |
10:23:27 | FromDiscord | <Rika> lmao |
10:37:47 | * | disso_peach joined #nim |
10:41:36 | * | ltriant joined #nim |
10:44:04 | NimEventer | New thread by drkameleon: Get time at compile-time, see https://forum.nim-lang.org/t/9698 |
10:47:08 | FromDiscord | <voidwalker> well, code works, I am getting empty result all the way to the top. I certainly do not like the number of lines needed. certainly I am doing something wrong. |
10:53:36 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hXC |
10:56:53 | FromDiscord | <voidwalker> before having to add timeout, I had just `let resp = await socket.recvFrom(UDP_MAX_SIZE)` |
11:04:40 | * | jmdaemon quit (Ping timeout: 256 seconds) |
11:14:31 | * | neceve quit (Ping timeout: 268 seconds) |
12:04:55 | FromDiscord | <ghkdgfs> can you enumerate a openArray without using a for loop? |
12:24:10 | FromDiscord | <planetis> std/enumerate only works in loops |
12:24:37 | FromDiscord | <planetis> write your own, the way sequtils works |
12:49:24 | * | rockcavera joined #nim |
12:51:17 | FromDiscord | <juelix> I currently have an older version of nim installed and would like to install a newer version of nim. Is there any way to remove the old version of nim and install the new version of nim I am using windows 11. |
12:55:51 | FromDiscord | <fbpyr> @juelix\: I like chocolatey for keeping nim up to date on win |
13:01:34 | FromDiscord | <juelix> In reply to @fbpyr "<@996411185933066301>\: I like": I don't understand your reply to ...... Do you mean that chocolatey is a clue to my question? Or is it just a bunch of bot nonsense? |
13:09:37 | FromDiscord | <Rika> chocolatey is a package manager for windows |
13:09:59 | FromDiscord | <Rika> how did you first install nim |
13:12:21 | FromDiscord | <locria> Is there a `echo` that puts space in between? |
13:13:27 | FromDiscord | <juelix> In reply to @Rika "how did you first": Not an exact recollection, but maybe I installed from choosnim. |
13:14:17 | FromDiscord | <locria> In reply to @ghkdgfs "can you enumerate a": zero_functional |
13:16:03 | FromDiscord | <fbpyr> sorry, I should have typed the whole url\: https://chocolatey.org↵@Rika thx for hinting↵(@juelix) |
13:18:55 | FromDiscord | <fbpyr> @juelix\: so with that package manager one can install nim via powershell\:↵`choco install nim`↵listed here\: https://community.chocolatey.org/packages?q=nim↵to update all choco installed packages\: `choco upgrade all` - quite convenient. 😌 |
13:19:49 | FromDiscord | <fbpyr> but I guess the official answer is `choosenim`↵(which funnily enough is also available via choco 😉 ) |
13:21:20 | FromDiscord | <fbpyr> on a win-machine,↵● where I always want the latest I go choco -\> nim↵● if I want to be able to switch nim versions I woulg use choco -\> choosenim -\> nim |
13:21:49 | FromDiscord | <pmunch> If you first installed from choosenim then you simply run \`choosenim update stable\` |
13:28:59 | FromDiscord | <Require Support> for threading: is it still fine to use `spawn` or is there a newer/better way of doing things? |
13:30:24 | * | pro joined #nim |
13:33:06 | * | pro left #nim (#nim) |
13:45:14 | NimEventer | New question by Andrea T.: Nim/Nimble: How to enable --threads:on only for files using it?, see https://stackoverflow.com/questions/74717623/nim-nimble-how-to-enable-threadson-only-for-files-using-it |
14:09:40 | * | anddam joined #nim |
14:11:55 | FromDiscord | <jtv> @locria I would assume the print macro from https://github.com/Yardanico/nimpylib would add in the space. Would be easy to do if not |
14:17:28 | * | derpydoo joined #nim |
14:25:13 | FromDiscord | <juelix> In reply to @fbpyr "sorry, I should have": Thanks to you and Rika for your kind and prompt replies! I was able to fix that problem! |
14:25:29 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hYt |
14:25:43 | FromDiscord | <Gumbercules> Not sure why you have it wrapped in one to begin with.... |
14:26:35 | FromDiscord | <Gumbercules> In reply to @NimEventer "New question by Andrea": That's not how it works... |
14:30:28 | FromDiscord | <Gumbercules> The question should have been how do I build multiple binaries using nimble and only have one utilize threading. |
14:31:53 | FromDiscord | <Gumbercules> And the answer is - you probably can't unless your source resides in different directories. This is a nimble issue though.... |
14:40:48 | FromDiscord | <Zoom> How can you overload `system.echo`? If I use `a: varargs[untyped]` for the args the overload is unused. |
14:46:46 | FromDiscord | <jtv> Per the docs, its signature is `proc echo(x: varargs[typed, `$`]) ` |
14:48:58 | FromDiscord | <Zoom> Yeah, but if I use it somehow styledWrite writes an arg seq out |
14:52:10 | FromDiscord | <starch> In reply to @auxym "`subprocess.run("yourNimExec.exe")`": my nim is a nim file |
14:52:13 | FromDiscord | <Rika> i dont understand your question |
15:01:08 | FromDiscord | <auxym> (if it's a nim source file, you have to compile it before running it) |
15:01:09 | FromDiscord | <auxym> sent a code paste, see https://paste.rs/dbH |
15:05:12 | FromDiscord | <juelix> What are some examples of programs that would benefit greatly from using nim over other languages (e.g. DB related, web app creation, etc...)? What are some examples? |
15:07:02 | FromDiscord | <juelix> I can't imagine what I could make from them, even looking at nim's tutorials. |
15:09:51 | FromDiscord | <Gumbercules> I mean, you can ask that question about any language I guess |
15:10:00 | FromDiscord | <Gumbercules> it's kind of an odd one.... |
15:10:07 | FromDiscord | <jtv> Yeah, Nim's documentation could be more inspiring, but it's got most of the flexibility of a Python, while being about as fast as C. So most things would benefit greatly. If you value readability in particular, then unless you are okay with Python, you're going to be hard pressed to find better options |
15:11:05 | * | kenran joined #nim |
15:11:43 | FromDiscord | <juelix> In reply to @Gumbercules "I mean, you can": I definitely continue to think so when I see tutorials in any language. |
15:12:37 | FromDiscord | <Gumbercules> A better question is what are Nim's strengths / weaknesses and how does it compare to a language you're familiar with the features and semantics of |
15:12:49 | FromDiscord | <Gumbercules> or how does Nim compare to language X |
15:12:58 | * | kenran quit (Remote host closed the connection) |
15:13:07 | FromDiscord | <Gumbercules> programs don't benefit greatly from using one language or another generally |
15:13:09 | FromDiscord | <Gumbercules> languages are designed to fit well into certain problem domains |
15:13:59 | FromDiscord | <Gumbercules> Nim is pretty flexible - while it is intended to be a systems programming language many people perform application and web development using it |
15:14:26 | FromDiscord | <Gumbercules> it can compile to C/C++, Objective-C and JavaScript |
15:14:46 | FromDiscord | <auxym> In reply to @jtv "Yeah, Nim's documentation could": Other advantage compared to python: compiles compiles to a single, standalone executable file. So when distributing a nim program, you don't depend on the user having a complicated environment setup (python version, tons of 3rd party libs with different versions, etc). Python distribution is a real pain. |
15:16:47 | FromDiscord | <jmgomez> In reply to @juelix "What are some examples": FullStack apps or Games too |
15:16:56 | FromDiscord | <jtv> IDK, I have long found that language choice can make a huge difference. Otherwise, there wouldn't be so much diversity in languages. For instance, Python is often very, very fast for getting something working, but tough for real production code due to how few errors get identified statically, and the fact that it is super slow |
15:17:52 | FromDiscord | <jtv> Whereas C not only has security issues, but the ecosystem sucks, people often rewrite a lot of their basic tools from the ground up every time. |
15:18:03 | FromDiscord | <jtv> 🤷 |
15:25:02 | FromDiscord | <Rika> In reply to @jtv "Whereas C not only": :kannakms: |
15:27:56 | FromDiscord | <jtv> It's funny, despite always knowing all that, they've been my two goto languages for more than 25 years, even though I tried to like Go. I wish I hadn't just last month found out about Nim :/ |
15:32:08 | FromDiscord | <juelix> Due to my lack of knowledge and imagination, I can basically only use libraries and such to create something, but if libraries and Websites with information are not as plentiful as nim currently is, how do you create something?(Please forgive my rudeness to the developers and others involved.) |
15:33:22 | FromDiscord | <juelix> In reply to @jtv "It's funny, despite always": I am amazed and respectful that you have been able to continue for 25 years! |
15:33:38 | FromDiscord | <jtv> Well, the standard library documentation is okay, and it's easy to find packages available through the nimble package manager, and you can search the package directory here: https://nimble.directory/ |
15:33:49 | FromDiscord | <jtv> Yes, I am old. |
15:34:10 | FromDiscord | <jtv> 🧓 |
15:35:11 | FromDiscord | <juelix> In reply to @jtv "Well, the standard library": I've never heard of this search feature before! I appreciate it very much! |
15:54:35 | FromDiscord | <exelotl> I've only just recently been getting into Python. The dynamic typing sucks but the ecosystem (flask, sqlalchemy, jinja, sphinx, pygments, pelican, etc.) is just fantastic |
15:55:20 | FromDiscord | <jtv> Yup, it's got such a big community, there's a lot to be said for it. |
15:58:10 | FromDiscord | <exelotl> it's basically become my fallback for when I can't find something that suits my needs in Nim (where rolling my own would be too much work). I've ended up using it for documentation, slideshows, static sites, and hosting a forum |
16:00:45 | FromDiscord | <jtv> I've long used it as a calculator, essentially. I could almost live with it as my login shell 🙂 |
16:01:27 | FromDiscord | <Rika> fish shell has `math` command lol |
16:01:41 | FromDiscord | <Rika> In reply to @jtv "I've long used it": there is actually a shell with that ideology |
16:01:53 | FromDiscord | <leetnewb> xonsh? |
16:01:56 | FromDiscord | <Rika> yes |
16:03:05 | FromDiscord | <leetnewb> I usually install fish and forget it's there. |
16:35:57 | FromDiscord | <rakgew> yep xonsh is pretty cool.↵my `.xonshrc` reads much nicer than my `.bashrc` |
16:40:05 | FromDiscord | <rakgew> for nim docs, is there a way to not only show the local offline html documentation from `nim_install_dir/doc/html` , but to access docs from packages installed with nimble? |
16:43:01 | FromDiscord | <Phil> In reply to @juelix "Due to my lack": Boy do I got a package idea for your |
16:45:40 | FromDiscord | <Phil> sent a long message, see http://ix.io/4hZC |
16:45:57 | FromDiscord | <Phil> (edit) "http://ix.io/4hZC" => "http://ix.io/4hZD" |
16:49:00 | FromDiscord | <Phil> The currently best approach I've seen is basically compiling the project as part of the test, running the binary, waiting until the server itself reacts to anything and the using httpclient to try out all sorts of different scenarios |
16:49:17 | FromDiscord | <Phil> (edit) "the" => "then" |
16:50:43 | FromDiscord | <Phil> Which is fine, just annoying to code yourself when e.g. the entire compile thing, running and waiting for a response could be in a package, as well as maybe some utilitie templates for asserting contents or other properties of the response |
16:53:55 | FromDiscord | <Phil> Nimja could actually also use some tooling for testing |
16:54:48 | FromDiscord | <Phil> Something that simplifies the entire process of "given this template and this input data, it should render this html" |
16:55:31 | FromDiscord | <jtv> Phil, why haven't you done it yet then? 🙂 |
16:56:28 | FromDiscord | <Phil> Because I'm working on an admin area package for prologue called snorlogue that basically replicates the admin area from Django without the authentication |
16:56:55 | FromDiscord | <Phil> Those ideas are basically on my "do next" list when I get to it |
16:57:06 | FromDiscord | <Phil> Days just don't have enough hours! |
16:57:36 | FromDiscord | <jtv> Sounds cool, tho I am not even a little bit a UI person |
16:57:57 | FromDiscord | <Phil> I mostly responded because op sounded like he couldn't think of a package that could be useful |
16:58:20 | FromDiscord | <Phil> And those two ideas for example would have a fair bit of practical benefits |
16:58:37 | FromDiscord | <Phil> Since e.g. nimja is used a fair bit |
17:00:10 | FromDiscord | <jtv> Oh, I took it more to mean they only build programs that are typing together pretty mature components |
17:02:56 | FromDiscord | <Phil> Not too unlikely I read it wrong, I'm on the go and on the phone and I read terribly on this thing since the environment demand some attention at least |
17:37:01 | FromDiscord | <guttural666> does Nim do stack unwinding with try and except? |
17:39:15 | FromDiscord | <jtv> Do you mean, does it deal with proper clean-up? Yes. |
17:41:05 | FromDiscord | <guttural666> yeah, something like c++ does, like deleting the constructed objects, the manual says nothing about it |
17:41:08 | FromDiscord | <ShalokShalom> In reply to @exelotl "I've only just recently": It's gradually typed and you can actually infer types |
17:41:25 | FromDiscord | <ShalokShalom> https://github.com/google/pytype |
17:43:12 | FromDiscord | <exelotl> yeah that's good until you find yourself in a situation where the tools can't infer the types anymore |
17:44:27 | FromDiscord | <guttural666> because my result here still seems to retain previously entered correct entries, e.g. with an input of 0, pls in answer, I still get a returned value of @[0] https://media.discordapp.net/attachments/371759389889003532/1050105521757233322/image.png |
17:46:24 | FromDiscord | <guttural666> maybe because the result is not constructed in the try block? anyway, just gonna delete the entries myself 😛 |
17:52:32 | FromDiscord | <guttural666> how can I enforce i to be a Natural in this loop so the compiler does not complain (seq.del(i) expects a Natural) https://media.discordapp.net/attachments/371759389889003532/1050107552945414244/image.png |
17:55:28 | FromDiscord | <Michal Maršálek> When did `[]` on Tables using a nonexistant key changed to throwing an error? And why? |
17:57:55 | * | Phytolizer joined #nim |
17:58:15 | Phytolizer | anyone know of a tool/macro i can use to trace all function calls with their arg values and return values in nim? |
18:03:21 | FromDiscord | <guttural666> tough questions all around an no good samaritan to answer them |
18:04:00 | FromDiscord | <exelotl> In reply to @guttural666 "how can I enforce": you are looping over an array which contains 1 element, the slice "0 .. result.len-1" |
18:04:55 | FromDiscord | <exelotl> if you get rid of the [] it should loop over the slice instead, which looks like what you want? |
18:05:21 | Phytolizer | @michal, probably because `[]=` will construct the value if it doesn't exist, so `[]` could be promoted to an error. i'm assuming that before it would construct the element? |
18:06:06 | FromDiscord | <guttural666> In reply to @exelotl "you are looping over": i'm actually constructing an array here, am I n ot? |
18:06:37 | Phytolizer | it's an array of 1 element, the slice |
18:06:59 | Phytolizer | e.g. `[1..2]` is `[1 .. 2]: array[0..0, HSlice[system.int, system.int]]` |
18:07:51 | FromDiscord | <guttural666> have to read up on slices |
18:08:07 | FromDiscord | <guttural666> it did compile, so mille grazie |
18:08:13 | FromDiscord | <jtv> Guttural, the result variable doesn't get cleaned up, its in scope for the whole function |
18:08:29 | FromDiscord | <jtv> So if stuff gets added to it before your exception gets thrown, it will be there |
18:09:04 | FromDiscord | <scruz> In reply to @guttural666 "have to read up": Are you looking for `range()` |
18:09:13 | FromDiscord | <jtv> Even in C++ it would do that; exceptions only clean up things going out of scope |
18:09:52 | FromDiscord | <guttural666> In reply to @jtv "Even in C++ it": yeah, I'm not the biggest expert in exceptions in c++ as well, never used them really, just trying to piece this together |
18:10:24 | FromDiscord | <scruz> In reply to @scruz "Are you looking for": https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Ranges |
18:11:38 | FromDiscord | <guttural666> In reply to @scruz "https://github.com/nim-lang/Nim/wiki/Nim-for-Python": I've written 3 functions in Python in my life haha |
18:11:52 | FromDiscord | <Michal Maršálek> In reply to @Phytolizer "@michal, probably because `[]=`": I like the change but at the same time, I'd like to see another type that would be the variation of Python's defaultdict (maybe making the default value static? `DefaultTable[K, V; Default: static V]`) |
18:12:20 | FromDiscord | <Gumbercules> In reply to @guttural666 "yeah, I'm not the": stack unwinding only happens if you allow the exception to bubble up |
18:12:45 | FromDiscord | <guttural666> In reply to @Gumbercules "stack unwinding only happens": yeah, and I think that seems to be similar to c++ then? if I read up on that correctly |
18:12:54 | Phytolizer | michal, you mean like getOrDefault? https://nim-lang.org/docs/tables.html#getOrDefault%2CTable%5BA%2CB%5D%2CA%2CB |
18:12:55 | FromDiscord | <Gumbercules> pretty much in any language that features exceptions |
18:12:58 | FromDiscord | <guttural666> if I handle shit locally, it doesn't unwind |
18:13:03 | FromDiscord | <Gumbercules> right |
18:13:11 | FromDiscord | <guttural666> In reply to @Gumbercules "pretty much in any": thanks for the insight |
18:13:16 | * | Phytolizer quit (Remote host closed the connection) |
18:13:37 | * | Phytolizer joined #nim |
18:13:48 | FromDiscord | <guttural666> how good / bad are exceptions in Nim? people get butthurt over c++'s regularly |
18:14:03 | FromDiscord | <guttural666> they are interoperable to them I learned |
18:14:20 | FromDiscord | <Gumbercules> I think the problem with exceptions is they're easily abused and misused |
18:14:36 | FromDiscord | <Gumbercules> exceptions should be reserved for exceptional scenarios - situations in your code where you cannot predict the outcome |
18:14:37 | Phytolizer | this isn't quite defaultdict because you can't provide what the default should be except at each call, (you can omit it but it'll just be "zeroed"), but it's close |
18:14:47 | FromDiscord | <guttural666> expesive to trigger as well I would assume |
18:15:18 | FromDiscord | <Gumbercules> so like - making a request to an external web service - good idea to wrap that in an `try/except` block and have your http client raise if it fails to make the request successfuly |
18:15:38 | FromDiscord | <guttural666> would there be a better way to handle this, if the user inputs bs in my case? i can't really tell https://media.discordapp.net/attachments/371759389889003532/1050113371460083782/image.png |
18:15:40 | FromDiscord | <Gumbercules> opening a file on a local filesystem - you can easily predict what might go wrong here and it's not going to be an exceptional scenario ever |
18:15:46 | FromDiscord | <guttural666> answer is readLine(stind) |
18:16:03 | FromDiscord | <Michal Maršálek> In reply to @Phytolizer "michal, you mean like": No, I mean like Python's defaultdict, where you don't need to specify the default each time. |
18:16:09 | FromDiscord | <guttural666> I want a list of ints |
18:16:18 | FromDiscord | <Gumbercules> if any of that code potentially raises - it's a good idea to wrap it in a try/catch like you are doing |
18:16:32 | Phytolizer | michal, yes i hear you. read my previous message, it's close but not exactly the same |
18:16:32 | FromDiscord | <Gumbercules> if it doesn't raise, there's no need |
18:17:03 | FromDiscord | <Gumbercules> I wish Nim treated errors as values and allowed users alternatives to stdlib procs that raise but this isn't the case |
18:17:06 | Phytolizer | if you say `someTable.getOrDefault("some key")`, you'll get a default constructed value if none exists in the map |
18:17:06 | FromDiscord | <Gumbercules> at least not everywhere |
18:17:06 | FromDiscord | <guttural666> In reply to @Gumbercules "if it doesn't raise,": I mistype, so I guess it's valid here haha 🙂 thanks for the guidance |
18:17:28 | FromDiscord | <Gumbercules> status.im has a pretty decent write up on exceptions that someone shared yesterday, let me find it |
18:17:38 | FromDiscord | <Gumbercules> https://status-im.github.io/nim-style-guide/errors.html |
18:17:45 | FromDiscord | <Michal Maršálek> In reply to @Phytolizer "if you say `someTable.getOrDefault("some": yes, but you cannot configure the value |
18:17:48 | FromDiscord | <guttural666> In reply to @Gumbercules "status.im has a pretty": always eager to learn, thanks! |
18:18:00 | FromDiscord | <Gumbercules> anytime! |
18:18:45 | Phytolizer | michal, right, but by that logic the old `[]` behavior couldn't have been configured either, no? |
18:18:59 | FromDiscord | <Gumbercules> you can actually |
18:19:04 | FromDiscord | <IsaacPaul> Imo, If it's not every frame it's exceptional. |
18:19:09 | FromDiscord | <Gumbercules> `table.getOrDefault(table, key, defaultVal) |
18:19:14 | FromDiscord | <Gumbercules> (edit) "defaultVal)" => "defaultVal)`" |
18:19:16 | Phytolizer | yes, we are discussing that function |
18:19:36 | FromDiscord | <Gumbercules> yeah I'm saying you can provide a default there |
18:19:52 | FromDiscord | <Michal Maršálek> In reply to @Gumbercules "yeah I'm saying you": I must be really bad at expresing myself 😄 |
18:19:55 | Phytolizer | as did i, but michal is asking about a type where you need not provide a default more than once |
18:19:55 | FromDiscord | <Gumbercules> maybe I'm misunderstanding the convo, if I am I apologize |
18:20:02 | FromDiscord | <Gumbercules> no it's probably just me |
18:20:05 | FromDiscord | <Gumbercules> ah I see |
18:20:16 | FromDiscord | <Michal Maršálek> I'm writing an impl of what I mean |
18:20:18 | FromDiscord | <Michal Maršálek> rn |
18:20:20 | FromDiscord | <Michal Maršálek> thold on |
18:20:57 | Phytolizer | it is probably not *too* difficult to handroll a default dict around a Table |
18:21:15 | FromDiscord | <Gumbercules> In reply to @IsaacPaul "Imo, If it's not": I don't get this - it has less to do with how often an error occurs an more about your ability to predict it |
18:21:25 | FromDiscord | <guttural666> In reply to @Gumbercules "https://status-im.github.io/nim-style-guide/errors.": it's crazy how something so seemingly trivial can result in decades long discussions |
18:21:32 | FromDiscord | <Gumbercules> I don't control an external service and I can't realistically predict what it might do |
18:21:51 | FromDiscord | <Gumbercules> if I open a file - nothing there that could happen is really exceptional |
18:22:06 | FromDiscord | <IsaacPaul> In reply to @Gumbercules "I don't control an": I can't realistically predict what my code will do on another machine. |
18:22:31 | FromDiscord | <IsaacPaul> > if I open a file↵Permission error for example |
18:22:38 | FromDiscord | <Gumbercules> that's predictable |
18:23:16 | FromDiscord | <Gumbercules> as opposed to - this person could return some crazy status code I've never heard of, break all sorts of common convention and do something really strange with their handling of this web request |
18:23:30 | FromDiscord | <IsaacPaul> That's also predictable |
18:23:32 | FromDiscord | <Gumbercules> they might not even serve the request |
18:23:33 | FromDiscord | <Gumbercules> not really |
18:23:42 | FromDiscord | <Gumbercules> not if the person is inventing things on the other end |
18:23:55 | FromDiscord | <Gumbercules> you know what potential errors might arise from a syscall |
18:23:57 | FromDiscord | <IsaacPaul> You can't parse or understand the request. That can be predicted. |
18:24:18 | FromDiscord | <IsaacPaul> Some guy breaks the server by mistyping 404. You can still handle it |
18:24:20 | FromDiscord | <Gumbercules> I'd still be able to parse a response with a bad HTTP code - what that bad HTTP status code indicates though and what I'm supposed to do about it.... |
18:24:32 | Phytolizer | gumbercules, that is like saying the user typing 35 control characters at the prompt is unpredictable. of course it is predictable |
18:24:45 | Phytolizer | the question is, do you want to be that careful |
18:26:21 | FromDiscord | <Gumbercules> the difference is you control the syscall to open the file |
18:26:31 | FromDiscord | <Gumbercules> you don't control what happens to the web request once it leaves your client and another server handles it |
18:26:40 | FromDiscord | <Gumbercules> you know exactly what errors the syscall might raise |
18:26:40 | Phytolizer | you do control how you handle the response, though |
18:26:43 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=4i00 |
18:27:11 | FromDiscord | <Gumbercules> right - but you cannot reasonably predict all of the outcomes from a web request and what they might mean |
18:27:18 | FromDiscord | <Gumbercules> or infer |
18:27:30 | FromDiscord | <Gumbercules> just like you can't do this with a database call |
18:27:45 | FromDiscord | <Gumbercules> which is why in these contexts exceptions make sense - because the other end of the call is unpredictable |
18:28:15 | FromDiscord | <Gumbercules> it's very different from invoking a function where it's specifically and explicitly going to potentially result in this set of errors |
18:28:51 | FromDiscord | <Gumbercules> and errors should be values anyway |
18:28:55 | Phytolizer | the only difference is between that of a parse error and a kernel error code. |
18:29:14 | FromDiscord | <jtv> Generally I'd parse and deal with the error on the parsing seprately from the dict insertion / removal. Much more obvious code, and then doesn't need an exception |
18:29:24 | Phytolizer | you could use that as justification for a JSON parser throwing an exception on invalid input, but should you? |
18:29:44 | FromDiscord | <Gumbercules> no because that's easily predictable |
18:29:49 | FromDiscord | <guttural666> https://media.discordapp.net/attachments/371759389889003532/1050116939449634836/boromir_software_error_handling.jpg |
18:30:01 | FromDiscord | <Gumbercules> you're writing a JSON parser you should assume your parser is going to encounter bad input |
18:30:11 | Phytolizer | in the same was as a server sending back gibberish is predictable |
18:30:15 | Phytolizer | why trust a server so much? |
18:30:40 | Phytolizer | what if the connection encounters a hiccup? should your program crash? |
18:30:42 | FromDiscord | <IsaacPaul> In reply to @IsaacPaul "Imo, If it's not": My point is you don't know what issues your users experience if you simply ignore errors and pretend as if everything is fine.↵↵So either use exceptions or a result type. A malformed http request can fit into either of those. But imo exceptions or result accomplish the same function. Communicating failure. |
18:31:08 | FromDiscord | <Gumbercules> In reply to @Phytolizer "what if the connection": well this is why you'd leverage exceptions in that scenario, because it's an exceptional outcome |
18:31:29 | FromDiscord | <Gumbercules> so no your program shouldn't crash |
18:31:38 | Phytolizer | and the user unplugging their hard drive resulting in a bunch of file open errors isn't? |
18:31:44 | FromDiscord | <Gumbercules> you'd have a tough time fitting all of the various errors that COULD occur into a result type for a web request |
18:31:56 | FromDiscord | <IsaacPaul> Most things that don't follow the 'happy path' really couldn't care less about how heavy an exception is. |
18:32:28 | FromDiscord | <Gumbercules> In reply to @Phytolizer "and the user unplugging": no because file open operations can only result in a small set of predictable errors |
18:32:38 | FromDiscord | <Gumbercules> file doesn't exist |
18:32:40 | FromDiscord | <Gumbercules> permissions are bad |
18:32:58 | Phytolizer | ok and an HTTP response only has a few errors: read failure, invalid response, a few others im sure |
18:33:04 | FromDiscord | <Gumbercules> no.... |
18:33:27 | FromDiscord | <Gumbercules> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes |
18:33:41 | FromDiscord | <IsaacPaul> Http has a load of stuff. For example the ssl could fail somewhere in the socket connection depending on the implementation |
18:34:07 | FromDiscord | <IsaacPaul> (edit) "in" => "above" |
18:34:11 | Phytolizer | sure but there are a few generic categories that all errors fall into. a valid-but-error status code is different from an invalid status code |
18:34:24 | Phytolizer | but an ssl error and a connection drop are in a similar category |
18:34:38 | FromDiscord | <Gumbercules> but should probably be handled differently |
18:34:45 | FromDiscord | <Gumbercules> if you can't open a file - you can't open a file |
18:35:10 | FromDiscord | <Gumbercules> if the request fails (not due to SSL issues) you might want to retry it |
18:35:23 | Phytolizer | but i thought that was exceptional according to your rules |
18:35:24 | FromDiscord | <Gumbercules> if it's an SSL error you might just give up |
18:36:19 | FromDiscord | <Gumbercules> what the external service might do is unpredictable and therefore could cause an exceptional error in your program yes |
18:36:38 | FromDiscord | <Gumbercules> I never said that every error was unpredictable |
18:36:52 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4i03 |
18:37:11 | FromDiscord | <voidwalker> (edit) "https://play.nim-lang.org/#ix=4i03" => "https://play.nim-lang.org/#ix=4i04" |
18:37:45 | FromDiscord | <Gumbercules> https://medium.com/continuousdelivery/exceptional-exceptions-5110671b3028 |
18:38:02 | FromDiscord | <Gumbercules> this has been written to death about - if I was the only person advocating this stance I might feel like continuing the debate |
18:38:27 | FromDiscord | <voidwalker> oh yeah, I wanted to ask. now I get a stack trace every time there's an exception. Does that happen on --release compile as well ? |
18:38:31 | FromDiscord | <Gumbercules> https://www.gingerbill.org/article/2018/09/05/exceptions-and-why-odin-will-never-have-them/ |
18:39:10 | FromDiscord | <voidwalker> I read there is some compute overhead in generating the stack trace, that's why I ask |
18:39:10 | FromDiscord | <Gumbercules> https://medium.com/geekculture/effective-java-use-exceptions-for-only-exceptional-circumstances-6e4762b5ebc2#:~:text=All%20this%20being%20the%20case%2C%20exceptions%20should%20be,to%20determine%20if%20it%E2%80%99s%20in%20that%20correct%20state. |
18:39:17 | Phytolizer | i don't like exceptions. but there is what seems to be an arbitrary line in the sand drawn of what can and can't be handled. please stop linking articles |
18:39:31 | FromDiscord | <Gumbercules> please stop telling me what to do 🙂 |
18:39:49 | FromDiscord | <voidwalker> please be nice to each other. articles are good, we are noobs : P |
18:40:11 | Phytolizer | 1 was enough |
18:40:20 | FromDiscord | <Gumbercules> I was making a point |
18:40:30 | FromDiscord | <Yardanico> In reply to @voidwalker "oh yeah, I wanted": -d:release disables stack traces by default, yes |
18:40:39 | FromDiscord | <Yardanico> you can still enable them if you want |
18:40:43 | FromDiscord | <Yardanico> `--stackTrace:on --lineTrace:on` |
18:40:57 | Phytolizer | i agree with those articles. but many things can be handled and treated as non-exceptional. it is completely a judgment call |
18:41:07 | FromDiscord | <voidwalker> Oh I see, interesting. So there is no significant compute overhead to handling many exceptions at runtime |
18:41:33 | FromDiscord | <IsaacPaul> In nim I would probably use a result type of exceptions since you aren't forced to handle it or ignore it |
18:41:39 | FromDiscord | <IsaacPaul> (edit) "In nim I would probably use a result type ... of" added "instead" |
18:42:02 | FromDiscord | <IsaacPaul> Right? its been a while lol |
18:42:04 | FromDiscord | <Gumbercules> In reply to @Phytolizer "i agree with those": well you are forced if you don't want to allow it to go uncaught |
18:42:06 | Phytolizer | yes, the default behavior of exceptions being to propagate is the main problem i have :P |
18:42:11 | FromDiscord | <Gumbercules> sorry wrong comment to reply to |
18:42:38 | FromDiscord | <Gumbercules> if you don't `try/except` an exception in Nim it will bubble up and you will experience stack unwinding eventually |
18:42:51 | FromDiscord | <Gumbercules> procedures aren't required to be documented with `raises: []` |
18:42:59 | Phytolizer | yes, that is the problem. you have to be very cautious when exceptions are possible |
18:43:16 | FromDiscord | <Gumbercules> a big issue is one can't even really tell when they are possible |
18:43:27 | FromDiscord | <Gumbercules> and if one wants to avoid them entirely they can't use the stdlib |
18:44:29 | FromDiscord | <guttural666> can I somehow manually throw this bad boy? https://media.discordapp.net/attachments/371759389889003532/1050120630428774470/image.png |
18:44:29 | FromDiscord | <IsaacPaul> Thats my biggest problem with nim tbh |
18:44:48 | FromDiscord | <Yardanico> In reply to @guttural666 "can I somehow manually": you just `raise` a new value error |
18:45:03 | Phytolizer | `raise newException(ValueError, "message")` is the syntax i think |
18:45:08 | FromDiscord | <guttural666> In reply to @Yardanico "you just `raise` a": perfect! works and thank you |
18:45:14 | FromDiscord | <Yardanico> also what's this https://media.discordapp.net/attachments/371759389889003532/1050120821798088826/image.png |
18:45:23 | FromDiscord | <Yardanico> if you want to clean a seq just do `result.setLen(0)` |
18:45:25 | FromDiscord | <Yardanico> or a string |
18:45:50 | FromDiscord | <guttural666> In reply to @Yardanico "if you want to": that's also what I was searching for, something like .clear() or something |
18:45:56 | FromDiscord | <guttural666> so thanks again! haha |
18:47:28 | FromDiscord | <Gumbercules> In reply to @IsaacPaul "Thats my biggest problem": is this being addressed in 2.0? I haven't been in the loop for quite some time. Pulled a stint with Odin but it's no panacea there either.... |
18:48:22 | FromDiscord | <.tochka> does {.global.} works in template for making single static? |
18:49:16 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4i07 |
18:49:30 | FromDiscord | <Horizon [She/Her]> https://github.com/Mythical-Forest-Collective/Code-Bricks/blob/master/bricky.nim#L84-L90 is one relevant part |
18:49:52 | FromDiscord | <Horizon [She/Her]> And then here: https://github.com/Mythical-Forest-Collective/Code-Bricks/blob/master/bricky.nim#L57-L72 |
18:50:03 | FromDiscord | <Horizon [She/Her]> I don't get why I get this error at all... |
18:50:11 | FromDiscord | <Yardanico> is that specific to Nim though? I feel like it's some JS-related DOM error |
18:50:15 | FromDiscord | <Yardanico> https://stackoverflow.com/questions/56906853/failed-to-execute-appendchild-on-node-the-new-child-element-contains-the-pa e.g. this |
18:51:03 | FromDiscord | <Horizon [She/Her]> Hm i'll check |
18:52:51 | FromDiscord | <Horizon [She/Her]> I don't think that's relevant? I don't see where I'm appending the wall (or brick) to itself at all |
18:53:17 | FromDiscord | <sOkam!> Are cpp vectors `seq` and maps `Table` in nim? 🤔 |
18:53:26 | FromDiscord | <Gumbercules> sounds like `brick` has a reference to `wall` |
18:53:40 | FromDiscord | <Gumbercules> the error says `The new child element contains the parent.` |
18:53:43 | FromDiscord | <Michal Maršálek> playground is down? 😦 |
18:53:54 | FromDiscord | <Gumbercules> not the child has a reference to itself |
18:54:38 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "sounds like `brick` has": It shouldn't have a direct reference, I'm using the `TrackingId` to track the walls and bricks... Maybe changing it to a ref object will fix it? |
18:54:58 | FromDiscord | <Gumbercules> let me look at the code and see if I can find out what's wrong |
18:55:39 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4i08 |
18:55:42 | FromDiscord | <Horizon [She/Her]> L64 and L65 |
18:56:07 | Phytolizer | sOkam!, generally yes, Table is like c++ unordered_map |
18:56:36 | FromDiscord | <sOkam!> ah map is ordered? i didn't know |
18:56:41 | Phytolizer | OrderedTable is like map |
18:56:46 | Phytolizer | yeah it's silly |
18:57:04 | FromDiscord | <sOkam!> kk, tysm |
18:57:26 | FromDiscord | <Gumbercules> In reply to @Event Horizon "It may be these": yeah that's what's causing it but the question is why does the brick node have the wall node added as a child |
18:58:35 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "yeah that's what's causing": As a child? I'm keeping the reference to the parent so when the user drags a brick, I can see where it is position-wise in the parent, and then snap off bricks below it to be dragged along |
18:58:53 | FromDiscord | <Gumbercules> I'm talking about the dom |
18:58:55 | FromDiscord | <Gumbercules> not about the Nim code |
18:59:10 | FromDiscord | <Horizon [She/Her]> Wait it has the wall node as a child? Where? |
18:59:33 | FromDiscord | <Gumbercules> well that's what the error says |
18:59:45 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix= |
18:59:54 | FromDiscord | <Gumbercules> meaning `brick` contains `wall` |
18:59:57 | FromDiscord | <Horizon [She/Her]> Yeah, I don't get how that's happening at all 😓 |
19:00:05 | FromDiscord | <Gumbercules> I think the problem might be you using `children` in your JS objects |
19:00:17 | FromDiscord | <guttural666> In reply to @Phytolizer "`raise newException(ValueError, "message")` is": I can add my custom message to that, that's cool |
19:00:21 | FromDiscord | <Gumbercules> HTML dom nodes already have a member named `children` |
19:00:55 | FromDiscord | <Horizon [She/Her]> Ah |
19:01:48 | FromDiscord | <Horizon [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4i0c |
19:01:58 | FromDiscord | <Horizon [She/Her]> Plus, i'd think it'd be unrelated considering they're different objects |
19:02:39 | FromDiscord | <Gumbercules> hmm |
19:02:50 | FromDiscord | <Gumbercules> this is a runtime error right? not a compile time error? |
19:02:59 | FromDiscord | <Horizon [She/Her]> Yup, runtime |
19:03:20 | FromDiscord | <Gumbercules> I'd just open up the dev console and put a breakpoint at ` wallElem.appendChild(brick.elem)` |
19:03:38 | FromDiscord | <Gumbercules> and then inspect `brick` to see if it has a reference to `wall` |
19:04:43 | FromDiscord | <Horizon [She/Her]> I set the breakpoint and ran the function, breakpoint stopped the execution, how would I see the contents? |
19:04:44 | FromDiscord | <Yardanico> yeah, there's `--sourceMap:on` but idk how well it works on latest nim |
19:04:53 | FromDiscord | <Yardanico> In reply to @Event Horizon "I set the breakpoint": the browser debugger will show you |
19:04:57 | FromDiscord | <Yardanico> all variables that are in the context |
19:05:04 | FromDiscord | <Horizon [She/Her]> Oh sourcemaps are probably useful, how do i use those? 😅 |
19:13:29 | FromDiscord | <Gumbercules> assuming they get generated in the correct place, I believe the browser should detect them and use them as long as feature is enabled |
19:13:37 | FromDiscord | <Gumbercules> it's been a while since I've done any FE web dev |
19:13:44 | FromDiscord | <Gumbercules> thankfully |
19:13:54 | FromDiscord | <Horizon [She/Her]> In reply to @Gumbercules "assuming they get generated": Hm nope, sourcemaps aren't showing up |
19:14:00 | FromDiscord | <Horizon [She/Her]> Still digging through the generated JS code |
19:16:35 | FromDiscord | <Horizon [She/Her]> Also, it's probably worth noting that the first time i run the method, it runs with no errors |
19:16:42 | FromDiscord | <Horizon [She/Her]> It's the second time that causes issues |
19:16:46 | FromDiscord | <Horizon [She/Her]> And any other tries |
19:18:31 | FromDiscord | <Horizon [She/Her]> I just managed to run it 3 times, without any issues...? |
19:18:43 | FromDiscord | <Horizon [She/Her]> And the 4th time it started spitting errors |
19:18:49 | FromDiscord | <Horizon [She/Her]> What the hell is this... |
19:19:25 | FromDiscord | <Horizon [She/Her]> Okay this is weirder than i thought |
19:19:39 | FromDiscord | <Horizon [She/Her]> Sometimes i can run it, a lot of the time it throws that same error as before |
19:20:11 | FromDiscord | <Horizon [She/Her]> Though only when the breakpoint is there?? |
19:24:20 | FromDiscord | <Horizon [She/Her]> I genuinely hate JS |
19:31:52 | FromDiscord | <Phil> All I want from a language |
19:32:07 | FromDiscord | <Gumbercules> is love? |
19:32:31 | FromDiscord | <Phil> Is static typing, enforcing optionals over null, first class functions/procs and default immutability |
19:32:48 | FromDiscord | <Phil> Also love but that takes a second step behind default immutability |
19:33:53 | FromDiscord | <Gumbercules> Odin may have those things |
19:33:57 | FromDiscord | <Phil> Given that js only delivers on one of those, I can only agree with the sentiment (directed at horizon) |
19:34:32 | FromDiscord | <Phil> (edit) "(directed" => "(this message is directed" | "horizon)" => "horizon stating they hate js)" |
19:34:44 | FromDiscord | <Gumbercules> static typing - check, enforcing optionals over null I'm not 100% on, first class functions - check, default immutability - check |
19:35:05 | FromDiscord | <Gumbercules> Odin doesn't have exceptions so... |
19:35:16 | FromDiscord | <Phil> Works for me, result types then? |
19:38:11 | FromDiscord | <Gumbercules> yeah essentially - https://www.gingerbill.org/article/2018/09/05/exceptions-and-why-odin-will-never-have-them/ |
19:39:14 | FromDiscord | <Gumbercules> this was written by the author of Odin - just FYI I don't program in Odin anymore, I ported a large portion of my engine to it and then threw my hands up for a couple of reasons, mostly because I felt like I was losing out on something by abandoning my efforts in Nim, but also because Odin lacks any sort of metaprogramming and also because of the dependency on LLVM |
19:40:11 | * | dnh joined #nim |
19:41:37 | FromDiscord | <Phil> I support the reasoning |
19:41:48 | FromDiscord | <Phil> If there is one thing I find to be true everywhere always |
19:41:57 | FromDiscord | <Phil> It's that explicit is better than implicit |
19:42:14 | FromDiscord | <Phil> It's why imo result types are always superior |
19:44:09 | * | dtomato4 quit (Quit: The Lounge - https://thelounge.chat) |
19:44:43 | FromDiscord | <Phil> Write code expressing your exact intent rather then code that happens to do what you want.↵Don't have things in your code you just "have to know".↵Nim provides something for that in the form of the raises pragma... But that becomes a massive pain when your libraries aren't using it |
19:45:34 | FromDiscord | <Phil> Because how can you know what exceptions your libraries might throw unless you read through the entire code which is insane workloads |
20:01:51 | FromDiscord | <Require Support> for threading: is it still fine to use spawn or is there a newer/better way of doing things? |
20:02:21 | * | derpydoo quit (Remote host closed the connection) |
20:03:25 | FromDiscord | <Gumbercules> In reply to @Isofruit "Because how can you": appears there's an ongoing RFC about this - https://github.com/nim-lang/RFCs/issues/493#issuecomment-1321540909 |
20:04:48 | FromDiscord | <Gumbercules> https://sr.ht/~duangle/scopes/ is another interesting language |
20:04:53 | FromDiscord | <Gumbercules> I played with it several years ago but haven't been back since |
20:09:18 | * | jmdaemon joined #nim |
20:12:20 | FromDiscord | <IsaacPaul> In reply to @Require Support "for threading: is it": https://github.com/mratsim/weave seems pretty neat |
20:13:28 | NimEventer | New thread by prestosilver: Making a upside-down card game: Flipcards, see https://forum.nim-lang.org/t/9700 |
20:17:38 | FromDiscord | <ieltan> Interesting↵https://www.hpcwire.com/2022/12/05/new-c-sender-library-enables-portable-asynchrony/ |
20:26:32 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
20:27:06 | * | kenran joined #nim |
20:31:25 | * | derpydoo joined #nim |
20:40:11 | * | kenran quit (Remote host closed the connection) |
20:44:47 | * | arkurious joined #nim |
21:18:04 | FromDiscord | <Horizon [She/Her]> Question: How are you supposed to construct an AST tree? Like, representing it internally? |
21:18:15 | FromDiscord | <Horizon [She/Her]> I already have the necessary types to hold the data |
21:18:34 | FromDiscord | <Horizon [She/Her]> I just don't know what the best way to organise tokens into a tree |
21:18:59 | * | andrewrk joined #nim |
21:19:37 | andrewrk | what is nim's strategy for building from source? do you use a previous build of nim? |
21:20:06 | andrewrk | oops I should have checked the README more carefully before asking |
21:20:27 | FromDiscord | <Horizon [She/Her]> There's csources haha |
21:20:37 | FromDiscord | <amadan> In reply to @Event Horizon "Question: How are you": Variant objects would work. This is a good example of how `NimNode` for macros is represented https://nim-lang.org/docs/macros.html#the-ast-in-nim |
21:24:25 | * | dtomato4 joined #nim |
21:25:02 | FromDiscord | <bren> sent a code paste, see https://play.nim-lang.org/#ix=4i0L |
21:32:52 | FromDiscord | <QuiteQuietQ> sent a code paste, see https://play.nim-lang.org/#ix=4i0R |
21:36:12 | FromDiscord | <amadan> sent a code paste, see https://play.nim-lang.org/#ix=4i0T |
21:37:08 | FromDiscord | <amadan> Without the ref the size of the object would be infinite |
21:39:43 | FromDiscord | <QuiteQuietQ> yep, I am getting illegal recursion in the type and the `ref` is clear to me now |
21:39:55 | FromDiscord | <QuiteQuietQ> i think it should throw some compilation error then |
21:41:24 | * | greaser|q quit (Changing host) |
21:41:24 | * | greaser|q joined #nim |
21:41:28 | * | greaser|q is now known as GreaseMonkey |
21:41:47 | FromDiscord | <planetis> Pretty sure this had an error message. |
21:42:14 | FromDiscord | <planetis> Does it still crash the complier if you remove the generics? |
21:42:22 | FromDiscord | <Gumbercules> does the compiler even crash? |
21:42:23 | FromDiscord | <amadan> Has error message when you remove the generic |
21:42:31 | FromDiscord | <Gumbercules> mine produces an exe |
21:42:39 | FromDiscord | <amadan> Get exit code 139 which is SIGSEV iirc |
21:42:46 | FromDiscord | <Gumbercules> mmm |
21:43:03 | FromDiscord | <amadan> (edit) "SIGSEV" => "SIGSEGV" |
21:43:31 | * | andrewrk left #nim (Leaving) |
21:44:35 | * | ltriant quit (Ping timeout: 264 seconds) |
21:46:07 | FromDiscord | <amadan> Hits call depth limit when debugging with compiler↵Guess it should error instead of expanding if it's seen `T` before↵Think I might be able to fix |
21:54:50 | NimEventer | New post on r/nim by Connect-Ad3976: Ideas for begginer projects, see https://reddit.com/r/nim/comments/zff7s0/ideas_for_begginer_projects/ |
21:57:26 | * | Guest35 joined #nim |
21:57:37 | * | Guest35 quit (Client Quit) |
22:07:18 | * | pbottle joined #nim |
22:12:56 | * | ltriant joined #nim |
22:17:57 | * | Guest63 joined #nim |
22:22:36 | * | Guest63 quit (Quit: Client closed) |
22:22:43 | FromDiscord | <Andreas> In reply to @IsaacPaul "https://github.com/mratsim/weave seems pretty neat": maybe a little bit off-topic here, but this https://katalog.ub.uni-freiburg.de/opac/RDSIndex/Search?lookfor=kid%3A1800973624 came along today.. so yes, weave is neat stuff.. |
22:33:50 | * | Phytolizer quit (Remote host closed the connection) |
22:40:07 | pbottle | I think I know the answer to this but I want to make sure: if I'm calling 6 a C function that isn't CPU bound but takes a long time to execute, async/await won't help me reduce the total run time of the program and I need to use Weave or a threadpool |
22:42:32 | FromDiscord | <amadan> In reply to @amadan "Hits call depth limit": nvm, bung seems to already be working on a fix that is less hacky than my approach |
22:45:43 | arkanoid | I've developed the very same number crunching algorithm (random-walk based) both in recursive and iterative mode. They return the very same result, but the different approaches open for some different optimization techniques. Which of the two would you choose as a target for further optimization? |
22:51:09 | FromDiscord | <Yepoleb> pbottle: async only helps when the main blocking prodecure is io bound and is written to support the async runner, that's currently only the case for network stuff afaik. For everything else you need a thread based executor. |
23:12:50 | * | jmdaemon joined #nim |
23:21:26 | pbottle | Thank you |
23:23:10 | NimEventer | New thread by guzba: Type aliases not quite working like I expected. Ideas for alternative approach?, see https://forum.nim-lang.org/t/9701 |