Re: GC for noobs

2014-02-28 Thread Xavier Bigand
Le 28/02/2014 13:22, Szymon Gatner a écrit : On Friday, 28 February 2014 at 11:43:58 UTC, Dicebot wrote: On Friday, 28 February 2014 at 11:28:01 UTC, Szymon Gatner wrote: I didn't mean "basic" in the sense of "easy" but in the sense of something that has to dealt with all the time / is common r

Re: GC for noobs

2014-02-28 Thread Dicebot
On Friday, 28 February 2014 at 12:52:28 UTC, Szymon Gatner wrote: I'm a C folk and I'm really happy :) +1 C'mon, GC has to be an itch for you mallocers :) Come to the dark side... It sometimes is. In that case we don't use GC. Don't get me wrong - there are issues with current GC enforcem

Re: GC for noobs

2014-02-28 Thread Mike Parker
On 2/28/2014 9:15 PM, Szymon Gatner wrote: So to sum up: C folks are not really happy, C++ folks are not really happy and C# folks are not really happy :P I'm a C folk and I'm really happy :)

Re: GC for noobs

2014-02-28 Thread Szymon Gatner
On Friday, 28 February 2014 at 12:48:47 UTC, Mike Parker wrote: On 2/28/2014 9:15 PM, Szymon Gatner wrote: So to sum up: C folks are not really happy, C++ folks are not really happy and C# folks are not really happy :P I'm a C folk and I'm really happy :) C'mon, GC has to be an itch for

Re: GC for noobs

2014-02-28 Thread Dicebot
On Friday, 28 February 2014 at 12:15:21 UTC, Szymon Gatner wrote: It really is, RAII is the most important idiom in C++, in short no RAII == buggy code. I mean proper C++ not C-with-classes-no-templates-no-exceptions bs. So to sum up: C folks are not really happy, C++ folks are not really hap

Re: GC for noobs

2014-02-28 Thread Szymon Gatner
On Friday, 28 February 2014 at 12:17:22 UTC, Dicebot wrote: On Friday, 28 February 2014 at 12:15:21 UTC, Szymon Gatner wrote: It really is, RAII is the most important idiom in C++, in short no RAII == buggy code. I mean proper C++ not C-with-classes-no-templates-no-exceptions bs. So to sum up

Re: GC for noobs

2014-02-28 Thread Szymon Gatner
On Friday, 28 February 2014 at 11:43:58 UTC, Dicebot wrote: On Friday, 28 February 2014 at 11:28:01 UTC, Szymon Gatner wrote: I didn't mean "basic" in the sense of "easy" but in the sense of something that has to dealt with all the time / is common requirement. Yes, it needs to be dealt with

Re: GC for noobs

2014-02-28 Thread Szymon Gatner
On Friday, 28 February 2014 at 11:54:52 UTC, Mike Parker wrote: On 2/28/2014 8:43 PM, Dicebot wrote: Most problems I have with D data structures come from qualifiers, not from resource management. I really don't understand why this looks that much of a problem. That said, my background very

Re: GC for noobs

2014-02-28 Thread Mike Parker
On 2/28/2014 8:43 PM, Dicebot wrote: Most problems I have with D data structures come from qualifiers, not from resource management. I really don't understand why this looks that much of a problem. That said, my background very influenced by plain C and that results in different habits and expe

Re: GC for noobs

2014-02-28 Thread Dicebot
On Friday, 28 February 2014 at 11:28:01 UTC, Szymon Gatner wrote: I didn't mean "basic" in the sense of "easy" but in the sense of something that has to dealt with all the time / is common requirement. Yes, it needs to be dealt with all the time but in a different ways. Problem is with gettin

Re: GC for noobs

2014-02-28 Thread Szymon Gatner
On Friday, 28 February 2014 at 10:44:22 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 18:29:57 UTC, Szymon Gatner wrote: I dig flexibility, I really do, and I appreciate D's features that enable that, but in case of such basic thing as a resource management, I just want things to work wi

Re: GC for noobs

2014-02-28 Thread Namespace
On Friday, 28 February 2014 at 10:45:53 UTC, Regan Heath wrote: On Thu, 27 Feb 2014 18:29:55 -, Szymon Gatner wrote: On Thursday, 27 February 2014 at 18:06:58 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:

Re: GC for noobs

2014-02-28 Thread Regan Heath
On Thu, 27 Feb 2014 18:29:55 -, Szymon Gatner wrote: On Thursday, 27 February 2014 at 18:06:58 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-

Re: GC for noobs

