From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Top 10 Worst C# Features
Date: Wed, 2 Sep 2015 14:39:39 -0500
Date: 2015-09-02T14:39:39-05:00 [thread overview]
Message-ID: <ms7j9r$ho$1@loke.gir.dk> (raw)
In-Reply-To: alpine.DEB.2.20.1509021228510.5314@debian
<Stefan.Lucks@uni-weimar.de> wrote in message
news:alpine.DEB.2.20.1509021228510.5314@debian...
...
>#2 Finaliz(ers) are fragile
>
>In Ada, the finalize procedure for an object can be called more than once,
>Finalize should rather not raise an exception, ... apparently, C#
>finalzisers suffer from similar problems: "any time a finalizer runs, you
>could argue that the program either has a bug or is in a dangerous state,
>such as being shut down unexpectedly via a thread abort".
Based on the article, the situation in Ada is far less bad than the C# one.
His description of C++ finalizers apply to Ada's as well: "[they] run
deterministically, run on the current thread, and never run on partially
constructed objects."
Moreover, they always run when objects are destroyed, while apparently in C#
they don't run for explicit calls to Dispose.
Ada's issues come from two things: extremely rare cases involving exceptions
where a finalizer might start twice, and the fact that someone can
explicitly call it on an object. If one has control over the entire system,
neither of these cases need happen; a program like AdaControl can enforce
appropriate style rules to avoid problems.
If not, it's relatively easy to make Finalize callable multiple times (you
just need a "Valid" bit in the object, which is turned off by Finalize; if
it's off, Finalize does nothing).
Of course, Ada gets this by not supporting garbage collection on objects
that have non-trival finalization (such an object cannot be garbage
collected until the finalization has run, meaning they have to exist until
they go out of scope, meaning no useful garbage collection can happen.
Fixing that would probably introduce more problems (although if the points
at which garbage collection could happen were appropriately limited it would
not be a huge issue; if this issue is ever addressed in Ada, that would have
to be the case).
In any case, Ada's situation is nothing like the asynchronous mess he
describes for C#. It may not be perfect, but it's a heck of a lot better
than C#.
Randy.
next prev parent reply other threads:[~2015-09-02 19:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 10:59 Top 10 Worst C# Features Stefan.Lucks
2015-09-02 17:37 ` Álex R. Mosteo
2015-09-02 19:39 ` Randy Brukardt [this message]
2015-09-03 8:14 ` Georg Bauhaus
2015-09-03 9:26 ` Dmitry A. Kazakov
2015-09-03 11:39 ` G.B.
2015-09-03 12:00 ` G.B.
2015-09-03 13:59 ` Dmitry A. Kazakov
2015-09-03 19:12 ` Randy Brukardt
2015-09-04 7:33 ` Georg Bauhaus
2015-09-04 21:34 ` Randy Brukardt
2015-09-05 6:31 ` Dmitry A. Kazakov
2015-09-05 6:44 ` Georg Bauhaus
2015-09-05 7:07 ` Dmitry A. Kazakov
2015-09-05 6:45 ` Niklas Holsti
2015-09-05 7:21 ` Dmitry A. Kazakov
2015-09-05 12:07 ` Peter Chapin
2015-09-06 10:45 ` Georg Bauhaus
2015-10-13 19:57 ` Eryndlia Mavourneen
2015-09-05 7:16 ` Shark8
2015-09-03 13:47 ` Dmitry A. Kazakov
2015-09-03 8:51 ` gautier_niouzes
2015-10-01 14:03 ` Paul Colin de Gloucester
2015-10-14 8:00 ` Maciej Sobczak
2015-10-14 14:26 ` Ben Bacarisse
2015-10-14 16:50 ` Paul Rubin
2015-10-14 18:17 ` Stefan.Lucks
2015-10-14 19:54 ` Ben Bacarisse
2015-10-15 12:24 ` Maciej Sobczak
2015-10-15 13:59 ` Ben Bacarisse
2015-11-06 14:50 ` Nicholas Collin Paul de Gloucester
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox