Re: What's happening with destructors?

2017-11-12 Thread Udiknedormin
@mratsim Well, if you call GC_collect manually then it's much worse than manual allocation and deallocation from memory pool, I guess. Could you explain further what getOccupiedMem changes in the case we were talking about (ref to ptr to memory external to thread heap)?

Re: What's happening with destructors?

2017-11-12 Thread Udiknedormin
Well, you said "today you can do" as a general advice so I assumed you try to show us "how simple it is to do it by hand", not "how easy it is to make sth only for internal usage". About this object being a ref one --- no, please read my comment again. Long story short: ref object can be

Re: What's happening with destructors?

2017-11-10 Thread mratsim
dataRef to have the deallocation of the data managed by Nim GC. data for normal use through foo[10] (thanks to UncheckedArray). Yes data is public because in my use case this is only used internally, and getter/setter would just add boilerplate for no gain. Same thing for len. Regarding copy,

Re: What's happening with destructors?

2017-11-10 Thread Udiknedormin
@mtrasim I've already said it's a bad idea (even on many architectures on which it's possible). And even if you don't really have a heap, it doesn't mean you couldn't use dynamic memory if a language supports custom allocators. You can provide a memory pool on a stack, that's what I actually

Re: What's happening with destructors?

2017-11-09 Thread mratsim
Many microcontroller only have a stack so you just can't use heap . Also @Varriount, @Udiknedormin today you can do: type SharedArray[T] = object dataRef: ref[ptr T] data*: ptr UncheckedArray[T] len*: int proc deallocSharedArray[T](dataRef:

Re: What's happening with destructors?

2017-11-09 Thread Udiknedormin
@Varriount It doesn't? I was pretty sure there was something called shared heap... Well, whatever. I think GC is much better for functional languages, RAI seems better for stateful ones. Oh, by the way --- I didn't really try it, but I guess idiomatic Nim programs could bring problmes on some

Re: What's happening with destructors?

2017-11-09 Thread Varriount
@Udiknedorm: The biggest problem with the current GC is that it doesn't support shared memory (though, I don't know why we can't do something like Go's channels). To me, these changes seem like an effort to reasonably support programs that don't want to rely on the GC.

Re: What's happening with destructors?

