Is it time to retire C and C++ for Rust in new programs? • The registry

Split We all know that the Rust language has become much more popular. According to Slashdata count, the number of Rust users has almost tripled in the last 24 months.

Markus Russinovich, Those of Microsoft Azure CTO, tweeted that “it’s about time Stop starting new projects in C/C++ and use Rust for scenarios where a non-GC language is required. For safety and reliability reasons. The industry should deprecate these languages.”

They are fighting words!

What caused this? As noted hereit’s not really a desire to start another endless programming language war – see vi vs EMACS, tabs vs spaces and Java vs Python. No, I think that’s what triggered his comment Linus Torvalds has given his blessing to bring Rust code into the Linux kernelstarting with Linux 6.1.

If the Linux kernel developers, the programmers of the most successful C project of all time, are embracing Rust, why not the author of Windows system internal tools?

Mind you, Russinovich isn’t suggesting that we discard everything already written in C or C++ and rewrite it in Rust in our plenty of free time. Far from it. As he tweeted after urging the industry to move away from C and C++, “There’s a tremendous amount of C/C++, which is maintained and further developed over decades (or longer). Last night I coded a feature for Handle that adds to the approximately 85,000 lines of Sysinternals C/C++ code I’ve written. However, when it comes to new tools, I tend to use Rust.”

Of course he’s right. When I started programming, everyone said COBOL was history. Forty years later COBOL is alive and well, and its programmers are still making money. Well there!

Languages ​​never die. They just stop being sexy.

Still, there are good reasons to retire C and C++ in favor of Rust. First, Rust was built with performance and security in mind. The C-Family is all about speed and more speed. Security came a long way second.

That’s right, you can certainly write in C or C++. For example, you can use a more secure language variant such as SEI-CERT C or use safer guidelines when working with a language like that C++ Core Guidelines. And as Bjarne Stroustrup, the creator of C++, said The registry recently: “We can now guaranteed to achieve perfect type and memory safety in ISO C++.”

In fact, you could always write perfectly safe C and C++ code. It’s just that it was never, never easy. Both languages ​​make it far too easy to make mistakes in memory. These include invalid heap and stack memory access; memory leaks; mismatched memory allocation and deallocation; and uninitialized memory access. And those are just the common mistakes I’ve made! As Naveen Gv, an Intel technical consulting engineer, put it: “Memory errors are very common in C and C++ Applications and… can be difficult to reproduce, difficult to debug, and potentially expensive to fix.”

Both languages ​​are “memory insecure”. They give developers fine-grained control over their application’s memory, but with great performance comes great potential for problems. A memory snowball slip can lead to an avalanche of mistakes.

These are not just theoretical errors. They happen all the time. In 2019, Microsoft admitted that 70 percent of its Common Vulnerabilities and Exposures (CVE) security issues were caused by developers Memory corruption errors in their C and C++ code.

As much as I love to poke fun at Microsoft security, this issue is far from unique to Microsoft. Google’s developers found the same percentage of memory issues in the Chromium/Chrome web browser code. I’m sure it’s that bad in pretty much anything written in C or C++.

Rust, on the other hand, is a memory-safe language. Sure, you can still make security mistakes with it. You can in any language. But, and this is the important part, it’s much harder to make the kind of simple memory bugs that plague C and C++ applications.

For this reason, Google and Microsoft started thinking about replacing C and C++ with Rust years before Rust started making headlines. Now Linux is embracing Rust too.

Security aside, Rust has the advantage of being easier to write concurrent programs. Rust was written for a world of containers and the cloud, while C was written for 16-bit DEC PDP-11 minicomputers. Well, both C and C++ are very flexible, but we’re a long way from uniprocessor/single-core computers!

However, Rust will not replace his older brothers tomorrow. It will take years, even decades, but it will happen. We’ve ignored security for generations, but now that our entire economy depends on secure technology, we can’t afford to be so reckless with our programs. ®

https://www.theregister.com/2022/09/28/is_it_time_to_retire_c/ Is it time to retire C and C++ for Rust in new programs? • The registry

Laura Coffey

World Time Todays is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@worldtimetodays.com. The content will be deleted within 24 hours.

Related Articles

Back to top button