Rust: A Language for the Next 40 Years - Carol Nichols

Rust: A Language for the Next 40 Years - Carol Nichols — ChariotSolutions

ChariotSolutions

AI-assisted summary of Rust: A Language for the Next 40 Years - Carol Nichols — original source. Check the original for full context.

Source published:

Key ideas

  • Microsoft security updates over a 12-year window revealed that roughly 70% of all vulnerabilities were caused by memory safety defects, underscoring that human discipline alone cannot fix C and C++ safety risks. (12:35)
  • Rust guarantees compile-time memory safety without a garbage collector via its ownership and borrowing system, which eliminates use-after-free, double frees, and data races while matching C's execution performance. (16:04)
  • The Rust Editions mechanism allows the language to evolve syntax and introduce reserved keywords without breaking backward compatibility, since all editions lower to a shared Mid-Level Intermediate Representation (MIR). (30:25)
  • Mozilla's audit of Firefox's legacy styling engine revealed that 51 out of 69 historical vulnerabilities (roughly 74%) would have been prevented entirely had the component been written in Rust instead of C++. (35:43)

Detailed notes

## Background Published on YouTube by ChariotSolutions on May 9, 2019, this presentation features Carol Nichols speaking at Philly ETE 2019. The session covers what makes the Rust programming language unique, exploring its compile-time memory safety guarantees, how the Rust Editions mechanism enables continuous evolution without breaking backwards compatibility, and the companies deploying Rust for critical systems.

## TL;DR Drawing an extended parallel to the 19th-century railroad industry's shift from deadly manual braking to the automated Westinghouse air brake, Carol Nichols argues that software engineering must move beyond relying on human discipline to prevent memory safety bugs in C. She breaks down how Rust's ownership and borrow-checking model guarantees memory and concurrency safety without runtime garbage collection, freeing developers from excessive cognitive overhead. Nichols explains the architecture of Rust Editions, which lowers distinct language editions to a shared intermediate representation to ensure long-term stability without stagnation. Highlighting real-world enterprise adoption across tech giants like Mozilla, Amazon, and Microsoft, she concludes with an impassioned plea for the industry to embrace memory safety and stop repeating the same forty-year-old vulnerabilities.

## Atmosphere & style Nichols establishes an engaging, candid, and witty rapport with the audience, pairing deep technical analysis with playful self-deprecation about her Pittsburgh sports loyalties and her self-acknowledged bias as a member of the Rust Core Team. The talk weaves seamlessly between an evocative historical narrative of railroad disasters and detailed discussions of compiler internals, maintaining clarity and accessibility throughout. The emotional arc feels pragmatic and grounded rather than evangelistic, culminating in an earnest, realistic appeal for the software industry to overcome systemic inertia and finally eliminate preventable classes of bugs.

## Bulletin - [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) Microsoft security updates over a 12-year window revealed that roughly 70% of all vulnerabilities were caused by memory safety defects, underscoring that human discipline alone cannot fix C and C++ safety risks. - [16:04](https://www.youtube.com/watch?v=A3AdN7U24iU&t=964s) Rust guarantees compile-time memory safety without a garbage collector via its ownership and borrowing system, which eliminates use-after-free, double frees, and data races while matching C's execution performance. - [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) The Rust Editions mechanism allows the language to evolve syntax and introduce reserved keywords without breaking backward compatibility, since all editions lower to a shared Mid-Level Intermediate Representation (MIR). - [35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) Mozilla's audit of Firefox's legacy styling engine revealed that 51 out of 69 historical vulnerabilities (roughly 74%) would have been prevented entirely had the component been written in Rust instead of C++.

## Key takeaways - [04:40](https://www.youtube.com/watch?v=A3AdN7U24iU&t=280s) The 19th-century railroad industry suffered massive brakeman fatalities until George Westinghouse invented the fail-safe air brake, which made safety the default operational state. - [06:48](https://www.youtube.com/watch?v=A3AdN7U24iU&t=408s) Railroad operators vigorously lobbied against safety mandates using contradictory economic and technological arguments until the Railroad Safety Appliance Act of 1893 legally enforced adoption. - [11:02](https://www.youtube.com/watch?v=A3AdN7U24iU&t=662s) C remains prevalent due to minimal runtime overhead, universal compiler targets, and platform stability, but demands severe compromises regarding memory safety. - [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) The belief that developers can simply 'be more careful' to prevent memory flaws is a proven myth refuted by widespread vulnerabilities found by elite security teams at Google and Microsoft. - [16:04](https://www.youtube.com/watch?v=A3AdN7U24iU&t=964s) Rust enforces memory safety at compile time using ownership, moves, and borrowing, automatically reclaiming heap memory at scope exit without a runtime garbage collector. - [19:39](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1179s) Rust prevents data races through strict aliasing rules that allow either a single mutable reference or multiple immutable references, but never both simultaneously. - [19:39](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1179s) Offloading manual memory bookkeeping to the compiler conserves the developer's finite cognitive capacity ('person-bytes') and democratizes systems programming. - [22:41](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1361s) The `unsafe` keyword isolates operations that cannot be statically verified by the compiler, turning reactive debugging into a localized audit of bounded code blocks. - [25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) Rust allows incremental adoption through C-compatible foreign function interfaces (FFI), enabling teams to rewrite high-churn or bug-prone components without full rewrites. - [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) Rust achieves 'stability without stagnation' via three-year Editions that desugar into a shared MIR representation, preventing ecosystem fragmentation across compiler versions. - [35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) Enterprise roadblocks remain for Rust, including the absence of ANSI/ISO formal standardization, certified compilers for mission-critical industries, and formal LTS release channels. - [38:17](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2297s) Major technology firms across the 'ABAMAGUBOXOFT' landscape—including Amazon (Firecracker), Google (Fuchsia), Facebook (Mononoke), and Microsoft—have deployed Rust in production systems. - [40:20](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2420s) Rust is governed by open, specialized working groups and public RFC debates rather than a single benevolent dictator, fostering long-term community trust. - [43:26](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2606s) Because invisible memory safety defects are unlikely to receive legislative safety mandates like physical train air brakes, software engineers must proactively demand safe defaults. - [49:05](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2945s) While Go targets garbage-collected application and microservice environments, Rust targets systems programming without runtime overhead or garbage collection pauses. - [51:47](https://www.youtube.com/watch?v=A3AdN7U24iU&t=3107s) Rust tooling is maturing rapidly around the Language Server Protocol (LSP), which provides IDE diagnostics and autocompletion that benefit from Rust's strong static types.

## Detailed walkthrough ### [00:13](https://www.youtube.com/watch?v=A3AdN7U24iU&t=13s) Introduction and Speaker Background

Carol Nichols (also known as Carol Goulding) introduces the presentation, "Rust: A Language for the Next 40 Years." Addressing her online handle `@carols10cents`, she points the audience to a GitHub repository containing links to the slides and follow-up reference materials. She is a prominent figure in the Rust ecosystem: she co-authored *The Rust Programming Language* book (freely available online and published in print by No Starch Press) and co-created the Manning live video course *Rust in Motion*. To encourage audience participation through the Slido Q&A platform, she offers three free access codes for the video course to the askers of her favorite questions.

Beyond authoring educational materials, Nichols is a co-founder of Integer 32, which she notes was the world's very first dedicated Rust consulting company. She organizes the regional Rust Belt Rust conference (scheduled for October 18–19, 2019, in Dayton, Ohio) and serves as an active member of the official Rust Core Team. Acknowledging her deep investment in the technology, she cheerfully warns the audience that she is not here to deliver an impartial assessment: “so if you were hoping for an objective unbiased look at rust you're not gonna get that from this talk I clearly have a slant here.” She even jokes about her Pittsburgh sports loyalty, stating her favorite hockey player is two-time Stanley Cup champion Bryan Rust of the Pittsburgh Penguins, daring the Philadelphia audience to throw tomatoes or batteries at her.

- Speaker: Carol Nichols / Goulding (`@carols10cents`) - Co-author of *The Rust Programming Language* (No Starch Press) and *Rust in Motion* (Manning) - Co-founder of Integer 32 (first Rust consulting firm) - Rust Belt Rust 2019 organizer (Dayton, Ohio, October 18–19) - Member of the Rust Core Team

---