2017-11-07 Thread Udiknedormin
@bpr Not in the core (or std, I guess, but's more realistic). But I never said I was talking about the core. @rayman22201 I was referring to a GC library for Rust. I can see @mratsim already mentioned one example (there are more, if my memory serves me well). There are two main reasons for it

Re: What's happening with destructors?

2017-11-07 Thread mratsim
It automatically [frees unreachable memory](https://aturon.github.io/blog/2015/08/27/epoch/#freeing-memory) for you and [collect garbage (thread-safely)](https://aturon.github.io/blog/2015/08/27/epoch/#managing-garbage) so you know the saying, if it quacks like a duck though the canonical

Re: What's happening with destructors?

2017-11-07 Thread Araq
@mratsim Very interesting read, but that's not a GC?

Re: What's happening with destructors?

2017-11-06 Thread mratsim
@Araq, What are your thoughts about [epoch-based GC](https://aturon.github.io/blog/2015/08/27/epoch/) as crossbeam is doing for Rust to build a library of lock-free data structures

Re: What's happening with destructors?

2017-11-05 Thread Araq
> I'm not understanding, are you saying that destructors and move semantics are > the resource management of Nim in the future? If so, what happens to the > tracing GC, regions, and all that? If not, I don't know which uniform > solution you are proposing. Yes, that's what I am saying for the

Re: What's happening with destructors?

2017-11-05 Thread bpr
@Udiknedormin Rust has absolutely no tracing GC at all. @Araq I'm not understanding, are you saying that destructors and move semantics are the resource management of Nim in the future? If so, what happens to the tracing GC, regions, and all that? If not, I don't know which uniform solution

Re: What's happening with destructors?

2017-11-05 Thread Araq
> I remember you always saying people who want to limit GC usage just don't get > it and it'll be fast anyway so why bother. Of course destructors have > advantages of their own (like deterministic freeing you mentioned) but if you > say Nim's GC is so blazingly fast (I don't doubt it, I just

Re: What's happening with destructors?

2017-11-05 Thread Udiknedormin
@rayman22201 As far as I know, destructors can be slower in no-single-ownership environments. That's why some languages (e.x. Rust) do the opposite of what Nim is doing now --- they introduce optional GC for cases when it's useful / more natural. @Araq > Destructors, assignment operators, the

Re: What's happening with destructors?

2017-10-27 Thread Araq
> Specifically your post on write tracking. It's obviously a really old post > (from 2013), and it looks like it was never fully implemented. It was implemented and produced impressive results. It makes Nim's effect system even more complex though and doesn't help much with destructors: It only

Re: What's happening with destructors?

2017-10-27 Thread rayman22201
@Araq, I found your earlier blog posts after reading the newest one. (those should really be more visible btw! they are very interesting!) Specifically your post on write tracking. It's obviously a really old post (from 2013), and it looks like it was never fully implemented. What happened

Re: What's happening with destructors?

2017-10-22 Thread Araq
More thorough tests are required but theoretically speaking the determinism can cost cycles. Most modern GCs do not emit write barriers for stack slots (this is true for Nim's GC too) but C++ like overloaded assignments/moves do not distinguish between stack slots and heap slots... The

Re: What's happening with destructors?

2017-10-21 Thread adrianv
@rayman22201 what I have seen is, that each proc that has a var of a type which is handled by a destructor needs a hidden try finally block (currently even if the var is not used). This can be a big overhead for small routines. The c target needs setjump/longjump which is a big overhead. The

Re: What's happening with destructors?

2017-10-21 Thread monster
@Araq I wanted to "show my appreciation" for this new development, but BoutySource doesn't let me leave a comment. I'm "skunkiferous" there; I think "monster" was already taken...

Re: What's happening with destructors?

2017-10-21 Thread rayman22201
@araq, I missed the live stream, but watched the recording on youtube. Thank you for taking the time to do the presentation! Very awesome. > The really hard part is replacing the existing runtime with one with a > different performance profile ("yay, deterministic freeing, yay more >

Re: What's happening with destructors?

2017-10-20 Thread bpr
Thanks @Araq! I'll watch the livestream later. Is the doc on regions now obsolete? It would seem that destructors now obviate much of the need for regions.

Re: What's happening with destructors?

2017-10-20 Thread Araq
Ok, blog post is here: [https://nim-lang.org/araq/destructors.html](https://nim-lang.org/araq/destructors.html) I will copy the "spec worthy" parts that have been implemented already into a wiki page.

Re: What's happening with destructors?

2017-10-18 Thread mratsim
It's not a presentation, it's Araq live coding the feature, probably destructors given the number of votes. It's also him who'll do whatever he wants with the video so pick his mind :p.

Re: What's happening with destructors?

2017-10-18 Thread bpr
Looking forward to the blog, and I hope whatever you come up with will not be wrong. Destructors have been a topic for a while. I'm also very interested in seeing where memory regions in Nim go, as per the "Future directions" part of the manual. @mratsim, will this Twitch stream presentation

Re: What's happening with destructors?

2017-10-18 Thread mratsim
Or vote and watch the Twitch stream [http://www.strawpoll.me/14163114](http://www.strawpoll.me/14163114)

Re: What's happening with destructors?

2017-10-18 Thread Araq
The implementation and the spec are developed together and I don't want to say more until I'm sure it's not embarrassingly wrong. But things are starting to look really good, expect a blog post about this in a couple of days.

What's happening with destructors?

2017-10-18 Thread bpr
I just noticed a burst of GitHub commits on "destructors", but I found nothing in the docs. Is there some change coming? How Nim handles destructors (and GC and memory regions, and ...) could be an interesting selling point. C++ and Rust shows that people are interested in no-GC approaches