惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
B
Blog
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Y
Y Combinator Blog
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
Recent Announcements
Recent Announcements
U
Unit 42
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
Recorded Future
Recorded Future
C
Check Point Blog
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Full Disclosure
小众软件
小众软件
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
爱范儿
爱范儿
P
Proofpoint News Feed
罗磊的独立博客
量子位
D
Docker
博客园_首页
D
DataBreaches.Net
Project Zero
Project Zero
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
Security Latest
Security Latest
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
Netflix TechBlog - Medium
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏

Stonecharioteer on Tech

I Traced My Traffic Through a Home Tailscale Exit Node What Was I Reading Last? In Three Not-So-Easy Pieces Dogfooding Is Hard Code blocks in your books, finally GoForGo v0.9.0 Merrilin - We built an app to read books I use a Macbook now Data Structures & Algorithms - Preparing for Interviews Using a local DNS namespace for local service discovery Direction KOllector - Publishing KOReader Highlights gbt: branches touched in the last 24 hours A Soiree into Symbols in Ruby Some Smalltalk about Ruby Loops Ruby Blocks Returning from Ruby Blocks, Procs and Lambdas My Linux Laptop Finally Works: How Claude Helped Me Fix Years of Annoyances TIL: Watchexec - Modern File Watching for Development Workflows A Less Busy Mind GoForGo - Learn Go through live examples Migrating My Old Blog to Hugo with Claude The Qtile Window Manager: A Python-Powered Tiling Experience Read the RFCs that Built the Internet Py-x-Protobuf - Or How I Learned to Stop Worrying and Love Protocol Buffers Python Reverse a List New Beginnings Leaving ChainSafe Systems Screen Lock for Cinnamon Desktop using Zenity and Terminal Commands Crews Not Teams A System for Getting Better at LeetCode So Far So Rust Retrying HTTP Requests with Rust A Primer on Control Charts Learning Rust Explicit is Better than Implicit: Rust for Pythonistas Using Custom Delimiters in Jinja Templates TIL: Creating Fixed Length Iterables in Python Documentation Without Assumption Vagrant Python - A Reflection in 2022 Learning Golang No, A Virtual Machine Is Not Enough: Why Developers Need Native Linux Empathy in Tech For Those Who Came in Late A Weekend With PostgreSQL TIL: Gooey and Python Fire for Quick GUIs and CLIs TIL: 2ality - Dr. Axel Rauschmayer's JavaScript Blog TIL: MassDNS - High-Performance Bulk DNS Lookups TIL: Matomo Analytics, Google Tech Writing, Memory Programming, and NES TV Signals TIL: MontyDB - MongoDB Implemented in Python Returning to the Craft of Programming TIL: CPUFetch, OneFetch, and Learn CSS TIL: DNS Performance Testing and Pi-hole with Unbound TIL: Eli Bendersky's Blog, Awesome By Example, NoCoDB, and Martin Kleppmann TIL: CRDTs, Extreme HTTP Performance, and BYTEPATH Game TIL: AutoInvent, ASGI, Python Packaging, RAPIDS GPU Computing, and FlaskCon TIL: MangaDesk - Terminal Client for MangaDex TIL: McFly - Smart Shell History Search TIL: Siege Load Testing and Awesome FastAPI Resources TIL: Ventoy Bootable USB and Justniffer Network Analysis TIL: CLI Code Review, Git Split Diffs, and Internal Combustion Engine TIL: Benford's Law, Web Security Headers, Event Sourcing, and Mozilla Security Guidelines How to Write Documentation - The README.md File The Importance of Documentation TIL: NNgroup UX Research, SponsorBlock, and Labella Python Library TIL: The Little Book of Rust Macros and Rust Performance Book TIL: Git-Bug Distributed Issue Tracker and Omni Kubernetes Monitoring TIL: Zellij - Modern Terminal Multiplexer TIL: How Discord Handles 2.5 Million Concurrent Voice Users TIL: Volumio - The Audiophile Music Player TIL: Areopagitica - Milton's Defense of Free Speech TIL: Fast Node Manager, Zoxide Smart CD, Technical Writing, PyO3, and Qubes OS TIL: Slurm Workload Manager for HPC Clusters TIL: Data Visualization Guide and Oso Authorization Academy TIL: CORS Deep Dive, Piku Tiny PaaS, Rust Strings, and Deno Standard Library TIL: Raspberry Pi OS Development, Vim Beginner Guide, Password Management, and QueryBook TIL: uBlock Origin Performance Optimization on Firefox TIL: Breaking PostgreSQL at Scale and LeetCode Problem Patterns TIL: Awesome Tmux Resources for Terminal Multiplexing TIL: Grit - A Multitree-Based Personal Task Manager TIL: Lens 4.2 Kubernetes IDE, Shell Scripting Guide, and Dark HTTP Server Do The Job You Hate So You Won't Hate The Job You Love TIL: Innernet VPN Solution and NoteCalc Calculator App TIL: Argo CD for GitOps and Lens Kubernetes IDE TIL: Modern Rust CLI Tools - System Monitoring, HTTP Requests, and DNS TIL: tz - A Time Zone Helper Tool TIL: Distributed Systems Education, Fallacies, and Self-Hosted Internet Archiving TIL: Real-Time Voice Cloning Technology TIL: ChartMuseum for Helm, AMD's Corporate Journey, and Kubernetes Pod Scaling TIL: Docker and Kubernetes Tools - Whaler, Descheduler, and Dive TIL: Post-Mortem Collection, Terminal Plotting, and Technical Twitter TIL: Dark Mode Toggle Web Component by Google Chrome Labs TIL: Python eval(), exec(), and compile() Functions TIL: Camelot PDF Tables, PostgreSQL Row Level Security, Zerodha Varsity, and Write Yourself a Git TIL: fuser Command for Process and File Investigation TIL: i Hate Regex - The Ultimate Regex Cheat Sheet TIL: Dolt - Git for Data and Database Version Control TIL: x86 Assembly Programming and SafeEyes Break Reminder TIL: Comprehensive Distributed Systems Reading List TIL: Cosmopolitan C Library, Distributed Systems Book, High Performance Browser Networking, and Rust Roguelike Tutorial
TIL: Modern Rust Learning Resources and Development Patterns
2020-07-13 · via Stonecharioteer on Tech

