> "The C programming language is terrible. I mean, magnificent, too. Much
> of the world in which we live was built atop C. It is foundational to
> almost all computer programming, both historically and practically;
> there’s a reason that the curriculum for Xavier Niel’s revolutionary
> “42” schools begins with students learning how to rewrite standard C
> library functions from scratch. But C is no longer suitable for this
> world which C has built."
>
> I disagree. True, working in C and C++ is like walking on a tight rope.
> But, if one cannot walk the tightrope then one should find something
> else to do in life. After all, working on the high wire is not for
> everyone.
Hmm, that analogy makes me wonder. Generally one assumes that safety
comes with other downsides. Sticking with that analogy, a bridge would
be a safer way to cross a canyon than a tight rope. But you might not
be able to afford building one (higher cost = higher runtime or memory
overhead).
The analogy of bridge vs tight rope does kind of fit for languages
that protect you better than C and C++ but intrinsically incur costs
due to design choices. It's not a secret that programs in interpreted
languages or even statically compiled languages such as Java are at a
disadvantage compared to C++ since they make it difficult to avoid
pointer-heavy data structes. Every variable in Python is a reference.
Every variable of a non-primitive type in Java is a reference.
Composing an object out of subobjects in Java doesn't give you a
single chunk of memory but a tree of objects linked by those kinds of
references. The cost is bad memory layout and potential cache misses.
In addition you usually have a garbage or cycle collector of some sort
which does have its own trade-offs.
But I don't think this analogy of a bridge fits with respect to Rust.
Rust would be like a tight rope that's safer than a normal tight rope
but still as cheap (or almost as cheap) as the normal one. Even if you
are good at walking on a tight rope and only very rarely loose your
balance by accident, why wouldn't you pick the safer one unless you
don't value your life? That's the whole point about Rust's existence!
* fearless concurrency
* memory safety without garbage collection
* zero-overhead abstractions
Frankly, I don't understand the opposition. I've programmed in C and
C++ for over 10 years. Yes, I care about performance. That's why I
switched to C++. And yes, I care about the three things I listed
above. C++ got that "zero-overhead principle" down. But its story
w.r.t. memory safety and data race freedom is lacking. Sure, there are
efforts in C++ (static checking for guideline adherence) but to be
honest, I'm not holding my breath. I start believing Stroustrup and
Herb Sutter when I get ahold of a working static analyzer and
annotated standard library that prevents use-after-free errors at
compile-time. Yes, effective use of C++ makes leaking resources by
accident pretty hard. That's cool. Thank you RAII. But we still deal
with things like references, non-owning pointers, iterators etc that
might be invalidated earlier than expected—even in "modern C++".
Sure, you could replace some of that with a std::weak_ptr that is
smart enough to figure out if the pointee is gone. But that's IMHO an
undesirable performance regression. Wouldn't it be cool if the
compiler could verify for you that non-owning pointers are never
going to be invalid if the program actually compiles?
So, before you dismiss Rust based on preconceived notions along the
lines of "higher overhead" or "not close enough to the metal", you
should probably stop and consider taking a closer look at Rust.
No, I don't buy into the idea that only incompetent programmers make
mistates. That's just nonsense.
my two cents,
SG