by Animats · 10y ago · 0 comments
C has three fundamental issues:
1) How big is it?
2) Who owns it?
3) Who locks it?
C's lack of help in dealing with all three is the main cause of most memory-related program bugs. I once tried to fix #1 in a backwards compatible way. See [1]. After much discussion on some mailing lists, there was general agreement that this was technically feasible but not politically feasible.
(I once had hope that Rust would replace C, but Rust has gotten too fancy, with too much input from the functional programming people, the template enthusiasts, and the type theorists. Rust isn't bad, but it's at least as complex as C++.)
[1] http://www.animats.com/papers/languages/safearraysforc43.pdf
Rust has gotten too fancy
Could you identify a simple Rust core that has all the good parts
while avoiding the complexity you mention? What is superfluous in Rust?By "templates" you mean macros? If so, how should a language implement the functionality that's currently delivered by macros?
I'm asking because I'm thinking about adding HKTs (higher-kinded types) to Rust.
> it's at least as complex as C++
You repeat this phrase like a broken record, but have yet to back it up every time that I have asked why you have this opinion. C++ is an order of magnitude more complex than Rust.- The functional control flow style, where everything involves closures, is much harder to understand than imperative control structures.
They're not opaque. Templates are more opaque because of the lack of self documenting bounds, perhaps (i still wouldn't call them opaque, just more so than Rust generics)
This is the millionth time you're repeating that garbage about imperative control flow. It boils down to a use of closures in a few stdlib functions. We've had this argument before, the essence of your point is that it is different from C. Of course there is a learning curve but that is there the other way too. Once you get used to it the control flow is pretty straightforward. And in most cases you can avoid the closures and write your if or loop manually.
Type Option. The 2014 version.[1] The 2016 version.[2]
(Coming soon, the "?" operator.[3])
Here's an example of excessive cleverness [4]:
fn main () {
let number: f64 = 20.;
// Perform a pipeline of options.
let result = Some(number)
.map(inverse)
.map(double)
.map(inverse)
.and_then(log)
.map(square)
.and_then(sqrt);
// Extract the result.
match result {
Some(x) => println!("Result was {}.", x),
None => println!("This failed.")
}
}
(It's surprising that you can use .map on a singleton. Does this actually generate collections of one element and discard them, or what?)The designers of Go knew when to stop. The designers of Rust don't.
[1] https://web.archive.org/web/20140814230239/http://doc.rust-l...
[2] https://doc.rust-lang.org/std/option/enum.Option.html
Yeah, i remember using the Mac OS written in Pascal. Strangely enough, i remember it being buggy as hell and crashing pretty often (no memory protection at all).
Also C standard library cannot be implemented without using Assembly, unless one makes use of extensions not defined in ANSI C.
But this is up to you to enforce.
2) & 3) are pretty much covered in undergrad CS programs. If it hurts, you're doing it wrong - you don't have to dip that deeply in to OO to find excellent patterns for solving it, of you even need to go that far.
On certain platforms like the Win32 API, 2) &3) are hopeless by, it seems, design. Just do your best then :)
The latter sentence sounds like a non sequitur.