Today I discovered excellent resources for learning Rust systematically, from beginner-friendly interactive tutorials to advanced concepts that highlight why Rust is becoming the go-to systems programming language.

Interactive Rust Learning

Tour of Rust - Interactive Learning

Tour of Rust provides an interactive way to learn Rust similar to Go’s famous tour. It covers almost the entire Rust Book content through hands-on exercises:

Tour of Rust Coverage

  • Basics: Variables, functions, control flow
  • Ownership: Borrowing, references, lifetimes
  • Types: Structs, enums, traits, generics
  • Error Handling: Result types and error propagation
  • Memory Management: Stack vs heap, smart pointers
  • Concurrency: Threads, channels, async/await
  • Advanced Features: Macros, unsafe code, FFI

The interactive format allows you to run Rust code directly in the browser, making it perfect for learning without setting up a local development environment.

Rust by Example

Rust by Example takes a hands-on approach to learning Rust concepts:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Pattern matching with enums
enum WebEvent {
    PageLoad,
    PageUnload,
    KeyPress(char),
    Paste(String),
    Click { x: i64, y: i64 },
}

fn inspect(event: WebEvent) {
    match event {
        WebEvent::PageLoad => println!("page loaded"),
        WebEvent::PageUnload => println!("page unloaded"),
        WebEvent::KeyPress(c) => println!("pressed '{}'", c),
        WebEvent::Paste(s) => println!("pasted \"{}\"", s),
        WebEvent::Click { x, y } => {
            println!("clicked at x={}, y={}", x, y);
        },
    }
}

fn main() {
    let pressed = WebEvent::KeyPress('x');
    let pasted = WebEvent::Paste("my text".to_owned());
    let click = WebEvent::Click { x: 20, y: 80 };

    inspect(pressed);
    inspect(pasted);
    inspect(click);
}

Advanced Rust Resources

Learn Rust the Dangerous Way

Learn Rust the Dangerous Way by Cliff Biffle teaches Rust from the perspective of a C programmer, highlighting dangerous practices and how Rust prevents them:

