Computer Old Farts Forum
 help / color / mirror / Atom feed
From: Dan Cross <crossd@gmail.com>
To: Ed Carp <erc@pobox.com>
Cc: Rob Pike <robpike@gmail.com>, COFF <coff@minnie.tuhs.org>
Subject: Re: [COFF] [TUHS] more about Brian...
Date: Sun, 6 Feb 2022 09:13:56 -0500	[thread overview]
Message-ID: <CAEoi9W6gk4cR0EoGzbDFqXkdz9o+Jiu0izMrYHtuq7Zxb=n0kw@mail.gmail.com> (raw)
In-Reply-To: <CACYmRNAKUYwVwbn+mXCAVyySV5sVEbZmN4wvQbQKXx-p+nKM=w@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 5205 bytes --]

Oh dear. This is getting a little heated. TUHS to Bcc:, replies to COFF.

On Sun, Feb 6, 2022 at 8:15 AM Ed Carp <erc@pobox.com> wrote:

> Since you made this personal and called me out specifically, I will
> respond:
>
> "In what way is automatic memory management harder, more unsafe, and
> less robust than hand-written memory management using malloc and
> free?"
>
> Because there's no difference in the two. Someone had to write the
> "automatic memory management", right?
>

I cannot agree with this, there is a big difference.

With GC, you are funneling all of the fiddly bits of dealing with memory
management through a runtime that is written by a very small pool of people
who are intimately familiar with the language, the runtime, the compilation
environment, and so on. That group of subject matter experts produce a
system that is tested by every application (much like the _implementation_
of malloc/free itself, which is not usually reproduced by every programmer
who _uses_ malloc/free).

It's like in "pure" functional languages such as Haskell, where everything
is immutable: that doesn't mean that registers don't change values, or that
memory cells don't get updated, or that IO doesn't happen, or the clock
doesn't tick. Rather, it means that the programmer makes a tradeoff where
they cede control over those things to the compiler and a runtime written
by a constrained set of contributors, in exchange for guarantees those
things make about the behavior of the program.

With manual malloc/free, one smears responsibility for getting it right
across every program that does dynamic memory management. Some get it
right; many do not.

In many ways, the difference between automatic and manual memory management
is like the difference between programming in assembler and programming in
a high-level language. People have written reliable, robust assembler for
decades (look at the airline industry), but few people would choose to do
so today; why? Because it's tedious and life is too short as it is.
Further, the probability of error is greater than in a high-level language;
why tempt fate?

[snip]
> "This discussion should probably go to COFF, or perhaps I should just
> leave the list. I am starting to feel uncomfortable here. Too much
> swagger."
>
> I read through the thread. Just because people don't agree with each
> other doesn't equate to "swagger". I've seen little evidence of
> anything other than reasoned analysis and rational, respectful
> discussion. Was there any sort of personal attacks that I missed?
>

It is very difficult, in a forum like this, to divine intent. I know for a
fact that I've written things to this list that were interpreted very
differently than I meant them.

That said, there has definitely been an air that those who do not master
manual memory management are just being lazy and that "new" programmers are
unskilled. Asserting that this language or that is "ours" due to its
authors while that is "theirs" or belongs solely to some corporate sponsor
is a bit much. The reality is that languages and operating systems and
hardware evolve over time, and a lot of the practices we took for granted
10 years ago deserve reexamination in the light of new context. There's
nothing _wrong_ with that, even if it may be uncomfortable (I know it is
for me).

The fact of the matter is, code written with malloc/free, if written
> carefully, will run for *years*. There are Linux boxes that have been
> running for literally years without being rebooted, and mainframes and
> miniframes that get booted only when a piece of hardware fails.
>

That there exist C programs that have run for many years without faults is
indisputable. Empirically, people _can_ write reliable C programs, but it
is often harder than it seems to do so, particularly since the language
standard gives so much latitude for implementations to change semantics in
surprising ways over time. Just in the past couple of weeks a flaw was
revealed in some Linux daemon that allowed privilege escalation to
root...due to improper memory management. That flaw had been in production
for _12 years_. Sadly, this is not an isolated incident.

