That is Why You and I Should Become Rustaceans

jo@sabotender
KBTG Life
Published in
15 min readMay 9, 2023
Ferris Crab, the unofficial mascot of Rust

Hi everyone!

Every time I see a picture of a crab, I always think of delicious crab dishes. But today, I want to talk about something completely different, something that’s technical and absolutely nothing to do with seafood. Psssssst… I have to snap out of my yummy seafood coma for now (by the way, in Thailand, there is an amazing seafood dipping sauce which goes great with crabs. You should try it once in your lifetime, and that’s my advice.)

This article, I want to introduce you to Rust programming language and why it’s so interesting right now. Even though I won’t be teaching you how to code in Rust here, if I get the chance to write other Rust’s articles, and I would love to, we can delve deeper together then.

Learning is the best weapon for software developers in this rapidly changing world. At the beginning of each year, KBTG encourages every employee to write their Individual Development Plans (IDPs), and managers are responsible for supporting and guiding them to achieve their IDP goals. Currently, KBTG has not officially adopted Rust as one of the company-standard programming languages. Many people may have heard of it. Many are interested. As for me, I’m determined to become a Rustacean this year, and that’s is my IDP.

By the way, If you are Thai and prefer to read the Thai version of this article, please follow the link below.

The Current State of Rust

I must confess that I’ve heard a lot about Rust programming language, but I haven’t had a chance to seriously study it. I have been writing Java for a long time and tried Go and Python a bit. Before, I was made to believe that all programming languages are similar to one another, even though their syntax and libraries may differ. Likewise, during a job interview, I heard from many applicants express the same belief that programming languages only differ in syntax. It was only when I tried Rust that my perception has changed. I can feel that there was something unique and interesting about Rust that obviously distinguishes it from other languages.

Stack Overflow Developer’s Survey 2022

In 2022, Rust once again claimed the title of the “Most Loved Programming Language” for the seventh consecutive year in Stack Overflow’s annual developer survey. It’s a position that’s highly valued and well-deserved, as the survey asks developers if they want to continue using Rust in the future, and a whopping 87% said “Yes!” That’s an impressive lead over Java, which has more developers who want to quit than continue using it.

Another highly coveted position is the “Most Wanted Technology”; Rust shares the top spot with Python, followed closely by TypeScript. In fourth place is the Go language, which is also a popular and trending language. Rust is not only a beloved language but also the one that developers are most interested in learning at the moment, tied with Go.

Rust is one of the greenest programming language

“ESG (Environmental, Social, and Governance)” trend is currently emerging, which means that no matter what business or profession we are in, we should pay attention to the environment and have a social responsibility. Of course, developers like us can also be a part of this trend with something called “Green Coding” (again, if I have an opportunity, I will explain this in my next article). Many of us may have heard of it, or even if we haven’t, I am pretty sure it’s not difficult to guess its meaning.

There is a research that is often cited or used as a reference, which was first conducted by Portuguese researchers in 2017 and reviewed again in 2021. Simply put, it is an experiment to find the greenest programming language, or the programming language that is the most environmentally friendly. Yes, it is interesting to know how they conducted the experiment, and what the findings are:

  1. Execution Time — how fast a program runs
  2. Memory Usage — the amount of memory used
  3. The impact of these two factors on Energy Consumption.

This experiment has been conducted on various programming languages, from the past to present. There are many control variables, as well as uncontrolled variables. Though some argue that adding more control variables would be beneficial. Regardless, I have included the results of this research here. If anyone is interested in reading the full paper, please click on the link provided at the image below.

The global results (on average) for Energy, Time, and Mb normalized to the most efficient language in that category. || Source: Pereira, et al. (2021)

Now, the interesting thing from the table above is that Rust is the language with extremely low energy consumption or, strictly speaking, the second greenest language after C, with very close numbers of Energy (J) consumption rate. This research also provides another interesting perspective, which is that languages that take less time to execute or use less memory do not necessarily consume less energy. If we look at Java, for example, we can see that it consumes a lot of memory, but surprisingly consumes less energy, which is quite intriguing.

TIOBE Programming Community Index as of April 2023

