News for hackers. Stuff that matters.
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @03:28AM (#5693496)
No language with a nondeterministic memory management will ever be able to be an alternative of C++.
Re:The C++ Programming Language (4th Edition) by Someone on Sunday May 12, 2013 @04:13AM (#5693576)
There isn't anything nondeterministic about garbage collection systems; it is just that it is hard to predict how much time they will take for a call.

However, the same can be said about classical C style memory management. An alloc can be almost immediate or take lots of time because it has to request a fresh memory block from the OS. Similarly, a free can or cannot take time to coalesce blocks.

Yes, the differences are much smaller there, certainly historically, but garbage collectors have improved, and I am not sure that C-style allocators can stay predictable in long-running programs. Let's say you have a terabyte of RAM, and want to run a multi-threaded server in it 'forever'. Chances are that your garbage-collected system will be more stable and use less memory because it can compact memory. A C style allocator would need quite a few heuristics (or maybe, even contain some machine learning code that builds a model of memory allocation patterns) to prevent memory fragmentation. Such features would make their timing less predictable.

Because of that, I think we may at some time see an OS with built-in garbage-collection become mainstream.

Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @06:05PM (#5696050)
> it is just that it is hard to predict how much time they will take for a call.

The problem is not how much but when - you never know when GC fires and interrupts your running code. That is a nondeterminism.

Re:The C++ Programming Language (4th Edition) by Someone on Monday May 13, 2013 @01:44AM (#5697364)
If it interrupts your running code, it only can happen at moments when you allocate memory, just like with malloc. You cannot predict when malloc calls brk(), either.

Also, most OS-es are non-deterministic, anyways. You cannot predict whether your code lives in cache/main memory, or on disk. In some systems, your data even might have to be brought in by a tape robot without your code being aware of it. As soon as a garbage collector manages to get its interruptions to be about equal to delays caused by caching and virtual memory, I doubt many people will care.

Re:The C++ Programming Language (4th Edition) by zura on Monday May 13, 2013 @06:44AM (#5698003)
I'm not talking about interruptions on allocations, but deallocations.

You never know when GC fires - starts harvesting for memory locations that need to be freed and frees them.

Re:The C++ Programming Language (4th Edition) by Someone on Tuesday May 14, 2013 @07:55AM (#5704262)
With Gargage collection, there are ni deallocations.

Also, garbage collection does not "harvest for memory locations that need to be freed and frees them.". Garbage collection does not collect garbage, it collects used space.

Re:The C++ Programming Language (4th Edition) by zura on Wednesday May 15, 2013 @04:16AM (#5710777)
I think you're misinformed.

Here are some more details if you're interested:

http://en.wikipedia.org/wiki/Garbage_collection_(computer_sc...

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @08:20AM (#5694009)
Are you sure you know what the language runtime does with your delete or how long a new takes?
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @10:11AM (#5694279)
I think we already had some conversation about this topic:

https://news.ycombinator.com/item?id=5503066

HN is small ;)

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @01:37PM (#5695059)
Most likely. :)
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @05:47PM (#5695997)
Just followed that thread again, and I think we're on the same side :)

I mean, when I say that I prefer deterministic memory management, that includes an automatic reference counting - smart pointers - which are now part of C++11.

On that thread, under my "deterministic", you assumed only "manual" as it seems.

Re:The C++ Programming Language (4th Edition) by pjmlp on Monday May 13, 2013 @02:06AM (#5697405)
Oh, great! :)