#3 is the source of race conditions. Go is no better than
C and C++ at this. I've discussed that before, so I won't
repeat it here.
There are advantages to not having a GC. In hard real time
systems, the impact of a GC randomly firing off is unacceptable.
I'd like to see a hard compiled language which solves all three
of those problems above without garbage collection. Even
Erlang has a garbage collector.
John Nagle
I'd like to see a hard compiled language which solves all threeof those problems above without garbage collection. Even
Erlang has a garbage collector.
John Nagle
--
I think you are putting the cart before the horse. Rust is attempting to make their gc optional. This newly attempted experiment has only begun, so I think it is premature to draw such strong conclusions at this point.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Many broken C/C++ programs suggest that not all developers can in fact do this right in every case, especially in concurrent applications, as have been outlined here.
On Tue, Jun 18, 2013 at 1:33 PM, C K Kashyap <ckka...@gmail.com> wrote:
> As per Øyvind's point the original scheme of COW proposed has a subtle (not
> so subtle now that I think of it) bug. As in, chances of losing updates.
> This could perhaps be fixed with a "version" in the data structure? As in
> the publisher notes the version that it copied and just before updating it
> checks the version again and if it is bumped, then re-do the whole thing.
> kinda like transaction blocks.
>
> I think even with this re-attempt logic in place, it's gonna be overall more
> simple than doing your own GC.
You either have 1 writer;
or protect updates with a mutex;
or use
plain CAS-loop on pointer value,
no separate version is required, the
pointer value itself acts as unique version.
On Tue, Jun 18, 2013 at 12:58 AM, Øyvind Teig <oyvin...@teigfam.net> wrote:
>
> After a thread A has modified on a copy and wants to update the original,
> oops.. some other thread B has also modified a copy and in fact suceeded in
> doing that.
> Provided this is not possible
>
> there must be atomic copy-on-write-update (which would make the copy
> unnecessary)
> ...
>
> Provided this is prohibited
>
> Is it so by programming pattern (don't like it: unsafe)
> or by compiler (don't think it's possible)
An example of a copy-on-write approach to a data structure is
std::string in current versions of the C++ library distributed with
GCC. The current version may be seen at
http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/bits/basic_string.h?view=markup
http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/bits/basic_string.tcc?view=markup
The essential steps are _M_leak and _M_mutate. The code keeps a
reference count to the string buffer. The reference count is
manipulated atomically. When a write operation is done, if there are
multiple references to the buffer, the buffer is first copied before
the write operation proceeds.
The essential steps are _M_leak and _M_mutate. The code keeps a
reference count in the shared string buffer to the (shared?) string buffer. The reference count in the shared string buffer ismanipulated atomically. When a write operation is done to the local string buffer, if there aremultiple references to the buffer in the shared string buffer, the shared string buffer is first copied from the shared to the local string buffer beforethe write operation to the local string buffer proceeds.
The only issue is getting rid of it when it's done,for which garbage collection is very convenient.
A problem with immutability is that somehow you have
to initialize the thing.
Stack allocated objects are freed when they are out of scope, it doesnot mean that they are not used anymore. This is a common mistake in
C/C++.
Owned pointers can't practically collect cycles.
Owned pointers force one to use atomic reference counting and mutexes
for object lifetime management. Both things kill parallel performance.
That's the trouble with trying to implement reference counting
via templates. It almost works. Almost. When it doesn't,
someone is stuck debugging a huge system with a reference count
error.