Rust 1.87.0 Official Release & 10th Anniversary of Rust 1.0

OSCHINA

↑ Click the blue text to follow us

May 15 marks the 10th anniversary of the release of Rust 1.0. The Rust project developers held a “Rust 10th Anniversary” celebration in Utrecht, Netherlands, and released the new version 1.87.0 on the same day.

Rust 1.87.0 Official Release & 10th Anniversary of Rust 1.0

The main new features of the new version include:

  • Standard library adds Anonymous Pipes
use std::io::Read;

let (mut recv, send) = std::io::pipe()?;

let mut command = Command::new("path/to/bin")
// Both stdout and stderr will write to the same pipe, combining the two.
    .stdout(send.try_clone()?)
    .stderr(send)
    .spawn()?;

let mut output = Vec::new();
recv.read_to_end(&mut output)?;

// It's important that we read from the pipe before the process exits, to avoid
// filling the OS buffers if the program emits too much output.
assert!(command.wait()?.success());
  • Security architecture intrinsics
#![forbid(unsafe_op_in_unsafe_fn)]

use std::arch::x86_64::*;

fn sum(slice: &[u32]) -> u32 {
#[cfg(target_arch = "x86_64")]
    {
if is_x86_feature_detected!("avx2") {
// SAFETY: We have detected the feature is enabled at runtime,
// so it's safe to call this function.
return unsafe { sum_avx2(slice) };
        }
    }

    slice.iter().sum()
}

#[target_feature(enable = "avx2")]
#[cfg(target_arch = "x86_64")]
fn sum_avx2(slice: &[u32]) -> u32 {
// SAFETY: __m256i and u32 have the same validity.
let (prefix, middle, tail) = unsafe { slice.align_to::<__m256i>() };

let mut sum = prefix.iter().sum::<u32>();
    sum += tail.iter().sum::<u32>();

// Core loop is now fully safe code in 1.87, because the intrinsics require
// matching target features (avx2) to the function definition.
let mut base = _mm256_setzero_si256();
for e in middle.iter() {
        base = _mm256_add_epi32(base, *e);
    }

// SAFETY: __m256i and u32 have the same validity.
let base: [u32; 8] = unsafe { std::mem::transmute(base) };
    sum += base.iter().sum::<u32>();

    sum
}</u32></u32></u32>
  • Inline assembly can jump to labeled blocks in Rust code using <span><span>asm!</span></span>
unsafe {
    asm!(
"jmp {}",
        label {
println!("Jumped from asm!");
        }
    );
}
  • Stable API and more

To celebrate the 10th anniversary of the stable release of Rust 1.0, Rust author Graydon Hoare wrote a long article titled 10 Years of Stable Rust: An Infrastructure Story, in which he mentioned a set of data:

  • Before 1.0, the Rust codebase recorded 40,000 changes; since then, there have been an additional 246,000 commits. This translates to nearly 2.8 merges per hour over the past 10 years.

  • The number of contributors has grown from less than 1,000 at 1.0 to about 6,700 now.

  • The project has closed over 47,000 issues and handled more than 140,000 PRs.

  • There were about 1,100 RFCs (Requests for Comments for language evolution) at 1.0, and now there are a total of 3,772.

  • Since 1.0, 87 official versions have been released, most of which have been released on time every six weeks.

  • Three Editions (version changes packaged, compatible with old code) have been introduced to bring in non-compatible changes that require opt-in.

  • The compatibility testing range for each version has grown from 2,500 crates to now 587,000.

It is said that when Rust was created, Graydon Hoare discovered that the elevator was broken when he got home and had to climb to the 21st floor. While climbing, he pondered that the elevator failure was likely caused by memory software faults in C/C++, and the more he thought about it, the angrier he became, leading him to decide to create a new memory-safe language.The editor sent this text to AI for verification, and received the following response:

This content is not entirely fabricated; it has a certain degree of truth. The birth of the Rust programming language is indeed related to Graydon Hoare’s experience with an elevator failure, but the specific details may have been exaggerated or interpreted over time.

In 2006, Graydon Hoare was working at Mozilla and living on the 21st floor of an apartment in Vancouver. One day, he came home to find the elevator broken again and had to climb the stairs. He was well aware that elevator software is mostly written in C or C++, which are prone to memory management issues that can lead to software crashes.

Thus, the idea of designing a new programming language was born, hoping that this language could write small and fast programs while fundamentally avoiding common issues like memory errors, leading to the birth of Rust.

However, the creation of Rust was not solely due to this chance event; Graydon Hoare had a profound understanding of the shortcomings of languages like C/C++ in terms of memory safety and concurrency, and had always hoped to explore a better programming language.

Moreover, the journey from the initial concept of Rust to its final form took a long time, with the collaborative efforts of many teams and individuals, including Mozilla.

END

Popular Articles

Visual Studio Code 1.100 ReleasedDeepGitee Project: Deeply Mining Gitee’s Open Source Treasures, Starting a Project’s Highlight JourneyRedis Open Sources Again, Officially Releases Version 8.0Software Factory Drives DevSecOps: Efficient Integration and Release Evolution PracticesWindows File Preview Tool with “macOS-like Magical Features” – QuickLook Officially Releases Version 4.0Rust 1.87.0 Official Release & 10th Anniversary of Rust 1.0Rust 1.87.0 Official Release & 10th Anniversary of Rust 1.0

ShareView and Like~Orz

Leave a Comment