That said, does manual memory management have a place in modern computing?
Of course it does, as you rightly point out. So does assembly language.
Rust came up in the context of this thread as a GC'd language, and it may
be worth mentioning that Rust uses manual memory management; the language
just introduces some facilities that make this safer. For instance, the
concept of ownership is elevated to first-class status in Rust, and there
are rules about taking references to things; when something's owner goes
out of scope, it is "dropped", but the compiler statically enforces that
there are no outstanding references to that thing. Regardless, when dealing
with some resource it is often the programmer's responsibility to make sure
that a suitable drop implementation exists. FWIW, I used to sit down the
hall from a large subgroup of the Go developers; we usually ate lunch
together. I know that many of them shared my opinion that Rust and Go are
very complimentary. No one tool is right for all tasks.

        - Dan C.

[-- Attachment #1.2: Type: text/html, Size: 6350 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

      parent reply	other threads:[~2022-02-06 14:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c0fd1aec-55a8-54a4-94dc-748068d9e15d@gmail.com>
     [not found] ` <202202011537.211FbYSe017204@freefriends.org>
     [not found]   ` <20220201155225.5A9541FB21@orac.inputplus.co.uk>
     [not found]     ` <202202020747.2127lTTh005669@freefriends.org>
     [not found]       ` <7C19F93B-4F21-4BB1-A064-0307D3568DB7@cfcl.com>
     [not found]         ` <1nFWmo-1Gn-00@marmaro.de>
     [not found]           ` <CAP2nic37m2aSCffgr8o_J+BkAbnrzFDUaHX9V0brd+L8+PqdPA@mail.gmail.com>
     [not found]             ` <202202040234.2142YeKN3307556@darkstar.fourwinds.com>
2022-02-04 23:18               ` [COFF] [TUHS] more about Brian... [really Rust] Dan Cross
2022-02-05 23:09                 ` [COFF] Zig (was Re: more about Brian... [really Rust]) Derek Fawcus
2022-02-06 12:32                   ` [COFF] Zig Ralph Corderoy
2022-02-06 12:49                   ` [COFF] Zig (was Re: more about Brian... [really Rust]) Dan Cross
2022-02-06 15:42                   ` Adam Thornton
     [not found]             ` <CALMnNGjfvtd=6qsmT6kXm3eEBM7OhhGSJ4Wbbjiv+B9P9rLafA@mail.gmail.com>
     [not found]               ` <alpine.DEB.2.21.2202040304380.28373@sd-119843.dedibox.fr>
     [not found]                 ` <CAD2gp_Rn_==vzUw80geH7ryLwmU+uiCidQVfMLn51HhZV1VHfA@mail.gmail.com>
     [not found]                   ` <e201372274da4ed9cf75bcaaf43a5d95@firemail.de>
     [not found]                     ` <1644006490.2458.78.camel@mni.thm.de>
     [not found]                       ` <20220206005609.GG3045@mcvoy.com>
     [not found]                         ` <21015c2c-2652-bbc3-dbd7-ad3c31f485a2@gmail.com>
     [not found]                           ` <CAKzdPgzSH94Xg=XYYKy6J+dWAD+ZVDzUTNE=YNRkyVRH69PJfA@mail.gmail.com>
     [not found]                             ` <CACYmRNDzrSvbwnAEAVz=REsdqSs675_pkBhi5dm5iWRCwRVo=A@mail.gmail.com>
     [not found]                               ` <CAKzdPgxQmB8ikjQwExOVnOwGDQrc-N==qzf=ZwhH7Ut-fD6pCg@mail.gmail.com>
     [not found]                                 ` <CACYmRNAKUYwVwbn+mXCAVyySV5sVEbZmN4wvQbQKXx-p+nKM=w@mail.gmail.com>
2022-02-06 14:13                                   ` Dan Cross [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEoi9W6gk4cR0EoGzbDFqXkdz9o+Jiu0izMrYHtuq7Zxb=n0kw@mail.gmail.com' \
    --to=crossd@gmail.com \
    --cc=coff@minnie.tuhs.org \
    --cc=erc@pobox.com \
    --cc=robpike@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).