Is C++ getting RUSTed?
Utkarsh Sharma
SME & Manager | SAP Certified Application Associate | Certified Data Scientist | Intel certified Machine Learning Instructor| Mentor
A StackOverFlow survey marked Rust as the most loved programming language, sitting at the number 1 spot with 78.9% preferred, with the later sitting in 22nd spot at 46.7%.
Both Rust and C++ are system programming languages which means they can be used to write low-level code like operating system Kernels or firmware for micro-controllers.
Also, both of them provide a high level of abstraction which helps in building applications like games and web applications.
Both overcome the problems of memory management which were present in C language like segmentation fault and undefined behaviors. They both do not have the garbage collector to manage the unused memory which makes the code more efficient and predictable.
In modern C++ to handle the problem of memory leak while using pointer operations there is a powerful concept introduced known as smart pointers. With using smart pointers, we do not need to explicitly call delete rather it will be automatically deleted. But still there are significant limitations to the use of this smart pointers. Rust takes it step further an introduces the concept of Borrow-Checker, a component bundled inside the compiler itself which makes sure that reference is not allowed to outlive the data they refer to. It also solves the problem of racing.
领英推荐
Rust also provides the functionality of Sync and Send which determines that a multithreading operation is safe or not. Although sharing memory between the threads is possible but if some thread tries to do it unsafely then Rust will stop you from doing so providing data races at an early stage.
Also, unlike C++ where every variable is mutable by default and we can make it immutable by adding a keyword Const, in Rust every variable is immutable by default, and we can make them mutable by adding mut keyword.
One more additional feature is managing the packages in Rust, Cargo is the official package manager of Rust. With the help of Cargo installing a package in Rust is a very simple task that is done by just adding a line of code in the dependency file.?
Digital Specialist Engineer | Azure PAAS Transformation | AKS | Azure Devops | Containerization
3 年Insightful! Off course StackOverFlow does represent a major part of the programming industry but for such comparisons I think the TIOBE index is also something to be considered! As it covers far more ground than any possible survey can cover.