Common Dangerous Patterns

C/C++ Problems that Rust Solves:

  • Buffer overflows - Rust’s bounds checking prevents array access violations
  • Use-after-free - Ownership system ensures memory safety
  • Double-free - RAII and ownership prevent double deallocations
  • Data races - Type system enforces thread safety at compile time
  • Null pointer dereferences - Option types eliminate null pointer errors
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Rust prevents dangerous memory access
fn safe_array_access() {
    let arr = [1, 2, 3, 4, 5];

    // This would panic at runtime, not cause undefined behavior
    // let value = arr[10]; // panic: index out of bounds

    // Safe alternative using get()
    match arr.get(10) {
        Some(value) => println!("Value: {}", value),
        None => println!("Index out of bounds"),
    }
}

// Ownership prevents use-after-free
fn ownership_safety() {
    let data = String::from("Hello");
    let reference = &data;

    // drop(data); // This would cause compile error
    // println!("{}", reference); // Can't use reference after data is dropped

    println!("{}", reference); // Safe because data is still alive
}

Little Book of Rust Macros

Little Book of Rust Macros provides comprehensive coverage of Rust’s macro system:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Declarative macros (macro_rules!)
macro_rules! vec {
    ( $( $x:expr ),* ) => {
        {
            let mut temp_vec = Vec::new();
            $(
                temp_vec.push($x);
            )*
            temp_vec
        }
    };
}

// Usage
let v = vec![1, 2, 3, 4, 5];

// Custom debug macro
macro_rules! debug_print {
    ($($arg:tt)*) => {
        #[cfg(debug_assertions)]
        println!("[DEBUG] {}", format_args!($($arg)*));
    };
}

// Only prints in debug builds
debug_print!("Processing item: {}", item_id);

Rust Adoption Challenges

Problems in Rust Adoption discusses real-world challenges when adopting Rust:

Rust Adoption Considerations

Learning Curve Challenges:

  • Ownership system - Requires fundamental shift in thinking
  • Lifetime annotations - Complex for beginners coming from GC languages
  • Compiler strictness - Initially frustrating but prevents runtime errors
  • Ecosystem maturity - Some libraries still emerging compared to C++ or Python

Migration Strategies:

  • Start with new components rather than rewriting existing code
  • Use Rust for performance-critical or safety-critical parts
  • Leverage FFI to integrate with existing C/C++ codebases
  • Invest in team training and mentorship

Py-Spy for Python Profiling

Py-Spy is a sampling profiler for Python programs, written in Rust for minimal overhead:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Install py-spy
pip install py-spy

# Profile a running Python process
py-spy record -o profile.svg --pid 12345

# Profile a Python script
py-spy record -o profile.svg -- python myscript.py

# Top-like interface for live profiling
py-spy top --pid 12345

Why Py-Spy is Special

Unlike traditional Python profilers, py-spy:

  • Zero overhead when not profiling
  • Works with any Python program without modification
  • Minimal impact on the target process (written in Rust)
  • Rich output formats including flame graphs and call trees
  • Works with C extensions and shows full stack traces

The fact that py-spy is written in Rust demonstrates Rust’s effectiveness for building high-performance tools that interact with other language runtimes.

Modern Command Line Tools

Several excellent command-line tools are written in Rust, showcasing its performance and ergonomics:

Tokei - Better Code Counting

tokei is a faster, more accurate alternative to cloc:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Count lines of code in a project
tokei

# Specific languages only
tokei --languages rust,python

# Exclude test files
tokei --exclude '*.test.*'

# JSON output for automation
tokei --output json

Bat - Enhanced Cat

bat provides syntax highlighting and Git integration:

1
2
3
4
5
6
7
8
# View file with syntax highlighting
bat src/main.rs

# Show line numbers and git changes
bat --number --show-all src/main.rs

# Use as pager replacement
export PAGER="bat --plain"

Ripgrep - Superior Grep

ripgrep offers incredible search performance:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Basic search
rg "pattern"

# Search specific file types
rg "TODO" --type rust

# Case insensitive with context
rg -i "error" -C 3

# Regular expressions
rg "fn\s+\w+\(" --type rust

