comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Languages don't  matter.  A mathematical refutation
Date: Mon, 6 Apr 2015 16:27:35 -0500
Date: 2015-04-06T16:27:35-05:00	[thread overview]
Message-ID: <mfuto8$pet$1@loke.gir.dk> (raw)
In-Reply-To: mfr0rb$s0v$1@dont-email.me

"Brian Drummond" <brian@shapes.demon.co.uk> wrote in message 
news:mfr0rb$s0v$1@dont-email.me...
> On Sun, 05 Apr 2015 10:00:46 +0200, Dmitry A. Kazakov wrote:
>
>> On Sat, 04 Apr 2015 13:44:49 -0700, Paul Rubin wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>>> In Ada memory management is automatic
>>>
>>> Do you mean something other than stack allocation and "new"?
>>
>> Stack
>
> Also storage pools, though you might call that a semi-automatic memory
> management system.

Especially true if you are using subpools.

You forgot containers. One of the most important purposes of the container 
packages is that they can take over the memory management (especially useful 
for indefinite types, like class-wide types). That means that one can build 
complex data structures but yet treat them for memory management purposes as 
if they are stack allocated.

For instance, an expression tree in a compiler can be made up of tagged 
nodes for the different kind of expression parts (operators, memberships, 
conditionals, allocators, etc.), and the tree can be stored in a tree 
container. Thus, no explicit memory management is needed to deal with tree 
temporaries and the like (and you really don't need any management for 
global trees [ones like default expressions and the like that get stored in 
the symboltable], as they never get freed until the end of the compilation).

Yes, the implementer has to create the memory management used to implement 
the containers, but the same is true for garbage collection. And the former 
is a lot easier to get right than the latter.

IMHO, the order of memory management preferability goes approximately as 
follows:

(1) Stack-based (in Ada, this includes dynamically-sized objects, such as an 
array whose length depends on a parameter; this probably isn't implemented 
with a traditional stack, but the compiler will do the management).

(2) Container-based. (discussed above).