Next, let’s take a look at the popularity rankings from the community’s perspective. Start with the TIOBE Index, which ranks popular programming languages without categorizing them according to their usage. That means it combines all programming languages to create the overall ranking. There are over a hundred programming languages listed, and if you’re interested in how they determine the rankings, you can check it out here. As for the latest rankings in April 2023, Rust has made a comeback and secured the 19th spot in the top 20! while Go is ranked 10th and Java is in the 3rd position. Looking at the graph, Rust’s popularity has been steadily increasing since its stable release back in 2015. While some claim that Rust is a successor of C/C++, you can’t deny that it takes time to become great and popular. If you look back at the history of the TIOBE Index, you’ll see that C/C++ has always been in the top 5 for ages!

Next up, let’s take a look at the stat from the SlashData State of the Developer Nation 23rd edition, which gathers data from over 26,000 developers as of Q3 2022. The data is quite interesting as it shows that the Rust language community is growing at an unprecedented rate, with a growth of over 3 times in just 2 years.

SlashData: State of the Developer Nation 23rd Edition

At the beginning of 2020, there were only around 600,000 Rust developers, but as seen in the chart above, this number has already reached 2.8 million as of Q3 2022. Additionally, according to the SlashData Programming Language Index, Rust has moved up from the14th to 12th place (I don’t have the image of SlashData Index to show here, but you can check it out in the full report linked below the chart above.)

GitHub Octoverse 2022 — The Fastest Growing Languages

Finally, let’s wrap up with the growth statistics from the 2022 GitHub Octoverse, which highlights the impressive growth of the Rust community in the open-source industry. As seen in the above image, Rust ranked second, just behind HCL (Hashicorp Configuration Language). This reiterates Rust’s growing presence and popularity among developers worldwide.

History of Rust

Rust was born from the personal project of Mr. Graydon Hoare in 2006 while working at Mozilla. Later on, the company officially supported the project and announced it in 2010, stating its purpose of being used in developing a new browser engine.

The Origin of the Name Rust

According to many sources, Graydon was the one who chose the name ‘Rust’ based on a type of fungus. This fungus has the properties of being robust, distributed, and parallel, which corresponds to the characteristics of the Rust programming language. One of the sources also says that Graydon’s love is not only for compiler, but also biology. “Hmm…apparently computers and biology can go together,” I thought to myself.

“Rust Fungus” Image by Hans from Pixabay

The Story Behind Rust’s Logo

For Rust’s logo, I stumbled upon a post from Graydon himself that said it was inspired by bike chainrings, signifying his and his team’s love for cycling. I will let you guys read Graydon’s message in the image below. This time I said to myself, “Okay… now it’s computers and transportation.”

Rust’s Logo
Graydon told the story of the Rust logo

So how did ‘Crab’ come about?

Crab comes from the fact that Rust developers call themselves, “Rustaceans”, which comes from playing with the English word “Crustacean”. Crustacean refers to marine animals with hard shells. Then, Karen Rustad Tölva designed a cute crab named “Ferris the Crab” (check out the first picture of this article) and it somehow became an unofficial mascot of the Rust language. The name “Ferris” comes from playing with the word “Ferrous”, which means “related to iron”, and this is in turn a play on the fundamental meaning of the word “Rust”, which means “corrosion”. “Again… it’s really multi-layered. It is slightly beyond my imagination,” I thought to myself.

“Crustaceans” by Peter Wilton, CC BY 2.0 , via Wikimedia Commons

Ferris the Crab has been produced in various forms of merchandise and is so cute! I want one so bad. Does anyone have a donation for me?

Rust Ferris Plushie at DevSwag

Rust Foundation

So in 2015, Rust released its first stable version 1.0, but I understand that its creator, Graydon, had already left Mozilla by then and later received an offer from Apple to work on the Swift language. I still remember reading an interview where he said he liked both languages and believed Rust had a promising future. Nevertheless, Graydon has already become a legendary originator of Rust.

Then, in 2021, after the COVID-19 pandemic, the Rust Foundation was founded by five major companies, namely AWS, Huawei, Microsoft, Google, and Mozilla, to drive all Rust-related technologies. Currently, the number of members has increased, including two more major players: Meta and JFrog.

Talking about the major players in Rust Foundation, firstly, I recommend reading the short article from AWS, “Why AWS loves Rust, and how we’d like to help”. It will help you make a decision as well.

Secondly, as for Microsoft, I’m a little confused because, as we all know, the Windows operating system has a lot of C/C++ codes. Rust is interesting enough to inspire Microsoft to explore how to replace C/C++ in Windows with Rust. At the same time, Microsoft has also been inspired by Rust and has become a case study, leading to the creation of the Verona project. The goal of Verona is to create a new infrastructure programming language with the primary feature of concurrent ownership for memory safety, just like Rust.

