On Mon, Sep 30, 2024 at 11:49:28AM -0400, Paul
Winalski wrote:
[moving to COFF as this has drifted away from
Unix]
On Sat, Sep 28, 2024 at 2:06???PM Larry McVoy <lm(a)mcvoy.com> wrote:
I have a somewhat different view. I have a son
who is learning to program
and he asked me about C. I said "C is like driving a sports car on a
twisty mountain road that has cliffs and no guard rails. If you want to
check your phone while you are driving, it's not for you. It requires
your full, focussed attention. So that sounds bad, right? Well, if
you are someone who enjoys driving a sports car, and are good at it,
perhaps C is for you."
If you really want a language with no guard rails, try programming in
BLISS.
Regarding C and C++ having dangerous language features--of course they do.
Every higher-level language I've ever seen has its set of toxic language
features that should be avoided if you want reliability and maintainability
for your programs. And a set of things to avoid if you want portability.
Regarding managed dynamic memory allocation schemes that use garbage
collection vs. malloc()/free(), there are some applications where they are
not suitable. I'm thinking about real-time programs. You can't have your
missle defense software pause to do garbage collection when you're trying
to shoot down an incoming ballistic missile.
That's why I like reference counting. It doesn't have the long pauses
that other garbage collection systems have, when the variable goes out
of scope, you decrement, last guy frees. Seems pretty simple.
The problem with ref counting is that it's not completely general;
circular data structures will never be collected, even if all external
references to them disappear. That said, reference counting is a
really powerful technique; it's just that it must be used carefully.
- Dan C.