[02:26](https://www.youtube.com/watch?v=A3AdN7U24iU&t=146s) The Perils of Early Railroads and the Brakeman's Dilemma

Setting up the roadmap for the talk, Nichols outlines an unexpected agenda: examining the 19th-century American railroad industry alongside the C programming language, introducing Rust, and dissecting what modern software engineering can learn from railroad safety evolution. Commercial rail transit emerged in the United States around 1830, rapidly outpacing legacy stagecoaches and transforming long-distance transportation. However, this runaway infrastructure growth introduced severe physical dangers because stopping a massive moving locomotive presented immense physical hurdles.

Collisions and derailments were frequent, but the most hazardous position fell to the brakeman. Because trains possessed no automated or centralized braking mechanism, the engineer signaled deceleration via a dedicated whistle pattern. Upon hearing the signal, brakemen had to manually run along the catwalks atop swaying railcars in rain, ice, or darkness, turning heavy hand wheels car-by-car to slowly apply individual friction brakes. If hand-braking failed or was delayed, trains routinely overshot depots or collided at high speeds. Falling from car roofs caused thousands of brakemen fatalities each year, making the profession the second deadliest job in the United States during the 1800s, surpassed only by underground mining.

```mermaid flowchart TD accTitle: The Manual Hand Brake Process accDescr: Sequence diagram showing how manual braking worked and failed on 19th-century trains.

subgraph Signalling["Signalling"] A["Engineer blows whistle signal"] end

subgraph ManualAction["Physical Execution"] B["Brakemen climb on top of cars"] C["Turn individual hand brake wheels car-by-car"] end

subgraph FailureModes["Failure Modes & Hazards"] D["Delayed or uneven stopping: Overshoot / Crash"] E["Slippery roofs in rain/ice: Brakeman falls & dies"] end

A --> B B --> C C --> D B --> E ```

---

[04:40](https://www.youtube.com/watch?v=A3AdN7U24iU&t=280s) George Westinghouse and the Invention of the Air Brake

In 1869, Pittsburgh inventor George Westinghouse introduced the railway air brake, a mechanical breakthrough whose core operational concepts remain the foundation of train safety today. Instead of individual physical labor atop car roofs, the Westinghouse air brake used compressed air supplied by a locomotive-driven compressor piped through hoses running the entire length of the train. This design allowed the engineer to control braking directly from the locomotive cab, instantly decelerating every car in unison without whistle cues.

Crucially, Westinghouse engineered a "fail-safe" architecture into the compressed-air lines. Air pressure in the line kept the brake shoes disengaged; if line pressure was vented by the engineer or lost due to a decoupled car or ruptured hose, internal reservoir pressure automatically drove the brake shoes against the wheels. Safety was guaranteed by default: any failure automatically forced the entire train to an emergency halt rather than allowing it to careen down the tracks. Despite early skepticism—including Cornelius Vanderbilt questioning how "mere air" could halt an iron train—rigorous public trials, complete with passenger cars padded with pillows to survive test impacts, proved that Westinghouse air brakes reliably outperformed manual methods.

- Air brake invented by George Westinghouse in 1869. - Controlled directly by the engineer via pressurized air lines. - Applied braking force to all connected cars simultaneously. - Fail-safe design: loss of air line pressure automatically engages the brakes, making the system safe by default.

---

[06:48](https://www.youtube.com/watch?v=A3AdN7U24iU&t=408s) The Battle Over Railroad Safety Mandates

While passenger train operators swiftly adopted air brakes because customer safety concerns dictated market demand, freight operators stubbornly resisted retrofitting their rolling stock. Lorenzo Coffin, a member of the Iowa Railroad Commission, became a crusader for mandatory safety appliances. When Coffin initially joined the commission, commissioners resigned themselves to tragedy, viewing high brakeman mortality rates as an unavoidable byproduct of heavy industry. Dismayed by steady streams of horrific casualty reports, Coffin recognized that these recurring deaths had a common root cause and pushed aggressively for federal intervention.

Nichols highlights the fascinating 1890 transcripts of Senate Interstate Commerce Committee hearings, where railroad executives mounted fierce resistance against government mandates. Railroad representatives argued that brakemen were cheap and expendable, and claimed that because air brakes could still occasionally fail, switching was pointless. They deployed contradictory anti-regulatory arguments: claiming that mandatory rules would freeze ongoing voluntary safety innovation, while simultaneously complaining that adopting air brakes right away risked locking them into obsolete sunk capital if better brake tech appeared later. Others pleaded poverty, complained that Congress should have regulated decades earlier, or resorted to slippery-slope fallacies. Nichols recounts her favorite rebuttal from the president of the Pennsylvania Railroad: “are you're gonna regulate the trains what's next are you gonna regulate the bridges it's like yes please we want the bridges to be safe too actually.”

Despite industry pushback, Congress passed the Railroad Safety Appliance Act in 1893, mandating air brakes and standard automatic couplers across interstate railroads. The law took full effect in 1900, producing an immediate and dramatic reduction in operating casualties, derailments, and brakeman fatalities.

---

[11:02](https://www.youtube.com/watch?v=A3AdN7U24iU&t=662s) The Persistence of C in Enterprise Computing

Transitioning back to modern software engineering, Nichols asks how many people in the room represent companies operating C in active production environments. A substantial number of hands go up, prompting an analysis of why companies have leaned so heavily on C for more than forty years. C is a battle-tested, highly predictable runtime environment that sits exceptionally close to bare-metal hardware and assembly code, giving developers fine-grained control with negligible overhead and minimal memory footprints.

```mermaid flowchart LR accTitle: Motivating Factors for Using C accDescr: Key technological and organizational reasons development teams select C.

subgraph Hardware["Hardware & Platform"] H1["Minimal overhead & memory usage"] H2["Direct machine/assembly mapping"] H3["Universal compiler availability"] end

subgraph Business["Enterprise & Ecosystem"] B1["40-year proven track record"] B2["Massive existing codebase"] B3["Slow language churn / stability"] end ```

The language features unmatched ubiquity, with compliant compilers targeting virtually any hardware architecture or embedded chip. Its core syntax appears deceptively simple and easy to pick up, and decades of legacy C libraries provide compelling integration momentum. For slow-moving enterprise environments that cannot afford shifting language standards or runtime deprecations, C provides rare platform stability. Yet, Nichols emphasizes, these operational advantages demand a steep compromise: unlocking this performance forces developers to accept a massive, fundamental disadvantage inherent to the language design.

- Proven reliability spanning more than 40 years of continuous use. - Extremely fast execution with minimal runtime overhead. - Universal compiler coverage across embedded, mobile, and server hardware. - High enterprise stability with minimal language-level syntax drift.

[12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) The Myth of "Just Be More Careful" in C

Shipping C code in production forces developers to accept a massive catalog of memory safety pitfalls: use-after-free, double frees, memory leaks, buffer over-reads, buffer overwrites, null pointer dereferences, and data races. When confronted with these chronic issues, a common defense from seasoned programmers is that developers should simply exercise greater vigilance. Nichols vigorously rejects that mindset, stating flatly: “It's not a matter of being more careful. It's the experience in past 40 years has shown we're not capable of being careful enough.”

To prove that raw human discipline cannot solve memory safety, Nichols points to high-profile security research. A famous Android vulnerability called Stagefright stemmed from a C code defect where, as one analysis blog post observed, avoiding it would require an individual programmer to be more careful than the entirety of the Android security team. Similarly, Microsoft analyzed its issued security updates over a 12-year window and discovered that roughly 70% of all vulnerabilities were caused by memory safety flaws. Relying on sheer attentiveness means demanding that ordinary C developers outperform Microsoft's entire elite security engineering organization on every single line of code they ship.

Existing remedies for C and C++ remain fundamentally reactive. Developers turn to tools such as Valgrind, AddressSanitizer (ASan), UndefinedBehaviorSanitizer (UBSan), MISRA C guidelines, or NASA’s IKOS tool, which performs abstract interpretation through static analysis. While NASA’s tooling exemplifies top-tier engineering rigor, Nichols points out that all these external checks share a core structural flaw: they are applied after the fact. Teams must remember to integrate them into CI pipelines, allocate dedicated sprint time to run them, and continually remediate findings. Meanwhile, alternative modern dialects of C have failed to gain traction, still lack rich abstractions, and force developers to reinvent basic wheels without modern tooling. C++ introduces useful idioms but retains pervasive undefined behavior, dangerous raw pointers, and complex multi-threaded concurrency bugs.

- Common C memory hazards: use-after-free, double free, memory leaks, buffer over-reads/overwrites, null pointers, and data races. - Microsoft security study: approximately 70% of all security patches issued over 12 years traced back to memory safety bugs. - C safety tooling evaluated: Valgrind, AddressSanitizer, UndefinedBehaviorSanitizer, MISRA guidelines, and NASA's IKOS static analyzer.

---

[16:04](https://www.youtube.com/watch?v=A3AdN7U24iU&t=964s) Reason 1: Memory Safety via Ownership and Borrowing

```mermaid flowchart TD accTitle: Rust Ownership and Lifetime Flow accDescr: Diagram illustrating how Rust checks value ownership, moves, immutable borrows, and scopes at compile time.

subgraph Alloc["Allocation"] A["String created on heap"] --> B["Owner: Variable x"] end

subgraph Actions["Assignment Scenarios"] B -->|"Scenario 1: Move (let y = x)"| C["y becomes sole owner"] C --> D["x invalidated; using x fails compilation"]

B -->|"Scenario 2: Borrow (let y = &x)"| E["y borrows x immutably"] E --> F["Both can read; x frees at scope exit"]

B -->|"Scenario 3: Return reference from inner scope"| G["Inner scope ends; x dropped"] G --> H["Dangling pointer prevented at compile time"] end ```

Rust emerged from Mozilla Research designed specifically to absorb the hard-won lessons of C while importing powerful concepts from across modern programming language research. Nichols identifies five reasons why Rust has the resilience to endure for the next 40 years, starting with its direct elimination of memory safety flaws at compile time through its ownership and borrowing model.

In basic Rust code, allocating a growable heap string binds that resource to an owner variable (such as `x`). When `x` reaches the end of its enclosing scope, the compiler automatically inserts cleanup instructions. There is no manual invocation of `free()`, nor is there a garbage collector pausing execution at runtime; the cleanup lifecycle is entirely determined during compilation. If a developer reassigns the value using `let y = x;`, Rust performs a move: ownership transfers completely to `y`, instantly invalidating `x`. Attempting to reference `x` thereafter triggers a compile-time rejection, eliminating both use-after-free and double-free vulnerabilities before the binary can even be produced.

Borrowing allows developers to inspect data without seizing ownership. By creating an immutable reference with `let y = &x;`, `y` is permitted to read the heap data while `x` remains the designated owner responsible for deallocation at scope exit. When programmers attempt to create dangling pointers—such as returning a reference to heap data initialized inside an inner scope—the borrow checker detects that the underlying owner will be deallocated as that inner block closes. The compiler halts the build immediately, refusing to permit a pointer that outlives its target.

---

[19:39](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1179s) Eliminating Data Races and Expanding the "Person-Byte"

Beyond basic pointer lifecycles, Rust enforces strict aliasing guarantees: code may hold either a single mutable reference to a piece of data or any number of immutable references, but never both simultaneously. This invariant eradicates data races by guaranteeing that no thread or function can mutate a value while another context is reading it. Furthermore, Rust does away with null pointers entirely, substituting the algebraic `Option` enum (`Some(T)` or `None`), which forces developers to explicitly handle missing values at compile time. Out-of-bounds collection accesses trigger controlled runtime panics rather than allowing arbitrary memory corruption. Because these ownership invariants cross thread boundaries in the type system, multithreaded and parallel concurrency bugs are captured before execution.

Nichols connects these language mechanics to a cognitive concept introduced earlier in the conference by Jessica Kerr: the "person-byte," defined as the finite amount of state, context, and complexity an individual developer can hold in their mind simultaneously. Keeping track of pointer lifecycles, manual allocations, and subtle aliasing hazards in C exhausts that mental cache, leaving little room for actual business logic. Nichols emphasizes: “There's someone who's really good at keeping track of tedious things and making sure that they're right every single time: it's our computers.” Rust assigns the exhaustive bookkeeping to the compiler.

This automated vigilance forms Nichols's second key reason why Rust will endure: it democratizes systems programming. By eliminating the prerequisite of an impossibly massive "person-byte" capacity to hand-track raw memory layouts, Rust makes writing high-performance low-level code accessible to far more developers without sacrificing safety or correctness.

- The aliasing rule: either one mutable reference XOR many immutable references at any given point in time. - Null replacement: Rust requires exhaustive pattern matching over `Option::Some` and `Option::None`. - Concurrency: thread-safe transfer of ownership and references enforced by the compiler's type system.

---

[22:41](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1361s) The `unsafe` Escape Hatch and Safety Trade-Offs

Rust acknowledges that certain low-level operations—such as direct pointer arithmetic, operating system calls, and foreign function interfaces (FFI) to external C libraries—cannot be verified statically by the compiler. For these specific situations, Rust supplies the `unsafe` keyword. Writing an `unsafe` block does not disable all compiler checks; rather, it allows the programmer to declare that they are manually auditing and upholding memory invariants that the compiler cannot deduce. Nichols underscores the structural value of this design: “What I like about this is that when if you have a seg fault or memory access problem at runtime, you know it came from one of those unsafe blocks.” Instead of hunting through millions of lines of code, debugging efforts can immediately focus on the contained `unsafe` boundaries.

Crucially, `unsafe` preserves Rust's safety posture because safety remains the baseline default. In contrast to sanitizers in C that require proactive, opt-in vigilance, Rust requires developers to explicitly opt *out* of compiler guardrails. Safe abstractions can be built around minimal unsafe foundations, a practice thoroughly documented in the community text known as *The Rustonomicon* and featured in conference talks like "Building an Unsafe Foundation."

Nichols cautions that Rust does not guarantee bug-free software; just as train air brakes cannot prevent every railway accident, the borrow checker cannot detect flawed business logic. Programmers still need unit tests, integration suites, and fuzz testing. However, choosing Rust removes the entire class of memory corruption vulnerabilities that plague C while preserving C-like execution speed, as Rust's safety guarantees operate almost entirely at compile time without a runtime garbage collector.

- The `unsafe` keyword: a deliberate, narrow opt-out for FFI, raw pointer manipulation, and extreme hardware/performance operations. - Debugging containment: runtime memory faults are localized to explicitly marked `unsafe` blocks. - Reference material: *The Rustonomicon* (the definitive book on advanced and unsafe Rust). - Runtime overhead comparison: Rust matches C's performance tier because its checks occur at compile time with zero garbage collection overhead.

[25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) Performance, Portability, and Gradual Interop

Carol Nichols explains that Rust minimizes runtime overhead by focusing on compile-time checks and zero-cost abstractions: “We have the goal of having zero cost abstractions which means that the abstractions you use are compiled down to code that you could not write better by hand.” While there is always room to optimize, the overall design aims to match C's execution performance in critical systems contexts.

Portability in Rust is tied directly to the LLVM infrastructure. Because the Rust compiler emits LLVM intermediate representation (LLVM IR), developers can target any architecture supported by LLVM. Nichols acknowledges that C compilers still target certain legacy or niche architectures that LLVM does not support. While a non-LLVM backend for Rust is technically feasible if the community chooses to invest the labor, current platform coverage might still be a deal-breaker for specialized embedded hardware.

On the ergonomic side, Rust has a significantly higher baseline complexity than C. Nichols notes that expressing intricate borrow-checker semantics and correctness guarantees requires richer language features and syntax, prompting an ongoing community effort to flatten the learning curve with books and courses.

For projects containing existing codebases, Rust supports direct foreign function interfaces (`extern` functions) to call C from Rust and expose Rust to C. Because many runtimes (like Python and Ruby) interface directly with C, teams can bridge to Rust through standard C-compatible boundaries. Nichols highlights an incremental conversion strategy she presented in another talk about rewriting the Zopfli compression library:

> “And the thing I like about this technique is that you don't even have to finish you don't have to convert the whole thing to Rust to see benefit you could convert just the parts that change the most the parts that have the most bugs and you could set it aside for a while if you have other high priority things to work on but you still get those benefits along the way of converting little pieces to Rust so you don't have to rewrite all of your stuff in Rust to see benefits.”

- Rust's Zopfli port was converted function by function while remaining compilable and test-green on every commit. - Interop capabilities allow mixed architectures without requiring full rewrites. - Lack of non-LLVM backends remains the primary barrier to matching C's absolute platform reach.

---

[28:47](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1727s) Stability Guarantees and Upgrades

Rust follows a six-week train release cycle modeled on the release cadences of browsers like Firefox and Chrome. Despite frequent releases, the project has maintained a strict backward compatibility policy since the release of Rust 1.0 in May 2015. Nichols explains that the project preserves limited escape hatches: the team reserves the right to fix compiler bugs, patch safety holes, and adjust type inference algorithms even if they occasionally demand new type annotations. However, the core language promises that valid code continues to compile without disruptive breaks.

Empirical evidence from community surveys backs up this design. In the 2018 Rust survey, 92.6% of respondents confirmed that updating the compiler had never broken their code. Nichols candidly points out a limitation in the phrasing of that survey question: it fails to isolate breakages in compilation (the specific guarantee Rust provides) from runtime regressions, performance swings, or bug repairs that alter execution behavior. She expresses an eagerness to capture more granular survey data on pure compile-time stability.

---

[30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) Stability Without Stagnation: The Editions Mechanism

To ensure Rust remains viable for decades without fracturing or freezing progress, the core team adopted the principle of "stability without stagnation." To evolve the language and introduce features requiring reserved words—such as the `async` keyword for asynchronous functions—without invalidating existing code that uses identifiers named `async`, Rust introduced Editions. Planned roughly on a three-year cycle, Editions allow opt-in changes without causing code breakage across compiler versions. Rust 2015 established the baseline, followed by Rust 2018.

Initially, Nichols had serious reservations about the architecture: “When I first heard of this idea I thought it sounded terrible from a compiler maintenance point of view you have to maintain two ways to use every feature forever because we wanted to commit to all editions being supported forever but it's actually not that bad.” The maintenance burden is constrained because Editions only modify surface-level syntax and desugaring into High-Level Intermediate Representation (HIR). Both editions lower into a shared Mid-Level Intermediate Representation (MIR), where critical systems tasks like borrow checking, optimization passes, and code generation take place.

```mermaid flowchart TD accTitle: Rust Edition Lowering Pipeline accDescr: Diagram illustrating how Rust 2015 and Rust 2018 source codes lower to a shared MIR representation.

subgraph Surface["Surface Level (Edition-Specific)"] direction LR Src2015["Rust 2015 Source"] --> HIR2015["HIR (2015)"] Src2018["Rust 2018 Source"] --> HIR2018["HIR (2018)"] end

subgraph Core["Shared Engine (Agnostic)"] direction TB HIR2015 --> MIR["Mid-Level IR (MIR)"] HIR2018 --> MIR MIR --> Passes["Borrow Checking & Optimizations"] Passes --> LLVM["LLVM IR"] LLVM --> Target["Machine Code"] end ```

Because editions lower into the same unified intermediate form, crates compiled under different editions interoperate seamlessly. A Rust 2015 crate can depend on a Rust 2018 dependency, and vice versa, eliminating language-level ecosystem splits. Nichols stresses that upgrading an edition is completely optional: “Never is a totally valid choice we plan to support Rust 2015 edition code for as long as Rust exists.” To assist migrations, the tooling suite includes `cargo fix` / `rustfix`, which automatically rewrites source files to match newer idioms. This design leads Nichols to conclude: “The editions concept I am confident that with using this to evolve the language means we're never going to have a Rust 2.0 we're not going to break backwards-compatibility so we hope to be as stable as C is for the next 40 years.”

---

[35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) Enterprise Adoption and Industry Roadblocks

Nichols outlines several institutional hurdles that must be addressed for broader enterprise penetration: - **Language Formalization:** Rust currently lacks a formal ANSI/ISO-style standard specification, which historically took decades for C to obtain. - **Compiler Certification:** Mission-critical and safety-critical industries require formally certified compilers, which do not yet exist for Rust. - **Release Cadence Options:** There is no official Long-Term Support (LTS) release pipeline for frozen compiler versions with backported security fixes. - **Enterprise Tooling:** Cargo assumes modern, connected development environments, making it harder to integrate into bespoke multi-language enterprise build systems or private package registries without open-source publishing. - **Library Breadth:** The ecosystem is still maturing, leaving gaps in specialized domains.

Despite these hurdles, major technology companies have bet heavily on Rust for foundational systems. The prime example is Mozilla's Firefox Quantum release, which replaced the legacy browser styling engine with a parallel CSS engine written in Rust (Stylo). Mozilla audited historical security vulnerabilities in the old C++ styling subsystem: out of 69 critical security bugs recorded across Firefox's history in that module, Rust’s memory-safety model would have completely prevented 51 of them—representing roughly three-quarters of all vulnerabilities.

[38:17](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2297s) Industry Adoption Across Tech Giants: The "ABAMAGUBOXOFT" Metric

Carol Nichols examines industry adoption of Rust by referencing a tongue-in-cheek acronym coined by Patrick McKenzie (`@patio11` on Twitter): **ABAMAGUBOXOFT**, representing the dominant tech giants (Apple, Amazon, Google, Facebook/Meta, Microsoft). Nichols notes that Rust has established a public presence across four out of these five major software ecosystems:

- **Apple**: Nichols notes she does not know of any public uses of Rust at Apple. Instead, Apple focuses on Swift, which Nichols observes is remarkably similar to Rust. Attending a Swift presentation earlier at the conference, she found herself constantly translating technical terms: “they have a lot of the same problems and a lot of trying to solve the same problems that rust is but use different words for it so I was like sitting there trying to translate him like ah stats oh oh they're hitting the same problem that we are they're really similar and there is cross-pollination there.” - **Amazon**: Nichols points to Amazon's open-source release of the Firecracker microVM, an infrastructure virtualization component written entirely in Rust. - **Google**: Despite Google being traditionally guarded about internal initiatives, Nichols highlights the open-source Fuchsia operating system project, noting that parts of its public codebase are written in Rust. - **Facebook**: Facebook developed the Mononoke Mercurial server in Rust to power their monolithic Mercurial repository after the canonical Mercurial implementation proved unable to scale quickly enough. - **Microsoft**: Microsoft announced an IoT Edge platform running Rust to perform local device-level analytics before streaming distilled results back to central servers.

```mermaid flowchart TD accTitle: Tech Giant Adoption of Rust accDescr: Mapping of Patrick McKenzie's big-tech acronym to public Rust adoption across major companies. A["ABAMAGUBOXOFT Ecosystem"] --> B["Apple"] A --> C["Amazon"] A --> D["Google"] A --> E["Facebook"] A --> F["Microsoft"]

B -.->|"No public Rust; uses Swift"| G["Swift cross-pollination"] C -->|"Built with Rust"| H["Firecracker microVM"] D -->|"Rust components"| I["Fuchsia OS"] E -->|"Rust backend"| J["Mononoke Mercurial Server"] F -->|"Edge analytics"| K["Azure IoT Edge Platform"] ```

---

[40:20](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2420s) Open Governance, RFCs, and Community Trust

The fifth major reason Nichols believes Rust is equipped to endure for decades is its project governance model. Rather than relying on technical merit alone or following the whims of a single figurehead, the project intentionally distributed control: “We don't have a BDFL, a benevolent dictator for life; there's not just one person making final decisions on Rust.” Development is overseen by specialized teams and working groups consisting of contributors from wide-ranging backgrounds: programming language theory PhDs, enterprise developers building commercial products, hobbyists, low-level systems specialists transitioning from C and C++, functional programmers from Haskell, and high-level developers from languages like Ruby and Python (which survey data shows is consistently the number-one feeder language into Rust).

Architectural decisions are vetted publicly using the Request for Comments (RFC) system. Working groups publish their rationale in the open on these RFCs, allowing the community to track every trade-off. Nichols stresses the psychological and operational necessity of this structure: “While we might not make a decision on something in the exact way you might want, our hope is that you'll at least understand why we're making those decisions and feel like we have heard your point of view.”

Nichols contrasts this with closed corporate stewardship, emphasizing that Rust's trajectory will never be steered in secret or hijacked without transparent public notice. Furthermore, Nichols underscores that Rust established a formal Code of Conduct from the very day it was open-sourced, removing endless meta-debates about establishing professional conduct standards and cementing a welcoming, professional baseline for contributors.

---

[43:26](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2606s) Lessons from the Railroad Industry: The Software Arrogance Trap

Nichols shifts to an analogy between software engineering and the historic rail transportation industry, starting with a critique of tech hubris. Nichols recounts several public missteps where Silicon Valley attempted to bypass established problem domains: Juicero attempting to engineer high-tech juice presses that performed no better than squeezing packets by hand; Lyft marketing shared commute vans that essentially reinvented the city bus; and Elon Musk attempting to intervene in the Tham Luang cave rescue with a miniature submarine instead of deferring to veteran cave rescue divers.

Nichols stresses that if software engineers claim they can solve society's problems through code, they must actually prove it. However, the path to systemic safety in software diverges sharply from physical industries: - In rail travel, physical hazards are visceral: anyone can see that riding on top of a railcar in winter is dangerous or that failing train brakes kill passengers. - Memory unsafety in software is invisible, making it difficult for the public and policymakers to grasp. Nichols jokes about the absurdity of congressional hearings: “I'm trying to imagine the the Senate transcripts from reading that in the future from now of software people trying to explain memory unsafety to senators and it's terrible it's I don't see this going well.”

Because binding external government safety mandates are improbable, the burden falls directly onto software professionals to become informed, demanding consumers who refuse to integrate unsafe, unvetted dependencies. Nichols presents a chronological timeline of railroad safety adoption:

| Milestone / Technology | Year | Elapsed Time | Significance | |:--- |:--- |:--- |:--- | | **Railroad Industry Genesis** | 1830 | — | Early commercial operation without standardized failsafes | | **Westinghouse Air Brake Invented** | 1869 | ~40 years | Technical solution to catastrophic braking failures | | **Universal Air Brake Adoption** | 1900 | ~30 years | Broad operational adoption across commercial fleets | | **Rust 1.0 Stabilization** | 2015 | — | Production-ready alternative offering compile-time memory safety |

Nichols asks whether the software industry can beat the railroad sector’s 30-year adoption curve, emphasizing: “I don't know how long it's gonna take us to adopt something that's memory safe. Can we do better than the railroad industry? I don't know. I want us to be better. I'm not sure if we are better. I hope that we're better.”

---

[46:55](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2815s) Conclusion: "Let's Make Some New Mistakes"

Concluding the core presentation, Nichols delivers an open, pragmatic invitation. She welcomes skepticism, stating that her loyalty lies not with language dogmatism, but with eliminating systemic memory safety vulnerabilities: “I am willing for Rust not to be the solution as long as we do something; let's just do something to fix these memory safety problems that keep happening over and over and over again.”

Whether the replacement turns out to be Rust, Go, or a diverse spectrum of purpose-built languages fitting specific operational niches, Nichols encourages the audience to move beyond recurring security blunders: “You don't have to choose Rust. I just I just want us to stop making the same mistakes over and over again. Let's make some new mistakes.”

Nichols presents her slides, contact handles (`@carols10cents`), a 40% discount code for Manning publications, and credits her test audience—her daughter Vivian and her cat Baby—before opening the floor to audience Q&A.

---

[49:05](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2945s) Q&A: Origins of the Name "Rust" and Rust vs. Go

Nichols reviews submitted audience questions and fields two primary topics:

**The Etymology of "Rust":** - Nichols shares multiple origins: early founders were avid bicycle riders who frequently had to deal with rusted bike parts, which inspired the gear-shaped Rust project logo. - Others cite the biological rust fungus that attacks wheat crops as a conceptual root. - Nichols personally associates the name with COR-TEN weathering steel, such as that used in the U.S. Steel Tower in Pittsburgh, which develops an intentional layer of surface rust to protect the underlying structure from deep corrosion without requiring exterior paint.

**Comparing Rust and Go:** When asked why someone should choose Rust over Go, Nichols points out that while they are frequently lumped together because they emerged around the same era as modernized alternatives to C and C++, they target different system trade-offs: - **Runtime Performance & Garbage Collection**: Go uses an automatic garbage collector, which can introduce runtime overhead or latency spikes that disqualify it for hard real-time systems, low-level embedded devices, or tight resource constraints. Rust requires zero runtime garbage collection. - **Ecosystem Fit**: If a team builds tooling that interfaces deeply with Google products or standard microservices, Go offers an integrated, highly streamlined experience. - Rather than declaring a unilateral winner, Nichols advises developers to experiment with introductory programming in both languages to discover which mental model best aligns with their technical requirements.

[51:47](https://www.youtube.com/watch?v=A3AdN7U24iU&t=3107s) Rust IDE Integration and the Language Server Protocol

Carol Nichols addresses an audience question regarding whether Rust currently possesses solid IDE integration. Her honest response is that the team is actively working on it, acknowledging it as an area where the ecosystem recognizes an urgent need for improvement. To bridge this gap, the community relies heavily on the Language Server Protocol (LSP), an industry effort designed to standardize communication between programming languages and various IDEs. Rust's LSP implementation already powers core editing features such as code completion, inline error diagnostics, and jumping directly to definitions. Currently, Visual Studio Code boasts the best-maintained plugin leveraging this protocol, while IntelliJ also provides a strong, dedicated Rust implementation.

```mermaid flowchart LR accTitle: Rust IDE Integration Flow accDescr: Shows how Rust language tools communicate through LSP or direct plugins into IDEs. subgraph Language ["Language Engine"] RLS["Rust Language Server / Analysis"] end subgraph Protocol ["Interface"] LSP["Language Server Protocol (LSP)"] end subgraph Editors ["Editor Environments"] VS["VS Code (Plugin)"] IJ["IntelliJ Rust (Direct Support)"] end RLS --> LSP LSP --> VS RLS -.-> IJ ```

Nichols reflects on her background prior to working with Rust, drawing a comparison to her time writing Ruby. She references Michael Feathers' seminal book, *Working Effectively with Legacy Code*, which emphasizes heavily leaning on editor tools, IDE integrations, and automated refactoring routines. In dynamic languages like Ruby, heavy metaprogramming makes automated tooling notoriously difficult; taking arbitrary strings and executing them as method calls prevents tools from guaranteeing that every call site has been caught. While that dynamic nature left her with what she describes as persistent IDE jealousy, Rust's strict static types make deep tooling fundamentally achievable. As Carol Nichols puts it: “I had a lot of jealousy for IDE tools while I was writing Ruby and I'm looking forward to the days that we have those tools for Rust, they're not there yet but they're more possible to make than they are in Ruby.”

- Features currently functional in Rust's Language Server Protocol implementation: - Code completion - Inline error highlighting - Jump-to-definition navigation - Leading environments for Rust tooling: - Visual Studio Code (utilizing the community's primary LSP plugin) - JetBrains IntelliJ (via its dedicated Rust plugin)

---

[53:45](https://www.youtube.com/watch?v=A3AdN7U24iU&t=3225s) The Status of Async/Await Across Rust Editions

Looking through the submitted questions, Nichols selects an inquiry regarding asynchronous programming: given that async functionality was discussed in the context of the 2018 Edition, is async syntax also available in the 2015 Edition? She clarifies a common misconception, revealing that fully fledged async support is actually not complete in either edition yet. When Rust 2018 was released, the team took the necessary preparatory step of reserving `async` as a language keyword so that future syntax changes would not cause breaking conflicts. While the initial goal had been to ship complete async support simultaneously with the 2018 Edition release, the underlying implementation and ergonomics required significantly more design work.

Active community discussions and RFCs continue to hammer out the exact syntax and execution semantics. Once async stabilizes, developers across both editions should theoretically have access to the functionality, but with an important syntactic trade-off. Because the 2015 Edition cannot reserve new keywords without breaking legacy codebases, any async features backported to 2015 will rely on alternative, less ergonomic constructs. Carol Nichols explains: “Once it is done it will probably be available in both, it's just that the syntax in Rust 2015 is not going to use a keyword so it's not going to be as nice as syntax as it will be in Rust 2018.” Handing out the final book token to the attendee who submitted the question, Nichols notes that her time has expired and wraps up the presentation to audience applause.

## Notable quotes > [19:39](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1179s) There's someone who's really good at keeping track of tedious things and making sure that they're right every single time: it's our computers. — Carol Nichols

> [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) It's not a matter of being more careful. It's the experience in past 40 years has shown we're not capable of being careful enough. — Carol Nichols

> [46:55](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2815s) I am willing for Rust not to be the solution as long as we do something; let's just do something to fix these memory safety problems that keep happening over and over and over again. — Carol Nichols

> [25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) We have the goal of having zero cost abstractions which means that the abstractions you use are compiled down to code that you could not write better by hand. — Carol Nichols

## Mentioned Carol Nichols, Integer 32, The Rust Programming Language, Rust in Motion, No Starch Press, Manning, George Westinghouse, Lorenzo Coffin, Cornelius Vanderbilt, Railroad Safety Appliance Act, Valgrind, AddressSanitizer, UndefinedBehaviorSanitizer, MISRA C, IKOS, NASA, Jessica Kerr, The Rustonomicon, LLVM, Zopfli, Mozilla, Firefox Quantum, Stylo, Patrick McKenzie, Apple, Amazon, Firecracker, Google, Fuchsia, Facebook, Mononoke, Microsoft, Azure IoT Edge, Juicero, Lyft, Elon Musk, Michael Feathers, Working Effectively with Legacy Code, Language Server Protocol, Visual Studio Code, IntelliJ

## Video description Learn what makes the programming language Rust a unique technology, such as the memory safety guarantees that enable more people to write performant systems-level code. Hear about how Rust Editions evolve the language and the compiler without breaking existing code. See who’s trusting Rust for critical products today. Join us on Rust’s journey to the future.

Philly ETE 2019 Playlist: https://www.youtube.com/playlist?list=PL9oQ7yETvN10Lopbg81O_bwElm9grUkDB On the Chariot Solutions site: http://chariotsolutions.com/screencasts/

[Source](https://www.youtube.com/watch?v=A3AdN7U24iU)

中文简报

Rust:面向未来40年的编程语言——Carol Nichols Carol Nichols借用19世纪铁路行业从致命的人工制动转向西屋自动空气制动的漫长历程作为类比,指出软件工程不能再依赖人类的自律来防范C语言中的内存安全漏洞。她详细剖析了Rust的所有权和借用检查模型如何在无需运行时垃圾回收的情况下保证内存与并发安全,从而将开发者从过度的认知负担中解放出来。Nichols还阐述了Rust Editions(版本)机制的设计构架,该机制将不同语言版本降解到统一的中间表示,以确保在保持长期稳定性的同时不至于停滞不前。在列举了Mozilla、亚马逊和微软等科技巨头的企业级实际应用后,她最后发出强烈呼吁,敦促整个行业拥抱内存安全,停止重复过去40年来反复出现的相同漏洞。 微软跨越12年的安全更新数据显示,大约70%的漏洞是由内存安全缺陷引起的,这突显出仅靠人类的自律无法消除C和C++的安全风险。 (12:35) Rust通过其所有权和借用系统在没有垃圾回收器的情况下确保了编译期内存安全,在消除释放后使用(use-after-free)、双重释放以及数据竞争的同时,还能匹敌C语言的执行性能。 (16:04) Rust Editions机制允许语言演进语法并引入保留关键字,而不会破坏向后兼容性,因为所有版本最终都会降解为统一的中级中间表示(MIR)。 (30:25) Mozilla对Firefox旧版样式引擎的审计表明,在其69个历史漏洞中,有51个(约74%)如果当初使用Rust而非C++编写,本可完全得以避免。 (35:43)

Detailed notes — zh

## Background 本视频由 ChariotSolutions 于 2019 年 5 月 9 日发布在 YouTube 平台上,内容为费城新兴技术大会(Philly ETE 2019)上 Carol Nichols 的主题演讲。根据页面介绍,演讲探讨了 Rust 作为一门独特编程语言的特性,包括其内存安全保证、通过 Rust Editions 在不破坏既有代码的前提下演进语言与编译器的机制,以及当前信任 Rust 的关键生产企业与未来发展方向。 ## TL;DR Rust 核心团队成员兼官方教材合著者 Carol Nichols 将 19 世纪美国铁路工业由原始制动转向空气制动器的漫长安全演进,与当今计算机行业从 C 语言向 Rust 的转型进行了深刻类比。她指出软件工业过去四十年反复被内存安全问题困扰,而单纯寄希望于程序员“更小心一点”已被证明是彻底的谬论。通过所有权与借用机制、零成本抽象、六周发布周期与三年一版的 Edition 兼容机制,Rust 在不牺牲底层性能的同时将内存安全从人脑心智负担转交由编译器自动化保障。结合科技巨头在生产环境中的落地案例以及开源透明的社区治理,Carol 展望了 Rust 成为未来四十年系统级软件基石的前景,并呼吁整个行业打破老旧漏洞的循环,拥抱现代安全基准。 ## Atmosphere & style 整场演讲兼具历史沉重感与技术幽默感,Carol 语言风趣坦率,开场即自嘲对 Rust 的“强烈偏向”并调侃冰球梗,迅速拉近了与现场技术受众的距离。叙事上她巧妙借古讽今,从铁路制动员的高危牺牲与企业反对管制的荒谬言论,自然过渡到软件工程中的傲慢心态与安全漏洞困局,说服力极强。台风稳健从容,既有深入编译器内部架构与所有权模型的硬核剖析,也有对语言复杂性、IDE 生态短板及标准化缺失的诚恳直面,整体传递出一种既满怀理想又务实求真的工程情怀。 ## Bulletin - [02:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=163s) 借用 19 世纪铁路工业从人工手动制动转向空气制动器的漫长博弈历史,Carol Nichols 论证了软件行业依靠个人“更小心一点”来避免内存安全隐患是注定失败的工程假设。 - [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) 微软与 Android 真实安全审计数据显示约 70% 的漏洞根源在于内存安全,而 Rust 通过所有权和借用检查在编译期拦截悬垂指针、双重释放与数据竞争,实现零运行时垃圾回收成本的内存安全。 - [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) Rust 创立了每三年一次的 Edition 版本机制,使语言能够在不破坏既有代码向后兼容性、不造成生态割裂的前提下向前演进,官方甚至保证永远不会出现类似破坏兼容性的“Rust 2.0”。 - [35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) 包括亚马逊(Firecracker)、谷歌(Fuchsia)、Facebook(Mononoke)以及微软在内的科技巨头已在关键基础设施中落地 Rust,Mozilla 研究更显示若早期采用 Rust 可直接免疫 Stylo 引擎历史上约 74% 的安全漏洞。 ## Key takeaways - [02:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=163s) 19 世纪铁路制动员曾是极度致命的职业,手动拧刹车不仅危险且制动缓慢,直到威斯汀豪斯发明空气制动器并由法律强制普及后,列车安全才实现根本性跨越。 - [11:02](https://www.youtube.com/watch?v=A3AdN7U24iU&t=662s) C 语言虽然拥有极致性能、极小抽象开销及长达 40 年的历史积淀,但缺乏内存安全保障使其在现代生产环境中潜藏着释放后使用、双重释放及缓冲区溢出等系统性缺陷。 - [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) 行业经验证明指望工程师“更细心”无法根绝内存缺陷,微软过去 12 年的补丁数据显示约 70% 的安全漏洞根本源于内存安全问题。 - [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) 现有针对 C/C++ 的 Sanitizer 动态分析与静态分析工具皆为事后补救措施,无法从源头阻止内存违规代码的诞生。 - [16:08](https://www.youtube.com/watch?v=A3AdN7U24iU&t=968s) Rust 通过所有权、移动语义和不可变/可变借用规则在编译期管理生命周期,无需垃圾回收器即可消除大部分内存隐患与并发数据竞争。 - [21:06](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1266s) Rust 把追踪内存和指针边界的繁重心智负担从程序员的“人脑带宽”转移给编译器,使普通开发者也能安全编写底层系统代码。 - [22:41](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1361s) Rust 的 `unsafe` 并非全盘放弃安全保障,而是显式缩小需人工重点审查的代码边界,遵循“默认安全、主动退出”的设计哲学。 - [25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) Rust 追求零成本抽象,并通过与 C 兼容的 FFI 接口支持按函数粒度渐进式重写遗留系统,降低系统迁移阻力与风险。 - [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) 通过六周一次的快速火车发布模式,结合仅在前端语法层生效的 Edition 机制,Rust 实现了“不带来停滞的稳定性”,确保新老版本库能够无缝混合链接。 - [35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) 尽管 Rust 依然面临缺乏 ISO/ANSI 行业标准、安全认证编译器及完善 LTS 支持等痛点,但已在各大科技公司的微虚拟机、单体代码库服务端和操作系统内核中大规模落地。 - [40:20](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2420s) Rust 采用基于 RFC 流程和跨领域工作组的开放透明治理模式,坚决摒弃“终身仁慈独裁者(BDFL)”与企业暗箱控制机制。 - [46:58](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2818s) 软件行业不能再陷入重复犯相同内存错误的死循环中,即使未来取代 C 语言的不仅是 Rust,推动整个行业去犯“全新的错误”也是技术进步的体现。 ## Detailed walkthrough ### [00:13](https://www.youtube.com/watch?v=A3AdN7U24iU&t=13s) 演讲者背景与讲座主题概述 演讲者 Carol Nichols(亦称 Carol Goulding)开门见山地宣布了本场演讲的题目是《Rust:未来四十年的语言》(Rust: A Language for the Next 40 Years)。她调侃自己在各个平台上的账号都是 `carols10cents`,并指引现场听众访问幻灯片代码仓库的短链接,以便查阅演讲中引用的丰富资料与链接列表。作为 Rust 领域的资深布道者与实践者,Carol 拥有多重核心身份:她不仅是官方畅销教材《The Rust Programming Language》(线上免费,No Starch Press 出版实体书)的合著者,也是 Manning 旗下视频课程《Rust in Motion》的共同作者,现场她还准备了三个该视频教程的免费兑换码,赠予在 Slido 问答平台上提出最佳问题的听众。 此外,Carol 是全球首家专注于 Rust 咨询的公司 Integer 32 的联合创始人,同时兼任区域性大会 Rust Belt Rust 的组织者,并且也是 Rust 核心团队(Rust core team)的成员。面对台下的听众,她幽默地坦白了自己的强烈偏向:“If you were hoping for an objective unbiased look at Rust, you're not gonna get that from this talk I clearly have a slant here.”(如果你期待对 Rust 进行客观、毫无偏见的审视,那这篇演讲可给不了你,我显然是有倾向性的)。她甚至开玩笑说,正因为太爱 Rust,连自己最喜欢的冰球运动员都是匹兹堡企鹅队(Pittsburgh Penguins)两次夺得斯坦利杯(Stanley Cup)的冠军成员 Brian Rust;在费城的大会上提到匹兹堡的球员,她笑着说大家要朝她扔西红柿或者电池都可以,自己抗得住。她指出,本次演讲将串联铁路工业史、C 语言与 Rust,探讨软件行业究竟能从百年前的铁路工业中汲取什么教训。 - 讲师著作:《The Rust Programming Language》(No Starch Press 出版,社区俗称“The Book”) - 在线课程:《Rust in Motion》(Manning 出版社出品,正在 Early Access 阶段) - 咨询公司:Integer 32(全球首家 Rust 咨询公司) - 社区活动:Rust Belt Rust(当年定于 10 月 18 日至 19 日在俄亥俄州代顿市举行) --- ### [02:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=163s) 19 世纪铁路的危险困境与制动员的牺牲 美国商业铁路的大规模建设始于 1830 年左右。在那个时代,火车的出现彻底颠覆了传统的驿马车(stagecoach),让人们横跨广袤国土的效率大为提升,全国各地的铁路线迅速铺设展开。然而,伴随着铁路线路和行车班次的爆发式增长,伤亡事故也呈现几何级数飙升。巨大且沉重的火车一旦全速运转起来,想要刹车停下极其困难,脱轨和碰撞事故屡见不鲜。 在当时的铁路上,最危险的职业莫过于“制动员”(brakeman)。那时的火车没有集中刹车机制,当火车司机(engineer)需要停车时,只能拉响特定代号的汽笛给信号;车上的制动员听到笛声后,必须手脚并用爬上车厢顶部,手动转动每一个车厢顶上的手轮制动装置,然后踩着摇晃的车厢顶跳到下一节车厢重复这一操作。这种停车方式极其原始粗糙:往好了说,制动员可能只是刹车不及而错过预定停靠的站台;往坏了说,如果前方遇到突发险情需要紧急制动,火车根本无法及时刹停,必然引发毁灭性的车毁人亡。在雨雪或结冰的恶劣天气下,制动员站在车顶极易失足坠落,每年有数以千计的制动员因此丧生。Carol 强调指出,在 19 世纪的美国,制动员是危险度仅次于采矿业的致命职业。 ```mermaid flowchart TD accTitle: 传统火车制动流程图 accDescr: 展示19世纪火车依靠司机吹汽笛通知制动员在车顶手动拧制动轮的原始且高危的刹车过程 subgraph Signal ["司机发出信号"] A["火车司机拉响汽笛警报"] end subgraph ManualBraking ["危险的手工逐节制动"] B["制动员爬上摇晃的车厢顶部"] C["手动用力旋转制动轮"] D["在恶劣天气(雨雪/结冰)下跳至下一节车厢"] end subgraph Hazard ["高概率悲剧后果"] E["失足跌落致死每年数千人"] F["制动过慢发生剧烈撞车事故"] end A --> B B --> C C --> D D --> E D --> F ``` --- ### [04:40](https://www.youtube.com/watch?v=A3AdN7U24iU&t=280s) 乔治·威斯汀豪斯与空气制动器的技术革命 转机出现在 1869 年,著名的匹兹堡发明家乔治·威斯汀豪斯(George Westinghouse)发明了首款空气制动器(air brake)。这套系统的底层机械原理经过后续几十年的打磨,至今仍是现代列车制动技术的核心基石。空气制动器不再依赖人力爬上车顶拧螺栓,而是由压缩空气进行全局控制。司机在车头驾驶室就可以直接操作总控制阀门,无需再依赖汽笛喊人;所有车厢通过气路管道串联相通,一旦司机开闸制动,整列火车的所有车厢都会在同一瞬间统一抱死刹车。 更具革命性的是系统后来加入的“故障安全”(fail-safe)机制,实现了默认安全的架构设计。气路系统必须施加气压才能撑开刹车片让列车前进;当气管失去压力或整列车的某处挂钩断裂脱节时,刹车机制会自动强制抱死,让列车立刻停下,而不是失控滑行。即便这项设计在今天看来极其精妙,当时却遭遇了广泛的质疑与保守势力的抵触。后来的范德堡大学创立者、铁路大亨考尼利斯·范德比尔特(Cornelius Vanderbilt)便曾公开讽刺,无法相信区区“空气”就能制动成百上千吨的重型列车。为此,威斯汀豪斯等人开展了大量公开对比测试,甚至让乘客坐在塞满缓冲枕头的车厢里高速冲撞测试,实证检验各种制动方式。最终,空气制动器以极佳的制动距离和稳定性彻底碾压了传统的手动轮刹。 - 驱动机制:采用集中压缩空气控制,彻底取代车厢顶部的人工转轮 - 协同联动:管路全列贯通,司机一人操控即可实现全车同步刹车 - 故障安全(Fail-Safe)设计:维持行驶必须充压,一旦气压泄漏或车厢脱节,默认状态立刻抱死刹车 - 市场态度:客运列车迅速采纳,铁路公司直接在广告中将其作为安全卖点,借此消除旅客对乘车安全的恐慌 --- ### [07:19](https://www.youtube.com/watch?v=A3AdN7U24iU&t=439s) 货运铁路的利益阻力与安全法案博弈 与客运列车迅速拥抱新技术不同,货运铁路采用空气制动器的过程异常漫长和痛苦。关键推动者洛伦佐·科芬(Lorenzo Coffin)当时在爱荷华州铁路委员会任职。他刚上任时,委员会普遍抱有一种麻木不仁的消极态度,大家认为铁路本身就是高危产业,“制动员每年死伤是理所当然的自然规律,没有什么可做的”。但科芬看着堆积如山的死伤报告,敏锐地意识到这些事故有着高度雷同的致病根源——制动失灵,必须通过制度变革解决。 科芬随即展开了长达数年的游说,推动国会立法强制全行业列车安装空气制动器。1890 年前后美国参议院州际商业委员会(Interstate Commerce Committee)的听证会记录中,充斥着铁路巨头们为规避监管而抛出的种种荒谬言论。铁路行业既不想承担为所有货车升级改造的高昂改造成本,又在潜意识里将制动员的生命视作便宜、可随时替换的消耗品。为了推脱责任,企业代表抛出了自相矛盾的说辞: 1. **“空气制动器也有失效概率”**:他们辩解称手动刹车会坏,空气刹车偶尔也会出故障,所以换了也没意义。 2. **“法规会扼杀自主创新”**:他们宣称企业原本一直在主动尝试各种安全新技术,一旦政府通过法律定下死板的最低门槛,企业就会只按法律及格线行事,彻底停止创新。 3. **“沉没成本担忧”**:同一批代表在下一句话里又自打耳光:“如果我们花重金铺满了空气刹车,未来出现更好的技术怎么办?岂不是成了巨大的沉没成本?” 4. **滑坡谬误推脱**:宾夕法尼亚铁路公司总裁在听证会上气急败坏地质问:“如果你们要监管火车,下一步是不是连桥梁都要监管了?”现场听众听到这里无不莞尔,Carol 也吐槽道:“是的,拜托请务必监管,我们当然希望桥梁也是安全的!” 这场漫长的博弈最终以立法的胜利告终。1893 年美国正式通过《铁路安全设备法案》(Railroad Safety Appliance Act),强行规定所有列车必须配备空气制动器和标准化自动车钩(standard couplers),并在 1900 年全面强制执行。这一法案让铁路碰撞事故以及制动员的伤亡率断崖式下跌,完成了工业史上里程碑式的安全跨越。 --- ### [11:02](https://www.youtube.com/watch?v=A3AdN7U24iU&t=662s) C 语言的历史地位与深层安全隐患 讲完这段沉重的铁路历史后,Carol 将话题引回计算机编程领域,转向了在系统级软件中统治数十年的 C 语言。她询问台下有多少人的公司至今仍在生产环境中运行 C 代码,现场不少人举手确认。Carol 客观列举了企业选择 C 语言的一系列极其坚实的理由: - **历史验证**:它是被工业界验证长达 40 年的成熟解决方案。 - **性能卓越**:运行速度极快,抽象开销几乎为零,无限贴近底层硬件与汇编。 - **硬件友好**:资源占用极低,几乎任何一个 CPU 架构或嵌入式平台都配有现成的 C 编译器。 - **语法极简**:语言表面规范非常精简,关键字很少(尽管 Carol 指出这种简单性极具欺骗性,因为看似简单的代码其暗藏的边界行为极其凶险)。 - **兼容性壁垒**:坐拥庞大的遗留 C 代码库,与底层系统交互极其平滑。 - **语言极其稳定**:对于演进极其缓慢的庞大企业级软件来说,C 几乎不变的特性保证了代码不会被激进更新轻易破坏废弃。 然而,Carol 话锋一转指出,虽然 C 语言具备以上所有无与伦比的技术优势,但使用它必须签署一份代价惨痛的“契约”——为了换取这些好处,开发者不得不承受一个足以压倒上述全部优势的致命缺陷,那就是 C 语言在内存安全保障上的彻底缺失。正如当年靠人力冒险在车顶拉刹车一样,C 语言将所有安全边界与资源生命周期的控制完全推给程序员,埋下了无数灾难性的系统隐患。 ### [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) C 语言的内存安全梦魇与“再小心一点”的谬论 Carol Nichols 直指 C 语言在生产环境中带来的系统性灾难:它在本质上是不具备内存安全性的。在生产环境中运行 C 代码,开发者就必须承担一整套棘手的风险清单:释放后使用(use-after-free)、双重释放(double free)、内存泄漏(memory leaks)、缓冲区越界读取与写入(buffer over-reads and overwrites)、空指针异常(null pointers)以及数据竞争(data races)。每当谈及这些隐患时,行业内总有一种声音辩解称“只要大家写代码时更小心一点,就能避免这些问题”。Carol 坚决反驳了这种观点,她强调过去 40 年的软件工程历史已经充分证明,人类根本不可能做到“足够小心”。 为了证明这一点,Carol 列举了行业顶尖团队的真实案例。Android 系统曾曝出名为 Stagefright 的严重漏洞;在一篇拆解 Stagefright 根本原因的 C 语言代码分析文章中,作者直言不讳地指出,想要避开这种漏洞,你必须比整个 Android 安全团队还要细心——而这意味着现实中每一个将 C 代码推向生产线的普通开发者都被迫承担这种不切实际的标准。此外,微软对过去 12 年间发布的各类安全补丁进行的一项知名研究显示,大约 70% 的安全漏洞直接归咎于内存安全问题。这就意味着,指望开发者靠个人自律避免错误,等于要求所有人都比微软安全团队还要专业且不犯错。 现有针对 C 语言的安全防护工具——无论是动态检测工具 Valgrind、AddressSanitizer、UndefinedBehaviorSanitizer,还是来自 NASA 具备严苛工程规范的静态抽象解释分析工具 IKOS,亦或是汽车行业的 MISRA C 编程规范——在 Carol 看来都有一个致命缺陷:它们全都是“事后补救措施(after the fact)”。开发者必须先写出代码,然后再想方设法去验证它的安全性;团队必须在开发流程中硬性排期、分配专门工时,并祈祷没有人遗漏任何检查步骤。至于市面上诞生的各种 C 衍生方言,由于缺乏抽象机制、迫使开发者反复造轮子且缺少现代化工具链,基本都没有流行起来。而转向 C++ 也无法彻底解决问题,未定义行为(undefined behavior)、裸指针漏洞以及多线程并发安全问题依然大量潜伏。Carol 总结道: > “It's not a matter of being more careful. We're in... it's the experience in past 40 years has shown we're not capable of being careful enough.”(这不是更小心一点就能解决的问题。过去40年的经验已经表明,我们根本不可能做到足够小心。) ### [16:08](https://www.youtube.com/watch?v=A3AdN7U24iU&t=968s) 理由一:所有权与借用机制从根源根除内存缺陷 正是为了应对底层系统软件面临的这些死结,源自 Mozilla Research 的编程语言 Rust 应运而生。它汲取了 C 语言这数十年踩过的坑,融合了多门现代语言的设计思想,试图推动整个行业向前发展,避免重蹈覆辙。Carol 提出了她认为 Rust 能够像 C 语言一样长盛不衰 40 年的五个核心理由,而第一个理由正是:Rust 从根源上解决了内存安全问题,显著提升了现有软件工程的基准线。 Rust 达成这一目标的核心利器是“所有权(ownership)与借用(borrowing)”系统。Carol 现场剖析了四段具体的代码模式来说明其运行机理: 1. **自动清理与无垃圾回收**:在基础示例中,`main` 函数在堆(heap)上分配了一块可变大小的 `String`,变量 `x` 是这块内存的唯一所有者。当 `x` 超出作用域离开生命周期时,编译器在编译期自动插入释放逻辑,堆内存被即时销毁。既不需要手动调用 `free`,运行时也没有任何垃圾回收器(Garbage Collector)开销。 2. **移动语义(Move)**:在第二个例子中,执行 `let y = x;` 后,堆字符串的所有权从 `x` 转移到了 `y`。若后续代码尝试继续读取 `x`,编译器会直接报错拒绝编译。因为底层数据永远只能拥有一个所有者,`y` 负责最终销毁,`x` 已失效,从而在编译期根除了双重释放和释放后使用。 3. **不可变借用(Immutable Borrow)**:如果代码改为 `let y = &x;`,则 `y` 成为对 `x` 所持有数据的只读借用。此时所有权依旧归属于 `x`,`x` 和 `y` 都可以合法读取该数据,并在函数末尾由 `x` 负责释放。 4. **悬垂指针(Dangling Pointer)拦截**:当尝试在一个内部嵌套作用域中声明堆变量,并将内部数据的引用返回给外部作用域时,Rust 编译器会察觉到该内部数据在离开作用域时就会被释放,外部接收到的将是一个指向已释放内存的引用,因此会在编译期直接报错,坚决阻止悬垂指针的产生。 ```mermaid flowchart TD accTitle: Rust 所有权与借用安全模型 accDescr: 展示 Rust 编译器如何在编译期管理变量生命周期并拦截悬垂指针 subgraph MemoryManagement["堆内存自动清理 (无 GC)"] A["分配堆字符串 String"] --> B["变量 x 获得唯一所有权"] B --> C["x 离开作用域 (Scope)"] C --> D["编译期自动插入释放代码 (Drop)"] end subgraph OwnershipTransfer["所有权转移 vs 借用"] E["let y = x (Move 移动语义)"] --> F["y 成为新所有者 / x 失效"] F --> G["再次访问 x -> 编译错误 (防 Double Free)"] H["let y = &x (Borrow 借用)"] --> I["y 拥有只读借用权限"] I --> J["x 仍保留所有权与清理职责"] end subgraph ScopeProtection["生命周期与悬垂指针防护"] K["内部作用域分配内存"] --> L["试图向外返回引用 &inner"] L --> M["内部数据随作用域结束被释放"] M --> N["外部引用悬空 -> 编译器拦截拒绝构建"] end ``` Carol 进一步罗列了 Rust 构筑的全面防御矩阵:在引用规则上,同一时间内要么只能拥有**一个可变引用**,要么可以拥有**任意多个不可变只读引用**,从而直接消除了同一数据被一边读一边写的并发数据竞争;Rust 完全废除了裸空指针,改用枚举类型 `Option<T>`(包含 `Some(T)` 和 `None`),强制开发者在编译期必须显式匹配并处理两种可能;在数组或数据结构越界访问时,程序会在运行时立即中止退出,绝不允许读取非法内存并带着污染的数据继续运行;最重要的是,这套所有权规则延伸至并发多线程环境,类型系统在编译期便会对跨线程传递所有权或共享借用进行验证,确保编写并发与并行程序时绝无跨线程数据竞争。 ### [21:06](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1266s) 理由二:解放“人脑带宽”,让普通开发者安全驾驭系统级编程 Carol 借用当天上午大会演讲者 Jessica 提出的概念——“人脑带宽(person byte)”,即一个人的大脑同一时间内所能容纳和处理的信息极限。在用 C 语言开发时,程序员必须在大脑中一边构思具体的业务逻辑与领域问题,一边紧绷神经去跟踪每一个指针、每一个缓冲区的内存边界与生命周期。这种心智负担极为繁重,不仅极其繁琐,而且事实证明人类大脑极易产生疏漏,没有人能够长期维持这种毫无差错的高压状态。 但这正是计算机最擅长的事情。计算机天生适合不知疲倦地跟踪各种繁琐而机械的规则,确保每一处验证每次都完全准确无误。Rust 的本质正是把这种繁琐的内存追踪负担从人脑转移到了计算机上。开发者写代码时尽可专注于自身领域的业务逻辑;如果不小心违反了规则,编译器会明确报错要求修正,而一旦编译通过,开发者就可以确信代码不存在低级内存缺陷,无需再整天提心吊胆。 这构成了 Carol 提出的第二个理由:Rust 让底层系统级编程变得人人皆可参与,而不再局限于极少数拥有超大“人脑带宽”、能在脑中完美兼顾领域逻辑与底层内存状态的所谓编程天才。Rust 扩大了能够安全编写系统级软件的人才基数。 - 繁琐规则自动化:由 Rust 编译器(borrow checker)承担机械、枯燥的指针与生命周期跟踪。 - 心智模型减负:开发者可以将注意力从“这块内存有没有被别处释放”中解放出来,全力攻坚业务域逻辑。 - 准入门槛重塑:让原本对系统编程望而却步的应用层开发者,也能安全编写出高性能、无段错误(segfault)的底层系统组件。 > “This makes low-level systems programming code something that everyone is capable of doing, not people who have extremely large person-byte capabilities to hold all this memory access in their head as well as the domain.”(这使得底层系统编程成为每个人都有能力做到的事情,而不再只属于那些拥有超大人脑带宽、能同时在脑海里装下所有内存访问规则和业务领域的人。) ### [22:41](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1361s) 逃生通道 `unsafe` 的设计哲学与性能取舍 为了应对现实系统中的极端情况,Rust 提供了一个逃生通道——`unsafe` 关键字。Carol 纠正了常见的误区:`unsafe` 并不意味着完全关停 Rust 的所有安全体系,它仅仅允许开发者做极少数受限的特定操作,例如进行裸指针算术运算,或是调用外部 C 代码(外部环境的状态编译器无法推断)。 `unsafe` 代码块的真正含义是开发者向编译器做出担保:“我知道你无法在编译期自动证明这段代码是绝对安全的,所以我作为人类开发者将亲自对这段代码进行代码审查,由我来确保它符合内存安全规则。”其优雅之处在于: 1. **缩小排错范围**:如果生产环境中发生段错误或内存破坏,排查人员立刻就能知道问题必定出在显式标记的 `unsafe` 代码块之内,而无需在成千上万行的全量代码中漫无目的地排查。 2. **默认安全,选择退出(Opt-out)**:与 C 语言工具链那种“代码默认不安全、必须由人主动记得去跑 sanitizer 工具”的机制截然相反,Rust 采用的是“默认安全,仅在必要时显式退出(opt-out)”。 3. **构建安全抽象**:开发者可以利用 `unsafe` 实现高效底层操作,随后将其封装在安全的公共 API 之中,外部调用者完全无法破坏其安全性。关于深入理解这一领域,Carol 推荐了关于“构建 unsafe 基石”的技术分享以及官方撰写的专著《The Rustonomicon》(俗称死灵书)。 Carol 也做出了诚实的免责声明:就像现代火车的空气制动器(air brakes)有时依然阻挡不了严重事故一样,Rust 并不能包治软件中的一切百病。它无法消除逻辑漏洞(logic bugs)——如果开发者把加法错写成减法,或者程序语义本身偏离了需求,编译器无能为力。因此,单元测试(tests)和模糊测试(fuzzers)依然不可或缺。 但在系统编程权衡的坐标系中,选用 Rust 换来了坚不可摧的内存安全性。而在性能层面,Rust 与 C 语言处于同一数量级:Rust 的所有权和生命周期校验几乎全都在编译阶段完成,运行时既没有垃圾回收器引起的 STW(Stop-The-World)暂停,也没有额外强加的检查包袱,实现了零成本抽象。 > “Like air brakes sometimes don't stop a train, Rust doesn't prevent all problems you might have a software. It does not prevent you from having logic bugs.”(就像空气制动器有时也拦不住脱轨的火车一样,Rust 无法防止软件中可能出现的所有问题。它并不能防止你写出逻辑 Bug。) ### [25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) 零成本抽象、可移植性与渐进式重写 C 语言遗产 在运行时检查开销极低的前提下,Rust 依然能够达成出色的运行效率。Carol Nichols 指出,Rust 的核心目标之一是实现“零成本抽象”(zero-cost abstractions),即开发者在代码中所采用的高级抽象语法,经编译器编译后,其执行效率丝毫不逊于手工精心编写的底层代码。Carol 谈到:“我们希望在任何你需要使用 Rust 的场景中,它的性能都能与 C 语言不相上下。” 关于跨平台可移植性,Rust 目前统一编译为 LLVM IR(中间表示),这意味着只要是 LLVM 能够支持的目标平台,Rust 都能直接编译运行。虽然传统 C 编译器支持的部分极其古老或小众的微处理器架构目前 LLVM 尚不支持,但从理论上讲,为 Rust 构建非 LLVM 的编译后端并不存在技术壁垒,仅需要社区持续投入工程实现。针对语言学习难度,Carol 直言不讳地承认 Rust 确实比 C 语言更为复杂,具有更多的语法规则和特性概念,这是为了向编译器准确传达复杂的内存管理与并发逻辑所必须付出的表达代价;但官方一直通过撰写官方图书、录制视频教程和开发多样化教学材料,竭力平缓陡峭的初学者学习曲线。 针对存量系统的迁移,Rust 提供了非常友好的渐进式兼容方案。通过声明 `extern` 函数,开发者可以轻松实现 Rust 与 C 语言的相互调用(FFI),进而借助 C 语言接口搭桥,使 Rust 能够与 Python 或 Ruby 等高级动态语言互相调用。Carol 分享了自己曾进行过的一场专题演讲:将原本由 C 语言编写的 Zopfli 压缩算法库逐个函数地移植到 Rust。通过这种方式,每次提交(commit)都能保持代码持续可编译且通过全量测试。Carol 极力推崇这种渐进改造策略: > “这种技术最让我喜欢的一点在于,你甚至根本不需要把它全部重写完;你无需将整个项目彻底改成 Rust 就能享受到它的好处。” - 开发者可以优先仅改造变更频率最高、历史 Bug 最集中的核心热点函数,其余稳定代码继续保留。 - 若团队中途遇到更高优先级的业务任务,重写工作可以随时搁置,此前已重写的部分仍能稳定提供内存安全与性能收益。 --- ### [28:47](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1727s) 六周发布周期、极高向后兼容性与稳定性承诺 很多初次接触 Rust 的工程师容易对语言的稳定性产生误解。Rust 采用了类似 Firefox 和 Chrome 浏览器的快速迭代发布火车机制(train release model),每隔六周就会准时发布一个新的稳定版本。这容易让人直觉上认为这门语言变动极其频繁、不够稳定。但实际上,自 2015 年 5 月正式推出 Rust 1.0 以来,官方团队始终坚守着极为严苛的向后兼容性承诺。 为了应对现实软件工程中的极端边界情况,Rust 官方仅在特定例外条件下保留有限的修改权限:允许修复编译器内部缺陷、修补安全漏洞以及对类型推断系统进行极少量的调整(这些调整偶尔可能需要开发者补充显式的类型注解),但官方要求这些变更绝不能在升级时给普通开发者带来阻碍。Carol 援引官方年度调查数据证实了这一承诺的兑现程度: > “在 2018 年的年度问卷调查中,我们设置了一个问题:‘升级编译器是否损坏了你的代码?’有 92.6% 的受访者明确回答没有损坏。” Carol 补充分析道,未来问卷的提问方式还需要进一步细化打磨,因为现有的问题并未严格区分“导致编译失败”(即破坏了 Rust 官方严肃保证的编译期兼容性)与“改变运行时行为、导致运行时变慢或变快”之间的区别,团队希望更深入地跟踪编译器在保障编译期向后兼容方面的绝对稳定性。 --- ### [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) Rust Edition 版本机制:如何在不割裂生态的前提下向前演进 为了让语言能长青发展 40 年,Rust 确立了“不带来停滞的稳定性”(stability without stagnation)的核心哲学:既要从过去的语言设计失误中吸取教训,引入更简洁好用的语法特性,又决不能破坏既有的向后兼容性。解决这一两难困境的核心机制便是“Rust Edition”(版本机制)。 Edition 是一种约每三年推出一次的可选(opt-in)机制,首版为 Rust 2015,随后发布了 Rust 2018。引入 Edition 最核心的诉求在于引入新关键字。例如 Rust 在筹备原生异步编程特性时,急需引入 `async` 关键字;但在 2015 版本的代码中,开发者很可能已经定义了名为 `async` 的普通函数。如果直接将 `async` 升级为全局保留关键字,老代码在升级编译器后就会直接报语法错误。通过 Edition 机制,只有当项目在配置中显式声明启用 2018 Edition 时,`async` 才会作为关键字生效;未开启的项目依然按 2015 Edition 规则编译,其已有的 `async` 标识符仍然完全合法有效。 Carol 坦言,自己刚听到这一方案时非常担忧编译器的维护成本,担心团队将不得不永远维护两套平行的功能实现;但深入了解编译架构后发现其实并非如此。Edition 的差异仅停留在编译器的前端表层(源码及 HIR 阶段),一旦降解为 MIR(中级中间表示),无论来自哪个 Edition,其内部数据结构与语义完全统一。 ```mermaid flowchart TD accTitle: Rust Edition 编译流程示意图 accDescr: 展示不同 Edition 源码在 HIR 阶段融合进统一 MIR 与 LLVM IR 的编译管线 subgraph FrontEnd ["前端语法解析(区分 Edition)"] A1["Rust 2015 源代码"] --> B1["HIR (2015 语法规范)"] A2["Rust 2018 源代码"] --> B2["HIR (2018 语法规范)"] end subgraph MidEnd ["统一编译器核心(无视 Edition 差异)"] B1 --> C["统一 MIR (中级中间表示)"] B2 --> C C --> D["借用检查、高级优化与代码生成"] end subgraph BackEnd ["底层代码生成"] D --> E["LLVM IR"] E --> F["目标机器码"] end ``` 这种架构设计带来了巨大的生态优势: - **消除了生态分裂的风险**:基于 Rust 2015 编写的依赖库可以被 Rust 2018 的主项目无缝引用,反之亦然,同一台编译器能毫无阻碍地链接所有 Edition 的代码。 - **决定权完全属于开发者**:用户可以每六周跟进升级最新的编译器版本以获得性能优化,但完全不需要被迫迁移语法版本;Carol 甚至明确强调,“永远不升级 Edition 也是完全被允许的选择”,Rust 2015 代码将获得与语言生命周期相同长度的持久支持。 - **自动化迁移工具配套**:Rust 提供了 `rustfix` 工具,能够自动检测并批量重构绝大部分需要适配新版本的语法,将升级摩擦力降到最低。 Carol 由此确信,通过 Edition 机制,Rust 绝不会重蹈其他语言生态大分裂的覆辙:“我确信利用这个机制来演进语言,意味着我们永远不会出现所谓的‘Rust 2.0’,我们绝不会打破向后兼容性。” --- ### [35:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2143s) 企业落地的现实痛点与 Mozilla 的生产级验证 要真正支持未来几十年的工业级软件工程,Carol 坦率承认 Rust 依然有许多尚未补齐的基础短板,这也制约了部分企业的大规模采用: - **缺乏正式行业标准**:目前尚无类似 ISO 或 ANSI 的国际标准化规范,而历史上 C 语言也是在工业界广泛使用多年后才制定了正式标准。 - **缺少经过安全认证的编译器**:在汽车电子、航空航天等对功能安全认证有强制要求的严苛行业中,认证编译器的缺失是一大准入门槛。 - **缺乏明确的长期支持(LTS)策略**:目前尚无针对特定版本的长期安全补丁回溯支持计划。 - **包管理工具链与企业级构建系统的整合难题**:官方主力构建工具 Cargo 深度捆绑默认工作流,对于拥有统一大型单体构建系统(monorepo build systems)的企业而言,整合难度较大;且当时官方体系对企业内部私有软件包仓库的支持尚不够完善。 - **第三方生态库仍在成长完善**:部分垂直业务领域可能尚未形成开箱即用且成熟健壮的第三方库。 尽管存在上述挑战,已有诸多大型企业在核心产品线上重注 Rust,从而为这门语言的长期前景背书。最典型的标杆当属 Mozilla 在 Firefox Quantum 架构中用 Rust 重写了关键的 CSS 渲染引擎(Stylo),使其具备了真正的网页 CSS 属性多线程并行渲染能力,从而大幅提升了浏览器的响应速度。 更为深远的意义体现在系统安全维度:Mozilla 团队对该 CSS 组件的历史安全性问题进行了系统性溯源分析。在以往采用 C++ 开发维护的漫长岁月中,该模块累计爆发过 69 个安全漏洞;研究发现,如果时间能够倒流,该组件从第一天起就完全采用 Rust 编写,其中足足 51 个安全漏洞(占比约四分之三)将在编译期被 Rust 的类型与内存安全检查机制直接拦截消除。Carol 认为,这一真实工业场景的量化结果强有力地证明了 Rust 的安全性价值。 ### [38:17](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2297s) 巨头企业的 Rust 采用现状与跨语言借鉴 Carol Nichols 借用 Twitter 知名技术博主 Patrick McKenzie(账号 @patio11)提出的首字母缩写词“ABAMAGUBOOKSOFT”来盘点头部大型软件公司对 Rust 的接纳程度。对于 Apple,她表示目前尚不知道其内部有任何公开使用 Rust 的案例;不过苹果拥有 Swift,而 Swift 在语言设计思路上与 Rust 惊人地相似。Carol 分享道,自己在会议早些时候旁听了一场 Swift 演讲,发现对方在努力解决许多与 Rust 几乎完全相同的问题,只是使用了不同的技术术语;她在台下一边听一边努力做术语映射:“哦,这就是那个意思,天哪,他们碰到了跟我们一模一样的难题!”她认为两门语言之间已经存在相互借鉴与技术授粉(cross-pollination),并期望未来双方能有更深入的相互学习。 至于其他科技巨头,Carol 指出它们已经广泛且公开地在关键基础设施中落地 Rust。这一广泛采纳证明了 Rust 绝非小众玩具,而是经受住了严苛的工业级检验。 - **Amazon**:近期正式开源并发布了基于 Rust 构建的 Firecracker microVM,用于支撑高密度、轻量化的无服务器计算与容器工作负载。 - **Google**:虽然整体较为保密,但其开源的下一代微内核操作系统 Fuchsia 项目中,已有相当一部分核心组件采用 Rust 编写。 - **Facebook**:为了应对超大型单体代码仓库(monorepo)带来的性能极限,原生 Mercurial 实现已经无法满足吞吐需求,因此他们采用 Rust 开发了高性能的 Mononoke Mercurial 服务端。 - **Microsoft**:公开宣布在其 IoT Edge 边缘平台上使用 Rust 进行设备端数据分析,完成边缘处理后再将分析结果汇总上报至云端服务器。 ```mermaid flowchart TD accTitle: Tech Giants Adopting Rust accDescr: Diagram showing four out of five big tech companies using Rust for different infrastructure projects. subgraph BigTech["ABAMAGUBOOKSOFT 工业级落地"] AMZN["Amazon"] -->|"Firecracker"| FC["轻量级 microVM 虚拟化"] GOOG["Google"] -->|"Fuchsia OS"| FCH["开源新一代操作系统组件"] META["Facebook"] -->|"Mononoke"| MNK["超大代码仓库 Mercurial 服务端"] MSFT["Microsoft"] -->|"IoT Edge"| IOT["边缘设备端分析平台"] end ``` --- ### [40:20](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2420s) 开放透明的社区治理与行为准则 在 Carol 看来,Rust 能够基业长青的第五大支柱在于其独特的“项目治理模式(Project Governance)”。一门技术的普及不仅取决于硬核的技术指标,更取决于其背后的政治与协作机制。Rust 从设计之初就摒弃了“终身仁慈独裁者(BDFL)”模式,没有任何单一个人拥有凌驾于整个语言之上的最终决断权。取而代之的是由众多团队与工作组(Working Groups)构成的分布式决策网络,成员背景极为丰富多样:既有深谙类型理论的程序语言博士(PhD),也有在工业界一线构建商业产品的架构师;既有纯粹出于技术热爱写代码的极客,也有分别来自 C/C++ 等底层系统语言、Ruby 与 Python 等高阶动态脚本语言,以及 Haskell 等纯函数式语言阵营的开发者。根据社区调查,Python 始终是转向 Rust 的第一大来源语言。 Carol 极为自豪地强调,Rust 绝不受制于任何商业闭门实体的私下操控。所有的重大演变都通过公开透明的 RFC(Request for Comments)机制推演,公众全程可查,负责决策的核心团队也必须在 RFC 讨论区公开阐述拍板的逻辑与考量。针对治理体系的公开性,Carol 坚定地表示:“Rust direction is not driven by a corporate closed entity making decisions in secret that you have no idea why they're doing and we're not going to take it in some surprising direction if we do you'll if we do take it in a different direction you'll know that we're doing it you'll be able to see us do that.” 此外,Rust 在完全开源的第一天起就引入了明确的社区行为准则(Code of Conduct)。这让整个社区彻底省去了“要不要引入行为准则”的无休止消耗与争拗;虽然治理团队自认并不完美,但始终在正视社区痛点,努力为所有专业开发者打造一个彼此尊重、包容且健康的工程协作空间。 --- ### [43:26](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2606s) 软件行业的傲慢、铁路工业的教训与监管困境 Carol 转而回顾铁路工业的演进历史,尖锐批评了软件工程行业长期蔓延的“盲目自大”:程序员往往天真地以为只要编写几行代码,就能轻而易举地解决其他行业几十年未解的痼疾。她列举了三个令人啼笑皆非的行业典型: 1. 某硅谷创业公司声称能做出革命性的榨汁机(Juicero),结果机器压榨出来的效果还不如人类徒手挤压果汁包; 2. 打车软件 Lyft 推出固定站点线路拼车,实际上只是用 App 笨拙地重新发明了早已有之的公共汽车; 3. 在泰国少年足球队被困溶洞时,Elon Musk 坚信自己能凭借特制微型潜水器搞定救援,结果比不过专业洞穴潜水员。 Carol 强调:“If we actually are better we need to show that we're better.” 面对安全困境,有人寄希望于强制性的外部法律监管,但软件行业面临着独有的公众认知鸿沟:公众很容易理解一列高速列车如果刹不住车会车毁人亡,也很容易明白在各种恶劣天气下爬上飞驰的火车车顶是极其致命的,但公众乃至立法机构根本无法具象化地理解什么是“内存不安全(Memory Unsafety)”,更无法一眼看穿这类底层漏洞会引发怎样灾难性的现实恶果。Carol 调侃道,一想到未来国会参议院的听证会记录里,一群软件工程师试图向年迈的参议员们苦苦解释什么是内存不安全,场面一定会陷入灾难性的鸡同鸭讲。 因此,外部政府监管短期内无法解决软件安全问题。程序员必须化身有自我觉醒、知情明智的消费者,在把底层依赖项引入系统之前,主动要求其具备真正的安全性。Carol 算了一笔时间账: - 铁路工业大约在 1830 年正式起步; - 乔治·威斯汀豪斯(George Westinghouse)于 1869 年发明了革命性的气动刹车(Air Brake); - 直到 1900 年左右,整个行业才实现全面强制普及。 这意味着,发明一种更安全的技术耗费了 40 年,而全行业彻底接受并全面部署它又耗费了整整 30 年。Rust 在 2015 年发布了 1.0 稳定版,扮演着“更安全、更优秀的现代化 C 语言”角色;而软件行业到底要花多少年才能完全采纳内存安全?Carol 坦言自己并不知道答案,但她由衷希望整个软件生态能够比铁路工业行动得更迅速。 --- ### [46:58](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2818s) 保持开放包容:跳出死循环,去犯“新的错误” 在讲座主体内容的尾声,Carol 真诚地向抱有怀疑态度的听众表达了开放包容的心态。她坦承自己完全愿意接受“Rust 并不是终极答案”的可能,但无论如何,整个行业都不能再对屡见不鲜、反复爆雷的内存安全漏洞视而不见:“I just I just want us to stop making the same mistakes over and over again let's make some new mistakes.” 她指出,未来的解决方案可能不止一个:如果不是 Rust,或许更偏向底层系统掌控的 Zig 是出路,听众可以去听紧接着的 Zig 演讲;也可能是明天专场要介绍的 Go 语言;又或许针对不同的场景,多元的工具会共生互补。只要能彻底摆脱长达数十年的老旧内存缺陷,全行业去犯一些前所未见的新错误,技术就是向前进步的。 随后进入现场互动环节。Carol 首先向听众分享了幻灯片链接、个人 Twitter 账号(@carols10cents)、Manning 出版社全场 40% 的折扣码,并幽默地致谢了自己的核心“内测受众”——女儿 Vivian 和宠物猫 Baby,感谢她们在自己试讲时展现出的非凡耐心与宝贵反馈。 --- ### [48:43](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2923s) 现场问答:Rust 名称渊源与 Rust vs Go 之抉择 在精选现场提问时,Carol 首先回答了一位名叫 Partha 的听众关于“Rust(铁锈)名字从何而来”的提问,并当场赠送给提问者一个装有实体礼品代码的信封。对于命名渊源,社区内流传着几种不同的说法: 1. **自行车爱好者视角**:Rust 的核心早期创立者们都极度热爱骑行,而链条与齿轮经常要面对铁锈的侵蚀,这也正是 Rust 语言官方 Logo 酷似自行车齿轮(bicycle gear)的由来; 2. **生物学真菌视角**:小麦等作物表面经常会生长一种名为“锈菌(Rust Fungus)”的致病寄生真菌,这在学术圈常被推测为灵感源头之一; 3. **柯尔顿耐候钢视角**:Carol 本人更钟情于将 Rust 联想为一种历经漫长岁月洗礼、坚固而稳定的存在。例如匹兹堡的地标建筑美国钢铁大厦(U.S. Steel Tower)所采用的柯尔顿耐候钢(Corten Steel),这种材料会特意在其表面氧化形成一层致密的铁锈保护层,从而免除后期涂刷油漆的繁琐,实现永久的自我保护。 紧接着,面对一位匿名观众关于“为什么在 Go 和 Rust 之间选择 Rust”的提问,Carol 分析了二者的本质定位与权衡取舍: - **垃圾回收(GC)开销**:Go 语言内置垃圾回收器,这在系统底层、硬实时或资源严苛的极致场景下可能是不可接受的一票否决项(deal breaker);如果在运行时绝对不允许额外的资源消耗或突发延迟,Rust 是毫无争议的首选。 - **生态集成亲和度**:如果系统需要深度对接 Google 旗下的产品与生态架构,选择 Go 语言往往能享有最为平滑的原生统一体验。 - **选型建议**:Carol 认为两者都在试图提供替代部分 C++ 应用场景的现代方案,由于诞生时间相近才频繁被拿来对比。她建议开发者亲自用两门语言各写一些入门代码,看看哪一门语言的设计哲学能与自己的心智模型产生共鸣,由自己做出最适合具体业务场景的技术抉择。最后,Carol 准备转向下一个关于“在主流 IDE 支持背景下如今选择 C 语言的现实理由”的提问。 ### [51:47](https://www.youtube.com/watch?v=A3AdN7U24iU&t=3107s) Rust 的 IDE 支持现状与工具生态展望 在演讲的问答环节中,现场观众提问 Rust 是否具备成熟可靠的 IDE 集成支持。Carol Nichols 坦诚地回答,团队目前正在全力推进这方面的改进,并且 Rust 团队深知这是目前必须做得更好的短板之一。她提到业界正在推行名为语言服务器协议(Language Server Protocol,简称 LSP)的规范,该协议旨在统一编程语言与各类 IDE 之间的通信方式,让语言工具能够向编辑器实时反馈代码信息。Rust 社区已经开发了基于 LSP 的具体实现,支持代码自动补全、行内错误提示以及跳转到定义等基础功能。在实际编辑器生态中,VS Code 拥有维护最良好的 LSP 插件,而 JetBrains 旗下的 IntelliJ 同样提供了相当出色的 Rust 插件支持。 Carol Nichols 随后分享了自己从动态语言转向 Rust 的个人体会。在深入使用 Rust 之前,她从事了很长一段时间的 Ruby 开发。她非常推崇 Michael Feathers 所著的《修改代码的艺术》(*Working Effectively with Legacy Code*),书中反复强调要学会“依赖你的工具”,善于借助 IDE 的自动化重构能力来维护大型系统。然而在 Ruby 这样的动态语言中,由于充斥着复杂的元编程特性,开发者甚至可以将一个动态拼接的字符串直接当作函数执行。这种高度动态的特性导致自动化分析工具根本无法确认某个函数究竟在何处被调用,许多高级重构工具因此难以发挥作用。Carol 坦言,当年写 Ruby 时她对其他语言强大的 IDE 工具充满艳羡。尽管 Rust 目前的 IDE 工具链尚未完全成熟,但得益于其严格的静态类型系统,构建强大自动化重构工具的技术可行性远高于 Ruby,她由衷期待这些工具在 Rust 生态中全面落地的那一天。 Carol Nichols 直言不讳地指出团队在此领域的决心与工具构建的可能性: > “This is another one of those things that we know we need to do better at.” > “I had a lot of jealousy for IDE tools while I was writing Ruby and I'm looking forward to the days that we have those tools for Rust; they're not there yet, but they're more possible to make than they are in Ruby.” - **LSP 协议与功能**:通过语言服务器协议统一语言后端与编辑器前端交互,当前已支持代码补全、行内编译报错以及定义跳转。 - **推荐编辑器支持**:VS Code(维护最完备的 LSP 客户端插件)和 IntelliJ(拥有专用的高质量 Rust 插件)。 - **工具链对比**:动态语言(如 Ruby)因动态调用和字符串求值等元编程限制,静态分析与安全重构困难;Rust 严格的静态类型系统为自动化重构提供了坚实的底层保障。 --- ### [53:45](https://www.youtube.com/watch?v=A3AdN7U24iU&t=3225s) Async/Await 在 2015 与 2018 Edition 中的实现与演进 Carol Nichols 接着从现场挑选了另一个关于异步编程的提问。提问者关注演讲中提到的异步功能(Async),询问 Async 是否已经在 Rust 2015 版本中可用,还是仅属于 Rust 2018 版本的新特性。Carol 明确澄清了一个常见的认知误区:实际上在当前这一刻,Async 在这两个版本中都尚未正式落地。在发布 Rust 2018 版本时,团队仅仅是在语法层面将 `async` 保留为了关键字。虽然团队最初的设想是在 2018 版本正式发布时同步推出完整的 async 语法支持,但该特性的工程量与复杂度极大,未能按期随版本交付,当时仍有大量核心贡献者正在加紧开发。 Carol 介绍,关于 Async 的具体语法设计和内部工作机制,Rust RFC(Request for Comments)流程中仍有大量的热烈讨论,欢迎对此感兴趣的开发者参与贡献与交流。针对两个版本的兼容性规划,她解释称,一旦 async/await 特性最终定稿并实现,它很可能会在 Rust 2015 和 Rust 2018 中同时获得支持。区别仅仅在于语法的人体工程学体验:Rust 2015 由于没有提前将 `async` 设为保留关键字,为了避免破坏既有代码中将 async 作为变量名或函数名的旧项目,它将无法直接使用该关键字,语法表达上会比拥有保留关键字的 Rust 2018 显得较为繁琐和不够优美。在回答完该问题并向提问者赠送纪念礼物后,Carol Nichols 表示本次演讲的时间已全部用尽,正式向全场致谢,演讲在热烈的掌声中圆满结束。 Carol Nichols 在解释 Async 的现状及未来跨版本支持时强调: > “When we created the 2018 Edition, we just reserved the keyword for async, and we wanted to have async support done by the time we shipped the Edition, but it's not done; people are working on it right now.” > “Once it is done, it will probably be available in both; it's just that the syntax in Rust 2015 is not going to use a keyword, so it's not going to be as nice a syntax as it will be in Rust 2018.” ```mermaid flowchart TD accTitle: Rust Async Feature Support Comparison accDescr: 比较 Rust 2015 与 Rust 2018 版本在 async/await 特性支持上的设计与语法差异。 subgraph R2018["Rust 2018 Edition"] A1["预留 async 关键字"] --> B1["定稿后享有优雅的原生关键字语法"] end subgraph R2015["Rust 2015 Edition"] A2["未将 async 设为关键字<br/>(防止破坏现有代码标识符)"] --> B2["定稿后支持异步能力<br/>但语法表现形式相对繁琐"] end RFC["底层 RFC 提案设计中<br/>(针对确切语法与机制的讨论)"] --> A1 RFC --> A2 ``` - **Async 当前交付状态**:在演讲录制期间(2019 年 5 月),async 机制尚未在任何 Edition 中正式稳定发布,底层细节仍在 RFC 阶段密集讨论。 - **Edition 间的语法策略差异**:Rust 2018 预留了 `async` 关键字,未来语法更加精简自然;Rust 2015 为保持向后兼容性不强制占用关键字,但后续仍会提供同等的底层异步功能接入方案。 ## Notable quotes > [12:35](https://www.youtube.com/watch?v=A3AdN7U24iU&t=755s) It's not a matter of being more careful. We're in... it's the experience in past 40 years has shown we're not capable of being careful enough. — Carol Nichols > [21:06](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1266s) This makes low-level systems programming code something that everyone is capable of doing, not people who have extremely large person-byte capabilities to hold all this memory access in their head as well as the domain. — Carol Nichols > [22:41](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1361s) Like air brakes sometimes don't stop a train, Rust doesn't prevent all problems you might have a software. It does not prevent you from having logic bugs. — Carol Nichols > [25:54](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1554s) 这种技术最让我喜欢的一点在于,你甚至根本不需要把它全部重写完;你无需将整个项目彻底改成 Rust 就能享受到它的好处。 — Carol Nichols > [46:58](https://www.youtube.com/watch?v=A3AdN7U24iU&t=2818s) I just I just want us to stop making the same mistakes over and over again let's make some new mistakes. — Carol Nichols > [30:25](https://www.youtube.com/watch?v=A3AdN7U24iU&t=1825s) 我确信利用这个机制来演进语言,意味着我们永远不会出现所谓的‘Rust 2.0’,我们绝不会打破向后兼容性。 — Carol Nichols ## Mentioned Carol Nichols, George Westinghouse, Cornelius Vanderbilt, Lorenzo Coffin, Brian Rust, Jessica, Patrick McKenzie, Elon Musk, Michael Feathers, The Rust Programming Language, Rust in Motion, Working Effectively with Legacy Code, The Rustonomicon, Integer 32, Rust Belt Rust, No Starch Press, Manning, Mozilla, Google, Amazon, Microsoft, Facebook, Apple, Lyft, Juicero, Rust, C, C++, Go, Zig, Swift, Ruby, Python, Haskell, Firefox, Firecracker, Fuchsia, Mononoke, Stylo, LLVM, Cargo, Valgrind, AddressSanitizer, UndefinedBehaviorSanitizer, IKOS, VS Code, IntelliJ ## Video description Learn what makes the programming language Rust a unique technology, such as the memory safety guarantees that enable more people to write performant systems-level code. Hear about how Rust Editions evolve the language and the compiler without breaking existing code. See who’s trusting Rust for critical products today. Join us on Rust’s journey to the future. Philly ETE 2019 Playlist: https://www.youtube.com/playlist?list=PL9oQ7yETvN10Lopbg81O_bwElm9grUkDB On the Chariot Solutions site: http://chariotsolutions.com/screencasts/ [Source](https://www.youtube.com/watch?v=A3AdN7U24iU)

Source quotes

[12:35] Carol Nichols: It's not a matter of being more careful. We're in... it's the experience in past 40 years has shown we're not capable of being careful enough. [21:06] Carol Nichols: This makes low-level systems programming code something that everyone is capable of doing, not people who have extremely large person-byte capabilities to hold all this memory access in their head as well as the domain. [22:41] Carol Nichols: Like air brakes sometimes don't stop a train, Rust doesn't prevent all problems you might have a software. It does not prevent you from having logic bugs. [25:54] Carol Nichols: 这种技术最让我喜欢的一点在于,你甚至根本不需要把它全部重写完;你无需将整个项目彻底改成 Rust 就能享受到它的好处。 [46:58] Carol Nichols: I just I just want us to stop making the same mistakes over and over again let's make some new mistakes. [30:25] Carol Nichols: 我确信利用这个机制来演进语言,意味着我们永远不会出现所谓的‘Rust 2.0’,我们绝不会打破向后兼容性。

Source quotes

[19:39] Carol Nichols: There's someone who's really good at keeping track of tedious things and making sure that they're right every single time: it's our computers. [12:35] Carol Nichols: It's not a matter of being more careful. It's the experience in past 40 years has shown we're not capable of being careful enough. [46:55] Carol Nichols: I am willing for Rust not to be the solution as long as we do something; let's just do something to fix these memory safety problems that keep happening over and over and over again. [25:54] Carol Nichols: We have the goal of having zero cost abstractions which means that the abstractions you use are compiled down to code that you could not write better by hand.

Original transcript

[0:13] so you are in the talk rust a language [0:16] for the next forty years my name is [0:18] Carol nickels or Golding it's [0:21] short-circuits I will answer two nickels [0:24] quicker but you can also call me Carol [0:26] building if you want [0:27] I'm Carol's ten cents on all the various [0:30] platforms I have a lot of links in my [0:33] slides so if you want to be able to [0:36] follow up on references and check out [0:38] some more things this short link will [0:40] take you to a repo where there's link to [0:43] view the slides on the web and the [0:46] readme has just the links pulled out as [0:51] sort of alluded to in the intro I'm the [0:54] co-author of the rest programming [0:56] language book which is available for [0:58] free online and available in print from [1:01] no starch press I'm also a co-author on [1:04] a Manning live video series called [1:07] rusted motion that's in early access [1:09] right now and thanks to Manning I have [1:13] three codes for free access to this rest [1:17] in motion so the favorite my favorite [1:19] three questions are going to get access [1:22] to this so please ask wonderful [1:24] questions on the slide slide Oh question [1:31] asking platform I am also a co-founder [1:36] of integer 32 the world's first rust [1:39] consulting company and I am an organizer [1:44] of rust belt rust a regional rust [1:48] conference this year we're going to be [1:49] in Dayton Ohio on October 18th and 19th [1:51] and I'm on the rust core team so if you [1:56] were hoping for an objective unbiased [1:58] look at rust you're not gonna get that [2:02] from this talk I clearly have a slant [2:07] here [2:08] I love rust so much that my favorite [2:10] hockey player is two-time Stanley Cup [2:13] winning champion Brian rust from the [2:16] Pittsburgh Penguins and yes you may [2:18] throw tomatoes at me or batteries or [2:19] whatever it is [2:20] that you do here in Philadelphia I could [2:24] take it alright so in this talk today [2:26] we're gonna talk a little bit about the [2:28] railroad industry but you weren't [2:30] expecting that but we are we're gonna [2:32] talk about C we're gonna talk about rust [2:35] and we're going to talk about what the [2:37] software industry can learn from the [2:39] railroad industry so a little railroad [2:43] industry history commercial railroads in [2:46] the United States started being built [2:48] around 1830 and trains are really great [2:51] they let you get across this huge [2:53] country of ours a lot faster than things [2:55] like stagecoaches and they really took [2:58] off built lots of lines of Braille all [3:03] around the country really fast but as [3:06] the miles of rail and as the train trips [3:08] grew injuries and deaths also grew it [3:12] turns out that once you get a big train [3:15] moving it's kind of hard to get it to [3:17] stop again and there were lots of [3:22] collisions there were lots of accidents [3:23] and one of the most dangerous jobs on [3:27] the railroads was that of the brake man [3:29] because the way you used to have to get [3:33] trains to stop is someone the engineer [3:37] would blow a certain signal with the [3:39] whistle that he wanted to stop and then [3:42] people would have to go off on the top [3:44] of each car and turn this wheel to put [3:47] the brakes on and then move to the next [3:50] car and eventually the train would [3:52] slowly come to a stop as all the brakes [3:55] were applied but this wasn't really an [3:58] exact science so if at best case if this [4:03] didn't go well you would miss the [4:05] station you were trying to stop at worst [4:07] case if you needed to stop in a hurry [4:10] probably couldn't and you there were [4:12] collisions and accidents and this job [4:17] being on top of the train when it was [4:18] rainy or icy it's pretty dangerous and a [4:22] lot of brake men would fell to fall off [4:24] the train and be killed this was a this [4:27] is the thousands of brakeman died every [4:33] year this is second only to [4:34] mining as the most dangerous career in [4:36] the eighteen hundred's [4:40] enter George Westinghouse a an amazing [4:44] Pittsburgher he invented lots of things [4:48] was part of making electricity viable [4:53] and and commercially available and in [4:56] 1869 he invented the first air brake [5:00] there have been improvements made over [5:03] the years but essentially his air brake [5:05] is what trains use today the way air [5:08] brakes work are that they're controlled [5:10] by compressed air rather than a physical [5:14] wheel on top the car there's a control [5:18] up in front for the engineer to turn the [5:22] brakes on and off so they don't have to [5:24] use the whistle to communicate all the [5:28] cars are connected so that when the [5:32] engineer turns the brakes on all of the [5:33] cars start breaking all the same time [5:36] and a later failsafe was added so that [5:41] when there isn't pressure to each car [5:43] through this connection the brakes are [5:46] on so that this is safe by default you [5:49] would have to apply the pressure to turn [5:50] the brakes off and get the car moving so [5:53] if something if all the Scotch is [5:54] connected the Train would would come to [5:57] a stop instead of continuing to go and [6:01] this system was a lot more complex than [6:03] the hand brakes and there was some [6:06] skepticism this was a quote from [6:09] Vanderbilt who was the guy behind [6:13] Vanderbilt University eventually but he [6:16] he couldn't believe that that error was [6:19] going to be what stops trains but they [6:22] did a lot of public tests a lot of [6:24] demonstrations that involved people [6:28] riding in train cars with like pillows [6:31] everywhere testing all these sorts of [6:33] different kinds of brakes and like [6:35] running into the wall is because when [6:36] different kinds of brakes didn't work [6:38] but the air brakes were passing all [6:40] these public tests and there were a lot [6:42] safer and a lot better at getting the [6:45] trains to stop then the hand brakes were [6:48] railroads are adopted these four [6:51] passenger trains pretty quickly because [6:53] consumers demanded it this is an [6:56] advertisement for a particular train and [6:59] the this yellow part here says that the [7:03] Swift operation of these nightly [7:04] carriers is safeguarded by Westinghouse [7:06] air brakes so this is something that the [7:08] market demanded that that they there [7:12] were people who were scared to ride [7:13] trains because they couldn't stop but [7:15] these air brakes gave people the [7:17] confidence that they could ride the [7:18] train safely [7:19] however on freight trains it took a lot [7:22] longer for these air wrecks to be [7:25] adopted and there was this person named [7:30] coffin who was a big advocate for [7:34] mandating these air brakes be used on [7:37] all trains and he worked for the Iowa [7:40] Railroad Commission and when he started [7:42] he said that the people on the [7:44] Commission just kind of thought that [7:47] this was the way it was [7:49] trains are dangerous and brakeman were [7:53] going to die so there wasn't really much [7:55] we could do that this is just how things [7:57] were but he a coffin got kept getting [8:03] all these reports about brakeman being [8:05] killed and was like no this is these are [8:08] all the same cause we have to do [8:09] something about this so he did a lot of [8:12] advocacy there's this there's [8:14] transcripts of a Senate hearing for the [8:17] run the Interstate Commerce Committee [8:19] that I just find riveting I like reading [8:22] these Senate transcripts from 1890 and [8:25] they're amazing coffin had a lot to say [8:28] in favor of mandating air brakes on all [8:31] trains the industry people were didn't [8:35] want to be regulated so they had a lot [8:38] of interesting arguments they they [8:42] didn't want to pay to add these air [8:44] brakes to all their trains they thought [8:47] that brakeman were kind of expendable [8:50] and cheaper which is terrible they were [8:53] like the air brakes are still gonna fail [8:55] sometimes the like it doesn't matter the [8:58] hand brakes fail the air brakes are also [9:00] going to fail so why so why should we [9:02] they simultaneously made two arguments [9:05] they said we are already innovating [9:08] without legislation we are testing new [9:10] things all the time to improve the [9:12] safety of the Train if you if you [9:14] regulate that there's some minimum [9:16] standard we're gonna adopt the thing [9:18] that'll meet the law and we're gonna [9:20] stop innovating so that was one argument [9:22] in like the next breath this guy at so [9:24] liberating testimony said and what if [9:29] something better comes along and we've [9:31] already have all this sunk costs into [9:33] these air brakes it's like wait a second [9:35] wait are you saying you're gonna keep [9:38] innovating are you saying you're gonna [9:39] stop innovating because now you're [9:41] saying what we're gonna happen they [9:43] really just didn't want to be regulated [9:46] they said they have other means they [9:49] have to pay for they can't possibly [9:50] afford these they said you should have [9:52] regulated this twenty five or thirty [9:53] years ago all sorts of things my [9:56] favorite my favorite objection from the [9:59] president of the Pennsylvania Railroad [10:01] Company was are you're gonna regulate [10:03] the trains what's next are you gonna [10:05] regulate the bridges it's like yes [10:09] please [10:10] we want the bridges to be safe too [10:12] actually so yeah it turns out that the [10:19] US railroad safety appliance Act passed [10:22] Congress in 1893 mandated the use of air [10:26] brakes and standard couplers to connect [10:29] the trans together in 1900 it was fully [10:32] enforced and all trains whether a [10:36] passenger freight had to be using these [10:38] safety devices and accidents and deaths [10:40] of both people being run into both [10:44] people and things being run into by [10:45] trains and brakeman operating the trains [10:48] went way down this helped a whole lot it [10:52] wasn't perfect but it was way better [10:56] okay that was your railroad history [10:59] lesson [11:02] so now we're gonna talk a little bit [11:04] about C so why might companies choose C [11:09] uh who-who works at a company who has Z [11:13] code in production today okay yeah good [11:18] all right you you might you probably [11:21] have a variety reasons why you're doing [11:23] that it's a proven solution that has [11:26] worked for 40 years it's fast it has [11:29] very little overhead it's kind of close [11:31] to the Machine close to the assembly [11:33] language it uses very little resources [11:37] there's a C compiler to target just [11:39] about any sort of platform you might [11:41] want to run on the language is simple [11:45] there's not a whole lot of syntax to [11:47] learn I would argue that it's a little [11:49] bit deceptively simple because there's a [11:52] lot of interesting things that C code [11:54] can do you might have a lot of existing [11:59] C code or you might want to interface [12:01] with existing C code that makes it easy [12:04] means using C would make that easier and [12:07] C doesn't really change a whole lot and [12:10] enterprise software the field moves [12:13] rather slowly and you don't want to have [12:16] lots of parts changing out from [12:18] underneath you and having your code [12:20] become obsolete so but in order to get [12:25] all these advantages you have to agree [12:28] to what I see as a huge disadvantage [12:31] that outweighs all of that is that C has [12:35] all these memory safety problems it's [12:39] not memory safe these problems include [12:42] use after free double free memory leaks [12:46] buffer over reads and over writes no [12:49] pointers databases oh my this is just a [12:53] lot of problems that you have to sign on [12:56] to when you are shipping C in production [13:01] and I'm sure those of you who have seen [13:03] production can tell lots of stories [13:05] about problems caused by all of these [13:09] and a lot of people say well it's you [13:14] just be more careful [13:15] then we can avoid these problems it's [13:17] not a matter of being more careful we're [13:20] in it's the experience in past 40 years [13:22] has shown we're not capable of being [13:25] careful enough there is a vulnerability [13:29] called stage fright in Android and this [13:32] blog post was illustrating some C code [13:35] to try and explain what the root cause [13:37] of stage fright was and - he said you'd [13:41] have to be more careful than the [13:42] entirety of the Android security team [13:45] every C developer shipping code [13:47] impression has to be more careful than [13:50] that there was a great presentation and [13:54] the post about Microsoft did some [13:58] studying of the problems that they had [14:01] to do issue security updates for over [14:05] the last 12 years about 70% of them were [14:08] due to memory safety problems [14:11] we're being you'd have to be more [14:13] careful than the Microsoft security team [14:17] there have been some efforts to make C [14:19] safer there are tools like valgrind [14:22] there's tools like address sanitizer [14:26] undefined behavior sanitizers I found [14:29] this tool called IKOS that does abstract [14:31] interpretation as a static static [14:34] analysis it's from NASA so you'd have [14:37] passive has a really rigorous [14:40] engineering discipline so if that's the [14:44] kind of investment you want to make you [14:47] can check out tools like that there are [14:49] the misra guidelines all of these kind [14:53] of strike me as things you do after the [14:57] fact you write the code first and then [14:58] you try and make it safe which you have [15:03] to make sure you do those things you [15:05] can't forever forget you have to build [15:06] them in the processes you have to [15:08] allocate time to do that and fix the [15:09] problems you find it seems like kind of [15:13] patching it after the fact there are [15:17] some varieties of C people are creating [15:22] none of these have really caught on much [15:26] you're still writing C that has [15:28] very little abstractions you have to [15:32] reinvent the wheel all the time you [15:33] don't have modern tools that go with it [15:35] and if you're gonna be switching [15:37] languages anyway I advocate that you [15:40] look at all your options and of course [15:44] they're C++ which improves some things [15:47] by not everything there's still a lot of [15:49] undefined behavior there's still a lot [15:51] of pointer problems you can get into [15:56] multi-threaded programming is still a [15:57] big problem in C++ so what can we do [16:04] about this and that brings us to the [16:08] Russ part so Russ is a language out of [16:14] Mozilla research it's trying to learn [16:18] from the mistakes of C and bring in [16:20] ideas from a bunch of other languages [16:22] too I see it as moving our industry [16:26] forward and trying not to repeat the [16:28] same mistakes over and over again I have [16:32] five reasons why I think Russ is ready [16:35] to last as long as C has the first [16:41] reason is that it fixes these memory [16:44] safety problems it's it's an improvement [16:47] upon the status quo it does this through [16:51] a system of ownership and borrowing and [16:56] I'm going to show some examples of how [16:58] this works this is some rest code it's a [17:01] main function that creates a string on [17:05] the heap that we can grow and change in [17:08] size the owner of that memory is this [17:12] variable X and when that owner goes out [17:16] of scope that's when the heap memory it [17:19] gets cleaned up automatically rust kind [17:22] of inserts a looks at this code I was [17:24] compiling inserts a statement at compile [17:26] time that at the end of main that cleans [17:30] up that memory so we don't have to write [17:34] free free the memory that X manually but [17:38] there's also not a garbage collector [17:40] running at runtime this is all [17:41] compile-time this is another example in [17:45] this example we've got the same string [17:47] in X then we say let y equals 2x and we [17:51] try to print out X this line here moves [17:56] ownership of the string from X to Y and [18:00] this code does not compile because we're [18:05] trying to use X again after we've moved [18:09] it into y so we see this data still only [18:12] has one owner after that point we've [18:16] moved it into y Y we'll clean that up [18:19] and X note is no longer valid and we're [18:22] no longer allowed to use it after we've [18:24] moved it so we don't have double three [18:26] problems and we can't use after free [18:30] this code instead of moving ownership [18:34] this borrows Y is a an immutable borrow [18:39] of X it's allowed to read the the data [18:42] that X owns but X is still responsible [18:45] for cleaning up the memory at the end of [18:47] the function and this code compiles and [18:50] we're allowed to read using either X or [18:53] Y in this example we are trying to [19:00] create a dangling pointer we have an [19:03] inner scope and we're trying to return a [19:07] reference to heap data from that inner [19:10] scope the problem is that the way rust [19:14] ownership works X is going to get [19:16] cleaned up at the end of that inner [19:18] scope so this code doesn't compile [19:21] because we're trying to use the [19:24] reference after that data has been [19:26] cleaned up and rust can see that at [19:28] compile time and doesn't let us run this [19:32] code because X gets cleaned up rust has [19:39] a lot of other safety mechanisms that I [19:41] don't have time to get into fully one of [19:44] the rules about references is that you [19:46] can have either one mutable changeable [19:51] reference at a time or you can have many [19:56] immutable references for reading at one [19:59] time so this prevents databases so that [20:03] you can't change a value while someone [20:05] else is trying to read it there are no [20:09] no pointers there's the option type that [20:14] represents either something and holds a [20:17] value or there's none the none value and [20:20] the compiler makes sure you handle both [20:23] some or none at compile time out of [20:28] balance array axises or data structure [20:31] accesses at run time it just stops the [20:34] program immediately and doesn't let you [20:36] continue with invalid data that isn't [20:39] part of your data structure the [20:42] ownership rules apply across multiple [20:44] threads there's parts of the type system [20:46] that allow you to express transferring [20:49] ownership or borrowing across multiple [20:52] threads [20:52] so now programming parallel or [20:56] concurrent programs is is checked at [20:59] compile time that you don't have data [21:01] races across threads Jessica this [21:06] morning said a neat word that I hadn't [21:07] heard before which is the person bite [21:10] it's what you can keep in your head all [21:13] at one time and trying to keep all these [21:17] rules and keep make sure you're doing [21:19] all these things right in your head with [21:22] C is really tedious and as we've seen is [21:27] error-prone it's it's too much for one [21:29] person to hold your head in addition to [21:31] your problem domain is and but there's [21:37] someone who's really good at keeping [21:39] track of tedious things and making sure [21:41] that they're right every single time [21:42] it's our computers so I see rust as [21:47] making the computer take care of all [21:49] that tedious tracking of whether the [21:53] memory accesses are right or not and I [21:55] can forget about that the compilers [21:57] gonna tell me when I get it wrong and I [21:58] have to go fix that yeah but if my comm [22:00] compiles I I don't have to worry that I [22:03] that I missed someplace and I can just [22:07] concentrate on my domain [22:09] and this is the second reason I think [22:12] Russ is is going to continue to grow and [22:15] to last for the next 40 years is that [22:18] this makes love level assistance [22:20] programming code something that everyone [22:22] is capable of doing not people who have [22:24] extremely large person bite capabilities [22:27] to hold all this memory access in their [22:29] head as well as the domain which I'm not [22:34] sure that anyone actually exists because [22:36] of the problems we see but more people [22:38] can program safe systems level code with [22:41] rust I do have a caveat there is an [22:45] escape hatch it's the unsafe keyword it [22:49] lets you opt-out of not all of Russ [22:52] safety checks it lets you do a few very [22:55] specific things e and by putting unsafe [23:00] around some of your code you're saying [23:01] okay compiler I understand that you [23:07] can't ensure that this code is going to [23:09] be safe every single time I as a person [23:12] I'm going to audit this specific code [23:14] and I will make sure that I'm following [23:16] the Murray rules and this is useful in [23:21] certain performance cases when you're [23:24] trying to express certain pointer [23:28] arithmetic when you're trying to call to [23:30] external code that the compiler can't [23:31] possibly know anything about so as and [23:34] as long as you don't put your entire [23:36] program in an unsafe block what I like [23:39] about this is that when if you have a [23:43] seg fault or memory access problem at [23:46] runtime you know it came from one of [23:48] those unsafe blocks it's like hey look [23:50] over here this is probably where the [23:53] memory problem came from because the [23:55] compiler didn't check this part so [23:56] you've you've lessened the places you [23:59] have to look to debug to figure out [24:02] those problems I also think that this [24:09] this unsafe keyword doesn't invalidate [24:11] things because this is this is opting [24:13] out of the safety checks rather than [24:15] opting into them so as opposed to the [24:21] the sanitizers that you have to [24:22] remember to run after all the changes to [24:25] your code this is this is the default is [24:30] too bright safe code and you can opt out [24:33] of it if you need to if you want more [24:36] information on writing unsafe code [24:39] there's this great talk for building an [24:42] unsafe foundation the other neat thing [24:44] is you can build safe abstractions out [24:46] of unsafe code and there's a whole book [24:49] on unsafe code called the Resta nomicon [24:56] like air breaks sometimes don't stop a [25:00] train rust doesn't prevent all problems [25:04] you might have a software it does not [25:07] prevent you from having logic bugs it [25:09] can't tell that you meant to tell the [25:12] program to do one thing and it's [25:13] actually doing another so you stole the [25:15] need things like tests and you still [25:18] need to write things like buzzers but by [25:22] choosing to use rust you're getting [25:24] memory safety you're not going to have [25:27] all those problems that C has so let's [25:30] go back through the reasons that you [25:33] might choose C and C what we're trading [25:35] off because there's always trade-offs [25:36] and in any sort of decision you might [25:40] make performance Russ is on the order of [25:44] C's performance there aren't the the [25:47] additional checks that Russ does are [25:49] mostly at compile time [25:51] there isn't a garbage collector it isn't [25:54] checking much at run time you can still [25:57] get we have the goal of having zero cost [26:01] abstractions which means that the [26:03] abstractions you use our compiled down [26:06] to code that you could not write better [26:08] by hand of course there are always [26:11] things we can improve on but zero cost [26:14] abstractions are what we're aiming for [26:16] we're hoping that rust will perform as [26:18] well as C in the situations you want to [26:21] use it portability [26:25] Russ compiles to LVM intermediate [26:29] representation so you can write rust and [26:32] compile it for any platform that ll be [26:34] I'm Ken [26:36] there are C compilers that target [26:38] platforms that LVM doesn't there could [26:41] be a non LOV M back-end for us there [26:44] isn't one yet there isn't I reason that [26:47] why there couldn't be other than people [26:49] putting in the work so if you need to [26:52] write code for one of the platforms that [26:54] Russ doesn't support that could be a [26:56] deal-breaker for you but we do support a [27:00] lot of platforms so this one is a little [27:03] bit of both the big downside is rust is [27:07] more complex and we are trying all the [27:10] time to lessen the learning curve [27:14] through books and video courses and and [27:17] various learning materials there's [27:20] definitely more features and syntax and [27:22] C but we're trying to express complex [27:26] ideas such that the compiler can [27:29] understand them and that that does take [27:32] more syntax and more complexity to [27:36] express if you have legacy code a neat [27:41] thing is that you can write extern [27:43] functions that let you call C from rust [27:46] and rust from C and a lot of languages [27:49] also have a way to interface with C so [27:51] you can use that so to say call rust [27:56] from Python or call Ruby from rust I [27:59] actually have a whole talk on porting a [28:03] library the softly compression library [28:06] that was written C porting it to rust [28:09] function by function [28:10] keeping it compiling and passing tests [28:12] at every commit and the thing I like [28:16] about this technique is that you don't [28:18] even have to finish you don't have to [28:20] convert the whole thing to rest to see [28:22] benefit you could convert just the parts [28:25] that change the most the parts that [28:28] happen most bugs and you could set it [28:31] aside for a while if you have other high [28:33] priority things to work on but you still [28:35] get those benefits along the way of [28:37] converting little pieces to rust so you [28:40] don't have to rewrite all of your stuff [28:43] in rust to see benefits stability is one [28:47] I want to spend a little more time on [28:48] there is a new [28:50] version of rust that comes out every six [28:52] weeks we have a train really small sort [28:55] of like Firefox and Chrome do so you [28:58] might think that Russ is really unstable [29:00] and it's gonna change all the time but [29:02] we have really strong backwards [29:05] compatibility guarantees we've committed [29:07] to rust 100 came out in May 2015 so [29:11] we've been stable and shipping stable [29:14] codes every six weeks since then there [29:17] is we do have a little bit of an out [29:21] we've given ourselves we reserve the [29:22] right to fixing piler bugs patch safety [29:24] holes and change type in France in ways [29:25] that occasionally require a new type of [29:26] annotations we do not expect any of [29:29] these changes cause headaches when [29:30] upgrading rust so we can fix our own [29:32] bugs in practice what this is meant we [29:35] we run a survey every year in the 2018 [29:38] survey we had a question that said has [29:41] upgrading broken your code and ninety [29:44] two point six percent of people have [29:46] said no it has not broken your code this [29:50] question I feel like we need to change [29:52] the wording of it a little bit because [29:53] it doesn't really distinguish between [29:56] breaking compilation which is what our [30:00] stability guarantees are really about [30:01] versus breaking runtime behavior or [30:05] slowing down your code at runtime or [30:07] speeding it up you don't you broken it [30:10] in that way and I'd like to I'd like to [30:13] be able to get into those problems a [30:15] little bit more and see how we're really [30:16] doing on our compiled time [30:19] stability guarantees another part that I [30:25] think part of our stability story that [30:28] will let us last for 40 years is that we [30:32] have a goal of stability without [30:35] stagnation we want to be able to evolve [30:38] rust to learn from our own mistakes to [30:41] make the language easier to use and to [30:43] learn while still not breaking our [30:46] backwards compatibility guarantees and [30:49] the mechanism that rust we've designed [30:53] to use in rust is called additions and [30:56] this is a link to a detailed [30:59] specification of what additions are I'm [31:02] gonna go over the hi love [31:03] idea mainly they are opt-in about every [31:09] three years is what we're thinking we've [31:10] just made Russ 2018 edition and the [31:14] original edition of Russ is 2015 so we [31:17] have two editions right now what they [31:19] are is it the biggest the biggest change [31:24] we want to make that's not backwards [31:26] compatible is adding new keywords for [31:28] adding new features so for instance [31:30] we're going to be adding asynchronous [31:33] functions to Russ the language soon and [31:37] we wanted the async keyword to be able [31:39] to do that but your existing code might [31:42] have function async so if we added that [31:45] of the keyword your function would no [31:47] longer be a valid bus function so we [31:51] added this idea of additions so that if [31:54] you opt in to treating your code as Russ [31:57] 28:18 edition code then async would be a [32:01] keyword but if you did nothing to your [32:03] code upgraded your compiler it would [32:07] still treat it as rust 2015 edition code [32:09] and it would continue to treat async as [32:12] not a keyword and can you could compile [32:16] your code when I first heard of this [32:19] idea I thought it sounded terrible from [32:21] a compiler maintenance point of view you [32:22] have to maintain two ways to use every [32:26] feature forever because we wanted to [32:28] commit to all editions being supported [32:31] forever but it's actually not that bad [32:35] the way editions way the compiler works [32:38] today is you have your Russ source code [32:40] the compiler turns it into a high level [32:43] intermediate representation and then [32:46] turns it into mid level intermediate [32:48] representation then turns it into LLVM [32:52] intermediate representation and LLVM [32:55] turns it into machine code a lot of the [32:58] complex analysis that the compiler does [33:01] such as borrow checking optimizations [33:03] and code generation happen at this [33:05] mirror this mid level intermediate [33:07] representation level the way additions [33:11] have been implemented is that they're [33:14] kind of at the surface level they [33:17] affect the code the source code that [33:18] you'll write and they affect the high [33:21] level intermediate representation but [33:24] once you get to the mid level [33:25] representation it the mid level stuff is [33:29] all the same whether it would no matter [33:31] which Edition you came from so all this [33:35] complex analysis code can stay the same [33:37] for both editions and it's only the the [33:40] first part of this conversion that is an [33:44] a maintenance burden this because - [33:51] because the compiler understands both [33:56] editions and multiple editions once we [33:58] have more and can compile 2015 code or [34:02] 2018 code that means we're not going to [34:05] have an ecosystem split Russ Russ 2015 [34:09] project can depend on a project written [34:12] using Russ 2018 idioms and vice versa so [34:17] it doesn't matter if all your [34:19] dependencies have opted in or not the [34:21] same compiler can understand either code [34:24] and can compile it all together and the [34:29] important things about this is that you [34:31] get to pick when you decide to change [34:34] which Edition you want to use you can [34:36] keep upgrading your compiler every six [34:38] weeks but you don't have to switch on [34:41] that flag to change the idioms until you [34:43] decide the benefits outweigh the cost of [34:46] upgrading and never is a totally valid [34:49] choice we plan to support Russ 28 2015 [34:53] edition code for as long as rust exists [34:57] in order to decrease the burden of [35:01] switching editions we also have a tool [35:03] call it Russ fix that for as many [35:06] changes that we can do automatically it [35:10] will apply those changes and fix up your [35:13] code and move you to the new edition [35:14] automatically so we're trying to if you [35:17] do want to switch to the new edition [35:18] we're trying to make that as painless as [35:20] possible also the editions concept I am [35:25] confident that with using this to evolve [35:28] the language means we're never going to [35:30] have [35:30] rust you oh we're not going to break [35:33] backwards-compatibility [35:34] so we hope to be as stable as c is for [35:39] the next four years we do have a lot of [35:43] things that aren't done yet with rust [35:45] that might prevent you from using it in [35:47] your company we don't have a standard [35:50] that's going to take a long time and a [35:53] lot of work we do want to get there [35:55] someday but it was years and years [35:57] before C has a standard so we do want to [36:00] get there but we're not there yet we [36:03] don't have a certified compiler that [36:04] will matter in some industries we do [36:08] want to have a long term support release [36:10] that gets things like security fixes and [36:13] certain bug fixes we don't have a policy [36:16] for that yet [36:17] cargo is the build tool that rust kind [36:21] of expects you to use if you you don't [36:24] use that it gets a little hard to tinker [36:27] with and some companies have build [36:28] systems that everything needs to feed [36:31] into and we have work to do to make [36:35] cargo fit into build systems that are if [36:39] you have we have an open-source package [36:43] registry for open source code we don't [36:45] have good solutions for libraries that [36:48] you might want to keep private only [36:50] share within your company and the [36:53] ecosystem is still growing [36:55] so there might not be a library for [36:57] everything you might want to do in rust [36:59] yet but these are all things we're [37:02] working on and we hope to get there soon [37:05] another reason I think we're going to [37:08] last is that there are today a number of [37:12] large enterprise software companies [37:14] using rusts and they've invested their [37:17] products in rust so they're invested in [37:21] rusts future the biggest one of course [37:23] is Mozilla he heard of the Firefox [37:26] quantum release a while ago where [37:29] Firefox got a lot faster one big reason [37:32] of that was a big component [37:35] got that was rewritten in rust were [37:38] shipped with that the component was the [37:41] CSS rendering that can [37:44] now render all the CSS properties in [37:47] your page in parallel and they did some [37:50] analysis of the security bugs in this [37:54] component that was written in C++ and [37:56] found that since the beginning of [37:59] Firefox [38:00] there were 69 security bugs in this CSS [38:03] component if they could have gone back [38:07] in time than written in rust from the [38:08] beginning rust would have prevented 51 [38:11] of those which is about 3/4 of them so I [38:15] think that's a pretty good improvement [38:17] on the security and of this Firefox of [38:22] honey and the speed increase - if you [38:28] know patio 11 on Twitter Patrick [38:30] McKenzie he has this word he likes to [38:32] say a Bama goo book soft and it [38:34] represents a number of big software [38:36] companies Apple I don't know of any [38:40] public uses of rust at Apple [38:43] they have Swift which actually is really [38:46] similar to rust I was in the Swift talk [38:49] earlier and they have a lot of the same [38:52] problems and a lot of trying to solve [38:54] the same problems that rust is but use [38:56] different words for it so I was like [38:58] sitting there trying to translate him [39:00] like ah stats oh oh they're hitting the [39:02] same problem that we are they're really [39:04] similar and there is cross-pollination [39:07] there [39:09] so we're I hope there's more in the [39:12] future and we can both learn from each [39:13] other [39:16] Amazon is the Amma part of this and they [39:20] recently announced their fire cracker [39:22] micro VM Google is also kind of [39:27] secretive they have this fuchsia [39:29] operating system project that they [39:31] haven't really said what it's for yet [39:33] but the code for it is like on the [39:35] internet and you know open source and [39:38] there's parts that in rust facebook has [39:42] the Mononoke mercurial server to manage [39:46] their huge mercurial mono repo that the [39:54] canonical implementation of mercurial [39:58] couldn't handle it fast enough and [40:00] Microsoft announced they have this IOT [40:05] edge platform that does analytics like [40:08] on IOT devices and then sends the [40:11] results to server so that's a Pam a GU [40:14] box off we've got four out of five of [40:16] those using rest publicly the fifth [40:20] reason that I think we're set up to last [40:22] is our project governance like the [40:27] trains the adoption of this is not only [40:32] for the technical reasons there's also [40:33] political reasons and I think we are [40:36] we're building a good foundation here we [40:39] don't have a be DFL a benevolent [40:41] dictator for life there's not just one [40:43] person making final decisions on on rust [40:47] we have a number of teams and working [40:50] groups made up of multiple people [40:52] responsible for different parts of [40:54] language and we have a lot of different [40:58] people represented on those teams and [41:00] working groups we have programming [41:02] language theorists people with PhDs and [41:05] programming languages we have people [41:09] using rust for a product for a company [41:11] we have people using rust for fun we [41:15] have people who come from the low level [41:17] languages like C and C++ we have people [41:20] from high level languages like I come [41:22] from Ruby and in our surveys Python is [41:25] consistently the number one language [41:27] that people come to rust from and if [41:31] there's people from functional languages [41:32] like Haskell that bring a lot of the [41:35] functional influence interests and our [41:40] big decisions are made in public by AI [41:43] system of requests for comments [41:45] proposals that everyone can see and the [41:48] teams responsible for making the final [41:50] decision state their reasoning in public [41:53] on these RFC's so while we might not [41:57] make a decision on something in the [41:59] exact way you might want our our hope is [42:02] that you'll at least understand why [42:04] we're making those decisions and feel [42:06] like we have heard your point of view [42:11] I feel really strongly that as an [42:14] open-source person that this is [42:15] important that this isn't driven Rus [42:20] direction is not driven by a corporate [42:22] closed entity making decisions in secret [42:26] that you have no idea why they're doing [42:27] and we're not going to take it in some [42:29] surprising direction if we do you'll if [42:33] we do take it in a different direction [42:34] you'll know that we're doing it you'll [42:36] be able to see us do that another big [42:39] you think part of our governance is that [42:41] we have a code of conduct and have since [42:43] the language was open-source and I loved [42:46] that this has been since the beginning [42:48] so we don't have to have the argument [42:49] about whether we should adopt one or not [42:51] that decision has already been made we [42:53] have one we are trying to make a [42:55] professional space for professionals to [42:58] work on technology and without problems [43:02] we're not perfect but we are trying [43:05] you're acknowledging that there are [43:07] problems that we need to be handling to [43:10] make rust a welcoming place for everyone [43:13] so just to sum up these are my five [43:18] reasons why I think Russ is going to be [43:20] able to last the next four years and now [43:26] we're going to talk a little bit more [43:27] about the railroad industry and how that [43:30] relates to what we're doing today [43:34] this the software industry has a [43:37] reputation for being a little bit [43:40] arrogant we think we can do things [43:43] better than other fields have done them [43:47] there's the time that a software company [43:50] thought they could do juice better than [43:52] other people and actually didn't work [43:55] any better than squeezing juice packet [43:57] by hand there was the time that lift [44:01] reinvented the bus and there's the time [44:08] that there were people stuck in a cave [44:12] and Elon Musk thought he could do cave [44:15] rescues better than the people who [44:16] specialized in that sort of thing so so [44:20] we think we're better than other [44:21] industries if you just add a little [44:22] software we can totally fix these long [44:24] standing problems that other industries [44:25] have had were so much better I think I [44:31] think we have to we have to work to [44:32] prove it if we if we actually are better [44:34] we need to show that we're better and we [44:39] binding regulation to do this but [44:42] there's a problem is that it's it's [44:44] pretty easy for everyone to understand [44:47] that if you can't stop a train people [44:49] are gonna get hurt [44:50] people are gonna kill pretty uneasy to [44:52] understand that being on top of a moving [44:54] train in any weather is a dangerous [44:57] thing but it's it's not easy to [45:01] understand what what memory on safety [45:04] even is and it's not easy even easy for [45:08] us to see what the effects of that are [45:11] so like I'm trying to imagine the the [45:16] Senate transcripts from reading that in [45:20] the future from now of software people [45:23] trying to explain memory on safety to [45:26] senators and it's terrible it's I don't [45:29] see this going well so I don't think I [45:33] don't think government is going to [45:35] improve the safety of software but I [45:38] think we can improve ourselves we can be [45:42] our own improved informed consumers that [45:46] demand that our dependencies are safer [45:49] before we incorporate them into our [45:52] software because we understand our own [45:55] problems that is the part that we can [45:58] show that we are better the railroad [46:02] industry got really started in 1830 [46:06] Westinghouse invented the air brake in [46:08] 1869 and then everyone was using it by [46:13] 1900 so this is about 80 years you know [46:18] no that's not right 7 years about 40 [46:23] years to invent a safer thing about 30 [46:27] years for people to start using it rust [46:31] became stable in 2015 I'm arguing that [46:34] that is a better safer sea [46:37] I don't know how long it's gonna take us [46:39] to adopt something that's memory safe [46:43] can we do better than the railroad [46:46] industry I don't know [46:48] I want us to be better I'm not sure if [46:51] we are better I hope that we're better [46:55] all right that's that's most of my [46:58] arguments if you're still feeling a [47:00] little skeptical that's totally fine I'm [47:03] I'm willing to be wrong I I am willing [47:06] for us and to not be the solution as [47:08] long as we do something let's just do [47:12] something to fix these memory safety [47:14] problems that keep happening over and [47:15] over and over again maybe maybe it's not [47:19] gonna be rushed maybe there's something [47:20] better than rest [47:21] maybe it's sake dick go to the next talk [47:25] I'm pleading fortitude maybe maybe it's [47:29] go there's a go talk tomorrow [47:31] or maybe maybe it's all of them maybe [47:33] it's there's not gonna be one [47:34] replacement maybe there's different [47:37] replacements that are better for [47:37] different situations that's fine I'm [47:40] totally okay with that you don't have to [47:42] choose rest I just I just want us to [47:45] stop making the same mistakes over and [47:47] over again let's make some new mistakes [47:53] [Applause] [47:54] [Music] [47:59] [Applause] [48:02] okay again this is the link to my slides [48:06] and links that I reference i'm carol's [48:09] ten cents [48:10] there's a code for everyone to have that [48:13] will get you 40% off anything I'm [48:15] Manning calm and that code is right [48:17] there [48:17] and I would like to thank my test [48:19] audience my daughter Vivian and my cat [48:22] baby they were very patient provide [48:24] valuable feedback okay let's see what [48:28] questions we have let me stop mirroring [48:31] here or start marine weather okay where [48:43] are my questions okay let's see which [48:47] ones I like best [49:05] okay let's do what's with the name rust [49:10] there's there's multiple stories here [49:13] the people who started rust enjoyed [49:18] riding bicycles and bicycles often have [49:20] to deal with rust the logo our logo is [49:24] kind of a bicycle gear there's also a [49:28] fungus called rust that grows on wheat [49:32] sometimes that is a potential [49:36] inspiration that has been suggested as [49:39] why why rust I like to think of it as [49:43] something something something stable [49:48] something that has been around a long [49:49] time a stable strong coating on the [49:53] outside there's actually this Corten [49:54] steel the u.s. steel tower in Pittsburgh [49:58] has built out of it it's steel that is [50:00] meant to rust on purpose to protect it [50:03] instead of paint so I like thinking of [50:06] Corten steel so partha I liked your [50:09] question if you are still here I have an [50:11] envelope for you there yeah thank you [50:17] okay [50:18] why would you recommend rust Oberg oh I [50:20] also like this question so anonymous who [50:23] asked this if you would make your way to [50:25] the front while I'm answering there are [50:29] a couple of big differences in rust and [50:31] go there actually is aiming for slightly [50:33] different spaces I they I think they get [50:37] compared a lot because they came out [50:38] around the same time and they're both [50:40] aiming to be kind of C++ alternatives go [50:43] has a garbage collector which might be a [50:46] deal breaker in your application so if [50:49] you can't have something at runtime [50:51] using resources then I would recommend [50:53] rust if you're trying to interface with [50:58] Google products I think go is probably [51:00] going to be a really smooth way to have [51:05] everything all in the same language for [51:09] simplicity purposes [51:14] and like hmm yeah III think you should [51:21] check them both out and you should make [51:23] I think one of them is going to resonate [51:26] with you over the other so I think you [51:27] should do some intro programming in both [51:30] of them and and make your own choice so [51:34] is someone going to fess up to asking [51:37] that question for a free code no okay [51:41] all right arguably one of the reasons [51:44] for choosing C these days is a great IDE [51:47] support does the rest have solid IV [51:49] integration we're working on it this is [51:51] another one of those things that we know [51:54] we need to do better at we there's this [51:58] thing called the language server [52:00] protocol that is trying to standardize [52:02] the way that languages can talk to II's [52:05] and tell the IDE things about the code [52:08] and we have an implementation that does [52:10] code completion inline errors jump to [52:13] definition and BS code has had the best [52:20] maintained plug-in that uses the [52:22] language server protocol IntelliJ also [52:24] has a pretty good rust support I'm I so [52:28] I did Ruby before bus and there and I [52:32] love the book working effectively with [52:35] legacy code by Michael feathers and but [52:37] in that book he talks a lot about [52:39] leaning on your tools using your ID [52:41] using automatic refactorings and in Ruby [52:44] because of all the meta programming and [52:46] like you didn't take a string and run it [52:48] as a function and you just you can't use [52:51] some of those tools because you can't be [52:52] sure that you caught everywhere that [52:54] that function is called because it might [52:56] be called dynamically from something so [52:58] I had a lot of jealousy for ie tools [53:04] while I was writing Ruby and I'm looking [53:05] forward to the days that we have those [53:07] tools for rust they're not there yet but [53:10] they're there more possible to make than [53:13] they are in Ruby so does anyone want to [53:17] claim that question thank you very much [53:21] [Music] [53:24] okay let's see what other question I [53:27] like um hmm latest question that's very [53:34] good question oh okay [53:45] this is this is a good question I [53:48] mentioned a new async in 2018 magician [53:52] and the it's async already in the 2015 [53:56] mission it's actually in neither Edition [53:58] right now when we created the 2018 [54:01] magician [54:01] we just reserved the keyword for async [54:04] and we wanted to have a sync support [54:06] done by the time we shipped the Edition [54:09] but it's it's not it's not done people [54:14] are working on it right now [54:15] there's a lot of open discussion on the [54:18] RFC's about the exact syntax the exact [54:20] way it's gonna work so if you're [54:22] interested you can go check that out but [54:26] it's is not an either and if once it is [54:29] done it will probably be available in [54:32] both it's just that the syntax in Rus [54:34] 2015 isn't is not going to use a key [54:37] word so it's not going to be as nice as [54:38] syntax as it will be in Rus 2018 so who [54:43] asks the async question all right [54:46] then that is all the codes I have and I [54:50] think I'm just about out of time so [54:52] thank you very much for having me [54:54] [Applause] [55:04] you