Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-14 Thread Kagamin via Digitalmars-d
On Saturday, 13 September 2014 at 21:46:45 UTC, Andrei Alexandrescu wrote: No, it's all eager copy. std::string is thoroughly botched. A good inexpensive lesson for us. -- Andrei I mean possible lifetime management options are: 1. string 2. string* 3. shared_ptrstring 4. weak_ptrstring 5.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-14 Thread Paulo Pinto via Digitalmars-d
Am 14.09.2014 10:27, schrieb Kagamin: On Saturday, 13 September 2014 at 21:46:45 UTC, Andrei Alexandrescu wrote: No, it's all eager copy. std::string is thoroughly botched. A good inexpensive lesson for us. -- Andrei I mean possible lifetime management options are: 1. string 2. string* 3.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-14 Thread po via Digitalmars-d
I mean possible lifetime management options are: 1. string 2. string* 3. shared_ptrstring 4. weak_ptrstring 5. unshared_ptrstring (not interlocked; does something like this exist?) This way string is just like any other object. It's C++ after all, the foot must be shot. Exactly, you can

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-14 Thread Paulo Pinto via Digitalmars-d
Am 14.09.2014 16:19, schrieb po: ... 6. string::c_str() (let char* botch string internals) It returns a const char* so you would have to cast const away to do that-- Which everyone does all the time, because the main reason c_str() exists is to interface with C style APIs, most of them

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-14 Thread Andrei Alexandrescu via Digitalmars-d
On 9/14/14, 1:27 AM, Kagamin wrote: On Saturday, 13 September 2014 at 21:46:45 UTC, Andrei Alexandrescu wrote: No, it's all eager copy. std::string is thoroughly botched. A good inexpensive lesson for us. -- Andrei I mean possible lifetime management options are: 1. string 2. string* 3.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread po via Digitalmars-d
Smart pointers are rarely used, most C++ stuff is done by value. Strings too? Two string types are used. -std::string type: by value, has smaller buffer optimization, used at startup/logging, and for any dynamic strings with unbounded possible values -immutable string handles: by value.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread Kagamin via Digitalmars-d
On Saturday, 13 September 2014 at 12:05:59 UTC, po wrote: Smart pointers are rarely used, most C++ stuff is done by value. Strings too? Two string types are used. -std::string type: by value, has smaller buffer optimization, used at startup/logging, and for any dynamic strings with

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread po via Digitalmars-d
Are you sure? From basic_string.h: _CharT* _M_refcopy() throw() { #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__builtin_expect(this != _S_empty_rep(), false)) #endif __gnu_cxx::__atomic_add_dispatch(this-_M_refcount, 1); return

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread Andrei Alexandrescu via Digitalmars-d
On 9/13/14, 9:13 AM, Kagamin wrote: On Saturday, 13 September 2014 at 12:05:59 UTC, po wrote: Smart pointers are rarely used, most C++ stuff is done by value. Strings too? Two string types are used. -std::string type: by value, has smaller buffer optimization, used at startup/logging, and

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread deadalnix via Digitalmars-d
On Saturday, 13 September 2014 at 19:34:10 UTC, Andrei Alexandrescu wrote: C++11 makes all refcounting implementations of std::string illegal. -- Andrei #facepalm

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread Kagamin via Digitalmars-d
On Saturday, 13 September 2014 at 19:34:10 UTC, Andrei Alexandrescu wrote: C++11 makes all refcounting implementations of std::string illegal. -- Andrei Ah, so lifetime management can be rolled on top of string if needed? Hmm... makes sense.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-13 Thread Andrei Alexandrescu via Digitalmars-d
Kagamin s...@here.lot wrote: On Saturday, 13 September 2014 at 19:34:10 UTC, Andrei Alexandrescu wrote: C++11 makes all refcounting implementations of std::string illegal. -- Andrei Ah, so lifetime management can be rolled on top of string if needed? Hmm... makes sense. No, it's all

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Jacob Carlborg via Digitalmars-d
On 11/09/14 21:02, eles wrote: Could you provide one or two short but illustrative examples in Tango and Phobos showing the howto and the why not in Phobos? Tango: import tango.text.Unicode; void foo () { char[3] result; // pre-allocate buffer on the stack auto b =

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Daniel Kozak via Digitalmars-d
V Fri, 12 Sep 2014 08:47:55 +0200 Jacob Carlborg via Digitalmars-d digitalmars-d@puremagic.com napsáno: On 11/09/14 21:02, eles wrote: Could you provide one or two short but illustrative examples in Tango and Phobos showing the howto and the why not in Phobos? Tango: import

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Thursday, 11 September 2014 at 19:56:17 UTC, Paulo Pinto wrote: Am 11.09.2014 20:32, schrieb Daniel Alves: It is incredible how Objective-C's ARC became a symbol for reference counting, instead of the living proof of Apple's failure to produce a working GC for Objective-C that didn't

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Thursday, 11 September 2014 at 20:11:45 UTC, deadalnix wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: - Other memory management technique require bookkeeping. In a multicore environment, that mean expensive synchronization. It is also true that when you

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Friday, 12 September 2014 at 06:47:56 UTC, Jacob Carlborg wrote: On 11/09/14 21:02, eles wrote: Thank you. Basically, it is about a different interface of the functions, something like the difference between new and placement new. This could be added to Phobos too, through those

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Friday, 12 September 2014 at 07:49:59 UTC, eles wrote: On Thursday, 11 September 2014 at 20:11:45 UTC, deadalnix wrote: - Other memory management technique require bookkeeping. In a multicore environment, that mean expensive synchronization. It is also true that when you start to really

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Friday, 12 September 2014 at 08:27:55 UTC, Dominikus Dittes Scherkl wrote: On Friday, 12 September 2014 at 07:49:59 UTC, eles wrote: On Thursday, 11 September 2014 at 20:11:45 UTC, deadalnix wrote: May be, but this complexity is hidden The old question: at what cost? There is always a

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread po via Digitalmars-d
programmers who really have this stuff down... how much of your code and your mental energy with C++ is spent on memory ownership rules? Is it really a productive use of your time? Does the program materially benefit from the design required to make it safe, correct, and self-documenting

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread ketmar via Digitalmars-d
On Fri, 12 Sep 2014 07:49:57 + eles via Digitalmars-d digitalmars-d@puremagic.com wrote: Remember, what people like in C is inclusively the shoot the foot simplicity and availability. If you want it, you do it. but you can shoot yourself in the foot in D! you can run around in circles

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Jacob Carlborg via Digitalmars-d
On 12/09/14 08:59, Daniel Kozak via Digitalmars-d wrote: toUpperInPlace could help little, but still not perfect Converting text to uppercase doesn't work in-place in some cases. For example the German double S will take two letters in uppercase form. -- /Jacob Carlborg

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Jacob Carlborg via Digitalmars-d
On 12/09/14 09:58, eles wrote: On Friday, 12 September 2014 at 06:47:56 UTC, Jacob Carlborg wrote: On 11/09/14 21:02, eles wrote: Thank you. Basically, it is about a different interface of the functions, something like the difference between new and placement new. This could be added to

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Paulo Pinto via Digitalmars-d
On Friday, 12 September 2014 at 07:46:03 UTC, eles wrote: On Thursday, 11 September 2014 at 19:56:17 UTC, Paulo Pinto wrote: Am 11.09.2014 20:32, schrieb Daniel Alves: It is incredible how Objective-C's ARC became a symbol for reference counting, instead of the living proof of Apple's

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Friday, 12 September 2014 at 12:39:51 UTC, Paulo Pinto wrote: On Friday, 12 September 2014 at 07:46:03 UTC, eles wrote: On Thursday, 11 September 2014 at 19:56:17 UTC, Paulo Pinto wrote: Am 11.09.2014 20:32, schrieb Daniel Alves: ARC was a term popularized by Apple when they introduced

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Kagamin via Digitalmars-d
On Friday, 12 September 2014 at 08:50:17 UTC, po wrote: But using modern C++11/14 + TBB it really isn't hard at all. It is fairly trivial to scale to N cores using a task based approach. Smart pointers are rarely used, most C++ stuff is done by value. Strings too? For instance, I work on

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Marco Leise via Digitalmars-d
Am Fri, 12 Sep 2014 13:45:45 +0200 schrieb Jacob Carlborg d...@me.com: On 12/09/14 08:59, Daniel Kozak via Digitalmars-d wrote: toUpperInPlace could help little, but still not perfect Converting text to uppercase doesn't work in-place in some cases. For example the German double S will

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Marco Leise via Digitalmars-d
Am Thu, 11 Sep 2014 13:44:09 + schrieb Adam D. Ruppe destructiona...@gmail.com: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: And I think of idea of complete extraction of GC from D. You could also recompile the runtime library without the GC. Heck, with the

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Paulo Pinto via Digitalmars-d
On Thursday, 11 September 2014 at 20:55:43 UTC, Andrey Lifanov wrote: Everyone tells about greatness and safety of GC, and that it is hard to live without it... But, I suppose, you all do know the one programming language in which 95% of AAA-quality popular desktop software and OS is written.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Chris via Digitalmars-d
On Friday, 12 September 2014 at 12:39:51 UTC, Paulo Pinto wrote: On Friday, 12 September 2014 at 07:46:03 UTC, eles wrote: On Thursday, 11 September 2014 at 19:56:17 UTC, Paulo Pinto wrote: Am 11.09.2014 20:32, schrieb Daniel Alves: It is incredible how Objective-C's ARC became a symbol for

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Marco Leise via Digitalmars-d
Am Fri, 12 Sep 2014 15:43:14 + schrieb Chris wend...@tcd.ie: [Caveat: I'm no expert] I once read a manual that explained the GC in Objective-C (years ago). It said that some objects never get collected although they're dead, but the garbage collector can no longer reach them. But maybe

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread eles via Digitalmars-d
On Friday, 12 September 2014 at 20:41:53 UTC, Marco Leise wrote: Am Fri, 12 Sep 2014 15:43:14 + schrieb Chris wend...@tcd.ie: With only ARC, if two objects reference each other, they keep each other alive indefinitely unless one of the references is a weak reference, which doesn't count

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-12 Thread Paulo Pinto via Digitalmars-d
Am 13.09.2014 01:52, schrieb eles: On Friday, 12 September 2014 at 20:41:53 UTC, Marco Leise wrote: Am Fri, 12 Sep 2014 15:43:14 + schrieb Chris wend...@tcd.ie: With only ARC, if two objects reference each other, they keep each other alive indefinitely unless one of the references is a

Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language) implemented garbage collector as a core feature, not as additional optional module or library. I and many other C/C++ programmers prefer to control things manually and use flexible

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Kagamin via Digitalmars-d
You can also help with allocators design: http://forum.dlang.org/thread/lji5db$30j3$1...@digitalmars.com

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Kagamin via Digitalmars-d
The current idea is to add @nogc attribute to functions in phobos, which can live without GC, so that you could use them from other @nogc functions.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread via Digitalmars-d
On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language) implemented garbage collector as a core feature, not as additional optional module or library. I can

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: And I think of idea of complete extraction of GC from D. You could also recompile the runtime library without the GC. Heck, with the new @nogc on your main, the compiler (rather than the linker) should even give you nicish

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
Thank you for quick response! I guess I need further investigation and write good tests to compare C++ and D solutions. The main advantage over GC-language is that in case of manual memory management I know completely when and what will be freed or allocated (with the help of smart

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread ketmar via Digitalmars-d
On Thu, 11 Sep 2014 15:23:53 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: is that in case of manual memory management I know completely when and what will be freed or allocated (with the help of smart pointers/reference counting, of course). but you don't. you

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
I have recently found: http://en.wikibooks.org/wiki/D_Programming/Garbage_collector/Thoughts_about_better_GC_implementations Good stuff there.

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Paulo Pinto via Digitalmars-d
Am 11.09.2014 14:38, schrieb Andrey Lifanov: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language) implemented garbage collector as a core feature, not as additional optional module or library. I and many other C/C++ programmers prefer

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
On Thursday, 11 September 2014 at 15:39:26 UTC, ketmar via Digitalmars-d wrote: On Thu, 11 Sep 2014 15:23:53 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: is that in case of manual memory management I know completely when and what will be freed or allocated (with

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Sean Kelly via Digitalmars-d
On Thursday, 11 September 2014 at 13:16:07 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language) implemented garbage collector as a core

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Paulo Pinto via Digitalmars-d
Am 11.09.2014 18:02, schrieb Sean Kelly: On Thursday, 11 September 2014 at 13:16:07 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language)

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread ketmar via Digitalmars-d
On Thu, 11 Sep 2014 15:54:17 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: What do you mean? Some sort of memory leak? no, i meat that predictability is lost there. and with single-linked lists, for example, freeing list head can take big amount of time too if the

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Ali Çehreli via Digitalmars-d
On 09/11/2014 09:59 AM, ketmar via Digitalmars-d wrote: On Thu, 11 Sep 2014 15:54:17 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: What do you mean? Some sort of memory leak? no, i meat that predictability is lost there. and with single-linked lists, for

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
Thank you all for replies! I'm not saying that GC is evil. I just want to have different options and more control, when this is required. If D offered such choice, many good C++ programmers would have certainly considered D as a perfect alternative to C++. D states that there is no strict

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Daniel Alves via Digitalmars-d
You know, currently I spend most of my time programming in ObjC, but I really love C, C++ and D. Since the Clang Compiler, ObjC dropped the GC entirely. Yes, that's right, no GC at all. And, in fact, it does support concurrent programming and everything else. The magic behind it is ARC -

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread ketmar via Digitalmars-d
On Thu, 11 Sep 2014 18:04:05 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: Thank you all for replies! I'm not saying that GC is evil. I just want to have different options and more control, when this is required. If D offered such choice but D *is* offering

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread ketmar via Digitalmars-d
On Thu, 11 Sep 2014 18:32:09 + Daniel Alves via Digitalmars-d digitalmars-d@puremagic.com wrote: compiler analyzes your code, figures out object scopes and sets the correct calls to retain/release/autorelease this *is* GC. it's just hidden behind compiler magic and can't be changed without

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread bachmeier via Digitalmars-d
On Thursday, 11 September 2014 at 18:32:10 UTC, Daniel Alves wrote: You know, currently I spend most of my time programming in ObjC, but I really love C, C++ and D. Since the Clang Compiler, ObjC dropped the GC entirely. Yes, that's right, no GC at all. And, in fact, it does support

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Joakim via Digitalmars-d
On Thursday, 11 September 2014 at 18:32:10 UTC, Daniel Alves wrote: You know, currently I spend most of my time programming in ObjC, but I really love C, C++ and D. Since the Clang Compiler, ObjC dropped the GC entirely. Yes, that's right, no GC at all. And, in fact, it does support

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread eles via Digitalmars-d
On Thursday, 11 September 2014 at 16:02:31 UTC, Sean Kelly wrote: On Thursday, 11 September 2014 at 13:16:07 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: hidden allocations anywhere. And it's completely possible with Tango to write an

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread via Digitalmars-d
On Thursday, 11 September 2014 at 16:02:31 UTC, Sean Kelly wrote: On Thursday, 11 September 2014 at 13:16:07 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Sean Kelly via Digitalmars-d
On Thursday, 11 September 2014 at 19:14:42 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 16:02:31 UTC, Sean Kelly wrote: On Thursday, 11 September 2014 at 13:16:07 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Paulo Pinto via Digitalmars-d
Am 11.09.2014 20:32, schrieb Daniel Alves: You know, currently I spend most of my time programming in ObjC, but I really love C, C++ and D. Since the Clang Compiler, ObjC dropped the GC entirely. Yes, that's right, no GC at all. And, in fact, it does support concurrent programming and

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread deadalnix via Digitalmars-d
On Thursday, 11 September 2014 at 12:38:54 UTC, Andrey Lifanov wrote: Hello everyone! Being a C/C++ programmer I don't understand, why such language as D (system programming language) implemented garbage collector as a core feature, not as additional optional module or library. I and many

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Andrey Lifanov via Digitalmars-d
Everyone tells about greatness and safety of GC, and that it is hard to live without it... But, I suppose, you all do know the one programming language in which 95% of AAA-quality popular desktop software and OS is written. And this language is C/C++. How do you explain this? Just because we

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread ketmar via Digitalmars-d
On Thu, 11 Sep 2014 20:55:42 + Andrey Lifanov via Digitalmars-d digitalmars-d@puremagic.com wrote: Everyone tells about greatness and safety of GC, and that it is hard to live without it... But, I suppose, you all do know the one programming language in which 95% of AAA-quality popular

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread Sean Kelly via Digitalmars-d
On Thursday, 11 September 2014 at 20:55:43 UTC, Andrey Lifanov wrote: Every experienced programmer can easily handle parallel programming and memory management in C++. Eliminate parallel programming from that statement and I could be convinced to believe you, though after years of diagnosing

Re: Getting completely (I mean ENTIRELY) rid off GC

2014-09-11 Thread deadalnix via Digitalmars-d
On Thursday, 11 September 2014 at 20:55:43 UTC, Andrey Lifanov wrote: Everyone tells about greatness and safety of GC, and that it is hard to live without it... But, I suppose, you all do know the one programming language in which 95% of AAA-quality popular desktop software and OS is written.