Rust CLI Tool Benefits

These Rust-based tools demonstrate key advantages:

  • Performance: Significantly faster than traditional Unix tools
  • Safety: Memory safety prevents crashes and undefined behavior
  • Ergonomics: Better defaults and user-friendly output
  • Cross-platform: Work consistently across Linux, macOS, and Windows
  • Modern features: Git integration, syntax highlighting, smart defaults

Systems Programming Insights

Linux From Scratch

Linux From Scratch teaches Linux system internals by building a complete Linux system from source code:

The project helps understand:

  • Boot process and system initialization
  • Package management and dependency resolution
  • System libraries and their interactions
  • Kernel compilation and configuration
  • Development toolchain creation

This knowledge is invaluable when working with Rust for systems programming, as it provides deep understanding of the runtime environment where Rust programs execute.

Memory Management Fundamentals

Understanding how Rust’s ownership system maps to actual memory management:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Stack allocation - automatic cleanup
fn stack_example() {
    let x = 42;           // Stored on stack
    let y = [1, 2, 3];    // Array on stack
} // x and y automatically cleaned up

// Heap allocation - controlled by ownership
fn heap_example() {
    let data = String::from("Hello");  // Heap allocated
    let moved_data = data;             // Ownership transfer
    // println!("{}", data);           // Compile error - data moved
    println!("{}", moved_data);        // OK - new owner
} // moved_data automatically freed

// Borrowing - temporary access without ownership transfer
fn borrowing_example() {
    let data = String::from("World");
    let len = calculate_length(&data); // Borrow, don't move
    println!("Length of '{}' is {}", data, len); // data still valid
}

fn calculate_length(s: &String) -> usize {
    s.len() // Can read, but can't modify without &mut
}

Integration and Interoperability

Foreign Function Interface (FFI)

Rust’s FFI capabilities make it excellent for:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Calling C code from Rust
extern "C" {
    fn abs(input: i32) -> i32;
    fn strlen(s: *const c_char) -> size_t;
}

// Exposing Rust code to C
#[no_mangle]
pub extern "C" fn add_numbers(a: i32, b: i32) -> i32 {
    a + b
}

// Python extension using PyO3
use pyo3::prelude::*;

#[pyfunction]
fn fibonacci_rust(n: u64) -> u64 {
    match n {
        0 => 0,
        1 => 1,
        _ => fibonacci_rust(n - 1) + fibonacci_rust(n - 2),
    }
}

#[pymodule]
fn rust_extensions(_py: Python, m: &PyModule) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(fibonacci_rust, m)?)?;
    Ok(())
}

Learning Strategy and Resources

  1. Start with Tour of Rust - Interactive, hands-on introduction
  2. Read Rust by Example - Practical code patterns and idioms
  3. Study The Rust Book - Comprehensive language reference
  4. Practice with Rustlings - Small exercises to reinforce concepts
  5. Explore Little Book of Rust Macros - Advanced metaprogramming
  6. Read “Learn Rust the Dangerous Way” - Systems programming perspective

Key Concepts to Master

Essential Rust Concepts

  1. Ownership and Borrowing - Core memory safety guarantees
  2. Pattern Matching - Exhaustive case analysis with match
  3. Error Handling - Result and Option types for safe error management
  4. Traits - Rust’s interface system for polymorphism
  5. Lifetimes - Ensuring references remain valid
  6. Concurrency - Safe parallel programming with ownership
  7. Macros - Code generation and domain-specific languages

Why Rust Matters

Rust addresses fundamental problems in systems programming:

  1. Memory Safety: Eliminates entire classes of bugs at compile time
  2. Performance: Zero-cost abstractions with C/C++ level performance
  3. Concurrency: Fearless concurrency through type system guarantees
  4. Tooling: Excellent package manager (Cargo) and development experience
  5. Ecosystem: Growing collection of high-quality libraries (crates)

Rust Philosophy

Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.

This exploration of Rust learning resources demonstrates why Rust has become essential for modern systems programming, offering both safety and performance without compromise.


These Rust learning resources from my archive showcase the language’s evolution from experimental to production-ready, with a rich ecosystem of educational content and powerful development tools.