Rust Vs C A Battle of Speed and Efficiency
Rust Vs C A Battle of Speed and Efficiency
Submitted: 2023, May 18; Accepted: 2023, Jun 17; Published: 2023, June 21
Citation: Vincent, Ng. (2023). Rust vs C++, a Battle of Speed and Efficiency. J Math Techniques Comput Math, 2(6), 216-
220.
Abstract
This study compares the performance of two excellent options for system-level development, the programming
languages C++ and Rust. Through a series of tests and experiments using socket servers and various algorithms, this
experiment analyses the speed and efficiency of code written in each language by looking at variables like memory
management, and compilation times. The findings reveal that Rust has a number of advantages over C++, including
quicker compilation times, improved memory safety, and in many situations equivalent or better performance. C++
still performs exceptionally well in several fields, nevertheless, such as low-level hardware programming and backward
compatibility. Overall, the results indicate that Rust is a strong candidate for systems programming jobs, especially for
new projects or those requiring a high level of performance and security.
2.4 Bubble Sort same checks until in the end there is a sorted list left. Refer to
Like previously I will explain the Bubble Sort algorithm before the pseudocode below to get a better view of how it should look
I show the code; Bubble sort works via comparing adjacent in code. The code for Rust and the C++ implementation can be
elements in an array and swapping them if they are not in the seen below in the pseudocode
correct order. The algorithm iterates over every index with the
As seen in terms of performance for the Counting Sort algorithm numbers. Below is the table for the Bubble Sort algorithm. Once
C++ is outperforming Rust by a little bit, this difference expands again C++ is outperforming Rust in terms of performance but in
more though with bigger volumes of inputs example 1,000,000 this case, the difference is actually
pretty small which shocked me as I expected more difference has so many built-in functions in the standard library that just
in terms of execution time, but turns out they’re pretty close. In makes writing code for these types of programs easier.
terms of code complexity, Rust wins against C++ because Rust
Languages Memory Used Memory Used Compilation Time Execution Time LOC
(kb) (kb) (seconds) (seconds) (Lines of Code)
(Compilation) (Execution)
Rust 112384 1584 0.655 0.003 27
C++ 66576 1424 0.499 0.002 38