<< 21-07-2018 >>

00:04:09*mwbrown quit (Quit: Exiting)
00:14:41*PMunch quit (Quit: leaving)
00:25:30FromGitter<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:15FromGitter<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:19FromGitter<rayman22201> terminal is cross platform, but it imports posix / winlean internally
00:28:16FromGitter<imdaveho> got it, ty!
00:28:46FromGitter<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:05FromGitter<imdaveho> I guess the outputted C would also contain the check but when it compiles, it'll clean up?
00:29:52FromGitter<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:17FromGitter<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:27FromGitter<imdaveho> hmm seems like you confirmed it
00:30:34FromGitter<imdaveho> that's fine :)
00:31:07FromGitter<rayman22201> Well, no compiler can make a binary work on multiple platforms at once lol
00:31:56FromGitter<imdaveho> srry I mean "build" on windows
00:32:21FromGitter<imdaveho> but I get what you're saying
00:32:36FromGitter<rayman22201> πŸ‘
00:43:41FromDiscord<exelotl> Finally working on the details for my very efficient but also friendly 2D game engine
00:45:40*wildlander joined #nim
00:46:29FromDiscord<exelotl> I want to make something where entities are objects which can contain components to define their behaviour,
00:46:34FromDiscord<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:49FromGitter<rayman22201> cool
00:48:31FromGitter<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:36krux02@rayman22201: it might turn out to be useful. But maybe it won't be that useful.
00:50:50krux02it is a neat idea. but I believe more in a more flexible entity component model
00:51:22FromGitter<rayman22201> maybe. It's a neat trick either way. I don't code games so idk lol
00:52:04FromGitter<rayman22201> Also, It seems like a very fun / doable project with Nim Macros.
00:52:13FromDiscord<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:02FromGitter<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:28FromDiscord<exelotl> Wizardry
00:53:55FromGitter<rayman22201> Macros are magic lol
00:55:24FromGitter<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:20FromDiscord<exelotl> I am so glad I finally picked up this language tbh xD. It's really quite something
00:56:44FromGitter<rayman22201> me too :-)
00:58:07FromDiscord<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:22FromGitter<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:36FromGitter<Varriount> What is the process of binding Go to C?
01:09:29FromGitter<rayman22201> https://golang.org/cmd/cgo/
01:10:59FromGitter<rayman22201> It's a lot more limited than Nim's C FFI
01:17:41FromGitter<Varriount> Well, that document is confusing
01:17:48*benji__ is now known as benjikun
01:18:22FromGitter<Varriount> Mostly because what Go calls a pointer is different from what C calls a pointer.
01:18:29FromGitter<rayman22201> welcome to Golang. Everything is "simple" yet somehow very confusing :-P
01:20:28FromDiscord<awr> i wish nim had a "recur" keyword
01:20:37FromDiscord<awr> something that could act as an alias to the current function
01:21:59FromGitter<rayman22201> why not just the name of the function?
01:23:31FromDiscord<awr> well for one you can't do recursion in anonymous procs without higher order magic
01:24:05FromDiscord<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:27FromGitter<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:19skrylartime 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:48FromGitter<Quelklef> Fuzzy idea:
03:38:12FromGitter<Quelklef> Attributes that may be patched onto typed outside of their definitions and used in another context
03:38:16FromGitter<Quelklef> For instance:
03:39:23FromGitter<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:19FromGitter<Quelklef> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b52ab2326bfd636be3b3895]
03:41:06FromGitter<Quelklef> This can currently be emulated with `.attr` and `.attr=` procs, but I wonder if doing so is abuse
03:41:17FromGitter<Quelklef> 1) .attr and .attr= procs as well as a table
03:41:38FromGitter<barcharcraz> @PMunch I'm still around. I'm Demos on IRC and matrix
03:42:43FromGitter<barcharcraz> hm I think you only need .attr and attr (you can use a gensym to store the value I think)
03:43:17FromGitter<Quelklef> Come again?
03:43:33FromGitter<barcharcraz> wait actually never mind.
03:43:49FromGitter<barcharcraz> another issue with using the table is you are gunna have to actually free memory at some point
03:44:10FromGitter<Quelklef> Ah yeah it's not gonna track refs
03:44:11FromGitter<Quelklef> Hmmmm
03:44:11FromGitter<barcharcraz> I'd say add a little table to the end of each Person struct for this
03:44:27FromGitter<barcharcraz> have like {.attrs.} type Person = ......
03:44:30FromGitter<Quelklef> pollutes the type definition though
03:44:32FromGitter<barcharcraz> and attrs can add the table
03:44:34FromGitter<Quelklef> Perhaps
03:44:38FromGitter<Quelklef> Ooh, I kind of like that
03:44:49FromGitter<Quelklef> Much better on memory anyway
03:44:56FromGitter<barcharcraz> I totally forget the rules around pragma type macros, but something like that
03:45:02FromGitter<Quelklef> Although, I think for my specific use, there's not going to be any memory freeing anyway
03:45:07FromGitter<Quelklef> it'd look like
03:45:15FromGitter<Quelklef> `type Person = object {.attrs.} \n rest`
03:45:15FromGitter<barcharcraz> That's what apply said :D
03:45:18FromGitter<barcharcraz> *apple
03:45:23FromGitter<Quelklef> eh?
03:45:29FromGitter<Quelklef> Oh
03:45:36FromGitter<barcharcraz> (chrome bug where it just never frees any memory on OSX because of a but in launchd)
03:45:41FromGitter<Quelklef> Lol, well I won't be *leaking* memory, just being irrespondible with it
03:45:58FromGitter<barcharcraz> the best kind of memory
03:46:20FromGitter<Quelklef> as long as i never push this code, nobody has to know
03:46:33FromGitter<barcharcraz> -_-
03:46:41FromGitter<Quelklef> ⏎
03:46:50Demos[m]it was a smile
03:46:55Demos[m]`-_-`
03:47:53FromGitter<Quelklef> oh
03:48:14Demos[m]yeah I'm in like 11 chat clients at once over here, sorry
03:48:35Demos[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:25Araqawr: I like the idea
05:19:25*miran joined #nim
05:23:42FromGitter<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:50FromGitter<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:41FromGitter<Quelklef> Ah, didn't see that
06:35:49FromGitter<Quelklef> but I second, third, and fourth that idea
06:36:12FromGitter<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:57FromGitter<rayman22201> https://gist.github.com/rayman22201/0675507877c0edd11c32fbcfa1e65482
06:51:00FromGitter<rayman22201> here you go
06:53:06FromGitter<Quelklef> beautiful
06:53:09FromGitter<Quelklef> but needs a pragma
06:53:22FromGitter<Varriount> Does it work with anonymous procedures though?
06:53:33FromGitter<Quelklef> What're the chances we get global macros?
06:53:45FromGitter<rayman22201> @Varriount
06:53:47FromGitter<Varriount> @Quelklef what would a "global macro" be?
06:54:01FromGitter<Quelklef> A macro which is applied to the entire AST of a module its imported into
06:54:24FromGitter<Varriount> Isn't that called a compiler plugin?
06:54:44FromGitter<Quelklef> Sure, but you can't import those, can you?
06:54:51FromGitter<Quelklef> i.e. they're not a "part of the language"
06:55:08FromGitter<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:56FromGitter<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:05FromGitter<rayman22201> it's a long way off though I imagine
06:57:15FromGitter<Quelklef> Sounds fancy
06:57:33FromGitter<Quelklef> This'd be cool "for now", though
06:57:41FromGitter<Quelklef> I can definitely see why it may be rejected
06:57:55FromGitter<Quelklef> but I personally would really like it
06:58:14FromGitter<rayman22201> why are pragmas an issue?
06:58:28*amosbird quit (Max SendQ exceeded)
06:58:31FromGitter<Quelklef> They're not 'really' an issue
06:58:33FromGitter<Quelklef> I just really like them
06:58:34FromGitter<Quelklef> because
06:58:53FromGitter<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:16FromGitter<Quelklef> Which seems ugly to me; pragmas should say: "hey, something's special about this node, look out for it!"
06:59:29FromGitter<Quelklef> kind of a weird way of putting it
06:59:34FromGitter<Quelklef> An alternative way of putting it:
06:59:38FromGitter<rayman22201> Yeah. I like pragrmas. I think they are fine, and provide good docs like you say.
06:59:49FromGitter<Quelklef> Ugh no
06:59:56FromGitter<Quelklef> Yeah it provides documentation but
07:00:17FromGitter<Quelklef> It's just ugly IMO to have to annotate every time you want to use a feature
07:00:29FromGitter<Quelklef> and sometimes you don't, right
07:00:37FromGitter<Quelklef> if it so happens to fit with the system
07:01:03FromGitter<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:05FromGitter<Quelklef> `sugar` macros don't need explicit annotation because it's enough to just make a `=>` operator
07:01:07FromGitter<Varriount> I would prefer pragmas in the same place that python allows decorators.
07:01:17FromGitter<Varriount> That is, right before the function signature.
07:01:33FromGitter<Quelklef> I agree @Varriount but I'd still prefer no explicit pragmas for certain things
07:01:37FromGitter<Varriount> (Maybe that could be a worthwhile compiler plugin)
07:01:51FromGitter<Quelklef> Like,
07:02:09FromGitter<Quelklef> I'm using `recur`. That should be enough. Having to mention it with `{.recursive.}` feels redundant
07:02:26FromGitter<Quelklef> Yes, I know, perhaps there's a function named `recur`. Then it's relevant
07:02:51FromGitter<rayman22201> exactly. being explicit lets you know what is going on
07:03:10FromGitter<Quelklef> Ugh I don't know what I'm trying to get at
07:03:12FromGitter<Quelklef> I guess it's this:
07:03:24FromGitter<Quelklef> haha just kidding I can't reify it
07:03:28FromGitter<Quelklef> it's 3am for me to be fair
07:04:26FromGitter<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:46FromGitter<Quelklef> Lisp lets you do global macros??
07:04:50FromGitter<Quelklef> I never learned that
07:05:13FromGitter<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:31FromGitter<Quelklef> Which is true, IMO, with macros anyway
07:05:55FromGitter<Quelklef> besides, you can already have """global""" macros
07:06:06FromGitter<Quelklef> ```myFancyDSL: ⏎ the entire file``` [https://gitter.im/nim-lang/Nim?at=5b52db5eee530e4aac8a1036]
07:06:41FromGitter<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:07FromGitter<Quelklef> but that's true anywa
07:07:10FromGitter<rayman22201> @Quelklef lol, yup! and I am ok with that!
07:07:16FromGitter<Quelklef> But
07:07:19FromGitter<Quelklef> consider that:
07:08:03FromGitter<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:44FromGitter<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:59FromGitter<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:00FromGitter<rayman22201> that's just being lazy. It's only one extra line :-P
07:09:12FromGitter<Quelklef> But it's much more flexibility
07:09:31FromGitter<rayman22201> How is your option B more flexible than option A?
07:09:43FromGitter<Quelklef> Well, not "flexible" per se
07:09:47FromGitter<Quelklef> but like
07:09:57FromGitter<Quelklef> Unobtrusive
07:10:10FromGitter<Quelklef> Although I suppose there is a case to be made that DSLs should be obtrusive
07:10:12FromGitter<rayman22201> other than having to indent the entire file which is a bit annoying, but meh
07:10:24FromGitter<Quelklef> And if you want to stack them, you have to have multiple indents
07:10:32FromGitter<Quelklef> Here's the thing
07:10:35FromGitter<rayman22201> DSLs should be clearly marked.
07:10:45FromGitter<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:10FromGitter<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:36FromGitter<Quelklef> And because we can already `myDSL: everything`, this feature is equally as powerful as the existing features
07:11:53FromGitter<Quelklef> And, as shown in the example, actually *better* at documenting (because of not having unqualified symbols)
07:12:23FromGitter<Quelklef> I don't want Nim to become a "magic" language like Ruby
07:12:39FromGitter<Quelklef> But at the same time, I avoid writing macros like `{.recursive.}` exactly for this reason: they're a pain to use
07:14:11FromGitter<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:25FromGitter<Quelklef> I mean
07:14:50FromGitter<Quelklef> just make a `globalMacro` which deferes to `recursive` for all function defs containing a call to `recur`
07:15:00FromGitter<Quelklef> defers*
07:15:28FromGitter<rayman22201> sure, but what if you don't want it on all functions?
07:15:57FromGitter<Quelklef> either have an `{.norecursive.}` pragma, or don't use the global macro
07:16:17FromGitter<rayman22201> lol
07:16:30FromGitter<Quelklef> seems reasonable to me
07:17:37FromGitter<rayman22201> sorry. It is reasonable, I just find inverting use case problems to be kind of funny / interesting
07:17:49FromGitter<Quelklef> Yeah it's a little odd
07:18:34FromGitter<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:51FromGitter<rayman22201> some kind of weird riddle or Dr. Suess rhyme is in there somewhere
07:18:58FromGitter<Quelklef> More like
07:20:00FromGitter<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:56FromGitter<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:23FromGitter<rayman22201> I do see your point. I'm not sure how I feel about it from a language design standpoint though....
07:22:38FromGitter<Quelklef> I can see it going both ways
07:22:48FromGitter<Quelklef> It's up to Araq, if this idea goes anywhere
07:22:50FromGitter<rayman22201> I go back to my lisp thing again. Lisp lets you do this, I think it hurt them
07:23:01FromGitter<Quelklef> What are those macros called?
07:23:10FromGitter<Quelklef> I know normal macros and reader macros but I've never heard of this
07:24:34FromGitter<rayman22201> It's not a special feature, it's that you can define a macro for your whole program
07:24:44FromGitter<rayman22201> both reader and normal macros support this
07:25:03FromGitter<rayman22201> see all the crazy Racket DSL's like scribble for example
07:25:37FromGitter<rayman22201> You can just import a macro at the top of your lisp program and it works everywhere
07:25:38FromGitter<Quelklef> I think this might be Racket-only, not CLisp
07:26:06FromGitter<rayman22201> I guess I was being overly generic, there are so many lsips
07:26:15FromGitter<rayman22201> s/lsip/lisp
07:26:17FromGitter<Quelklef> yeah haha
07:26:36FromGitter<Quelklef> I mean I think there will always be potential to abuse a system
07:26:41FromGitter<Quelklef> especially something like a macro system
07:26:45FromGitter<rayman22201> true
07:27:18FromGitter<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:27FromGitter<Quelklef> besides, I think the syntactic variety in Nim will alleviate some problem
07:27:36FromGitter<Quelklef> Eh, I suppose
07:27:55FromGitter<Quelklef> I gotta go to bed
07:28:07FromGitter<rayman22201> me too... >.<
07:28:09FromGitter<Quelklef> I hope Araq sees this, I'm curious about his thoughts. My bet is he's on your side
07:28:13FromGitter<rayman22201> good night!
07:28:18FromGitter<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:43livcdwhat's the latest video you guys can find on YT about Nim ? (probabl #nim-offtopic)
09:07:53federico3livcd: https://www.youtube.com/watch?v=hzxr9_ZK9uY perhaps
09:34:37*stefanos82 joined #nim
09:49:41*ng0 joined #nim
10:06:57FromGitter<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:51FromGitter<mratsim> a stream uses a pointer + length
10:09:00FromGitter<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:20FromGitter<tim-st> I dont have too much knowlege about it, but my guess is it could work like this
10:09:41FromGitter<tim-st> when I call `stream.readChar`
10:10:07FromGitter<mratsim> use readData to read into a buffer that you control
10:10:31FromGitter<tim-st> exactly this is what I assumed the stream does for me in the background
10:10:52FromGitter<tim-st> the docs talk about a buffer and buffer size so maybe it works like I said
10:10:57FromGitter<tim-st> I'm not sure :\
10:12:05FromGitter<mratsim> just go through the source code here: https://github.com/nim-lang/Nim/blob/master/lib/pure/streams.nim#L43
10:12:33FromGitter<tim-st> I did already do this, and it isnt clear to me
10:12:35FromGitter<mratsim> a stream is a type with several proc fields that defines how reading and writing works
10:12:51FromGitter<mratsim> Filestream uses this: `result.readDataImpl = fsReadData`
10:13:04FromGitter<mratsim> fsReadData: result = readBuffer(FileStream(s).f, buffer, bufLen)
10:13:07FromGitter<tim-st> so what does `proc newFileStream(filename: string; mode: FileMode = fmRead; bufSize: int = -1)`
10:13:12FromGitter<tim-st> mean
10:13:16FromGitter<tim-st> the bufSize
10:13:20FromGitter<mratsim> so it indeed uses a pointer + length for buffer
10:13:52FromGitter<mratsim> bufSize is use as input for the β€œopen” function which is defined in system.nim
10:14:19FromGitter<tim-st> hm, so `open` does buffer automatically?
10:14:22FromGitter<mratsim> https://nim-lang.org/docs/system.html#open,File,string,FileMode,int_2
10:15:16FromGitter<mratsim> I suppose there is a C library behind that uses this because -1 is not very Nim-like
10:15:34FromGitter<mratsim> https://github.com/nim-lang/Nim/blob/master/lib/system/sysio.nim#L365
10:15:55FromGitter<mratsim> c_setvbuf comes from stdio.h
10:16:04FromGitter<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:25FromGitter<mratsim> doc is there: http://pubs.opengroup.org/onlinepubs/009604499/functions/setvbuf.html
10:16:25FromGitter<data-man> @tim-st: if you on devel try MemMapFileStream from memfiles.nim
10:16:54FromGitter<mratsim> use readData
10:17:18FromGitter<tim-st> currently I use `if s.readData(addr(c), char.sizeof) == 1`
10:17:40FromGitter<tim-st> @data-man thanks, does it work the same for windows and unix or has one os downside with it?
10:18:19FromGitter<tim-st> In java they have BufferStream or something, it the same in nim?
10:18:31FromGitter<data-man> @tim-st: the tests are passed on both :-)
10:19:15FromGitter<mratsim> use StringStream or ByteStream if you want to stream from a buffer
10:19:26FromGitter<mratsim> use FileStream if you want to Stream from a file
10:20:06FromGitter<mratsim> ByteStream are not merged :/ https://github.com/nim-lang/Nim/pull/7481
10:20:14FromGitter<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:27FromGitter<tim-st> @data-man thanks, looks good, I think I use this
10:20:32FromGitter<tim-st> I dont need to buffer there?
10:21:09FromGitter<data-man> Yes, without any buffer
10:21:18FromGitter<tim-st> ok, good, thanks
10:21:36FromGitter<tim-st> I dont want to implement my own buffering, I think that should do the stdlib of a language
10:23:50FromGitter<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:49FromGitter<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:00FromGitter<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:25FromGitter<tim-st> @data-man do I have to close a `MemMapFileStream`?
10:25:58FromGitter<tim-st> @mratsim yes, because of this java has an own type for this automatical thing
10:26:06FromGitter<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:24FromGitter<tim-st> it's passed to the initProc
10:26:29FromGitter<tim-st> static[int]
10:27:04FromGitter<mratsim> but you probably need dynamic buffering, say if latency is suddenly high at runtime, you need to increase buffer size
10:27:32FromGitter<tim-st> then one can use a SlowAutoBuffer which uses seq
10:27:41FromGitter<data-man> @tim-st: Sure, for (MemMap)FileStream closing is recommended
10:28:08FromGitter<tim-st> ok, thanks, I tried to match json and would need an extra closing proc :\
10:28:14FromGitter<mratsim> But I think this kind of stuff should be done in a separate lib, not on the β€œlow-level” stream
10:28:35FromGitter<tim-st> java does it too, it's very commonly used there afaik
10:29:28FromGitter<mratsim> for example you can have: network file β€”> Buffer β€”> Uncompress β€”> Buffer β€”> Display
10:29:52FromGitter<tim-st> For this one would use two buffers I think
10:30:06FromGitter<tim-st> also you can determine the average compress ratio
10:30:35FromGitter<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:57FromGitter<mratsim> buffering for gzip is also different from buffering for LZMA
10:31:51FromGitter<mratsim> and assuming we add a naive auto buffering in streams
10:32:11FromGitter<mratsim> everyone who needs to implement its own buffering mechanism will have to workaround this generic auto-buffering
10:32:57FromGitter<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:01FromGitter<mratsim> alternatively you can add bool β€œautoBuffer” to the proc
10:33:34FromGitter<mratsim> for me the problem is that, if you don’t care about perf you don’t need a buffer
10:33:54FromGitter<mratsim> if you care, you better write your own buffer for your use case (networking, compression, …)
10:34:42FromGitter<mratsim> readData is enough to batch read a stream with the best perf possible
10:35:09FromGitter<tim-st> I just use `MemMapFileStream` for now it will work and dont forces me to create my own
10:35:24FromGitter<tim-st> thanks for your help though :)
10:35:30FromGitter<mratsim> no problem
10:35:46FromGitter<tim-st> maybe I can exchange them later and test performance
10:36:45FromGitter<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:06FromGitter<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:20FromGitter<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:38FromGitter<tim-st> in module `lexbase`it's implemented but with additional fields and a cstring as buffer
12:11:59FromGitter<mratsim> You can PR streams to add a BufferedStream type with read/peek/write proc
12:12:22FromGitter<mratsim> it can be build on top of Stream so it can work with File/String/Gzip streams
12:12:49FromGitter<mratsim> the default buffer size should be configurable
12:16:03FromGitter<tim-st> yes, already thought about it^^
12:36:15FromGitter<Varriount> I wonder if C# new Pipes concept might not be better
12:36:16*mrRobot_ joined #nim
12:36:43mrRobot_hello
12:38:06FromGitter<Varriount> Hello!
12:38:57mrRobot_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:13mrRobot_@Varriount hello bud
12:40:14mrRobot_perhaps nim programs can be compiled to ANSI C or something like it?
12:41:06YardanicomrRobot_, your program should be for windows or for linux?
12:41:08mrRobot_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:33mrRobot_Hello @Yardanico, preferably both
12:41:46mrRobot_I would like fast start up times
12:41:57Yardanicowhat do you mean by that? nim is compiled to native code
12:42:15Yardanicoit doesn't have any VM so start-up times will be the same as with programs in C/C++
12:42:37YardanicomrRobot_, 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:59mrRobot_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:38mrRobot_ah right Yardanico, I'm a newbie to Vim but have programmed in loads of other languages like Haskell, Java, JavaScript, etc
12:43:45Yardanicovim is not nim :P
12:43:46mrRobot_Nim*
12:44:15Yardanicobut to make your Nim program portable you would do the same as you would do with C program
12:45:45dom96Indeed, Nim compiles to C
12:45:51dom96and then compiles the C to a binary for you
12:48:11mrRobot_... and then I can run it theoretically anywhere, awesome my dudes :)
12:48:55mrRobot_but what about including dependencies, is there something like the equivalent of Java fat jars, where everything is bundled together?
12:49:10YardanicomrRobot_, well, you can compile any C code into your nim program
12:49:52Yardanicostatic linking :)
12:50:39*cspar_ quit (Ping timeout: 260 seconds)
12:52:27FromGitter<Varriount> You can theoretically use musl or ulibc to reduce the C library dependencies
12:53:17FromGitter<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:41Calinouhi, 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:52Calinouwithout hardcoding the index in an `if` condition, of course :)
12:54:16YardanicoI 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:31Yardanicoif i == n: last iteration
12:54:34CalinouI 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:14mrRobot_Yardanico, Varriount, dom96, thankss my dudes
12:55:46CalinouI'll just `let` the first and last indexes so that I can reuse them
12:57:30FromGitter<Varriount> Calinou: you can just use an if statement and a boolean
12:57:36dom96mrRobot_: You can bundle up the .exe and .dll together into a zip :)
12:57:48dom96Static linking is possible too, but a bit tough to do, especially on Windows
12:57:59dom96If you can get the C source code of the library then it's much easier.
12:58:11dom96(And even Rust/Go can't statically link as easily in that instance ;))
12:58:37mrRobot_dom96, I'm planning to use https://download.libsodium.org/doc/
12:58:37Calinouis there an universal packer for Windows? i.e. something that lets you bundle data in an executable in a language-agnostic way
12:58:59CalinouAppImage can do that on Linux :)
12:59:11FromGitter<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:34dom96data-man: check `git blame` :)
13:00:02dom96mrRobot_: 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:21dom96https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compile-pragma
13:00:42dom96IIRC you can write something like {.compile: "libsodium/src/*.c".}
13:00:47mrRobot_dom96, this is all very useful stuff to know, I'm currently writing it all down
13:01:59dom96also, there seem to be two wrappers for libsodium already https://nimble.directory/search?query=sodium
13:02:34mrRobot_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:55dom96the authors probably didn't need it
13:03:06FromGitter<Vindaar> @data-man @dom96 but it does actually work for `styledEcho` as well as `styledWrite`unless I'm missing something
13:03:31mrRobot_right right I see
13:03:43Calinouhttps://hastebin.com/kayohiguqi.nim
13:03:46Calinouthis is horribly stateful :D
13:03:49Calinoubut it works
13:04:12Calinoualso, I wonder, do people use .float or float() more often to convert between types?
13:04:29mrRobot_I'll be creating a complete and up-to-date libsodium binding for nim very soon then I think :)
13:04:34dom96probably the former because it's easier to add into code :)
13:04:41dom96mrRobot_: awesome!
13:04:56YardanicoCalinou, float(value) :)
13:05:26FromGitter<Vindaar> Calinou: I personally use .float almost exclusively
13:05:45dom96mrRobot_: 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:56miranis there a way to create two enums, one of which will contain all values of the other + some more?
13:06:06dom96miran: macros
13:06:18mirane.g. enum A = X, Y; enum B = (X and Y from A), Z
13:07:08mirandom96: heh, i'm not there yet :) still haven't had the time to learn macros
13:07:49FromGitter<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:13FromGitter<mratsim> maybe it will help you get started
13:08:25mrRobot_dom96, I'll try my dude haha
13:08:44FromGitter<mratsim> getTypeImpl is probably the way to go @miran
13:09:10miranthanks @mratsim, i'll take a look
13:09:57FromGitter<data-man> @Vindaar: The example from https://nim-lang.org/blog/2018/03/01/version-0180-released.html compiles for you?
13:10:39mrRobot_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:23mrRobot_basically, I want to create a nim-based CLI libsodium app, then also use that code to create a Java app
13:11:50Yardanicowhy would you do that? :P you can write everything in Nim :D
13:11:53mrRobot_truly taking the "write once, run anywhere" to the extremes here haha
13:12:50mrRobot_Yardanico, I know, but at some point I may need a GUI, which I can write in Swing or some other language :)
13:12:59Calinouhave you looked at Kotlin by the way?
13:13:01Calinouout of curiosity
13:13:12*yglukhov[i] joined #nim
13:13:14mrRobot_yep I know Kotlin very well
13:14:19mrRobot_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:05Calinouyeah, I understand
13:15:11CalinouI'm porting a Node.js CLI app to Nim for the same reason
13:15:38mrRobot_oh really, how's it going for you so far?
13:15:39Calinou(static typing and small binaries are nice to have too)
13:15:51mrRobot_yeah the small binaries really appealed to me
13:15:56Calinouit's going alright :) I just got color preview to work
13:16:00Calinouhttps://github.com/Calinou/clr
13:16:56mrRobot_looks sweet my dude!!
13:18:09Calinouoriginal Node.js app is here, https://github.com/Calinou/colour-cli
13:19:12mrRobot_have you measured the startup times in the nodejs app?
13:19:39Calinouyeah
13:19:43mrRobot_I can imagine it being slow
13:20:00Calinou<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:00Calinou<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:07mrRobot_I've done React and Vue apps and sometimes the compilations take ages
13:20:13Calinouthe CLI framework I use in Node.js (Caporal) is known to be slow, which doesn't help
13:20:22Calinouit's very nice to use, but it comes at a cost
13:20:29CalinouI use docopt in Nim, which is much more barebones
13:20:40Calinou(but it's probably enough for my use cases)
13:20:55mrRobot_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:13Calinou(I'm using an i7-6700K + a SSD by the way)
13:21:21mrRobot_40MB and 168ms to start down to 0.9ms?!?!
13:21:25Calinouwhich is much faster than the average PC out there
13:21:27Calinouyeah
13:21:40mrRobot_holy sweet potato
13:21:58zacharycarter[m]hrm work on web dev stuff or game stuff today
13:21:58zacharycarter[m]decisions decisions....
13:22:12Calinoumost static languages can deliver really good performance for CLI apps
13:22:20CalinouI wrote a CLI app in Go, it was very fast to start up too
13:22:33mrRobot_you ever tried to write a kotlin/java CLI app?
13:24:31FromGitter<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:32zacharycarter[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:35zacharycarter[m]also - I'm using Nim in my current web project and compilation can still take a while - especially bundling
13:26:49zacharycarter[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:17zacharycarter[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:34zacharycarter[m]and Parcel is supposedly faster anyway - although I have yet to see any real benchmarks
13:27:57zacharycarter[m]NodeJS sucks for plenty of other reasons though
13:28:24FromGitter<kaushalmodi> @data-man dom96: You missed the later posts. True color is working fine as I and @Vindaar later showed.
13:30:03mrRobot_zacharycarter, thanks for the info
13:30:20mrRobot_yeah webpack is crazy
13:31:54zacharycarter[m]np
13:31:56mrRobot_also not really sure how portable clojure is
13:32:24zacharycarter[m]well traditionally it runs on the JVM - so anywhere the JVM is running
13:32:40zacharycarter[m]but this example shows how to use GraalVM to speed up start up time of Clojure apps
13:32:46zacharycarter[m]GraalVM != JVM
13:32:53zacharycarter[m]https://www.graalvm.org/
13:34:02mrRobot_cool I'll look into Graal too :)
13:34:47FromGitter<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:02zacharycarter[m]:thumbsup:
13:35:12zacharycarter[m]πŸ‘
13:35:15zacharycarter[m]stupid riot
13:35:36FromGitter<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:28livcdzacharycarter[m]: mrRobot_: graal and the ecosystem around it is very promising
13:36:29CalinoumrRobot_: I've never used Kotlin, no chance to use it :(
13:36:36CalinouI wrote some Java for an university course but that's it
13:37:02FromGitter<kaushalmodi> Wait, that example is using `int` as variable name?
13:37:17zacharycarter[m]Kotlin > Java for sure
13:37:22zacharycarter[m]Java is turrible
13:37:27FromGitter<kaushalmodi> ``````
13:37:47zacharycarter[m]I stay as far away from the JVM as possible in general though
13:38:33Calinouyeah, Kotlin definitely seems more terse
13:39:12*Ven`` quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:39:40dom96mrRobot_: 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:43dom96That's how I'd do it
13:42:43mrRobot_awesome
13:48:23mrRobot_thanks for all the info people, I'll soon be starting my journey with nim, cheers!! :)
13:50:03FromGitter<mratsim> @mrRobot_ can’t you just use the JNI with libsodium C?
13:50:41zacharycarter[m]for android?
13:50:52zacharycarter[m]JNI is awful dude
13:50:58zacharycarter[m]I mean it works once you get it working
13:51:03zacharycarter[m]but have fun getting from A -> B
13:51:14zacharycarter[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:33zacharycarter[m]and I was using other shared libs - bgfx and others
13:52:38zacharycarter[m]https://github.com/fragworks/frag-android
13:52:49mrRobot_mratsim: I've done that but the startup time and bundling the JDK into a portable format is heavyweight
13:53:43mrRobot_Yeah plus the JNI experience on Android is real bad
13:53:52mrRobot_I actually had to use JNA because it was that bad
13:54:59mrRobot_so now I'm moving onto greener fields and trying out nim
13:58:30*Perkol joined #nim
13:59:00Perkoliterator walkDirRec(dir: string; yieldFilter = {pcFile}; followFilter = {pcDir}): string {..} How do I pass yieldFilter to it?
13:59:49dom96yieldFilter = {...}?
14:00:43Perkolfor file in walkDirRec "c:\\Dev\\1", yieldFilter = {pcDir}: ?
14:02:41*ieatnerd1 joined #nim
14:08:15dom96for file in walkDirRec("c:\\Dev\\1", yieldFilter = {pcDir}):
14:08:35dom96or just walkDirRec("...", {pcDir})
14:10:24*cspar_ quit (Ping timeout: 244 seconds)
14:18:04FromGitter<Vindaar> @miran: hacked something together (can probably be improved a lot though, hehe): https://gist.github.com/Vindaar/e803d2e5705febd8de018821fbeb7f6b
14:18:32FromGitter<Vindaar> And of course it can only deal with enums without specific values :D
14:20:12miran@Vindaar this is the first time someone named his type by me. watch out mr. Boolean, here i come!
14:20:27FromGitter<Vindaar> hahaha :D
14:22:28FromGitter<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:11Yardanicocompile to x32 on centos 7 image in docker or statically link with musl/ulibc
14:24:20ieatnerd1Hey, 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:07FromGitter<Vindaar> ieatnerd1: how do you know when one string ends?
14:25:17FromGitter<viniarck> Thanks @Yardanico. This wouldn't work for OSX though, would it? I also want to ship a binary for OSX users
14:26:19FromGitter<mratsim> I think you can use Travis to build the binaries after CI is successful
14:27:13ieatnerd1a single char needs to be a single string, not putting multiple chars into a string.
14:27:21FromGitter<viniarck> Sounds like a great option.
14:27:31FromGitter<Vindaar> ah, that's what you mean
14:28:18ieatnerd1yeah. 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:25FromGitter<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:41dom96ieatnerd: $char
14:29:22FromGitter<mratsim> no but you can start by combining Travis build artifacts: https://docs.travis-ci.com/user/uploading-artifacts/
14:29:45FromGitter<mratsim> with Travis config for Nim: https://github.com/mratsim/Arraymancer/blob/master/.travis.yml
14:29:53FromGitter<viniarck> Right on. I'll explore that. Thanks for pointing that out.
14:29:53FromGitter<mratsim> ^ for stable
14:29:58FromGitter<viniarck> Cool
14:29:59FromGitter<Vindaar> ieatnerd1: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b5343679ddf5f4aadfc98ef]
14:30:17FromGitter<mratsim> for devel on OSX and devel with docker on Linux: https://github.com/status-im/nimbus/blob/master/.travis.yml
14:30:29FromGitter<viniarck> Awesome. Thanks again.
14:33:50FromGitter<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:10mirani 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:54FromGitter<tim-st> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b53484ec579673e6b86389a]
14:51:00FromGitter<tim-st> does the var line copy?
14:51:23FromGitter<Vindaar> miran: are you sure it's not the rest of the code? seems to work fine for me
14:52:01FromGitter<Vindaar> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b534891f02a0977a3eea860]
14:52:17miranargh, of course it is, i'm stupid
14:55:37FromGitter<tim-st> solved my question, I used var type now as param
14:57:28Calinou@viniarck 32-bit x86 is barely used anymore on Linux, and it hasn't been supported by Apple for years on macOS
14:57:29ieatnerd1Dom, if youre still there I wanted to say thanks. I got it all to work eventually.
14:57:37*riidom joined #nim
14:57:49Calinouit's nice to provide ARMv7 and ARMv8 binaries for ARM SBC users though (such as Raspberry Pi)
14:58:04Calinou(that is, for Linux)
14:58:43Calinouwhat about https://pryp.in/blog/22/advanced-uses-of-travis-ci-with-nim.html by the way?
14:59:17Calinouhttps://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:46dom96ieatnerd1: np :)
15:24:28dom96yay, choosenim being used :)
15:24:34dom96I use choosenim in all my travis scripts now too
15:24:53dom96Pro Tip: You can set an env var to pin the version of Nim that choosenim will install
15:25:10dom96you should also really cache ~/.nimble and ~/.choosenim
15:25:22dom96https://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:20FromGitter<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:36FromGitter<viniarck> Thanks @dom96.
15:41:47*Ven`` joined #nim
15:42:21*yglukhov[i] joined #nim
15:42:49FromGitter<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:01dom96Come on guys, not far off 600 responses now: https://goo.gl/forms/t2gWWBEDC1walw6s2. We can get there!
16:13:17FromGitter<Quelklef> Why is it "extreme like" and "really dislike"?
16:13:21FromGitter<Quelklef> seems unequal
16:15:18*yglukhov[i] joined #nim
16:16:00*BitPuffin joined #nim
16:18:33FromGitter<viniarck> @dom96, just retweeted on twitter too this form, hope that helps. 600 is the minimum responses this survey is aiming at?
16:19:08dom96we got 600 last year, so I wanna beat it
16:19:14mirandom96: any success with posting it on reddit/HN/lobsters?
16:19:40FromGitter<viniarck> I see. Yep. Way to go!
16:19:42miran(and i don't mean r/nim, but something more general like r/programming)
16:19:52dom96nope :/
16:20:35FromGitter<mratsim> r/programminglanguage?
16:21:05FromGitter<mratsim> I discovered it yesterday, the community is very much into super obscure language, Nim could actually be a mainstream language there
16:22:54FromGitter<mratsim> I mean obscure like: Inko, Plasma, Dashrep, Felix, Egison, ….
16:23:01dom96Feel free to submit it wherever
16:29:06FromGitter<tim-st> When I use `Positive` instead of `int` compiler says it cannot prove that my result is initialized?!
16:29:46FromGitter<tim-st> Positive as a generics type
16:30:43FromGitter<mratsim> because by default initialization is at binary 0
16:30:57FromGitter<tim-st> it's `static[Positive]`
16:31:00FromGitter<mratsim> but binary 0 (i.e. plain 0 for int) is not part of Positive range
16:31:18FromGitter<mratsim> in those case the compiler always throws that warning
16:31:24FromGitter<tim-st> but why?
16:31:50FromGitter<mratsim> i think it’s because no one fixed this bug
16:32:03FromGitter<tim-st> ok
16:32:23FromGitter<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:36zacharycarter[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:50zacharycarter[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:01FromGitter<Quelklef> What's your use-case
16:43:04FromGitter<Quelklef> Can you do:
16:43:25FromGitter<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:39zacharycarter[m]with
16:44:10zacharycarter[m]```
16:44:10zacharycarter[m]proc getTicks(): Ticks {.inline.} =
16:44:11zacharycarter[m] result = Ticks(clock_gettime(CLOCK_MONOTONIC))
16:44:27zacharycarter[m]okay thanks
16:44:39FromGitter<tim-st> I cannot get `system.readChars*(f: File, a: var openArray[char], start, len: Natural): int` working, it returns always `0` :(
16:44:39FromGitter<Quelklef> Wait, that's not gonna work cause it's in system
16:44:44dom96Quelklef: You can start out by asking on the forum if you wish :)
16:44:48FromGitter<Quelklef> oh no it isn't, just kidding
16:44:50FromGitter<Quelklef> good luck
16:45:06FromGitter<Quelklef> @dom96 okay, will do
16:45:13zacharycarter[m]although damn I'm not importing timers - I'm importing times
16:45:18zacharycarter[m]yeah :/
16:45:58dom96zacharycarter[m]: Duplicates time(r)s.nim in your project
16:46:02dom96*Duplicate
16:46:37zacharycarter[m]thanks!
16:47:25FromGitter<Varriount> zacharycarter: patchFile might work
16:49:11zacharycarter[m]ah - wasn't aware of that - thanks! that's awesome!
16:55:13FromGitter<mratsim> @dom96 published: https://www.reddit.com/r/ProgrammingLanguages/comments/90qp1k/nim_language_community_survey/
16:55:46dom96"[Removed]"
16:56:34FromGitter<mratsim> are you talking to me?
16:56:47dom96Yes, refresh your link
16:57:24FromGitter<mratsim> it works for me :?
16:57:59dom96try it in a private tab?
16:58:08zacharycarter[m]worked perfect
16:58:16zacharycarter[m]thanks Varriount and dom96
16:58:41FromGitter<mratsim> ah right, strange
16:59:27FromGitter<mratsim> maybe under moderation?
17:00:08dom96perhaps
17:00:34FromGitter<mratsim> or I took 5 min to write the post and didn’t post it until 20 min after so
17:06:33FromGitter<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:57FromGitter<mratsim> rejoice @miran: https://github.com/nim-lang/Nim/pull/8383
17:15:11*yglukhov[i] joined #nim
17:15:17FromGitter<Varriount> zacharycarter: Which technique did you end up going with?
17:16:41copygirlHey 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:09FromGitter<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:27copygirlAlso 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:34FromGitter<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:19copygirlI'm not entirely sure how to all approach this. My question is likely too generic to really get an answer.
17:22:35zacharycarter[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:08FromGitter<mratsim> just make a PR no? we can discuss on both anyway
17:23:24zacharycarter[m]πŸ‘
17:24:30copygirlMhh.. 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:53FromGitter<mratsim> ah it’s for users.
17:25:17zacharycarter[m]https://github.com/nim-lang/Nim/pull/8389
17:25:30copygirlWell, "user-developers", ideally.
17:28:51FromGitter<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:22copygirlThe 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:14zacharycarter[m]plugin architecture?
17:30:17zacharycarter[m]like hot reloading shared libs?
17:30:21FromGitter<mratsim> would there be a json config file for example that will track name, version, author and things like that?
17:30:26copygirlRecompile necessary.
17:30:36zacharycarter[m]oh
17:30:45copygirlSo I don't think plugins in that sense.
17:31:10FromGitter<barcharcraz> I would recomend just requireing an import someplace
17:31:35FromGitter<barcharcraz> that said you can do it (you can do anything using slurp and gorge tbh)
17:31:47FromGitter<mratsim> yeah, have a file modules.nim, require users to drop their module and add a line to modules.nim
17:32:04FromGitter<barcharcraz> a more principled framework for slurp/gorge based compiler plugins would be kinda nice though
17:32:15FromGitter<mratsim> once done we can think of a more automated solution.
17:32:49copygirlWhat are slurp / gorge?
17:32:51FromGitter<barcharcraz> works essentially like rust's new proc macros (except the code has to actually parse, which sucks)
17:32:58FromGitter<barcharcraz> static_read and static_exec
17:33:01FromGitter<mratsim> slurp= staticRead, gorge = staticExec
17:33:32copygirlWhere did those nicknames come from?
17:33:40FromGitter<barcharcraz> araq I think
17:33:53AraqPerl
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:57copygirlMhh.. this is one of the things I'm looking forward to JAI for.
17:39:03*ieatnerd1 quit (Ping timeout: 256 seconds)
17:40:00copygirlI suppose I could write a build script that edits the right source files.
17:40:20copygirlAnd for other questions I have I guess I need to dig in deeper first.
17:42:32*Perkol quit (Quit: Leaving)
17:47:11Calinoudom96: choosenim works nicely here, thanks for this tool :)
17:47:38*yglukhov[i] joined #nim
17:47:52dom96Glad you like it :)
17:48:10*NimBot joined #nim
17:52:05*yglukhov[i] quit (Ping timeout: 240 seconds)
18:33:46Calinouhttps://github.com/tldr-pages/tldr/pull/2207 has been merged :D
18:33:52CalinouI'll submit pages for nimble and choosenim soon
18:34:29*dddddd joined #nim
18:37:31dom96Nice :D
18:38:32FromGitter<viniarck> Sweet.
18:40:16FromGitter<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:09FromGitter<tim-st> *complete file data
18:49:40FromGitter<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:13FromGitter<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:23FromGitter<barcharcraz> they should be quite similar
19:00:03FromGitter<tim-st> in the docs `newString` contains the word uninitialized and newStringOfCap doesnt
19:00:30FromGitter<barcharcraz> I bet the only difference is that newStringOfCap sets the length to zero, where newString sets it to x
19:00:46FromGitter<tim-st> yes, that was my guess too, maybe someone knows
19:01:11FromGitter<barcharcraz> a shame that it's a magic
19:01:23FromGitter<tim-st> yes^^
19:02:21FromGitter<tim-st> I found them hidden in `sysstr.nim` as `rawNewStringNoInit`
19:04:45FromGitter<tim-st> @barcharcraz you were correct; but I've seen they both initialize
19:05:01FromGitter<tim-st> although the same proc exists without initalizing, hm...
19:06:21FromGitter<tim-st> ah, maybe the uninitalized is only called if I add the pragma, but if so then the docs arent correct
19:10:19FromGitter<tim-st> I think this should be changed, to always be uninitalized
19:12:37*Vladar quit (Quit: Leaving)
19:16:56FromDiscord<exelotl> how do nim's method dispatch trees perform when you have a wide and shallow object hierarchy?
19:17:30FromDiscord<exelotl> like 100 different entity types all inheriting from 1 base entity
19:22:10*ieatnerd1 quit (Ping timeout: 268 seconds)
19:23:19Calinouzacharycarter[m]: :o https://github.com/nathan/pax
19:23:31Calinouwe were talking about bundlers today :P
19:31:10*Jesin joined #nim
19:32:42Araqexelotl: they suck for everything, hardware advanced to the point where an indirect call is much better than what Nim does.
19:33:15Araqat least they can be inlined though...
19:33:51Araqwe 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:44Calinouis there a data structure akin to dictionaries in Nim?
19:45:57FromGitter<Quelklef> Tables
19:46:12Calinouoh, it's in a module
19:46:18Calinouthat's why I didn't really find any infos about them in the manual
19:47:02FromDiscord<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:02FromDiscord<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:43FromDiscord<exelotl> but I could imagine it being slower than multi-methods are currently
19:58:12Demos[m]weren't they plans to have a seperate vtable like functionality
19:58:13Demos[m]like rust's trait objects
20:02:36Calinouhttps://nim-lang.org/docs/tables.html#pairs.i,Table[A,B]
20:02:47*nsf joined #nim
20:02:57Calinouis it just me, or fetching the values is possible but undocumented?
20:03:07CalinouI had to use `echo` in a for loop to determine the fields :P
20:03:21Calinou.val[0] accesses the key, and .val[1] accesses the value
20:05:05Araqit's just you, tuples are documented, but not every stdlib routine that uses tuples, do document tuples.
20:05:38Araqit's called a "language vs library distinction"
20:05:40Calinouright
20:06:38AraqDemos[m]: they got chancelled/delayed.
20:07:03Araq*cancel
20:07:13Demos[m]oh, that's too bad
20:07:56Demos[m]it's good to combat the feature creep and push 1.0 though
20:08:00Araqexeltotl: 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:11FromDiscord<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:31FromGitter<rayman22201> @dom96. You and I need to have ourselves a classic forum debate war! :-P
20:09:09FromGitter<rayman22201> @awr. I made made a macro for you last night: https://gist.github.com/rayman22201/0675507877c0edd11c32fbcfa1e65482
20:09:44FromDiscord<awr> yeah i've been meaning to look
20:09:45FromDiscord<awr> good work
20:09:58FromDiscord<awr> i imagine it doesn't work with anon procs though right
20:10:02dom96rayman22201: Does that involve lots of GIFs? :D
20:10:29FromGitter<rayman22201> @awr It does indeed work with anonymous procs. Check out the second example at the bottom of the gist
20:11:00FromGitter<rayman22201> @dom96 It can if you like :-P (Deploying troll cannons!)
20:11:04Calinouhttps://i.imgur.com/kKZRF03.png
20:11:06Calinoubase functionality is done :D
20:11:17FromGitter<rayman22201> pretty!
20:11:18Calinou(Node.js on top, Nim on the bottom)
20:12:01dom96Calinou: Needs more symmetry
20:12:02FromGitter<rayman22201> I'm sad about the Node.js part :-P
20:12:03CalinouI had mistakenly labeled the HSL value as HSV in the Node.js app, I fixed that in Nim
20:12:29Calinou(and added an HSV display, as some apps still prefer HSV today)
20:14:11FromDiscord<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:52FromGitter<rayman22201> yes
20:20:16Araqawr: what is a pattern in the compiler that I sometimes use:
20:20:37Araqproc foo(context; n; args) =
20:20:48Araq template rec(n) = foo(context, n, args)
20:20:57Araq for c in n: rec(c)
20:21:12Araq1 local template that doesn't just "recurse"
20:21:35Araqit captures the point of the recursion, only what changes in the recursion stays a parameter
20:22:37Araqand that's much better than your 'recur' keyword, IMO.
20:24:15FromGitter<rayman22201> Araq your was is definitely more efficient. It's almost like unrolling the recursion into a procedural loop.
20:24:35FromGitter<rayman22201> not almost, it is. I think
20:25:18Araqhmm, 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:11FromGitter<rayman22201> OH, I see. nvm then.
20:27:26Araqanyway, 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:58FromGitter<rayman22201> lol, well that was @Quelklef's question.
20:29:35FromGitter<rayman22201> I was always on the side of keeping it on a per-proc basis.
20:29:54FromGitter<rayman22201> He wanted to whole-sale enable it for the entire file
20:30:04FromGitter<Quelklef> yes indeed
20:30:11FromGitter<rayman22201> Hi @Quelklef
20:30:14FromGitter<Quelklef> howdy
20:31:31Araqabout 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:04FromGitter<rayman22201> lol. That is kind of what my macro is doing
20:43:10*miran_ is now known as miran
20:43:20FromGitter<rayman22201> takes the function and passes it to itself
20:43:26FromGitter<rayman22201> via wrapper
20:44:23FromGitter<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:09FromGitter<rayman22201> but If I were to have gifs, this one is my first choice: https://gph.is/Vxc2Q6 ;-)
20:51:56Calinouhow can I wrap a long list of `if … or` checks?
20:56:17Araqafter the 'or'
20:57:07Calinouthat works, thanks :)
20:57:17CalinouI'm more used to putting the "or" at the beginning of the line, not at the end
20:58:25Calinoudo you generally use 4 spaces instead of 2 for continuation indents in Nim?
21:01:53FromGitter<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:50FromGitter<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:36FromGitter<kayabaNerve> New question. Why does it require `ref object`?
21:05:33CalinouI just finished implementing all the color conversion commands :)
21:05:45Calinoumy 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:37FromGitter<Quelklef> @kayabaNerve CAn you post code?
21:40:23FromGitter<Varriount> Calinou: It would be neat if you could write a blog post or something detailing your experience.
21:41:43CalinouI don't have a personal blog
21:41:44FromGitter<Varriount> Even if it's just a forum post.
21:42:51FromGitter<rayman22201> Make a guest post on the Nim blog!
21:45:05FromGitter<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:39Calinoualso, docopt doesn't let me use negative numbers as positional arguments, it seems
22:14:49Calinou(it probably thinks those numbers are arguments)
22:56:11FromGitter<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:30FromGitter<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:09FromGitter<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