Finally, for Google, I think they’re more focused on learning to compete. I’ll expand on this at the very end of the article.

Why Rust is very Compelling

If I were to summarize why Rust is so cool, even though I’m still a baby Rustacean myself, I can only scratch the surface. But if these things make me interested in Rust, maybe it could make you, the reader, interested in Rust too.

Rust presents a unique balance or trade-offs between low-level coding concepts (think of C programming with multiple layers of pointers) and high-level coding concepts presented in modern languages (think of interfaces, abstractions, functional programming, etc.).

Now, let me give you more technical examples:

  1. Rust offers Data Race Free Concurrency Programming!
    Apart from the popular selling point of Rust in terms of memory safety, those who have dealt with concurrency programming should understand that data race is one of the most difficult problems to solve. It’s difficult to debug and fix, and many languages help developers by providing out-of-the-box tools to detect data races, especially. However, for Rust, not only will you not encounter Null Pointer References, Dangling Pointers, Invalid Memory Addresses, etc., but you can also incredibly eliminate data races from your codes.
  2. Rust offers Memory Safety at Compile-time without Garbage Collector!!
    Some modern languages don’t want developers to worry about memory management, which is as problematic as in C/C++, so they usually come with something called garbage collector in runtime, for the purpose of managing space in memory. In some languages like Java, they even take out the usage of pointer type altogether. Having a garbage collector means giving up resources to make it work, and each language has different levels of resource consumption. However, Rust does not require a garbage collector at all. Using Rust, you won’t have any problems with space in memory, and your program will work very fast. At first, I felt like it was too good to be true.
  3. Rust offers Abstraction Concepts with No (or Minimal) Performance Cost!!!
    This point is not easy to explain. To understand this, you may need to write Rust for a bit and touch on some features first; the features that people like me, who have been fed up with Java for a long time, find very surprising and amazing how they work like magic. Examples of this are Rust’s Traits and Async/Await.

I think Rust is following these Zero-overhead principles that were laid out by the creators of C++ pretty well.

- What you don’t use, you don’t pay for
- What you do use is just as efficient as what you could reasonably write by hand

That’s dope!

Up until now, I’ve been feeling that Rust does add some burden to programmers writing code, but in exchange for an incredible and unbelievably different result when your program runs. Rust itself sees these trade-offs as worth it! When I learned the language, it made me think of the term “Mechanical Sympathy”. If you’re not familiar with this term, try googling it up! It is something like if we understand computers better, we will be better programmers. And Rust makes us that way.

I love this sentence I saw on the internet describing Rust:

“Once your code compiles, it is correct!”

That’s awesome!

And I want to give you another example, which may seem small to experienced programmers but is undeniably crucial: variable declaration. In English, “Variables” means “likely to change often”, but in practice, most of the time, the value of a variable in our codes doesn’t change. Therefore, when declaring a variable in Rust, it is immutable by default. If you want a variable to be mutable, you have to use a special keyword to designate it. This is opposite to what I am used to in Java, but Rust’s approach has proven to be beneficial for the compiler.

I talk a lot about the advantages of Rust, but of course there are also some frustrations. I said earlier that Rust does burden programmers in some ways, especially for baby Rustaceans like me. Here are my top 3 frustrating things about Rust:

  1. str and String
    Rust has a lot of data types for working with text, and str and String are just two of them. They’re not interchangeable and lead to confusion for beginners.
  2. Ownership and Borrow Checker
    This is the “heart” of the language that everyone needs to understand. It’s the secret weapon for ensuring memory safety, but it’s definitely not easy to grasp.
  3. Kinda slow compile times
    If you’ve written Go before, you should know what I mean. But one thing that’s nice about Rust’s compiler is that it’s very friendly —not only does it tell you where you’ve made a mistake, but also suggests ways to fix it.

Learning Rust isn’t easy, but it’s definitely fun. It’s not as simple as the Go language, but that’s what makes it fascinating.

As a bonus, I recommend an article for those who currently write in Go or want to compare Go with Rust. The article is “Go vs Rust: How can you determine which language is better for your next project?” in which the author provides a useful perspective on how to choose the languages. Below is a summary table for a quick look.

+----------------------+--------------------+---------------------------+
| Characteristics | Go | Rust |
+----------------------+--------------------+---------------------------+
| Memory Management | Garbage Collector | Ownership Model |
| Speed and Performance| Medium | High |
| Learning Curve | Low | High |
| Compile Time | Fase | Slow |
| Deployment | Static Binary | Static Binary |
| Concurrenty | Goroutines | Async/Await and Threading |
+----------------------+--------------------+---------------------------+