(3) Finalization-based. (Using a controlled wrapper of some sort; deallocate 
on finalize. Smart pointers fall into this category. The only reason that 
these fall below (2) is that these are user-defined, meaning there is a 
higher possibility of errors. [Implementers make mistakes, but there are 
more people using there stuff so they don't last as long.])

(4) Subpool-based. (Sometimes called "arenas"; this is a semi-automatic 
mechanism in that all items of a group are freed together.)

(5) Manual allocate/deallocate (with or without storage pools).

Garbage collection probably helps with (5) [few programmers are good enough 
to do that correctly all of the time]; there might be an argument that it is 
better than (4) [I doubt it, because the overhead is so much worse, but at 
least that's open to debate.] Whether GC is better than (3) depends on the 
quality of one's programmers; if they know enough to use existing libraries 
rather than rolling their own (or at least copy from existing designs), then 
(3) is a clear win over GC. GC might be an advantage to a naive team, but 
I'd rather they stay far away from any software. ;-)

GC has nothing to offer for (1) and (2), and in some cases might even be 
harmful (by covering up bugs, as pointers to stuff that ought to be dead 
still exist and appear to work).

Anyone that thinks that Garbage Collection is something required hasn't 
thought enough about how memory management can be done better. Indeed, it 
seems to foster terrible programming practices because it's "easy"; for 
example, Firefox doesn't seem to release memory until a tab is closed, then 
not then until a decent amount of time afterwards. It has no problem going 
catotonic from running out of memory (and the reason it hangs is that the GC 
thrashes).

                                   Randy.


  reply	other threads:[~2015-04-06 21:27 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 11:46 Languages don't matter. A mathematical refutation Jean François Martinez
2015-03-25 15:19 ` Paul Rubin
2015-04-03  0:50   ` robin.vowels
2015-04-03  2:18     ` Jeffrey Carter
2015-04-03 13:37       ` Bob Duff
2015-04-03 14:13         ` Dmitry A. Kazakov
2015-04-03 17:34           ` Paul Rubin
2015-04-03 19:34             ` Dmitry A. Kazakov
2015-04-03 19:58               ` Paul Rubin
2015-04-04  6:59                 ` Dmitry A. Kazakov
2015-04-06 21:12                   ` Paul Rubin
2015-04-07  5:57                     ` Dmitry A. Kazakov
2015-04-08  4:12                       ` Paul Rubin
2015-04-08  6:45                         ` Dmitry A. Kazakov
2015-04-04  0:41             ` Dennis Lee Bieber
2015-04-04  3:05               ` Paul Rubin
2015-04-04 14:46                 ` Dennis Lee Bieber
2015-04-04 15:41                   ` brbarkstrom
2015-04-04 19:20                   ` Paul Rubin
2015-04-04 20:00                     ` Dmitry A. Kazakov
2015-04-04 20:44                       ` Paul Rubin
2015-04-05  8:00                         ` Dmitry A. Kazakov
2015-04-05  9:55                           ` Brian Drummond
2015-04-06 21:27                             ` Randy Brukardt [this message]
2015-04-06 17:07                           ` Paul Rubin
2015-04-06 17:41                             ` Dmitry A. Kazakov
2015-04-06 18:35                               ` Paul Rubin
2015-04-06 21:46                                 ` Randy Brukardt
2015-04-06 22:12                                   ` Paul Rubin
2015-04-06 23:40                                     ` Jeffrey Carter
2015-04-07 19:07                                     ` Randy Brukardt
2015-04-08  3:53                                       ` Paul Rubin
2015-04-08 21:16                                         ` Randy Brukardt
2015-04-09  1:36                                           ` Paul Rubin
2015-04-09 23:26                                             ` Randy Brukardt
2015-04-09  2:36                                           ` David Botton
2015-04-09  8:55                                           ` Georg Bauhaus
2015-04-09  9:38                                             ` Dmitry A. Kazakov
2015-04-09 13:14                                               ` G.B.
2015-04-09 14:35                                                 ` Dmitry A. Kazakov
2015-04-09 15:43                                                   ` G.B.
2015-04-09 17:26                                                     ` Dmitry A. Kazakov
2015-04-09 18:40                                                   ` Niklas Holsti
2015-04-09 19:02                                                     ` Dmitry A. Kazakov
2015-04-09 20:38                                                       ` Paul Rubin
2015-04-09 23:35                                             ` Randy Brukardt
2015-04-10 14:16                                               ` G.B.
2015-04-10 20:58                                                 ` Randy Brukardt
2015-04-07  0:36                                 ` Dennis Lee Bieber
2015-04-05 13:57                     ` Dennis Lee Bieber
2015-04-03 16:17         ` J-P. Rosen
2015-04-03 17:33           ` Bob Duff
2015-04-26 11:38             ` David Thompson
2015-04-03 19:00         ` Georg Bauhaus
2015-04-03 19:12         ` Jeffrey Carter
2015-04-03 22:37           ` Bob Duff
2015-04-03 23:38             ` Jeffrey Carter
2015-04-04  0:15               ` Bob Duff
2015-04-04  7:06                 ` Dmitry A. Kazakov
2015-04-04  2:59               ` Paul Rubin
2015-04-04  0:56             ` Dennis Lee Bieber
2015-03-25 17:12 ` Jean François Martinez
2015-03-26 13:43 ` Maciej Sobczak
2015-03-26 15:01   ` Jean François Martinez
2015-03-26 17:45     ` Jeffrey Carter
2015-03-26 15:21   ` Dmitry A. Kazakov
2015-03-27 11:25     ` Jean François Martinez
2015-03-27 17:36       ` Dmitry A. Kazakov
2015-03-30 10:31         ` Jean François Martinez
2015-03-30 11:52           ` Dmitry A. Kazakov
2015-03-30 12:32             ` G.B.
2015-03-30 13:48               ` Dmitry A. Kazakov
2015-03-30 15:47                 ` G.B.
2015-03-30 16:05                   ` Dmitry A. Kazakov
2015-04-02 12:59                     ` brbarkstrom
2015-04-02 13:35                       ` Dmitry A. Kazakov
2015-04-02 14:48                         ` jm.tarrasa
2015-04-02 15:55                           ` brbarkstrom
2015-04-02 16:21                             ` Jean François Martinez
2015-04-02 16:48                             ` Dmitry A. Kazakov
2015-04-02 16:41                           ` Dmitry A. Kazakov
2015-04-04 10:02                             ` jm.tarrasa
2015-04-04 11:16                               ` Dmitry A. Kazakov
2015-04-02 15:58                         ` Jean François Martinez
2015-04-02 16:39                           ` Dmitry A. Kazakov
2015-04-03  9:46                             ` Jean François Martinez
2015-04-03 14:00                               ` Dmitry A. Kazakov
2015-04-03 17:12                                 ` Jean François Martinez
2015-04-02 17:17                         ` G.B.
2015-04-02 19:09                           ` Dmitry A. Kazakov
2015-04-02 18:24                       ` Niklas Holsti
2015-04-02 18:43                       ` Jeffrey Carter
2015-03-30 11:36         ` Jean François Martinez
2015-03-30 10:48       ` jm.tarrasa
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox