4 ms·
Rust is important, but that article isn't very good. Rust is at the level of C/C++, without an elaborate run-time system. It solves the three basic problems t
by Animats 12y ago
Rust is important, but that article isn't very good.
Rust is at the level of C/C++, without an elaborate run-time system. It solves the three basic problems that cause most failures in C/C++ programs: "How big is it?", "Who deletes it", and "Who locks it". It does this without throwing a garbage collector at the problem, which means it can be used for operating systems and hard real time.
The basic memory management mechanism is single-owner pointers, with language enforcement to make this work even as pointers are passed to functions. (Pointers passed to functions are "borrowed"; you can't keep a copy whose scope outlives the function return.) For more complex ownership, there are pointers with reference counts. For data shared across thread boundaries, there are atomic, locked pointers with reference counts.
We need Rust. We're still seeing CERT advisories on buffer overflows in C/C++ programs, after almost four decades of C. The threats are getting worse, too; it's not script kiddies any more, it's governments.
I just hope the Rust crowd doesn't screw up.
- lifthrasiir 12y agoYou are correct and many Rust developers and contributors are aware of that point, but the OP wants to highlight the often neglected portion of Rust that may appeal to C/C++ users. Not every C/C++ user would move to Rust just for the safety (I did, but their mileages may vary). Some people look for the better abstraction, some look for the performance, and some others look for just fun. Rust is trying to appeal to many of them, not just the paranoid C/C++ developers; I think this article is very adequate for them.
- Animats 12y agonot just the paranoid C/C++ developers You're not paranoid when they're out to get you. The most recent US-CERT advisory: Alert (TA14-300A) Phishing Campaign Linked with “Dyre” Banking Malware (Adobe Reader vulnerability) "...memory corruption vulnerabilities that could lead to code execution". This has been going on for over thirty years. It's time for the suffering to stop.
- pjmlp 12y agoThe sad part of this whole history is tha thirty years ago, if you didn't had access to an UNIX system, C didn't had any value. Those of us in other systems already had better alternatives, but then UNIX was pushed into the enterprise and succeeded at that, with the outcome of thirty years of buffer overflows.
- Dewie 12y agoAnd us who were born later than that get taught that C was the only viable and logical option at that time, from a technical standpoint.
- pjmlp 12y agoFrom people most likely younger than me.
- Animats 12y agoThere are a sizable number of programmers who believe a language has to be unsafe to be fast. This is because, for several decades, most compilers with subscript checking were really dumb about it. This started with Berkeley Pascal for BSD, which made a subroutine call for every subscript check and gave Pascal under UNIX a bad name. Good Pascal compilers were hoisting subscript checks out of loops in the 1970s, but not on UNIX. Then there was the C++ approach, trying to do it in templates. That leads to dumb subscript checking, because the compiler has no idea that the "if" involved in subscript checking is a subscript check and could potentially be hoisted out of the loop and done once at loop entry. For most math code, where this really matters, you can do one check at the top of the loop. Maybe zero checks, if the upper bound is coming from some "range" or "len" construct. At last, smart subscript checking is coming back. This is partly because languages now usually have a "do this to all that stuff" construct ("for i in foo ..." or similar) and it's a no-brainer that you don't need to check subscripts on every iteration. The Go compiler at least has that. How smart is the Rust compiler about this? It potentially could be very smart. This is important. Otherwise, people will want to turn subscript checks off for "performance".
- shadowmint 12y agoI think thats a bit unfair on the article. The memory management, and low level control make rust special. Thats what the author is talking about. ...why is an article that shows how to put rust into action bad? Its a great practical article about dipping your toes into the water of using rust in my oppinion. /shrug