
Author | Yun ZhaoIn 2022, more and more developers are finding that team leaders are starting to let their teams refactor projects using Rust. Even if the team leader doesn’t push it, colleagues around seem to be quietly practicing the “borrow checker”, and sometimes you can see them yelling at the screen: “What the hell, I’m not doing this anymore!”Netizens jokingly say: Just ten lines of Rust code can make you decisively give up!Learning Rust is difficult, and this has become a consensus. However, those who complain about its difficulty often find themselves practicing again after a while, fighting and failing repeatedly. A senior tech expert once complained: I have given up on Rust four times already!Rust is both loved and hated; it can make you so frustrated that you feel like you can’t even hit the keyboard hard enough, yet every time you see projects running on GitHub so efficiently and elegantly, you can’t help but admire it.

Source: Zhihu

The Charm of RustThe praise for Rust by enterprises is not a fleeting trend.Take the recent announcement by e-commerce software developer Shopify embracing Rust as an example. Shopify elaborated on the appeal and evaluation considerations of Rust for its business from five aspects: consistency, performance, community, productivity, and safety.Business needs align, performance is efficient, although the entry is difficult, development is quite efficient, community-driven open-source projects, and memory safety. It can be said that Shopify has covered every benefit of Rust.Consistency: Shopify’s system programming needs to cover multiple domains, and this number may increase over time. These include high-performance servers, Ruby extensions that improve performance or connect to other libraries, and compilation to Web Assembly. Shopify’s appeal is to invest in a single language and apply it across many domains, which means identifying a language that can be used very flexibly.Performance: Shopify needs to scale efficiently and sustainably to support global commerce. Rust provides us with predictable native code performance, including fine control over memory usage, making it suitable for the lowest levels of our stack. Of course, Rust is not the only language that can provide or approximate this performance. On this basis, modern C++ can also be considered, and if the allocation behavior and performance of the garbage collector are acceptable, Go can be used.Community: The Rust language and ecosystem are driven by a healthy community. Shopify plans to participate in this community like Ruby, Rails, React Native, and other open-source projects. The RFC process and governance structure of Rust provide a strong foundation for inclusive and thoughtful discussions to drive the future of the language and tools. Our contributions are expected to make Rust more efficient in Shopify’s use and improve the work of all Rust developers. This is also the reason Shopify joined the Rust Foundation. We hope to support Rust‘s excellent governance model and the maintenance of “Rust commons”, bringing Shopify’s knowledge and perspectives into the larger Rust dialogue.Productivity: In some circles, Rust is known for being difficult to learn and use, but developers inside and outside Shopify find that after the initial learning period, they become very efficient and comfortable using Rust. Rust also has a strong library ecosystem (“crates”) and good IDE integration tools, not to mention very good compiler error messages. The powerful features of the type and macro system allow for very expressive APIs and syntax, focusing developers’ energy on expressing their intentions rather than juggling a lot of states and invariants in their minds. Go also has a good reputation here, while C and C++ do not fare as well.Safety: Rust provides many tools that help the compiler ensure program correctness, including safely managing memory and allowing for “fearless concurrency”. As Shopify’s use of Rust becomes more complex, more ways will be found to use Rust‘s type system and safety rules to maintain invariants in the system. From our initial projects, we found that Rust exposes more errors at compile time rather than at runtime compared to other languages we evaluated. Rust developers often say, “Deployment is not a problem,” and this is the reason.

The Driving Force BehindRust is considered a young generation in the programming language world, but its ability to win the title of “Most Loved Programming Language” in the Stack Overflow Developer Survey for seven consecutive years speaks volumes about its strength.This strength comes not only from the characteristics of Rust itself but also from endorsements by several top companies or celebrities.Perhaps the most well-known is Microsoft. In February 2019, a report stated that 70% of security issues are memory safety issues. To address security problems, Microsoft began experimenting with using Rust to replace C/C++ in rewriting Windows components; Microsoft’s DeisLabs team also chose Rust to build the Kubernetes tool Krustlet, claiming that Rust is more suitable for Kubernetes development than Go.Another example is Facebook: since 2016, they have been using Rust, starting a rewrite project called Mononoke; with the Mononoke project proving Rust is viable, the internal Rust development team reached 100 people by 2019 and began applying it to the Diem blockchain project; in 2020, they established an internal Rust developer experience team to continue contributing to the Rust community and support internal Rust project development.Then there is Google: the Fuchsia operating system, developed since 2016, made its debut in December 2020 at Google Open Source, with 22% of its code written in Rust.It is worth mentioning that the safe language features overlap naturally with the characteristics of blockchain, making blockchain one of the earlier fields to adopt Rust. The Parity client developed by Dr. Gavin Wood should be the first blockchain project to use Rust, launched in 2015, and Parity Technologies’ products also include Polkadot, substrate, etc. The release of Parity caused quite a stir at the time.By the way, Mozilla, as the origin of the Rust project, originally planned to rewrite the entire Firefox browser in Rust, but unfortunately, only less than 10% was completed, and the entire Rust project was cut! However, it is precisely because it was cut that Rust has flourished today.Many big names in the tech circle also hold Rust in high regard, with Linux being one of them.At the 2022 Open Source Summit hosted by the Linux Foundation, Linus announced: Linux is starting to embrace Rust!Not long after, Azure CTO Mark Russinovich even called for the discontinuation of C/C++, suggesting the use of Rust, sparking heated discussions among netizens.At the same time, Nick Cameron, then Microsoft’s chief engineer, frequently mentioned Rust in his personal blog and provided many constructive suggestions for the development of Rust.Even Guido van Rossum, the founder of Python, went so far as to praise Rust, even at the cost of delaying Python 4.0. Guido stated that Python 4.0 is unlikely to see the light of day and believes that Rust is a fascinating language that can almost perfectly handle memory management issues.Looking back domestically, companies like Huawei, Alibaba, Baidu, and ByteDance have already entered the Rust arena. Huawei, as the only founding member of the Rust Foundation in China, is quite active in the Rust community, developing tools like Tokei and Cargo-Geiger, and attempting to apply Rust to open-source projects: StratoVirt is an enterprise-level virtualization platform on openEuler, aimed at cloud data centers, implementing a unified architecture that supports virtual machines, containers, and serverless scenarios. In addition, Huawei has also initiated a non-commercial organization called Rusted AI to promote the application of Rust in the AI field.The ByteDance Feishu team has been introducing Rust since 2017, with the non-UI part of the Feishu client implemented cross-platform in Rust; in May 2021, they open-sourced the rsmpeg project (a library for FFmpeg), also using Rust as the main language.Alibaba has also increased its investment in Rust in the cloud-native space; for example, in November, the Nacos multi-language system welcomed the Rust version.