Rust language has many interesting stories and case studies. Many companies have switched from Java to Rust or even from Go to Rust. Personally, I’m hopeful that Rust will have a bright future. It’s exciting to think about what Rust can achieve in the future and how far it can be extended.

Opinionated Interesting Use Cases of Rust

Before I tell you what I personally find most interesting about Rust’s use cases, I think I need to summarize Rust’s general advantages a bit so that even non-technical readers can understand why Rust is so awesome and worth studying.

  • Not only is Rust memory safe, but it’s almost bug-free
    As I mentioned earlier, Rust is designed to force programmers to write code in a certain way, and the result is that if your code compiles, it means there are very few bugs left.
  • Once you have memory safety, security will follow
    There are many vulnerabilities that attackers can exploit when it comes to memory. Memory safe language is very compelling because it means that errors in code cannot lead to security vulnerabilities. With no vulnerabilities, Rust’s security is just as strong as other languages.
  • Not only is it fast, but it also consumes extremely low resources
    There are many benchmark articles comparing Rust to other languages on the internet, and I am quite confident that you will be impressed with the results. All you need to do is trade it in for the hard work and diligence of studying Rust, practicing writing it until you become proficient.
  • Once resource consumption is very low, sustainability will follow.
    As mentioned above, you are doing more for the environment when you write Rust than other languages.

Now I am ready to talk about what I think are interesting use cases for Rust.

Rust with Blockchain and Web3 services

At first, I couldn’t believe that Rust was being used for programming on Blockchain, apart from Solidity. Some of the well-known names using Rust include Polkadot, Solana, Elrond, Near Protocol, and Hyperledger Sawtooth. If you look up Web3 Programming Languages, you’ll find that Rust is one of them too.

Rust with WebAssembly (WASM)

WebAssembly is a program that was originally designed to work in browsers. So, what makes it so special? It’s special because it works at near-native speed, allowing it to do things that regular browser code can’t do. And most importantly, it can work together with JavaScript. We can compile Rust code into a WebAssembly Module. This means we can use Rust to write an entire application that works on browsers or we can write only a part of the code and work alongside existing JavaScript code.

Server-side WebAssembly for Microservices

Continuing from the previous point, the use of WebAssembly is now spreading to the server side, not just browsers. According to research by IEEE Software, WASM apps that run on the server-side are faster and consume fewer resources than writing Rust code in a Linux container, roughly by 100 times. Personally, I admit that I haven’t studied the details of this yet, as it may be beyond the level of a baby Rustacean like me. But I can sense that if this continues, it will be truly amazing. Another thing that I’ve heard is that Microsoft is experimenting with something called Rust-based Kruslet. I understand that Microsoft is also trying to make Rust that compiles to WASM work outside the browser, namely on Kubernetes.

Conclusion: Rust Learning Roadmap and the Carbon Language

For those of you who are wondering how to get started, if you already have a background in programming, I recommend the e-Learning “Take Your First Steps with Rust” or Microsoft’s Beginner’s Series to Rust, which I personally like for its text-based approach and easy-to-understand layout. The content is concise and suitable for beginners, but if you have no prior programming experience at all, it might be difficult for you. Alternatively, for novices or those who prefer an interactive approach, platforms like Udemy or YouTube have plenty of resources available. And for those of us currently studying Rust, you might be interested in this Rust Web Developer Roadmap.

Rust Web Developer Roadmap 2022

Lastly, I would like to chit-chat about a language called Carbon. Carbon is a language that Google introduced in mid-2022 with the ambitious goal of becoming the successor to C++ with a focus on performance and interoperability with C++ (Doesn’t it seem similar to Rust?). When I first heard about Carbon, I couldn’t help but think that a company like Google, the top-tech company in the world, felt the need to do something to maintain its standing position. Using other people’s products may not be as appealing as using their own. Learning from past mistakes to create something better than before is the way of the world. I think that’s the same way we learn everything.

Happy Rustaceans!

Want to read more stories like this? Or catch up with the latest trends in the technology world? Be sure to check out our website for more at www.kbtg.tech

--

--

jo@sabotender
KBTG Life

principal DEVelopment eXcellence engineer — DEVX@KBTG / Full-time Daddy / Console Gamer & Gunpla Collector