You have probably heard of the programming language Rust. You may also have seen people talk about it as a safer, more secure C / C++. But exactly what is Rust, why are people interested in its use, how popular is it and what are the primary use cases for Rust?
17-02-2025
You have probably heard of the programming language Rust. You may also have seen people talk about it as a safer, more secure C / C++. For example, the US Government has produced a directive indicating that Rust should be used instead of C/C++ in critical applications. But exactly what is Rust, why are people interested in its use, how popular is it and what are the primary use cases for Rust?
What is Rust?
Rust is a general-purpose programming language launched in 2010 by Mozilla. That is, it is a language that can be used to write a wide variety of applications rather than being designed for a specific type of task such as data processing or mobile software development etc. However, Mozilla created it explicitly to address issues they saw in older languages such as C/C++.
It is a compiled language as opposed to an interpreted language such as JavaScript
and Python or one that uses byte codes and an intermediate virtual machine such as Java
and C#.
Like many modern languages it is a high-level programming language; however, unlike many of the current tranche of new languages it does not adopt the automatic memory management and garbage collection strategy of languages such as Python, JavaScript, Java and C# etc. In many ways, it makes the programmer work at a lower level and take more direct care of memory usage.
However, it is a very strict language and one which applies to rules at compile time rather than runtime. It therefore positions Rust as a far more strongly typed and rigorous language than certainly Java Script and Python; and in practice more so than Java and C#.
Why the Interest in Rust?
So, Rust claims to be fast and safe. What does this mean, well it is fast because it is a statically compiled language that does away with memory managers and garbage collectors. Instead the programmer must handle where and when memory is being used. Although compared to the features for this in languages such as C/C++ it is done at a much higher level and strenuous checks are performed at compile time to ensure no data is accessed incorrectly.
So how is it safer than languages such as C/C++. First let’s consider what the issues are with regard to memory usage in these languages. The first issue is that programmers must allocate and deallocate memory when they use it. In some cases, the complexity of the application may mean that it is not always clear that this has happened correctly. You have probably heard of the phrase memory leak! This can happen when memory is allocated to the program but once the program stops using that memory it is never freed up.
The second issue is the idea of access memory beyond that which has been allocated for use. For example, you create an array of ten elements (which are indexed 0 to 9) but then try to access the element in index position 10 – this could be some random part of memory which is not being used for the array, and this can cause parts of the program to access corrupted data etc.
The third issue is associated with temporal access; this occurs typically in a multiple thread / multiple process program. In such situations concurrent behaviour may try to access / update some shared data structures. If one concurrent program element tries to read from such as shared structure in memory which another is writing to it then again data corruption can occur.
To overcome this Rust explicitly has the concepts of:
Now when a variable is created, it allocates the necessary memory for that variable to hold a value. When an actual value is assigned to the variable, the variable owns the data; it is now not possible to assign the value to something else. Once the variable goes out of scope, the memory is freed up so that there is no chance of anything else continuing to use the value.
So far so good; but what if another piece of code wants to use the value in the variable; it must now borrow it. Borrowing is a bit like a reference in a language such as C/C++. The Borrow Checker checks what is borrowing a value and ensures that while something is borrowing the value nothing else can access that value. Once some code has finished using the value then the borrow is returned and the owner of the value can access it again.
This approach is referred to as a ‘zero-cost abstractions’ (in fact Rust exploits numerous such abstractions). They are considered Zero Cost because at runtime they have zero cost, and all the work is done at compile time. Note that one downside of such abstractions is that at compile time it can sometimes feel like Rust is fighting the in part due to the learning curve required to work in a idiomatic Rust manner. You may find people talk about ‘fighting the borrow checker’ for example.
However, the upside of the ‘zero cost abstractions’ is very fast runtimes which are comparable with code developed using C/C++.
How Popular is Rust?
Rust often comes out as one of the most popular languages for developers. For example in the most recent (at time of writing) TIOBE index Rust had jumped from position 18 to position 13 in just one year. This puts it just behind the core top ten popular languages (such as Python, C++, Java etc.). The TIOBE index is an indicator of the popularity of programming languages.
So, although it is not as popular as those very well established programming languages; it is rapidly on the rise.
Rust Use Cases
I recently saw a question on one of the forums asking what type of application is Rust best suited for? Of course, Rust is a general-purpose programming language so there are a wide range of application types that you might implement using Rust. Just as we can say the same thing about Python. However, as with a language such as Python we probably wouldn’t use it create a real time air traffic control system, but we would use it to performance data analytics and AI related work; there are areas that Rust seems particularly well suited to. For example:
Systems Programming Rust can be used to create operating system level tasks where its performance and memory safety are particularly beneficial. For those interested in this area have a look at Rust and Linux – although this initiative is going slower than originally hoped Rust is now being integrated in Linux as a systems programming language.
Embedded System Rust is particularly well suited to embedded environments due to its efficiency and memory safety.
Real Time Applications Again due to its efficiency and lack of automatic memory management and garbage collection delays it is well suited to real time systems where reliable, consistent and fast operation are important.
Critical Systems Although systems may be embedded, real time and critical, there is a difference between each of these concepts. A critical system is one that must be highly reliable and retain this reliability over time. Rust is particularly well suited to such systems. There is even a specific Safety-Critical Rust Consortium focussed on this area.
Network Programming As with the above areas, Rust is very well suited to Network Programming due to its performance, memory safety and concurrency aspects.
Game Development A particularly interest application area for Rust is Game Development. Games need to be fast, efficient in their use of memory, reliable and tend to rely heavily on concurrent aspects to the game play. Concurrency is another particularly strong point for Rust. However, this area is relatively under developed, not least as the major game engines such as Unreal and Unity are written in languages such as C++ and C#.
Machine Learning / AI Interesting there is much to commend Rust for Machine Learning and AI. After all these tasks tend to use a lot of memory, can take a long time to run and need to be stable – all things that Rust addresses. However, the ecosystem available for Rust is currently quiet limited particularly when compared to that available for Python.
Web Development You might expect us to reference the server-side aspects of a web application as being particularly suitable for Rust and indeed they are. However, the combination of Rust and Web Assembly makes Rust a very good fir for create the client side aspects of a high performance web application.
High Velocity Trading Systems
A specific application area which may be one of the most commercial for Rust is potentially in high velocity automated trading systems. These systems have traditionally been written in C / C++ however reliability and predictably are extremely important for such systems. Rust brings numerous potential benefits with it making it an ideal replacement for these languages.
Summary
Rust is a powerful, fast, efficient and effective high-level language. It does have a steep learning curve associated with but once mastered provides significant benefits to a programmer and the systems they are developing when compared with (most) other programming languages.
Would you like to know more?
If you found this article interesting you might be interested in our Rust Training Course.
We maintain a robust range of hands-on training courses covering Coding, Data Science, DevOps, Security and more - available for on-site and online delivery as part of a full-stack training programme or as short standalone workshops. We would love to discuss your learning needs - get in touch for a no-obligation scoping chat.
We use cookies on our website to provide you with the best user experience. If you're happy with this please continue to use the site as normal. For more information please see our Privacy Policy.