In 2023, Is It Worth Picking Up Rust Again?Yes, it is definitely worth it. Whether from a trend or reality perspective, the value of Rust is already very clear.First, in terms of popularity, the Stack Overflow Developer Survey and the annual Rust survey indicate that the proportion of people using Rust as a working language is continuously increasing. Once this inertia is established, it will become a trend similar to the global popularity of Java.Moreover, with the support of the Rust Foundation, this trend will accelerate. It is reported that the founding members of the Rust Foundation have committed to providing an annual budget of over one million dollars for the maintenance, development, and promotion of Rust projects within two years.Secondly, Rust represents a “avant-garde” programming philosophy. The improvement of software performance always lags behind the improvement of hardware performance. The multi-core programming concept based on Rust combines low-level control of performance with modern language features, with syntax similar to C++, but ensuring memory safety, which is enough to allow it to stand firm in the future programming world.Furthermore, Rust has proposed eye-catching concepts such as “concurrency without data races”, “memory safety without garbage collection”, and “fearless of hackers”, attracting countless geeks and experts to gather around its projects, continuously evolving and presenting an increasingly open and healthy community ecosystem.Additionally, Rust represents a new way of collaboration in open-source projects: decision-making power in Rust projects is uniquely delegated and distributed, with the core team having more privileges.Finally, the demand is there. If in the past, leaders asked for Rust refactoring to tell a story, and learning Rust was just for show, nowadays the application scenarios of Rust are becoming increasingly clear: blockchain development, embedded development, distributed systems, cloud-native, WASM, GUI, etc., are all seeing its presence.The previous dream of a single language tackling multiple domains was attempted by Java but ultimately failed; Rust has become the new hope, with companies like Shopify evaluating it as highly compatible with their business.As one developer commented: The great advantage of Rust in large enterprise environments is that it is truly very versatile, capable of replacing multiple languages with one. Rust can do everything that C/C++ can do, everything that Java can do, and most of what JavaScript can do (as WASM improves). This one-stop programming language store is a dream of Java, but the failure of embedded Java and Java applets crushed that dream. Rust has the potential to revive it.

Difficulty: How to Lower the BarrierBeginners of Rust often find themselves halfway through writing, hearing a voice in their heads: Why make things difficult for myself? For example, this friend—Originally wanting to use Rust to write an API gateway integrating business logic, but ended up getting frustrated with the errors from futures, thinking that it was useless to struggle with something that has no state, so they just used Node to get it online.The steep learning curve of Rust is widely recognized. Whenever faced with setbacks, Go, C#, Crystal, and Dart become its alternatives. Many developers even struggle to understand the borrow checker after months of learning.Therefore, even if Rust can produce highly efficient code, companies may remain skeptical about their developers’ productivity using it.The biggest question is whether Rust will be accepted by less technically skilled programmers, especially as its complexity continues to increase. Teaching and training in Rust will be key.Habits need to be cultivated, just like the unfamiliar concepts of garbage collection, runtime exceptions, and functional programming; it is a process of continuous adaptation and adjustment.We can see that the Rust community has been tirelessly promoting learning, from the activity level of the community to the supplementation of tutorials, etc. In addition, the Linux Foundation has also released tutorials on how to write kernel modules in Rust.Recently, a thoughtful person used OpenAI’s ChatGPT to learn Rust. An author tried to engage with it on Rust topics, and the responses were quite satisfactory. For example:
-
Write a program that reads file contents and adds detailed comments for each line
-
Given the source code and compiler errors, it provided clearer explanations and helped fix them
-
Asked a question about rust-analyzer failing to discover workspace, ChatGPT provided detailed solutions. Later, it even helped write a complete command-line program
Is there a difficulty in learning? If you learn, then what is difficult will also become easy; if you don’t learn, then what is easy will also become difficult. Rust tortures me a thousand times, yet I treat Rust like my first love! Let’s encourage each other!

● The first wafer fab is about to start, can India’s “chip dream” succeed?● In 2023, I advise you not to be a full-stack developer!● The rankings are out! Java has fallen behind C++ for the first time!Three cheers for the editor!