Rust is 4 years old today, why are more and more well-known projects using Rust?
Source: blockchain stronghold by Mike Tang
Four years ago today (15 May 2015), the Rust programming language core team officially announced the release of Rust 1.0.
Over the past four years, its elegant ability to solve high concurrency and high security system problems has become increasingly popular with developers. And for the fourth year in a row, he won first place in the Stack Overflow developer's "favorite programming language."
Recently, more and more well-known blockchain projects have chosen Rust as their development language, including: Parity, Polkadot, Substrate, Grin, Ethereum classic, Holochain, cardano-rust, Exonum, Lighthouse, Nimiq, Nervos, conflux-rust, Codechain, Witnet and many other well-known projects.
This paper attempts to explore the reasons behind this trend. It also systematically explains the impact of Rust language on block chain development and its advantages.
Rust: a secure and concurrent software system
Rust is a system-level programming language designed to ensure memory and thread safety and prevent segment errors.
As a system-level programming language, its basic philosophy is "zero overhead abstraction." In theory, it's the same speed as C/C++. Rust can be categorized as a generic, multi-paradigm, compiled programming language similar to C/C++.
Unlike these two programming languages, Rust is thread-safe! Its goal is to create a secure and concurrent software system. Rust emphasizes security, concurrency, and memory control. Although Rust borrows C/C++ syntax, it eliminates null and dangling Pointers, which are at the root of system crashes, memory leaks, and insecure code in C/C++.
While Rust is a system-level programming language, that doesn't mean it has to write only the underlying programs (operating systems, drivers, tools, databases, search engines, etc.), its level of abstraction is absolutely amazing, and it's proven to be as good and easy to model as C++/Java/Python/Ruby.
But super-abstract languages like Haskell are not where Rust is headed either. Rust strives to find a balance between abstraction and the real world.
Now, for the fourth year in a row, Rust has won the no. 1 spot in StackOverflow's language of the year award.
The history of the Rust language
Rust was originally a personal project of Mozilla employee Graydon Hoare. It began in 2009 with support from Mozilla research and was announced in 2010.
Bootstrapping implemented between 2010 and 2011. Since then, Rust has undergone significant design changes and iterations (with great difficulty) before finally releasing version 1.0 on May 15, 2015.
In the course of this development, Rust has built a strong and vibrant community with a solid set of project contributions (which is the real scary part). Rust is now maintained by the Rust project developer community.
The following figure describes the Rust gene map:
Rust is still a niche language
Rust has come a long way since 1.0 to date (May 2019). But overall, Rust isn't particularly widely used (it's too young, after all) compared to Python, C, C++, and so on.
According to the survey, a large part of the reason for the low usage of Rust is the small number of companies that have chosen Rust.
However, Rust is becoming more and more of a work force. Over the past year, Rust has seen surprising growth in commercial applications. Including some well-known companies:
Amazon: build tool with Rust;
Facebook: source control tool;
Google: as part of the Fuchsia project;
Microsoft: use Rust partially in the new Azure iot framework;
Twitter: use Rust as part of building team support.
Domestic baidu, ali, has also been in the internal small scope of the use of Rust. I believe Rust will grow even faster as more companies choose Rust.
Gavin Wood brought Rust to the blockchain
The first to apply Rust to a well-known blockchain project was probably Gavin Wood. Dr. Gavin Wood left the Ethereum community in the second half of 2015 to start Parity Technologies and launch Parity, the Ethereum client, which successfully occupied half of the Ethereum community. The Parity client was written in Rust.
The MaidSafe project was around even before Parity. MaidSafe tries a lot with the Rust language. The security emphasis of the Rust language itself, as well as frontier projects such as MaidSafe, may have given Gavin good reason to choose Rust as the parity development language.
The language features of Rust itself (security, high performance, concurrent programming) and the features of blockchain (distributed, cryptographic, security-sensitive) inherently overlap considerably.
Not only that, Rust is different as a programming language, not because of how beautiful its syntax is (actually a little ugly for some) or how popular the community is, but because of the confidence gained when writing code with it.
It seems that Rust can affect the efficiency and expressiveness of your code, but, quite surprisingly, the opposite is true: it's much easier to write an efficient, customizable Rust program than it is to write a potentially dangerous one.
Here are the Linux kernel bugs found between January and April 2018:
For Rust, the 51% portion of the figure on the right can be avoided at the language level. That said, for Rust, none of these issues exist on the right side of the figure.
At present, there are two views: "one only needs to know how to write C" and "one only needs to leave the bottom of the pile for the professionals", neither of which is enough. The Linux kernel is written by strong programmers, probably the top 5 percent of the industry, but still, CVE comes out year after year.
You might not think that 50 bugs in a million lines of code is a big deal. But in some key areas, bugs are a systemic risk (for example, a bug in a heart pacemaker can be life-threatening). Also, those are the 50 bugs we've found, who knows how many bugs we haven't found yet? With Rust, we know the answer beforehand.
The nice thing is that Rust implements memory security and concurrency security without sacrificing performance. Even better, it addresses both memory security and data competition with the same set of abstractions.
Rust's zero-overhead abstraction allows you to enjoy security without losing performance. This is what traditional programmers dream of.
Take Parity, which USES Rust precisely because you don't have to worry about writing complex and high-performance code in Rust. Write programs in Rust, away from undefined behavior, data contention, and memory security issues. Not to mention, Rust is fast, fun to write, easy to read, and has almost no runtime.
Memory security issues are so difficult because you can't easily write tests to catch them. If you don't find a bug before the beta phase, the bug may stay in the code for years, like a ticking time bomb. Of course, there are tools like Valgrind to help you catch these bugs. But if no memory problems are triggered during execution, or if the code generated by such tools is not executed at run time, they will not be caught.
So, by using Rust, we eliminate one of the most complex and unpredictable classes of errors.
Rust has built-in formal proof theories, but only for memory security and concurrency. Rust internally justifies your program with logic. This is why you write Rust code with such confidence. Every time you compile, you have a set of mathematical theories to prove it to.
For a long time, one of the killer features of functional programming languages like Haskell was the ease with which formal proofs could be made, which was impossible with traditional imperative programming languages (due to Shared variability, unsafe pointer manipulation, and uncontrollable side effects).
But Rust changed that, and as an imperative language, it was on the road to being proven. So far, part of the standard library has been proven correct.
Well-known blockchain projects developed with Rust
parity
When it comes to well-known blockchain projects written in Rust, Parity is at the forefront. Parity is an ethereum node client called Parity -ethereum.
Parity Technologies is the name of their company. Parity now has a suite of clients and libraries, including:
parity-ethereum;
parity-zcash;
parity-bitcoin;
shasper
In other words, Parity Technologies provided a family bucket for developing blockchains using Rust.
polkadot/substrate
Polkadot is a project by the Web3 foundation, developed by Parity Technologies, that aims to do more than connect blockchains.
Polkadot enables developers and enterprises to build block chains, or parachain, using their protocols. As long as these parallel chains are based on Polkadot, they will share the same authoritative proof (PoA) consensus.
Since this type of consensus is embedded in Polkadot, parallel chain developers can focus on the specificity of their respective blockchains. All parallel chains are seamlessly connected to a generic blockchain called the relay chain, which ACTS as the link between all parallel chains.
The Polkadot project, led by Gavin Wood, is actually being developed by the same company as the parity bucket above, but by different teams.
If you follow the progress of Polkadot in real time, you'll probably see the word "Substrate" a lot. It is an important part of the Polkadot project. Parity Substrate is a Polkadot independent project. Polkadot is Substrate based, and other Substrate based projects can also run on the Polkadot network (forming an ecosystem).
So what is a Substrate? You can think of it as a framework similar to Express or other Web applications, but it is a framework for building distributed or decentralized systems, such as cryptocurrency projects, or message bus systems.
Just as most Web applications do not need to re-implement their own HTTP protocol, for each team creating a new chain, there is no need to implement network and consensus code from scratch, which is a waste of effort.
Not to mention that in order to implement business logic, you have to hire cryptographers, security researchers, network engineers, developers (to coordinate updates), and so on. If you're building a new project using a Substrate, you can easily and quickly create a chain by implementing a few function callbacks in your code.
* reference links:
https://github.com/paritytech/polkadot
https://github.com/paritytech/substrate
grin
Grin is the little web celebrity of today's blockchain world. One of the few projects aimed at becoming real money.
Grin is committed to providing a cryptocurrency that is both private and scalable and is scheduled for release in early 2019. Several unique properties: the use of a privacy protected blockchain format called MimbleWimble; It is cheap and easy to run a full node with only a small amount of data stored in the blockchain.
Mimblewimble was developed by anonymous people with teams around the world; There are no pre-dug PoW mechanisms, more equal and decentralized.
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia