00:04:09 | * | mwbrown quit (Quit: Exiting) |
00:14:41 | * | PMunch quit (Quit: leaving) |
00:25:30 | FromGitter | <imdaveho> hi everyone, new here, quick question on the terminal lib in the std lib, is it cross platform? as it will "just work" regardless of *nix, windows, osx? |
00:26:15 | FromGitter | <imdaveho> or will I have to import posix / winlean as well? I guess it depends on the use case, but if I just consider the terminal lib only... |
00:27:19 | FromGitter | <rayman22201> terminal is cross platform, but it imports posix / winlean internally |
00:28:16 | FromGitter | <imdaveho> got it, ty! |
00:28:46 | FromGitter | <rayman22201> but the compiled code will only end up with what you need for what ever platform you are on. Nim does a good job of stripping unused code. |
00:29:05 | FromGitter | <imdaveho> I guess the outputted C would also contain the check but when it compiles, it'll clean up? |
00:29:52 | FromGitter | <rayman22201> I actually think the outputted C will only have the final code. The tree shaking happens before it gets to C I believe. |
00:30:17 | FromGitter | <imdaveho> or does the outputted C depend on the platform its on? eg. if I compile on windows, i'll need to name the result as `output_win.c` and `output_nix.c` |
00:30:27 | FromGitter | <imdaveho> hmm seems like you confirmed it |
00:30:34 | FromGitter | <imdaveho> that's fine :) |
00:31:07 | FromGitter | <rayman22201> Well, no compiler can make a binary work on multiple platforms at once lol |
00:31:56 | FromGitter | <imdaveho> srry I mean "build" on windows |
00:32:21 | FromGitter | <imdaveho> but I get what you're saying |
00:32:36 | FromGitter | <rayman22201> π |
00:43:41 | FromDiscord | <exelotl> Finally working on the details for my very efficient but also friendly 2D game engine |
00:45:40 | * | wildlander joined #nim |
00:46:29 | FromDiscord | <exelotl> I want to make something where entities are objects which can contain components to define their behaviour, |
00:46:34 | FromDiscord | <exelotl> but the calls to comp.update() and comp.draw() should be inserted at compile time so you never need to loop over a component list |
00:46:49 | FromGitter | <rayman22201> cool |
00:48:31 | FromGitter | <rayman22201> Another neat ECS thing to try would be to have templates / macros that convert array of structs into structs of arrays. Jonathan Blow does it in one of his Jai demos. It's super cool |
00:49:36 | krux02 | @rayman22201: it might turn out to be useful. But maybe it won't be that useful. |
00:50:50 | krux02 | it is a neat idea. but I believe more in a more flexible entity component model |
00:51:22 | FromGitter | <rayman22201> maybe. It's a neat trick either way. I don't code games so idk lol |
00:52:04 | FromGitter | <rayman22201> Also, It seems like a very fun / doable project with Nim Macros. |
00:52:13 | FromDiscord | <exelotl> Oh that does sound neat, but probably not something I'll try because I don't like structs of arrays that much, I'm far too attached to the idea of an entity being a single self contained object |
00:53:02 | FromGitter | <rayman22201> Well, that is the cool macro trick. You write the macro so that it "looks" like you are dealing with a self contained entity, but then it gets rewritten into an array access. |
00:53:11 | * | krux02_ joined #nim |
00:53:12 | * | krux02 quit (Read error: Connection reset by peer) |
00:53:28 | FromDiscord | <exelotl> Wizardry |
00:53:55 | FromGitter | <rayman22201> Macros are magic lol |
00:55:24 | FromGitter | <rayman22201> Jonathan Blow had to write a whole language to do that trick, we can probably do it with a few clever Nim macros :-P |
00:56:20 | FromDiscord | <exelotl> I am so glad I finally picked up this language tbh xD. It's really quite something |
00:56:44 | FromGitter | <rayman22201> me too :-) |
00:58:07 | FromDiscord | <exelotl> I dabbled in Go a bit before this but quickly ran into brick walls. The process of binding C libraries is horrifying |
00:59:22 | FromGitter | <rayman22201> I ran the Go meetup group in my city for a hot minute.... Used it extensively at a job I had at the time. It was cool at first but I quickly outgrew it. |
01:06:07 | * | smt joined #nim |
01:06:28 | * | smt quit (Remote host closed the connection) |
01:06:36 | FromGitter | <Varriount> What is the process of binding Go to C? |
01:09:29 | FromGitter | <rayman22201> https://golang.org/cmd/cgo/ |
01:10:59 | FromGitter | <rayman22201> It's a lot more limited than Nim's C FFI |
01:17:41 | FromGitter | <Varriount> Well, that document is confusing |
01:17:48 | * | benji__ is now known as benjikun |
01:18:22 | FromGitter | <Varriount> Mostly because what Go calls a pointer is different from what C calls a pointer. |
01:18:29 | FromGitter | <rayman22201> welcome to Golang. Everything is "simple" yet somehow very confusing :-P |
01:20:28 | FromDiscord | <awr> i wish nim had a "recur" keyword |
01:20:37 | FromDiscord | <awr> something that could act as an alias to the current function |
01:21:59 | FromGitter | <rayman22201> why not just the name of the function? |
01:23:31 | FromDiscord | <awr> well for one you can't do recursion in anonymous procs without higher order magic |
01:24:05 | FromDiscord | <awr> and secondly (to me anyway) it would be a useful bit of syntactic sugar |
01:25:10 | * | stefanos82 quit (Quit: Quitting for now...) |
01:27:01 | * | brainproxy quit (Quit: WeeChat 2.2) |
01:27:27 | FromGitter | <rayman22201> hrmmm....thinking about this. a macro maybe... to the Nim playground |
01:30:04 | * | Shivelight joined #nim |
01:31:27 | * | krux02_ quit (Remote host closed the connection) |
01:32:13 | * | krux02 joined #nim |
02:03:19 | skrylar | time to be awake now |
02:18:03 | * | cspar joined #nim |
02:32:31 | * | erratic joined #nim |
03:01:44 | * | krux02 quit (Quit: Leaving) |
03:10:32 | * | xylef joined #nim |
03:18:55 | * | mwbrown joined #nim |
03:30:39 | * | xylef quit (Ping timeout: 260 seconds) |
03:37:48 | FromGitter | <Quelklef> Fuzzy idea: |
03:38:12 | FromGitter | <Quelklef> Attributes that may be patched onto typed outside of their definitions and used in another context |
03:38:16 | FromGitter | <Quelklef> For instance: |
03:39:23 | FromGitter | <Quelklef> ```# a.nim β type Person = object β name: string``` [https://gitter.im/nim-lang/Nim?at=5b52aaeb32fa1b740857652e] |
03:39:29 | * | Shivelight quit (Quit: Connection closed for inactivity) |
03:40:19 | FromGitter | <Quelklef> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b52ab2326bfd636be3b3895] |
03:41:06 | FromGitter | <Quelklef> This can currently be emulated with `.attr` and `.attr=` procs, but I wonder if doing so is abuse |
03:41:17 | FromGitter | <Quelklef> 1) .attr and .attr= procs as well as a table |
03:41:38 | FromGitter | <barcharcraz> @PMunch I'm still around. I'm Demos on IRC and matrix |
03:42:43 | FromGitter | <barcharcraz> hm I think you only need .attr and attr (you can use a gensym to store the value I think) |
03:43:17 | FromGitter | <Quelklef> Come again? |
03:43:33 | FromGitter | <barcharcraz> wait actually never mind. |
03:43:49 | FromGitter | <barcharcraz> another issue with using the table is you are gunna have to actually free memory at some point |
03:44:10 | FromGitter | <Quelklef> Ah yeah it's not gonna track refs |
03:44:11 | FromGitter | <Quelklef> Hmmmm |
03:44:11 | FromGitter | <barcharcraz> I'd say add a little table to the end of each Person struct for this |
03:44:27 | FromGitter | <barcharcraz> have like {.attrs.} type Person = ...... |
03:44:30 | FromGitter | <Quelklef> pollutes the type definition though |
03:44:32 | FromGitter | <barcharcraz> and attrs can add the table |
03:44:34 | FromGitter | <Quelklef> Perhaps |
03:44:38 | FromGitter | <Quelklef> Ooh, I kind of like that |
03:44:49 | FromGitter | <Quelklef> Much better on memory anyway |
03:44:56 | FromGitter | <barcharcraz> I totally forget the rules around pragma type macros, but something like that |
03:45:02 | FromGitter | <Quelklef> Although, I think for my specific use, there's not going to be any memory freeing anyway |
03:45:07 | FromGitter | <Quelklef> it'd look like |
03:45:15 | FromGitter | <Quelklef> `type Person = object {.attrs.} \n rest` |
03:45:15 | FromGitter | <barcharcraz> That's what apply said :D |
03:45:18 | FromGitter | <barcharcraz> *apple |
03:45:23 | FromGitter | <Quelklef> eh? |
03:45:29 | FromGitter | <Quelklef> Oh |
03:45:36 | FromGitter | <barcharcraz> (chrome bug where it just never frees any memory on OSX because of a but in launchd) |
03:45:41 | FromGitter | <Quelklef> Lol, well I won't be *leaking* memory, just being irrespondible with it |
03:45:58 | FromGitter | <barcharcraz> the best kind of memory |
03:46:20 | FromGitter | <Quelklef> as long as i never push this code, nobody has to know |
03:46:33 | FromGitter | <barcharcraz> -_- |
03:46:41 | FromGitter | <Quelklef> β |
03:46:50 | Demos[m] | it was a smile |
03:46:55 | Demos[m] | `-_-` |
03:47:53 | FromGitter | <Quelklef> oh |
03:48:14 | Demos[m] | yeah I'm in like 11 chat clients at once over here, sorry |
03:48:35 | Demos[m] | the matrix <-> irc <-> gitter pipeline has some leaks |
04:15:16 | * | leorize quit (Ping timeout: 256 seconds) |
04:23:50 | * | Shivelight joined #nim |
04:26:24 | * | dddddd quit (Remote host closed the connection) |
05:00:14 | * | cspar_ joined #nim |
05:03:09 | * | cspar quit (Ping timeout: 268 seconds) |
05:17:25 | Araq | awr: I like the idea |
05:19:25 | * | miran joined #nim |
05:23:42 | FromGitter | <Quelklef> awr? |
05:26:57 | * | nsf joined #nim |
05:52:54 | * | skrylar quit (Remote host closed the connection) |
06:06:25 | * | xylef joined #nim |
06:13:50 | FromGitter | <Varriount> @Quelklef ``` β <awr> i wish nim had a "recur" keyword β <awr> something that could act as an alias to the current function β β `````` [https://gitter.im/nim-lang/Nim?at=5b52cf1eb2411177a25f956b] |
06:33:05 | * | miran quit (Ping timeout: 248 seconds) |
06:35:41 | FromGitter | <Quelklef> Ah, didn't see that |
06:35:49 | FromGitter | <Quelklef> but I second, third, and fourth that idea |
06:36:12 | FromGitter | <Quelklef> and fifth and sixth as well |
06:39:29 | * | Shivelight quit (Quit: Connection closed for inactivity) |
06:48:44 | * | Vladar joined #nim |
06:50:57 | FromGitter | <rayman22201> https://gist.github.com/rayman22201/0675507877c0edd11c32fbcfa1e65482 |
06:51:00 | FromGitter | <rayman22201> here you go |
06:53:06 | FromGitter | <Quelklef> beautiful |
06:53:09 | FromGitter | <Quelklef> but needs a pragma |
06:53:22 | FromGitter | <Varriount> Does it work with anonymous procedures though? |
06:53:33 | FromGitter | <Quelklef> What're the chances we get global macros? |
06:53:45 | FromGitter | <rayman22201> @Varriount |
06:53:47 | FromGitter | <Varriount> @Quelklef what would a "global macro" be? |
06:54:01 | FromGitter | <Quelklef> A macro which is applied to the entire AST of a module its imported into |
06:54:24 | FromGitter | <Varriount> Isn't that called a compiler plugin? |
06:54:44 | FromGitter | <Quelklef> Sure, but you can't import those, can you? |
06:54:51 | FromGitter | <Quelklef> i.e. they're not a "part of the language" |
06:55:08 | FromGitter | <rayman22201> @Varriount It works on anonymous procs. see second example at bottom of the gist |
06:55:38 | * | amosbird quit (Ping timeout: 256 seconds) |
06:56:01 | * | amosbird joined #nim |
06:56:56 | FromGitter | <rayman22201> @Araq has a vague plan for making Nim super modular for v2, which would let you install compiler plugins in a way kind of like that. |
06:57:05 | FromGitter | <rayman22201> it's a long way off though I imagine |
06:57:15 | FromGitter | <Quelklef> Sounds fancy |
06:57:33 | FromGitter | <Quelklef> This'd be cool "for now", though |
06:57:41 | FromGitter | <Quelklef> I can definitely see why it may be rejected |
06:57:55 | FromGitter | <Quelklef> but I personally would really like it |
06:58:14 | FromGitter | <rayman22201> why are pragmas an issue? |
06:58:28 | * | amosbird quit (Max SendQ exceeded) |
06:58:31 | FromGitter | <Quelklef> They're not 'really' an issue |
06:58:33 | FromGitter | <Quelklef> I just really like them |
06:58:34 | FromGitter | <Quelklef> because |
06:58:53 | FromGitter | <Quelklef> for instance your `{.recursive.}` pragma says: "hey, I'm using feature X, so look out for it!" |
06:58:56 | * | amosbird joined #nim |
06:59:16 | FromGitter | <Quelklef> Which seems ugly to me; pragmas should say: "hey, something's special about this node, look out for it!" |
06:59:29 | FromGitter | <Quelklef> kind of a weird way of putting it |
06:59:34 | FromGitter | <Quelklef> An alternative way of putting it: |
06:59:38 | FromGitter | <rayman22201> Yeah. I like pragrmas. I think they are fine, and provide good docs like you say. |
06:59:49 | FromGitter | <Quelklef> Ugh no |
06:59:56 | FromGitter | <Quelklef> Yeah it provides documentation but |
07:00:17 | FromGitter | <Quelklef> It's just ugly IMO to have to annotate every time you want to use a feature |
07:00:29 | FromGitter | <Quelklef> and sometimes you don't, right |
07:00:37 | FromGitter | <Quelklef> if it so happens to fit with the system |
07:01:03 | FromGitter | <rayman22201> side note: the macro works pretty well as a first pass but It could be made smarter. right now it just wraps the function in a wrapper function, but it could detect if it is a named function and replace "recur" automagically with the function name, otherwise do what it does now for lambdas / anon procs. |
07:01:05 | FromGitter | <Quelklef> `sugar` macros don't need explicit annotation because it's enough to just make a `=>` operator |
07:01:07 | FromGitter | <Varriount> I would prefer pragmas in the same place that python allows decorators. |
07:01:17 | FromGitter | <Varriount> That is, right before the function signature. |
07:01:33 | FromGitter | <Quelklef> I agree @Varriount but I'd still prefer no explicit pragmas for certain things |
07:01:37 | FromGitter | <Varriount> (Maybe that could be a worthwhile compiler plugin) |
07:01:51 | FromGitter | <Quelklef> Like, |
07:02:09 | FromGitter | <Quelklef> I'm using `recur`. That should be enough. Having to mention it with `{.recursive.}` feels redundant |
07:02:26 | FromGitter | <Quelklef> Yes, I know, perhaps there's a function named `recur`. Then it's relevant |
07:02:51 | FromGitter | <rayman22201> exactly. being explicit lets you know what is going on |
07:03:10 | FromGitter | <Quelklef> Ugh I don't know what I'm trying to get at |
07:03:12 | FromGitter | <Quelklef> I guess it's this: |
07:03:24 | FromGitter | <Quelklef> haha just kidding I can't reify it |
07:03:28 | FromGitter | <Quelklef> it's 3am for me to be fair |
07:04:26 | FromGitter | <rayman22201> The problem I have with global macros is what I call the "lisp dsl" problem. Lisp lets you do global macros, and doesn't clearly separate or identify when a macro is happening vs regular code (because there isn't much difference in lisp but I digress... |
07:04:46 | FromGitter | <Quelklef> Lisp lets you do global macros?? |
07:04:50 | FromGitter | <Quelklef> I never learned that |
07:05:13 | FromGitter | <rayman22201> This ends up being a situation where everybody has their own flavor of lisp and you can't really read anybodies code because you don't know wtf is going on |
07:05:31 | FromGitter | <Quelklef> Which is true, IMO, with macros anyway |
07:05:55 | FromGitter | <Quelklef> besides, you can already have """global""" macros |
07:06:06 | FromGitter | <Quelklef> ```myFancyDSL: β the entire file``` [https://gitter.im/nim-lang/Nim?at=5b52db5eee530e4aac8a1036] |
07:06:41 | FromGitter | <rayman22201> Macros are super powerful, but I think they need to be clearly and explicitly documented and annotated, otherwise people have no way of knowing what the hell your weird syntax is doing. |
07:07:07 | FromGitter | <Quelklef> but that's true anywa |
07:07:10 | FromGitter | <rayman22201> @Quelklef lol, yup! and I am ok with that! |
07:07:16 | FromGitter | <Quelklef> But |
07:07:19 | FromGitter | <Quelklef> consider that: |
07:08:03 | FromGitter | <Quelklef> ```wrapwith DSL β the entire file``` β β (I use something other than `import` to signify that it's doing a global macro) [https://gitter.im/nim-lang/Nim?at=5b52dbd305e1cc3553fed3de] |
07:08:44 | FromGitter | <Quelklef> If you want to figure stuff out in the first one, you see that it's (likely, since the symbol is unqualified) from the `DSL` module, and look at its docs |
07:08:59 | FromGitter | <Quelklef> If you want to figure stuff out in the second one, you see that it's from the `DSL` module, and look at its docs |
07:09:00 | FromGitter | <rayman22201> that's just being lazy. It's only one extra line :-P |
07:09:12 | FromGitter | <Quelklef> But it's much more flexibility |
07:09:31 | FromGitter | <rayman22201> How is your option B more flexible than option A? |
07:09:43 | FromGitter | <Quelklef> Well, not "flexible" per se |
07:09:47 | FromGitter | <Quelklef> but like |
07:09:57 | FromGitter | <Quelklef> Unobtrusive |
07:10:10 | FromGitter | <Quelklef> Although I suppose there is a case to be made that DSLs should be obtrusive |
07:10:12 | FromGitter | <rayman22201> other than having to indent the entire file which is a bit annoying, but meh |
07:10:24 | FromGitter | <Quelklef> And if you want to stack them, you have to have multiple indents |
07:10:32 | FromGitter | <Quelklef> Here's the thing |
07:10:35 | FromGitter | <rayman22201> DSLs should be clearly marked. |
07:10:45 | FromGitter | <Quelklef> if I want to add a `recur` keyword, I want to be able to implement it "as a language feature" and forget about it |
07:11:10 | FromGitter | <Quelklef> It'd be really nice to be able to do that with an `import` or a `wrapwith` or whatever import-like feature |
07:11:36 | FromGitter | <Quelklef> And because we can already `myDSL: everything`, this feature is equally as powerful as the existing features |
07:11:53 | FromGitter | <Quelklef> And, as shown in the example, actually *better* at documenting (because of not having unqualified symbols) |
07:12:23 | FromGitter | <Quelklef> I don't want Nim to become a "magic" language like Ruby |
07:12:39 | FromGitter | <Quelklef> But at the same time, I avoid writing macros like `{.recursive.}` exactly for this reason: they're a pain to use |
07:14:11 | FromGitter | <rayman22201> so, full disclosure, the way I wrote that macro would not work as a global macro. I "cheated" in that I use the {.recursive.} pragma as an anchor so I know what function I'm dealing with. |
07:14:17 | * | ng0 joined #nim |
07:14:25 | FromGitter | <Quelklef> I mean |
07:14:50 | FromGitter | <Quelklef> just make a `globalMacro` which deferes to `recursive` for all function defs containing a call to `recur` |
07:15:00 | FromGitter | <Quelklef> defers* |
07:15:28 | FromGitter | <rayman22201> sure, but what if you don't want it on all functions? |
07:15:57 | FromGitter | <Quelklef> either have an `{.norecursive.}` pragma, or don't use the global macro |
07:16:17 | FromGitter | <rayman22201> lol |
07:16:30 | FromGitter | <Quelklef> seems reasonable to me |
07:17:37 | FromGitter | <rayman22201> sorry. It is reasonable, I just find inverting use case problems to be kind of funny / interesting |
07:17:49 | FromGitter | <Quelklef> Yeah it's a little odd |
07:18:34 | FromGitter | <rayman22201> The whole idea of, is it better to paint the whole room blue, and then paint one wall red, or paint the whole room red, and then paint 3 walls blue :-P |
07:18:51 | FromGitter | <rayman22201> some kind of weird riddle or Dr. Suess rhyme is in there somewhere |
07:18:58 | FromGitter | <Quelklef> More like |
07:20:00 | FromGitter | <Quelklef> "I have 100 walls. On each of them is painted a blue or red stripe. Generally, I want the painter to pain the walls the same color. There are a few exceptions where I want a blue-striped wall painted red. Should I point out all the blue-striped walls I want painted blue, or all the blue-striped walls I want painted red?" |
07:20:56 | FromGitter | <Quelklef> "I have 100 functions. On each of them I either use `recur`, or I don't. Generally, I want `recur` to refer to the function. There are a few exceptions where I want `recur` to refer to a func/variable named recur. Should I annotate all the functions where `recur` stands for recursion, or all those where it doesn't?" |
07:22:23 | FromGitter | <rayman22201> I do see your point. I'm not sure how I feel about it from a language design standpoint though.... |
07:22:38 | FromGitter | <Quelklef> I can see it going both ways |
07:22:48 | FromGitter | <Quelklef> It's up to Araq, if this idea goes anywhere |
07:22:50 | FromGitter | <rayman22201> I go back to my lisp thing again. Lisp lets you do this, I think it hurt them |
07:23:01 | FromGitter | <Quelklef> What are those macros called? |
07:23:10 | FromGitter | <Quelklef> I know normal macros and reader macros but I've never heard of this |
07:24:34 | FromGitter | <rayman22201> It's not a special feature, it's that you can define a macro for your whole program |
07:24:44 | FromGitter | <rayman22201> both reader and normal macros support this |
07:25:03 | FromGitter | <rayman22201> see all the crazy Racket DSL's like scribble for example |
07:25:37 | FromGitter | <rayman22201> You can just import a macro at the top of your lisp program and it works everywhere |
07:25:38 | FromGitter | <Quelklef> I think this might be Racket-only, not CLisp |
07:26:06 | FromGitter | <rayman22201> I guess I was being overly generic, there are so many lsips |
07:26:15 | FromGitter | <rayman22201> s/lsip/lisp |
07:26:17 | FromGitter | <Quelklef> yeah haha |
07:26:36 | FromGitter | <Quelklef> I mean I think there will always be potential to abuse a system |
07:26:41 | FromGitter | <Quelklef> especially something like a macro system |
07:26:45 | FromGitter | <rayman22201> true |
07:27:18 | FromGitter | <rayman22201> That's kind of why I don't mind some "pain" of extra typing like pragmas. They help deter too much abuse. |
07:27:27 | FromGitter | <Quelklef> besides, I think the syntactic variety in Nim will alleviate some problem |
07:27:36 | FromGitter | <Quelklef> Eh, I suppose |
07:27:55 | FromGitter | <Quelklef> I gotta go to bed |
07:28:07 | FromGitter | <rayman22201> me too... >.< |
07:28:09 | FromGitter | <Quelklef> I hope Araq sees this, I'm curious about his thoughts. My bet is he's on your side |
07:28:13 | FromGitter | <rayman22201> good night! |
07:28:18 | FromGitter | <Quelklef> later! |
07:36:50 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
07:54:11 | * | ftsf quit (Remote host closed the connection) |
07:54:35 | * | ftsf joined #nim |
08:44:03 | * | wildlander quit (Quit: Konversation terminated!) |
08:56:27 | * | dorelix joined #nim |
09:06:43 | livcd | what's the latest video you guys can find on YT about Nim ? (probabl #nim-offtopic) |
09:07:53 | federico3 | livcd: https://www.youtube.com/watch?v=hzxr9_ZK9uY perhaps |
09:34:37 | * | stefanos82 joined #nim |
09:49:41 | * | ng0 joined #nim |
10:06:57 | FromGitter | <tim-st> when I read from a stream let's say only one byte, does it use a buffer in the background that automatically renews if needed? |
10:07:27 | * | xylef quit (Ping timeout: 240 seconds) |
10:07:51 | FromGitter | <mratsim> a stream uses a pointer + length |
10:09:00 | FromGitter | <tim-st> My idea was does it do read calls to the system for every single read char, or does it directly read a buffer of len `x` and read from this and renews if needed? |
10:09:20 | FromGitter | <tim-st> I dont have too much knowlege about it, but my guess is it could work like this |
10:09:41 | FromGitter | <tim-st> when I call `stream.readChar` |
10:10:07 | FromGitter | <mratsim> use readData to read into a buffer that you control |
10:10:31 | FromGitter | <tim-st> exactly this is what I assumed the stream does for me in the background |
10:10:52 | FromGitter | <tim-st> the docs talk about a buffer and buffer size so maybe it works like I said |
10:10:57 | FromGitter | <tim-st> I'm not sure :\ |
10:12:05 | FromGitter | <mratsim> just go through the source code here: https://github.com/nim-lang/Nim/blob/master/lib/pure/streams.nim#L43 |
10:12:33 | FromGitter | <tim-st> I did already do this, and it isnt clear to me |
10:12:35 | FromGitter | <mratsim> a stream is a type with several proc fields that defines how reading and writing works |
10:12:51 | FromGitter | <mratsim> Filestream uses this: `result.readDataImpl = fsReadData` |
10:13:04 | FromGitter | <mratsim> fsReadData: result = readBuffer(FileStream(s).f, buffer, bufLen) |
10:13:07 | FromGitter | <tim-st> so what does `proc newFileStream(filename: string; mode: FileMode = fmRead; bufSize: int = -1)` |
10:13:12 | FromGitter | <tim-st> mean |
10:13:16 | FromGitter | <tim-st> the bufSize |
10:13:20 | FromGitter | <mratsim> so it indeed uses a pointer + length for buffer |
10:13:52 | FromGitter | <mratsim> bufSize is use as input for the βopenβ function which is defined in system.nim |
10:14:19 | FromGitter | <tim-st> hm, so `open` does buffer automatically? |
10:14:22 | FromGitter | <mratsim> https://nim-lang.org/docs/system.html#open,File,string,FileMode,int_2 |
10:15:16 | FromGitter | <mratsim> I suppose there is a C library behind that uses this because -1 is not very Nim-like |
10:15:34 | FromGitter | <mratsim> https://github.com/nim-lang/Nim/blob/master/lib/system/sysio.nim#L365 |
10:15:55 | FromGitter | <mratsim> c_setvbuf comes from stdio.h |
10:16:04 | FromGitter | <tim-st> I just want to prevent the worst case scenario when I parse a file using a stream and call the `readChar` that it does read the char always from the file, my hope was it reads like 1024 bytes into a string and reads from this and then reads next 1024 bytes into the buffer string |
10:16:25 | FromGitter | <mratsim> doc is there: http://pubs.opengroup.org/onlinepubs/009604499/functions/setvbuf.html |
10:16:25 | FromGitter | <data-man> @tim-st: if you on devel try MemMapFileStream from memfiles.nim |
10:16:54 | FromGitter | <mratsim> use readData |
10:17:18 | FromGitter | <tim-st> currently I use `if s.readData(addr(c), char.sizeof) == 1` |
10:17:40 | FromGitter | <tim-st> @data-man thanks, does it work the same for windows and unix or has one os downside with it? |
10:18:19 | FromGitter | <tim-st> In java they have BufferStream or something, it the same in nim? |
10:18:31 | FromGitter | <data-man> @tim-st: the tests are passed on both :-) |
10:19:15 | FromGitter | <mratsim> use StringStream or ByteStream if you want to stream from a buffer |
10:19:26 | FromGitter | <mratsim> use FileStream if you want to Stream from a file |
10:20:06 | FromGitter | <mratsim> ByteStream are not merged :/ https://github.com/nim-lang/Nim/pull/7481 |
10:20:14 | FromGitter | <tim-st> Yes, I want to stream from a file only, but with a buffer behind that does the buffering automatically for me |
10:20:27 | FromGitter | <tim-st> @data-man thanks, looks good, I think I use this |
10:20:32 | FromGitter | <tim-st> I dont need to buffer there? |
10:21:09 | FromGitter | <data-man> Yes, without any buffer |
10:21:18 | FromGitter | <tim-st> ok, good, thanks |
10:21:36 | FromGitter | <tim-st> I dont want to implement my own buffering, I think that should do the stdlib of a language |
10:23:50 | FromGitter | <mratsim> I donβt understand your performance need. β β If you need to read char by char but and donβt care about perf, use readChar β If you just want to copy several chars, just use readData β If you need performance, but char by char read, use readData store in an array[1024, byte], and yield from it. [https://gitter.im/nim-lang/Nim?at=5b5309b626bfd636be3bfbf7] |
10:24:49 | FromGitter | <mratsim> i.e. having auto-buffering, means that people who really care about perf will have to disable it because a generic buffer will never met their own specific use case |
10:25:00 | FromGitter | <tim-st> I want the last one but dont want to implement it on my own; I think the `Stream` should do it in background |
10:25:25 | FromGitter | <tim-st> @data-man do I have to close a `MemMapFileStream`? |
10:25:58 | FromGitter | <tim-st> @mratsim yes, because of this java has an own type for this automatical thing |
10:26:06 | FromGitter | <mratsim> I donβt think it should, how do you determine the buffer size automatically? What if itβs a network file, or a bittorrent file? what if you need it for video streaming. |
10:26:24 | FromGitter | <tim-st> it's passed to the initProc |
10:26:29 | FromGitter | <tim-st> static[int] |
10:27:04 | FromGitter | <mratsim> but you probably need dynamic buffering, say if latency is suddenly high at runtime, you need to increase buffer size |
10:27:32 | FromGitter | <tim-st> then one can use a SlowAutoBuffer which uses seq |
10:27:41 | FromGitter | <data-man> @tim-st: Sure, for (MemMap)FileStream closing is recommended |
10:28:08 | FromGitter | <tim-st> ok, thanks, I tried to match json and would need an extra closing proc :\ |
10:28:14 | FromGitter | <mratsim> But I think this kind of stuff should be done in a separate lib, not on the βlow-levelβ stream |
10:28:35 | FromGitter | <tim-st> java does it too, it's very commonly used there afaik |
10:29:28 | FromGitter | <mratsim> for example you can have: network file β> Buffer β> Uncompress β> Buffer β> Display |
10:29:52 | FromGitter | <tim-st> For this one would use two buffers I think |
10:30:06 | FromGitter | <tim-st> also you can determine the average compress ratio |
10:30:35 | FromGitter | <mratsim> but at every step the kind of buffering needed is different. You cannot just slap a generic buffer implementation to cover all use cases, so I think this buffering should be done in specialized lib for networking, for uncompressing, etc |
10:30:57 | FromGitter | <mratsim> buffering for gzip is also different from buffering for LZMA |
10:31:51 | FromGitter | <mratsim> and assuming we add a naive auto buffering in streams |
10:32:11 | FromGitter | <mratsim> everyone who needs to implement its own buffering mechanism will have to workaround this generic auto-buffering |
10:32:57 | FromGitter | <tim-st> I expected the auto buffer to have the very same inteface like current one, just with different name, I dont see problems there tbh |
10:33:01 | FromGitter | <mratsim> alternatively you can add bool βautoBufferβ to the proc |
10:33:34 | FromGitter | <mratsim> for me the problem is that, if you donβt care about perf you donβt need a buffer |
10:33:54 | FromGitter | <mratsim> if you care, you better write your own buffer for your use case (networking, compression, β¦) |
10:34:42 | FromGitter | <mratsim> readData is enough to batch read a stream with the best perf possible |
10:35:09 | FromGitter | <tim-st> I just use `MemMapFileStream` for now it will work and dont forces me to create my own |
10:35:24 | FromGitter | <tim-st> thanks for your help though :) |
10:35:30 | FromGitter | <mratsim> no problem |
10:35:46 | FromGitter | <tim-st> maybe I can exchange them later and test performance |
10:36:45 | FromGitter | <mratsim> basically memmap loads file in RAM on a as needed basis. Iβm not sure how itβs implemented on the C side, especially if there is read-ahead. |
11:25:53 | * | ftsf quit (Ping timeout: 248 seconds) |
11:40:11 | * | xylef joined #nim |
11:52:14 | * | miran joined #nim |
11:55:10 | * | Ven`` joined #nim |
11:58:06 | FromGitter | <tim-st> Here is an article about BufferedInputStream (https://docs.oracle.com/javase/7/docs/api/java/io/BufferedInputStream.html) tests in Java: https://pzemtsov.github.io/2015/01/19/on-the-benefits-of-stream-buffering-in-Java.html |
11:58:20 | FromGitter | <tim-st> So I think it would be quite useful to have it in nims stdlib too |
11:58:31 | * | yglukhov[i] joined #nim |
12:02:09 | * | Ven`` quit (Ping timeout: 248 seconds) |
12:03:18 | * | dorelix quit (Ping timeout: 244 seconds) |
12:03:34 | * | Ven`` joined #nim |
12:05:38 | FromGitter | <tim-st> in module `lexbase`it's implemented but with additional fields and a cstring as buffer |
12:11:59 | FromGitter | <mratsim> You can PR streams to add a BufferedStream type with read/peek/write proc |
12:12:22 | FromGitter | <mratsim> it can be build on top of Stream so it can work with File/String/Gzip streams |
12:12:49 | FromGitter | <mratsim> the default buffer size should be configurable |
12:16:03 | FromGitter | <tim-st> yes, already thought about it^^ |
12:36:15 | FromGitter | <Varriount> I wonder if C# new Pipes concept might not be better |
12:36:16 | * | mrRobot_ joined #nim |
12:36:43 | mrRobot_ | hello |
12:38:06 | FromGitter | <Varriount> Hello! |
12:38:57 | mrRobot_ | I was wondering if anyone could help me. I'm creating a CLI application that has to be portable (i.e you can drop a binary on a USB and it works on practically any machine) There is some emphasis on cryptography. I'm wondering if nim is suitable for this? |
12:39:13 | mrRobot_ | @Varriount hello bud |
12:40:14 | mrRobot_ | perhaps nim programs can be compiled to ANSI C or something like it? |
12:41:06 | Yardanico | mrRobot_, your program should be for windows or for linux? |
12:41:08 | mrRobot_ | I searched Google and there was some talk of adding dependencies breaking portability. I'm planning to interface with the C libsodium library into the mix somewhere |
12:41:33 | mrRobot_ | Hello @Yardanico, preferably both |
12:41:46 | mrRobot_ | I would like fast start up times |
12:41:57 | Yardanico | what do you mean by that? nim is compiled to native code |
12:42:15 | Yardanico | it doesn't have any VM so start-up times will be the same as with programs in C/C++ |
12:42:37 | Yardanico | mrRobot_, I think you can statically link musl or compile your programs on centos 7 to make it portable to almost any linux distro |
12:42:59 | mrRobot_ | The other languages that I can think of that would be able to do this would Rust and Go as they have little to no start up time but Go is too simplistic and Rust is too verbose |
12:43:38 | mrRobot_ | ah right Yardanico, I'm a newbie to Vim but have programmed in loads of other languages like Haskell, Java, JavaScript, etc |
12:43:45 | Yardanico | vim is not nim :P |
12:43:46 | mrRobot_ | Nim* |
12:44:15 | Yardanico | but to make your Nim program portable you would do the same as you would do with C program |
12:45:45 | dom96 | Indeed, Nim compiles to C |
12:45:51 | dom96 | and then compiles the C to a binary for you |
12:48:11 | mrRobot_ | ... and then I can run it theoretically anywhere, awesome my dudes :) |
12:48:55 | mrRobot_ | but what about including dependencies, is there something like the equivalent of Java fat jars, where everything is bundled together? |
12:49:10 | Yardanico | mrRobot_, well, you can compile any C code into your nim program |
12:49:52 | Yardanico | static linking :) |
12:50:39 | * | cspar_ quit (Ping timeout: 260 seconds) |
12:52:27 | FromGitter | <Varriount> You can theoretically use musl or ulibc to reduce the C library dependencies |
12:53:17 | FromGitter | <Varriount> Although I don't have any explicit instructions on how to do so. |
12:53:30 | * | yglukhov[i] quit (Remote host closed the connection) |
12:53:41 | Calinou | hi, how can I check whether an iteration in a for loop is the first one or the last one? (I'm iterating over a range of integers with 0..n) |
12:53:52 | Calinou | without hardcoding the index in an `if` condition, of course :) |
12:54:16 | Yardanico | I don't think there's a way to do this without indexing, that's easy to do with `if`, why would you need something else? :) |
12:54:31 | Yardanico | if i == n: last iteration |
12:54:34 | Calinou | I guess I'm too used to things like Twig which have a built-in way to check whether the current index is the first/last one |
12:55:14 | mrRobot_ | Yardanico, Varriount, dom96, thankss my dudes |
12:55:46 | Calinou | I'll just `let` the first and last indexes so that I can reuse them |
12:57:30 | FromGitter | <Varriount> Calinou: you can just use an if statement and a boolean |
12:57:36 | dom96 | mrRobot_: You can bundle up the .exe and .dll together into a zip :) |
12:57:48 | dom96 | Static linking is possible too, but a bit tough to do, especially on Windows |
12:57:59 | dom96 | If you can get the C source code of the library then it's much easier. |
12:58:11 | dom96 | (And even Rust/Go can't statically link as easily in that instance ;)) |
12:58:37 | mrRobot_ | dom96, I'm planning to use https://download.libsodium.org/doc/ |
12:58:37 | Calinou | is there an universal packer for Windows? i.e. something that lets you bundle data in an executable in a language-agnostic way |
12:58:59 | Calinou | AppImage can do that on Linux :) |
12:59:11 | FromGitter | <data-man> @dom96 β β > because truecolor support is very recent and the person that implemented likely didn't think to implement it for styledEcho β β No, my initial implementation works fine. So the question goes to persons who later broke it and who merged a PRs without verification. [https://gitter.im/nim-lang/Nim?at=5b532e1f26bfd636be3c4e6d] |
12:59:34 | dom96 | data-man: check `git blame` :) |
13:00:02 | dom96 | mrRobot_: You can likely just grab the repo and use the {.compile.} Nim pragma to embed it in your exe https://github.com/jedisct1/libsodium |
13:00:21 | dom96 | https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compile-pragma |
13:00:42 | dom96 | IIRC you can write something like {.compile: "libsodium/src/*.c".} |
13:00:47 | mrRobot_ | dom96, this is all very useful stuff to know, I'm currently writing it all down |
13:01:59 | dom96 | also, there seem to be two wrappers for libsodium already https://nimble.directory/search?query=sodium |
13:02:34 | mrRobot_ | dom96, I had a look at those but they both seem to not implement everything from libsodium, not really sure why they haven't |
13:02:55 | dom96 | the authors probably didn't need it |
13:03:06 | FromGitter | <Vindaar> @data-man @dom96 but it does actually work for `styledEcho` as well as `styledWrite`unless I'm missing something |
13:03:31 | mrRobot_ | right right I see |
13:03:43 | Calinou | https://hastebin.com/kayohiguqi.nim |
13:03:46 | Calinou | this is horribly stateful :D |
13:03:49 | Calinou | but it works |
13:04:12 | Calinou | also, I wonder, do people use .float or float() more often to convert between types? |
13:04:29 | mrRobot_ | I'll be creating a complete and up-to-date libsodium binding for nim very soon then I think :) |
13:04:34 | dom96 | probably the former because it's easier to add into code :) |
13:04:41 | dom96 | mrRobot_: awesome! |
13:04:56 | Yardanico | Calinou, float(value) :) |
13:05:26 | FromGitter | <Vindaar> Calinou: I personally use .float almost exclusively |
13:05:45 | dom96 | mrRobot_: consider improving the libsodium wrappers that already exist if you can. Of course I can understand the temptation of creating your own, and by all means go for it too :) |
13:05:56 | miran | is there a way to create two enums, one of which will contain all values of the other + some more? |
13:06:06 | dom96 | miran: macros |
13:06:18 | miran | e.g. enum A = X, Y; enum B = (X and Y from A), Z |
13:07:08 | miran | dom96: heh, i'm not there yet :) still haven't had the time to learn macros |
13:07:49 | FromGitter | <mratsim> Here is a simple macro with enum that fills holes: https://github.com/status-im/nimbus/blob/master/nimbus/vm/interpreter/utils/macros_gen_opcodes.nim#L25 |
13:08:13 | FromGitter | <mratsim> maybe it will help you get started |
13:08:25 | mrRobot_ | dom96, I'll try my dude haha |
13:08:44 | FromGitter | <mratsim> getTypeImpl is probably the way to go @miran |
13:09:10 | miran | thanks @mratsim, i'll take a look |
13:09:57 | FromGitter | <data-man> @Vindaar: The example from https://nim-lang.org/blog/2018/03/01/version-0180-released.html compiles for you? |
13:10:39 | mrRobot_ | dom96, perhaps you'd know the answer to this one. If I do compile to C, would I be able to interop that C code via JNI to some Java code, or is that a no-go? Are there pitfalls for using this approach? |
13:11:23 | mrRobot_ | basically, I want to create a nim-based CLI libsodium app, then also use that code to create a Java app |
13:11:50 | Yardanico | why would you do that? :P you can write everything in Nim :D |
13:11:53 | mrRobot_ | truly taking the "write once, run anywhere" to the extremes here haha |
13:12:50 | mrRobot_ | Yardanico, I know, but at some point I may need a GUI, which I can write in Swing or some other language :) |
13:12:59 | Calinou | have you looked at Kotlin by the way? |
13:13:01 | Calinou | out of curiosity |
13:13:12 | * | yglukhov[i] joined #nim |
13:13:14 | mrRobot_ | yep I know Kotlin very well |
13:14:19 | mrRobot_ | essentially, I'm a Java dude through-and-through, but want a faster CLI app than what Java can provide (plus I really want to learn nim lol) |
13:15:05 | Calinou | yeah, I understand |
13:15:11 | Calinou | I'm porting a Node.js CLI app to Nim for the same reason |
13:15:38 | mrRobot_ | oh really, how's it going for you so far? |
13:15:39 | Calinou | (static typing and small binaries are nice to have too) |
13:15:51 | mrRobot_ | yeah the small binaries really appealed to me |
13:15:56 | Calinou | it's going alright :) I just got color preview to work |
13:16:00 | Calinou | https://github.com/Calinou/clr |
13:16:56 | mrRobot_ | looks sweet my dude!! |
13:18:09 | Calinou | original Node.js app is here, https://github.com/Calinou/colour-cli |
13:19:12 | mrRobot_ | have you measured the startup times in the nodejs app? |
13:19:39 | Calinou | yeah |
13:19:43 | mrRobot_ | I can imagine it being slow |
13:20:00 | Calinou | <Calinou> according to hyperfine, startup time is 0.9 ms (-d:release) or 1.1 ms (-d:release --opt:size), the binary is pretty small too (231 KB optimized for speed and stripped, 153 KB optimized for size and stripped) |
13:20:00 | Calinou | <Calinou> in comparison, the Node.js app takes 168 ms to start when not packaged into a standalone binary. If I package it using `pkg`, it's faster (114 ms) but the binary is 40 MB as it bundles Node.js |
13:20:07 | mrRobot_ | I've done React and Vue apps and sometimes the compilations take ages |
13:20:13 | Calinou | the CLI framework I use in Node.js (Caporal) is known to be slow, which doesn't help |
13:20:22 | Calinou | it's very nice to use, but it comes at a cost |
13:20:29 | Calinou | I use docopt in Nim, which is much more barebones |
13:20:40 | Calinou | (but it's probably enough for my use cases) |
13:20:55 | mrRobot_ | omg wtf --> in comparison, the Node.js app takes 168 ms to start when not packaged into a standalone binary. If I package it using `pkg`, it's faster (114 ms) but the binary is 40 MB as it bundles Node.js <-- |
13:21:13 | Calinou | (I'm using an i7-6700K + a SSD by the way) |
13:21:21 | mrRobot_ | 40MB and 168ms to start down to 0.9ms?!?! |
13:21:25 | Calinou | which is much faster than the average PC out there |
13:21:27 | Calinou | yeah |
13:21:40 | mrRobot_ | holy sweet potato |
13:21:58 | zacharycarter[m] | hrm work on web dev stuff or game stuff today |
13:21:58 | zacharycarter[m] | decisions decisions.... |
13:22:12 | Calinou | most static languages can deliver really good performance for CLI apps |
13:22:20 | Calinou | I wrote a CLI app in Go, it was very fast to start up too |
13:22:33 | mrRobot_ | you ever tried to write a kotlin/java CLI app? |
13:24:31 | FromGitter | <Vindaar> @data-man oh, sorry. No, that doesn't compile for me either. I only tested something like β β ```code paste, see link``` β β viridis_data is simply an array of color tuples. I though there was an issue with true colors and `styledWrite` / `styledEcho` in general [https://gitter.im/nim-lang/Nim?at=5b53340ff02a0977a3ee768b] |
13:25:30 | * | cspar_ joined #nim |
13:25:32 | zacharycarter[m] | mrRobot: https://www.astrecipes.net/blog/2018/07/20/cmd-line-apps-with-clojure-and-graalvm/ |
13:26:00 | * | nsf quit (Quit: WeeChat 2.1) |
13:26:35 | zacharycarter[m] | also - I'm using Nim in my current web project and compilation can still take a while - especially bundling |
13:26:49 | zacharycarter[m] | though I'm pretty much forced to bundle unless I want to go through a bunch of extra headache to load Monaco editor from a CDN |
13:27:17 | zacharycarter[m] | the Nim compiler is fast - the bundler not so much - I'm using Parcel though instead of webpack though because I can't effing stand webpack |
13:27:34 | zacharycarter[m] | and Parcel is supposedly faster anyway - although I have yet to see any real benchmarks |
13:27:57 | zacharycarter[m] | NodeJS sucks for plenty of other reasons though |
13:28:24 | FromGitter | <kaushalmodi> @data-man dom96: You missed the later posts. True color is working fine as I and @Vindaar later showed. |
13:30:03 | mrRobot_ | zacharycarter, thanks for the info |
13:30:20 | mrRobot_ | yeah webpack is crazy |
13:31:54 | zacharycarter[m] | np |
13:31:56 | mrRobot_ | also not really sure how portable clojure is |
13:32:24 | zacharycarter[m] | well traditionally it runs on the JVM - so anywhere the JVM is running |
13:32:40 | zacharycarter[m] | but this example shows how to use GraalVM to speed up start up time of Clojure apps |
13:32:46 | zacharycarter[m] | GraalVM != JVM |
13:32:53 | zacharycarter[m] | https://www.graalvm.org/ |
13:34:02 | mrRobot_ | cool I'll look into Graal too :) |
13:34:47 | FromGitter | <kaushalmodi> @data-man About truecolors and terminal, I'll check out that example code when I get to a computer. But if you know it's not compiling, can you open an issue for that? |
13:35:02 | zacharycarter[m] | :thumbsup: |
13:35:12 | zacharycarter[m] | π |
13:35:15 | zacharycarter[m] | stupid riot |
13:35:36 | FromGitter | <kaushalmodi> My example code was this (looks similar, so need to understand what the error is): https://gitter.im/nim-lang/Nim?at=5b5254cbc579673e6b844002 |
13:36:28 | livcd | zacharycarter[m]: mrRobot_: graal and the ecosystem around it is very promising |
13:36:29 | Calinou | mrRobot_: I've never used Kotlin, no chance to use it :( |
13:36:36 | Calinou | I wrote some Java for an university course but that's it |
13:37:02 | FromGitter | <kaushalmodi> Wait, that example is using `int` as variable name? |
13:37:17 | zacharycarter[m] | Kotlin > Java for sure |
13:37:22 | zacharycarter[m] | Java is turrible |
13:37:27 | FromGitter | <kaushalmodi> `````` |
13:37:47 | zacharycarter[m] | I stay as far away from the JVM as possible in general though |
13:38:33 | Calinou | yeah, Kotlin definitely seems more terse |
13:39:12 | * | Ven`` quit (Quit: My MacBook has gone to sleep. ZZZzzzβ¦) |
13:39:40 | dom96 | mrRobot_: yeah, you'll be able to interop from Java. What might be easier though is if you just execute the CLI app in your Java GUI |
13:39:43 | dom96 | That's how I'd do it |
13:42:43 | mrRobot_ | awesome |
13:48:23 | mrRobot_ | thanks for all the info people, I'll soon be starting my journey with nim, cheers!! :) |
13:50:03 | FromGitter | <mratsim> @mrRobot_ canβt you just use the JNI with libsodium C? |
13:50:41 | zacharycarter[m] | for android? |
13:50:52 | zacharycarter[m] | JNI is awful dude |
13:50:58 | zacharycarter[m] | I mean it works once you get it working |
13:51:03 | zacharycarter[m] | but have fun getting from A -> B |
13:51:14 | zacharycarter[m] | I did it for frag and I think the project is still up if you want to see how I did it |
13:51:33 | zacharycarter[m] | and I was using other shared libs - bgfx and others |
13:52:38 | zacharycarter[m] | https://github.com/fragworks/frag-android |
13:52:49 | mrRobot_ | mratsim: I've done that but the startup time and bundling the JDK into a portable format is heavyweight |
13:53:43 | mrRobot_ | Yeah plus the JNI experience on Android is real bad |
13:53:52 | mrRobot_ | I actually had to use JNA because it was that bad |
13:54:59 | mrRobot_ | so now I'm moving onto greener fields and trying out nim |
13:58:30 | * | Perkol joined #nim |
13:59:00 | Perkol | iterator walkDirRec(dir: string; yieldFilter = {pcFile}; followFilter = {pcDir}): string {..} How do I pass yieldFilter to it? |
13:59:49 | dom96 | yieldFilter = {...}? |
14:00:43 | Perkol | for file in walkDirRec "c:\\Dev\\1", yieldFilter = {pcDir}: ? |
14:02:41 | * | ieatnerd1 joined #nim |
14:08:15 | dom96 | for file in walkDirRec("c:\\Dev\\1", yieldFilter = {pcDir}): |
14:08:35 | dom96 | or just walkDirRec("...", {pcDir}) |
14:10:24 | * | cspar_ quit (Ping timeout: 244 seconds) |
14:18:04 | FromGitter | <Vindaar> @miran: hacked something together (can probably be improved a lot though, hehe): https://gist.github.com/Vindaar/e803d2e5705febd8de018821fbeb7f6b |
14:18:32 | FromGitter | <Vindaar> And of course it can only deal with enums without specific values :D |
14:20:12 | miran | @Vindaar this is the first time someone named his type by me. watch out mr. Boolean, here i come! |
14:20:27 | FromGitter | <Vindaar> hahaha :D |
14:22:28 | FromGitter | <viniarck> Hi Guys, what's the recommended way to distribute Nim binaries for the most mainstream CPUs and OSes out there? I'm running Linux amd64 arch, should I install a X compiler toolchain or is there any other Nim tool that might help me with that (from what I've read niminst requires the X compilers in place)? |
14:23:11 | Yardanico | compile to x32 on centos 7 image in docker or statically link with musl/ulibc |
14:24:20 | ieatnerd1 | Hey, quick question since I cant seem to find an answer online. I've got a seq of char's, but need them to be a seq of strings. how do I change from char to string, without making all the chars into a single string? |
14:25:07 | FromGitter | <Vindaar> ieatnerd1: how do you know when one string ends? |
14:25:17 | FromGitter | <viniarck> Thanks @Yardanico. This wouldn't work for OSX though, would it? I also want to ship a binary for OSX users |
14:26:19 | FromGitter | <mratsim> I think you can use Travis to build the binaries after CI is successful |
14:27:13 | ieatnerd1 | a single char needs to be a single string, not putting multiple chars into a string. |
14:27:21 | FromGitter | <viniarck> Sounds like a great option. |
14:27:31 | FromGitter | <Vindaar> ah, that's what you mean |
14:28:18 | ieatnerd1 | yeah. I can iterate over my seq[char] but then dont know how to get that char to a string to add to my seq[string] |
14:28:25 | FromGitter | <viniarck> @mratsim, would you happen to know a Nim project that's building some binaries on Travis CI for different platforms? I wanted to take a look on it. |
14:28:41 | dom96 | ieatnerd: $char |
14:29:22 | FromGitter | <mratsim> no but you can start by combining Travis build artifacts: https://docs.travis-ci.com/user/uploading-artifacts/ |
14:29:45 | FromGitter | <mratsim> with Travis config for Nim: https://github.com/mratsim/Arraymancer/blob/master/.travis.yml |
14:29:53 | FromGitter | <viniarck> Right on. I'll explore that. Thanks for pointing that out. |
14:29:53 | FromGitter | <mratsim> ^ for stable |
14:29:58 | FromGitter | <viniarck> Cool |
14:29:59 | FromGitter | <Vindaar> ieatnerd1: β β ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b5343679ddf5f4aadfc98ef] |
14:30:17 | FromGitter | <mratsim> for devel on OSX and devel with docker on Linux: https://github.com/status-im/nimbus/blob/master/.travis.yml |
14:30:29 | FromGitter | <viniarck> Awesome. Thanks again. |
14:33:50 | FromGitter | <Vindaar> or if you want it concise with sequtils: β β ```let s = a.mapIt($it)``` [https://gitter.im/nim-lang/Nim?at=5b53444e26bfd636be3c834e] |
14:36:36 | * | mrRobot_ quit (Ping timeout: 252 seconds) |
14:49:10 | miran | i have in a try block `pos = stdin.readLine().parseInt`, and this works as expected for one-digit numbers. but when i input more than one digit, it waits until i press enter twice!? |
14:50:54 | FromGitter | <tim-st> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b53484ec579673e6b86389a] |
14:51:00 | FromGitter | <tim-st> does the var line copy? |
14:51:23 | FromGitter | <Vindaar> miran: are you sure it's not the rest of the code? seems to work fine for me |
14:52:01 | FromGitter | <Vindaar> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b534891f02a0977a3eea860] |
14:52:17 | miran | argh, of course it is, i'm stupid |
14:55:37 | FromGitter | <tim-st> solved my question, I used var type now as param |
14:57:28 | Calinou | @viniarck 32-bit x86 is barely used anymore on Linux, and it hasn't been supported by Apple for years on macOS |
14:57:29 | ieatnerd1 | Dom, if youre still there I wanted to say thanks. I got it all to work eventually. |
14:57:37 | * | riidom joined #nim |
14:57:49 | Calinou | it's nice to provide ARMv7 and ARMv8 binaries for ARM SBC users though (such as Raspberry Pi) |
14:58:04 | Calinou | (that is, for Linux) |
14:58:43 | Calinou | what about https://pryp.in/blog/22/advanced-uses-of-travis-ci-with-nim.html by the way? |
14:59:17 | Calinou | https://github.com/mratsim/Arraymancer/blob/master/.travis.yml looks good for me. I'd love to see something like Goreleaser but for Nim :) |
15:06:41 | * | yglukhov[i] quit (Remote host closed the connection) |
15:11:15 | * | leorize joined #nim |
15:23:46 | dom96 | ieatnerd1: np :) |
15:24:28 | dom96 | yay, choosenim being used :) |
15:24:34 | dom96 | I use choosenim in all my travis scripts now too |
15:24:53 | dom96 | Pro Tip: You can set an env var to pin the version of Nim that choosenim will install |
15:25:10 | dom96 | you should also really cache ~/.nimble and ~/.choosenim |
15:25:22 | dom96 | https://github.com/dom96/jester/blob/master/.travis.yml |
15:34:32 | * | Ven`` joined #nim |
15:40:41 | * | Ven`` quit (Remote host closed the connection) |
15:41:20 | FromGitter | <viniarck> Cool. Yep. Exactly @Calinou, when I first asked I was looking for something like Goreleaser. I'm looking into choose nim and these Travis CI setups. I'll probably start a Nimreleaser project. I really want to ship binaries easily. Coming from Python, this was one of the biggest hurdles. |
15:41:36 | FromGitter | <viniarck> Thanks @dom96. |
15:41:47 | * | Ven`` joined #nim |
15:42:21 | * | yglukhov[i] joined #nim |
15:42:49 | FromGitter | <viniarck> Thanks @Calinou |
15:46:06 | * | cspar_ joined #nim |
15:46:19 | * | epictek[m] quit (Read error: Connection timed out) |
15:46:49 | * | yglukhov[i] quit (Ping timeout: 260 seconds) |
15:46:50 | * | epictek[m] joined #nim |
15:50:05 | * | ieatnerd1 quit (Ping timeout: 276 seconds) |
16:10:01 | dom96 | Come on guys, not far off 600 responses now: https://goo.gl/forms/t2gWWBEDC1walw6s2. We can get there! |
16:13:17 | FromGitter | <Quelklef> Why is it "extreme like" and "really dislike"? |
16:13:21 | FromGitter | <Quelklef> seems unequal |
16:15:18 | * | yglukhov[i] joined #nim |
16:16:00 | * | BitPuffin joined #nim |
16:18:33 | FromGitter | <viniarck> @dom96, just retweeted on twitter too this form, hope that helps. 600 is the minimum responses this survey is aiming at? |
16:19:08 | dom96 | we got 600 last year, so I wanna beat it |
16:19:14 | miran | dom96: any success with posting it on reddit/HN/lobsters? |
16:19:40 | FromGitter | <viniarck> I see. Yep. Way to go! |
16:19:42 | miran | (and i don't mean r/nim, but something more general like r/programming) |
16:19:52 | dom96 | nope :/ |
16:20:35 | FromGitter | <mratsim> r/programminglanguage? |
16:21:05 | FromGitter | <mratsim> I discovered it yesterday, the community is very much into super obscure language, Nim could actually be a mainstream language there |
16:22:54 | FromGitter | <mratsim> I mean obscure like: Inko, Plasma, Dashrep, Felix, Egison, β¦. |
16:23:01 | dom96 | Feel free to submit it wherever |
16:29:06 | FromGitter | <tim-st> When I use `Positive` instead of `int` compiler says it cannot prove that my result is initialized?! |
16:29:46 | FromGitter | <tim-st> Positive as a generics type |
16:30:43 | FromGitter | <mratsim> because by default initialization is at binary 0 |
16:30:57 | FromGitter | <tim-st> it's `static[Positive]` |
16:31:00 | FromGitter | <mratsim> but binary 0 (i.e. plain 0 for int) is not part of Positive range |
16:31:18 | FromGitter | <mratsim> in those case the compiler always throws that warning |
16:31:24 | FromGitter | <tim-st> but why? |
16:31:50 | FromGitter | <mratsim> i think itβs because no one fixed this bug |
16:32:03 | FromGitter | <tim-st> ok |
16:32:23 | FromGitter | <Quelklef> hey @dom96 thoughts on allowing an import-like expression (say, "`wrapwith`") which passes an entire module's AST into a another module's macro? So `wrapwith myDsl; theRestOfTheFile` would be the same as `import myDsl; myDsl.myDslsPowerfulMacro: theRestOfTheFile`? I think it'd be awesome but I feel a little iffy about starting an RFC |
16:42:36 | zacharycarter[m] | is there a way to override a symbol in a module? I need to replace the implementation of - https://github.com/nim-lang/Nim/blob/devel/lib/system/timers.nim#L43 - when a certain flag is defined |
16:42:50 | zacharycarter[m] | and I don't want to have to use a forked version of Nim - but I've never gotten much feedback on this issue |
16:43:01 | FromGitter | <Quelklef> What's your use-case |
16:43:04 | FromGitter | <Quelklef> Can you do: |
16:43:25 | FromGitter | <Quelklef> ```when not flag: β import X β else: β import X excluding Y β implement Y``` [https://gitter.im/nim-lang/Nim?at=5b5362adf477e4664ab28696] |
16:43:38 | * | zacharycarter[m] sent a long message: < https://matrix.org/_matrix/media/v1/download/matrix.org/WoygDBjunncggdWgBPMKlPgV > |
16:43:39 | zacharycarter[m] | with |
16:44:10 | zacharycarter[m] | ``` |
16:44:10 | zacharycarter[m] | proc getTicks(): Ticks {.inline.} = |
16:44:11 | zacharycarter[m] | result = Ticks(clock_gettime(CLOCK_MONOTONIC)) |
16:44:27 | zacharycarter[m] | okay thanks |
16:44:39 | FromGitter | <tim-st> I cannot get `system.readChars*(f: File, a: var openArray[char], start, len: Natural): int` working, it returns always `0` :( |
16:44:39 | FromGitter | <Quelklef> Wait, that's not gonna work cause it's in system |
16:44:44 | dom96 | Quelklef: You can start out by asking on the forum if you wish :) |
16:44:48 | FromGitter | <Quelklef> oh no it isn't, just kidding |
16:44:50 | FromGitter | <Quelklef> good luck |
16:45:06 | FromGitter | <Quelklef> @dom96 okay, will do |
16:45:13 | zacharycarter[m] | although damn I'm not importing timers - I'm importing times |
16:45:18 | zacharycarter[m] | yeah :/ |
16:45:58 | dom96 | zacharycarter[m]: Duplicates time(r)s.nim in your project |
16:46:02 | dom96 | *Duplicate |
16:46:37 | zacharycarter[m] | thanks! |
16:47:25 | FromGitter | <Varriount> zacharycarter: patchFile might work |
16:49:11 | zacharycarter[m] | ah - wasn't aware of that - thanks! that's awesome! |
16:55:13 | FromGitter | <mratsim> @dom96 published: https://www.reddit.com/r/ProgrammingLanguages/comments/90qp1k/nim_language_community_survey/ |
16:55:46 | dom96 | "[Removed]" |
16:56:34 | FromGitter | <mratsim> are you talking to me? |
16:56:47 | dom96 | Yes, refresh your link |
16:57:24 | FromGitter | <mratsim> it works for me :? |
16:57:59 | dom96 | try it in a private tab? |
16:58:08 | zacharycarter[m] | worked perfect |
16:58:16 | zacharycarter[m] | thanks Varriount and dom96 |
16:58:41 | FromGitter | <mratsim> ah right, strange |
16:59:27 | FromGitter | <mratsim> maybe under moderation? |
17:00:08 | dom96 | perhaps |
17:00:34 | FromGitter | <mratsim> or I took 5 min to write the post and didnβt post it until 20 min after so |
17:06:33 | FromGitter | <mratsim> deleted and tried another one, the post is also auto-removed for some reason β¦. |
17:09:17 | * | yglukhov[i] quit (Remote host closed the connection) |
17:09:57 | FromGitter | <mratsim> rejoice @miran: https://github.com/nim-lang/Nim/pull/8383 |
17:15:11 | * | yglukhov[i] joined #nim |
17:15:17 | FromGitter | <Varriount> zacharycarter: Which technique did you end up going with? |
17:16:41 | copygirl | Hey everyone! It's been a while. I'm considering picking up Nim for a hobby gamedev project again. I would like to make the various systems modular so they could in theory be expanded and replaced. Something where you can just drop a source file in a specific folder and recompile without having to edit other source files would be sweet. What are my options in this case? |
17:18:09 | FromGitter | <mratsim> Have a .nim file that keeps track of imports and exports and edit it when you add a new file in a directory: https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer.nim |
17:18:27 | copygirl | Also compile time code generation, such as "entity type E has component C" - and if such a definition does not exist, code requesting component C would error at compile time. |
17:19:34 | FromGitter | <mratsim> I would have to see a type definition but you can use static: assert for compile time error: https://github.com/status-im/nim-stint/blob/master/stint/io.nim#L21 |
17:21:19 | copygirl | I'm not entirely sure how to all approach this. My question is likely too generic to really get an answer. |
17:22:35 | zacharycarter[m] | Question - if I want to propose a simple one line change to add like a mime type to https://nim-lang.org/docs/mimetypes.html - should I make an issue or just make a PR? |
17:23:08 | FromGitter | <mratsim> just make a PR no? we can discuss on both anyway |
17:23:24 | zacharycarter[m] | π |
17:24:30 | copygirl | Mhh.. I don't know if I'd want a .nim file to keep track of modules. It wouldn't be much effort but I feel like it would be clunky to require "users" to do that on top of dropping in a module / system in a folder and recompile. |
17:24:53 | FromGitter | <mratsim> ah itβs for users. |
17:25:17 | zacharycarter[m] | https://github.com/nim-lang/Nim/pull/8389 |
17:25:30 | copygirl | Well, "user-developers", ideally. |
17:28:51 | FromGitter | <mratsim> Iβm not too sure how to best approach that @copygirl. I have some ideas to do things in a dirty manner: β β nimble script + walkDir β> write a config file β> staticRead the config file in a macro and insert the import |
17:29:22 | copygirl | The idea is that the engine would be made out of independent systems that could be added, modified and removed without everything crushing down (unless other systems depend on them). So for example, two different "physics" systems that you could choose between, or that have different features. Or an optional "building integrity" system that would have buildings collapse if not supported properly. |
17:30:14 | zacharycarter[m] | plugin architecture? |
17:30:17 | zacharycarter[m] | like hot reloading shared libs? |
17:30:21 | FromGitter | <mratsim> would there be a json config file for example that will track name, version, author and things like that? |
17:30:26 | copygirl | Recompile necessary. |
17:30:36 | zacharycarter[m] | oh |
17:30:45 | copygirl | So I don't think plugins in that sense. |
17:31:10 | FromGitter | <barcharcraz> I would recomend just requireing an import someplace |
17:31:35 | FromGitter | <barcharcraz> that said you can do it (you can do anything using slurp and gorge tbh) |
17:31:47 | FromGitter | <mratsim> yeah, have a file modules.nim, require users to drop their module and add a line to modules.nim |
17:32:04 | FromGitter | <barcharcraz> a more principled framework for slurp/gorge based compiler plugins would be kinda nice though |
17:32:15 | FromGitter | <mratsim> once done we can think of a more automated solution. |
17:32:49 | copygirl | What are slurp / gorge? |
17:32:51 | FromGitter | <barcharcraz> works essentially like rust's new proc macros (except the code has to actually parse, which sucks) |
17:32:58 | FromGitter | <barcharcraz> static_read and static_exec |
17:33:01 | FromGitter | <mratsim> slurp= staticRead, gorge = staticExec |
17:33:32 | copygirl | Where did those nicknames come from? |
17:33:40 | FromGitter | <barcharcraz> araq I think |
17:33:53 | Araq | Perl |
17:34:21 | * | ieatnerd1 joined #nim |
17:34:37 | * | yglukhov[i] quit (Remote host closed the connection) |
17:37:06 | * | Ven`` quit (Quit: My MacBook has gone to sleep. ZZZzzzβ¦) |
17:38:57 | copygirl | Mhh.. this is one of the things I'm looking forward to JAI for. |
17:39:03 | * | ieatnerd1 quit (Ping timeout: 256 seconds) |
17:40:00 | copygirl | I suppose I could write a build script that edits the right source files. |
17:40:20 | copygirl | And for other questions I have I guess I need to dig in deeper first. |
17:42:32 | * | Perkol quit (Quit: Leaving) |
17:47:11 | Calinou | dom96: choosenim works nicely here, thanks for this tool :) |
17:47:38 | * | yglukhov[i] joined #nim |
17:47:52 | dom96 | Glad you like it :) |
17:48:10 | * | NimBot joined #nim |
17:52:05 | * | yglukhov[i] quit (Ping timeout: 240 seconds) |
18:33:46 | Calinou | https://github.com/tldr-pages/tldr/pull/2207 has been merged :D |
18:33:52 | Calinou | I'll submit pages for nimble and choosenim soon |
18:34:29 | * | dddddd joined #nim |
18:37:31 | dom96 | Nice :D |
18:38:32 | FromGitter | <viniarck> Sweet. |
18:40:16 | FromGitter | <tim-st> isnt `streams.readAll` mostly called on the complete stream data, someone has an idea? https://github.com/nim-lang/Nim/blob/855956bf617f68ac0be3717329e9e1181e5dc0c6/lib/pure/streams.nim#L104 |
18:46:09 | FromGitter | <tim-st> *complete file data |
18:49:40 | FromGitter | <tim-st> ok, I see, the underlying `system.readAll(f: File)` cannot be used because `Stream` doesnt require a file |
18:51:57 | * | cspar_ quit (Ping timeout: 268 seconds) |
18:53:57 | * | ieatnerd1 joined #nim |
18:58:13 | FromGitter | <tim-st> When I have the choice between `newString(x)` and `newStringOfCap(x)`which one is better only regarding performance? |
18:58:20 | * | yglukhov[i] joined #nim |
18:59:23 | FromGitter | <barcharcraz> they should be quite similar |
19:00:03 | FromGitter | <tim-st> in the docs `newString` contains the word uninitialized and newStringOfCap doesnt |
19:00:30 | FromGitter | <barcharcraz> I bet the only difference is that newStringOfCap sets the length to zero, where newString sets it to x |
19:00:46 | FromGitter | <tim-st> yes, that was my guess too, maybe someone knows |
19:01:11 | FromGitter | <barcharcraz> a shame that it's a magic |
19:01:23 | FromGitter | <tim-st> yes^^ |
19:02:21 | FromGitter | <tim-st> I found them hidden in `sysstr.nim` as `rawNewStringNoInit` |
19:04:45 | FromGitter | <tim-st> @barcharcraz you were correct; but I've seen they both initialize |
19:05:01 | FromGitter | <tim-st> although the same proc exists without initalizing, hm... |
19:06:21 | FromGitter | <tim-st> ah, maybe the uninitalized is only called if I add the pragma, but if so then the docs arent correct |
19:10:19 | FromGitter | <tim-st> I think this should be changed, to always be uninitalized |
19:12:37 | * | Vladar quit (Quit: Leaving) |
19:16:56 | FromDiscord | <exelotl> how do nim's method dispatch trees perform when you have a wide and shallow object hierarchy? |
19:17:30 | FromDiscord | <exelotl> like 100 different entity types all inheriting from 1 base entity |
19:22:10 | * | ieatnerd1 quit (Ping timeout: 268 seconds) |
19:23:19 | Calinou | zacharycarter[m]: :o https://github.com/nathan/pax |
19:23:31 | Calinou | we were talking about bundlers today :P |
19:31:10 | * | Jesin joined #nim |
19:32:42 | Araq | exelotl: they suck for everything, hardware advanced to the point where an indirect call is much better than what Nim does. |
19:33:15 | Araq | at least they can be inlined though... |
19:33:51 | Araq | we should remove the 'multi' aspect of them and use a more traditional vtable thing |
19:39:40 | * | stefanos82 quit (Quit: Quitting for now...) |
19:44:44 | Calinou | is there a data structure akin to dictionaries in Nim? |
19:45:57 | FromGitter | <Quelklef> Tables |
19:46:12 | Calinou | oh, it's in a module |
19:46:18 | Calinou | that's why I didn't really find any infos about them in the manual |
19:47:02 | FromDiscord | <exelotl> Araq: oh that's a shame. I think multi-methods would be really good for 1 usage I had in mind (doing collision detection between entities with various different types of collision mask, e.g. hitbox vs hitbox, hitbox vs circle, circle vs point) |
19:51:02 | FromDiscord | <exelotl> in some other engine I've used, they do that using a hash table where the keys are runtime types and the values are collision functions |
19:51:43 | FromDiscord | <exelotl> but I could imagine it being slower than multi-methods are currently |
19:58:12 | Demos[m] | weren't they plans to have a seperate vtable like functionality |
19:58:13 | Demos[m] | like rust's trait objects |
20:02:36 | Calinou | https://nim-lang.org/docs/tables.html#pairs.i,Table[A,B] |
20:02:47 | * | nsf joined #nim |
20:02:57 | Calinou | is it just me, or fetching the values is possible but undocumented? |
20:03:07 | Calinou | I had to use `echo` in a for loop to determine the fields :P |
20:03:21 | Calinou | .val[0] accesses the key, and .val[1] accesses the value |
20:05:05 | Araq | it's just you, tuples are documented, but not every stdlib routine that uses tuples, do document tuples. |
20:05:38 | Araq | it's called a "language vs library distinction" |
20:05:40 | Calinou | right |
20:06:38 | Araq | Demos[m]: they got chancelled/delayed. |
20:07:03 | Araq | *cancel |
20:07:13 | Demos[m] | oh, that's too bad |
20:07:56 | Demos[m] | it's good to combat the feature creep and push 1.0 though |
20:08:00 | Araq | exeltotl: if you can implement the dispatching on your own, do it. it's nearly always better. there are talks where they do it in C++ in order to make it faster |
20:08:11 | FromDiscord | <awr> thinking about the possibility of a `recur` keyword: if you didn't use it but just referred to the function name, what would that be? a compiler warning? |
20:08:31 | FromGitter | <rayman22201> @dom96. You and I need to have ourselves a classic forum debate war! :-P |
20:09:09 | FromGitter | <rayman22201> @awr. I made made a macro for you last night: https://gist.github.com/rayman22201/0675507877c0edd11c32fbcfa1e65482 |
20:09:44 | FromDiscord | <awr> yeah i've been meaning to look |
20:09:45 | FromDiscord | <awr> good work |
20:09:58 | FromDiscord | <awr> i imagine it doesn't work with anon procs though right |
20:10:02 | dom96 | rayman22201: Does that involve lots of GIFs? :D |
20:10:29 | FromGitter | <rayman22201> @awr It does indeed work with anonymous procs. Check out the second example at the bottom of the gist |
20:11:00 | FromGitter | <rayman22201> @dom96 It can if you like :-P (Deploying troll cannons!) |
20:11:04 | Calinou | https://i.imgur.com/kKZRF03.png |
20:11:06 | Calinou | base functionality is done :D |
20:11:17 | FromGitter | <rayman22201> pretty! |
20:11:18 | Calinou | (Node.js on top, Nim on the bottom) |
20:12:01 | dom96 | Calinou: Needs more symmetry |
20:12:02 | FromGitter | <rayman22201> I'm sad about the Node.js part :-P |
20:12:03 | Calinou | I had mistakenly labeled the HSL value as HSV in the Node.js app, I fixed that in Nim |
20:12:29 | Calinou | (and added an HSV display, as some apps still prefer HSV today) |
20:14:11 | FromDiscord | <awr> excuse my grogginess but i don't understand how it works wrt anon functions. is it copying the proc body and making it a named function inside the proc? |
20:17:25 | * | nsf quit (Quit: WeeChat 2.1) |
20:19:52 | FromGitter | <rayman22201> yes |
20:20:16 | Araq | awr: what is a pattern in the compiler that I sometimes use: |
20:20:37 | Araq | proc foo(context; n; args) = |
20:20:48 | Araq | template rec(n) = foo(context, n, args) |
20:20:57 | Araq | for c in n: rec(c) |
20:21:12 | Araq | 1 local template that doesn't just "recurse" |
20:21:35 | Araq | it captures the point of the recursion, only what changes in the recursion stays a parameter |
20:22:37 | Araq | and that's much better than your 'recur' keyword, IMO. |
20:24:15 | FromGitter | <rayman22201> Araq your was is definitely more efficient. It's almost like unrolling the recursion into a procedural loop. |
20:24:35 | FromGitter | <rayman22201> not almost, it is. I think |
20:25:18 | Araq | hmm, I fear you misread the 'for c in n' part, that's just 'items' for AST nodes at work and unrelated to the 'rec' template |
20:26:11 | FromGitter | <rayman22201> OH, I see. nvm then. |
20:27:26 | Araq | anyway, it also answers your other questions, "what if my proc doesn't want to use 'recur'? how to enable it on a proc basis?" |
20:28:58 | FromGitter | <rayman22201> lol, well that was @Quelklef's question. |
20:29:35 | FromGitter | <rayman22201> I was always on the side of keeping it on a per-proc basis. |
20:29:54 | FromGitter | <rayman22201> He wanted to whole-sale enable it for the entire file |
20:30:04 | FromGitter | <Quelklef> yes indeed |
20:30:11 | FromGitter | <rayman22201> Hi @Quelklef |
20:30:14 | FromGitter | <Quelklef> howdy |
20:31:31 | Araq | about recursions in anon procs, use the Y combinator? |
20:40:38 | * | miran_ joined #nim |
20:40:57 | * | miran quit (Ping timeout: 256 seconds) |
20:43:04 | FromGitter | <rayman22201> lol. That is kind of what my macro is doing |
20:43:10 | * | miran_ is now known as miran |
20:43:20 | FromGitter | <rayman22201> takes the function and passes it to itself |
20:43:26 | FromGitter | <rayman22201> via wrapper |
20:44:23 | FromGitter | <rayman22201> ok @dom96 I responded. You'll have to forgive me. I decided to skip the gifs. :-) https://forum.nim-lang.org/t/4044 |
20:48:09 | FromGitter | <rayman22201> but If I were to have gifs, this one is my first choice: https://gph.is/Vxc2Q6 ;-) |
20:51:56 | Calinou | how can I wrap a long list of `if β¦ or` checks? |
20:56:17 | Araq | after the 'or' |
20:57:07 | Calinou | that works, thanks :) |
20:57:17 | Calinou | I'm more used to putting the "or" at the beginning of the line, not at the end |
20:58:25 | Calinou | do you generally use 4 spaces instead of 2 for continuation indents in Nim? |
21:01:53 | FromGitter | <kayabaNerve> I have a type named Vec3, and have a const of sizeof(Vec3). I get "cannot run in the VM". Does anyone here know what my issue is? It works with bool and it is in the same file. |
21:02:50 | FromGitter | <kayabaNerve> They're (happens for multiple) are just objects (not ref object of RootObj) with floats in them. |
21:02:57 | * | miran quit (Ping timeout: 240 seconds) |
21:03:36 | FromGitter | <kayabaNerve> New question. Why does it require `ref object`? |
21:05:33 | Calinou | I just finished implementing all the color conversion commands :) |
21:05:45 | Calinou | my Nim rewrite now has feature parity with the original Node.js app I wrote |
21:13:03 | * | dorelix joined #nim |
21:13:59 | * | BitPuffin quit (Remote host closed the connection) |
21:36:37 | FromGitter | <Quelklef> @kayabaNerve CAn you post code? |
21:40:23 | FromGitter | <Varriount> Calinou: It would be neat if you could write a blog post or something detailing your experience. |
21:41:43 | Calinou | I don't have a personal blog |
21:41:44 | FromGitter | <Varriount> Even if it's just a forum post. |
21:42:51 | FromGitter | <rayman22201> Make a guest post on the Nim blog! |
21:45:05 | FromGitter | <kayabaNerve> @Quelklef β type Vec2 = ref object β β ```a: float``` β ... [https://gitter.im/nim-lang/Nim?at=5b53a96126bfd636be3d63e5] |
21:59:23 | * | yglukhov[i] quit (Remote host closed the connection) |
22:14:39 | Calinou | also, docopt doesn't let me use negative numbers as positional arguments, it seems |
22:14:49 | Calinou | (it probably thinks those numbers are arguments) |
22:56:11 | FromGitter | <kayabaNerve> I moved from string splits to temp vars and a for loop and my code execution became 35x worse :( I also edited a couple of things but that should've be 2x at worst lol. |
22:56:30 | FromGitter | <kayabaNerve> (so if they stack, my poor string work in an attempt to gain speed was 17x) |
23:05:05 | * | shashlick quit (Remote host closed the connection) |
23:05:26 | * | shashlick joined #nim |
23:10:09 | FromGitter | <Varriount> Calinou: For long conditions, I generally find it more readable to shove the checks into a boolean variable assignment. |
23:13:47 | * | arecacea1 quit (Remote host closed the connection) |
23:14:11 | * | arecacea1 joined #nim |
23:32:25 | * | shashlick quit (Remote host closed the connection) |
23:32:44 | * | shashlick joined #nim |
23:38:51 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
23:49:57 | * | craigger quit (Quit: bye) |
23:51:55 | * | xylef quit (Ping timeout: 256 seconds) |
23:52:24 | * | craigger joined #nim |