2014-02-28 Thread Dicebot
On Thursday, 27 February 2014 at 18:29:57 UTC, Szymon Gatner wrote: I dig flexibility, I really do, and I appreciate D's features that enable that, but in case of such basic thing as a resource management, I just want things to work without surprises by default. Resource management (including

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:39:48 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;) Or in VC2013, but if you can use Intel compiler then it is bett

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 15:09:39 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and fea

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : h

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;)

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/concurrency.d#L281 (Isolated!T) Priceless for message passin

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 15:56:26 UTC, Remo wrote: On Thursday, 27 February 2014 at 15:39:48 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;) Or

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:58:50 UTC, bearophile wrote: Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amount of D code (perhaps 200_000 lines or more), I still use Python a lo

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:49:48 UTC, Szymon Gatner wrote: You can disable postblit to make entity non-copyable: http://dlang.org/struct.html#StructPostblit How can I then use it as a function return value? Or store in a container? Actually if postblit had a bool param saying that t

Re: GC for noobs

2014-02-27 Thread Dicebot
There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/concurrency.d#L281 (Isolated!T) Priceless for message passing concurrency.

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:15:06 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:58:50 UTC, bearophile wrote: Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amoun

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:41:27 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. For exam

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 16:10:34 UTC, Adam D. Ruppe wrote: On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. st

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. For example in C++ I can create a function that returns a Texture clas

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:09:39 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and fea

Re: GC for noobs

2014-02-27 Thread Adam D. Ruppe
On Thursday, 27 February 2014 at 17:31:57 UTC, Dicebot wrote: Isn't it exactly what Phobos RefCounted does? Yes, though knowing how the implementation works is good for stuff like interfacing with C where you might need different acquire/free/add count/release functions than phobos uses. ht

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 18:06:58 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig :

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:29:05 UTC, Szymon Gatner wrote: Explicit call to init() / terminate() are so C :/ It is much better than C because of `scope(exit) terminate()` though :) Also you can use struct destructors same as in C++ Worst part is there is no even standard shared/weak

Re: GC for noobs

2014-02-27 Thread John Colvin
On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe

Re: GC for noobs

2014-02-27 Thread bearophile
Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amount of D code (perhaps 200_000 lines or more), I still use Python a lot, etc. Bye, bearophile

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 16:10:34 UTC, Adam D. Ruppe wrote: struct RefCountingStruct { private struct Impl { // implementation here int refcount; } Impl* payload; alias payload this; Isn't it exactly what Phobos RefCounted does?

Re: GC for noobs

2014-02-27 Thread Adam D. Ruppe
On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. struct MovingStruct { @disable this(this); typeof(this) release

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:18:47 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 14:14:43 UTC, Namespace wrote: Why not? Overhead? No RAII support? Simply no reason to use classes, structs have all features I need for cases when polymorphism is not necessary (95%+). Being value

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else i

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:14:43 UTC, Namespace wrote: Why not? Overhead? No RAII support? Simply no reason to use classes, structs have all features I need for cases when polymorphism is not necessary (95%+). Being value type is also convenient as it leaves more control to the prog

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 13:44:11 UTC, Namespace wrote: On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via inte

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 14:12:58 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:44:11 UTC, Namespace wrote: On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all th

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else i

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else in my personal code.

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 13:07:37 UTC, Mike Parker wrote: On 2/27/2014 9:25 PM, Szymon Gatner wrote: This is just an example but I would think that it is something rather important to have... What about child objects un-registering themselves in d-tors from a list that parent object

Re: GC for noobs

2014-02-27 Thread Mike Parker
On 2/27/2014 10:00 PM, Szymon Gatner wrote: Still, this feels like working around a language issue, if c-tor order is defined why d-tor isn't? I am ok with non-deterministic time of execution of d-tors/finalizers but not-having parent-child d-tor order defined? That is weird. I've never seen

Re: GC for noobs

2014-02-27 Thread Mike Parker
On 2/27/2014 9:25 PM, Szymon Gatner wrote: This is just an example but I would think that it is something rather important to have... What about child objects un-registering themselves in d-tors from a list that parent object holds and parent is destroyed first? What about asynchronous completi

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 13:04:17 UTC, Namespace wrote: I use this solution especially because I have to finalize the data before I call SDL_Quit. And therefore I cannot trust the non-deterministic execution of the Dtor. I fully understand that ;) I will take a look at DGame too for

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 12:32:36 UTC, Namespace wrote: On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 13:00:27 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 12:32:36 UTC, Namespace wrote: On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better.

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile In my specific example I am creating OpenGL Rend

Re: GC for noobs

2014-02-27 Thread bearophile
Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 10:40:15 UTC, Tobias Pankrath wrote: Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory manage

Re: GC for noobs

2014-02-27 Thread Tobias Pankrath
Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory management environments would give more and not less guarantees. Anyway, I

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 09:57:51 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:55:14 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the

Re: GC for noobs

2014-02-27 Thread Tobias Pankrath
On Thursday, 27 February 2014 at 09:55:14 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. A

Re: GC for noobs

2014-02-27 Thread Tobias Pankrath
On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. Adding destroy() calls in parent d-tors helped with some of crashes but

GC for noobs

2014-02-27 Thread Szymon Gatner
Hi, I am evaluating D for future projects and coming from C++ I find it really hard to understand semantics of destruction of GC-managed code. After many application-shutdown crashes caused by invalid order of class destructor calls I really think I need to change the way I am thinking abou