Exploring the "Rustification" of Python: A Deeper Dive
Written on
Chapter 1: Introduction to Rust's Influence
In a recent episode of the Real Python podcast, Wes McKinney, the creator of Pandas, was posed the question: "What excites you about the current developments in the Python community?" Without missing a beat, Wes responded, "I'm really enthusiastic about the 'Rustification' of Python." Interestingly, Rust is also the next programming language he aspires to master.
Rust's rising prominence within the programming community is hard to ignore. Its popularity has surged year after year. While I may not be well-versed in Rust, I currently utilize ruff for linting in Neovim and have begun experimenting with uv for Python package installations. Both of these tools are developed in Rust and are supported by Astral.
So, what makes this highly regarded language so special?
History of Rust
Rust originated as a personal project by Graydon Hoare back in 2006 during his tenure at Mozilla. By 2009, Mozilla recognized Rust's potential to enhance safety and concurrency in systems programming, leading to the company's sponsorship of the project. The language made its public debut with the release of Rust 0.1 in 2010. Since then, it has garnered immense popularity, even being recognized as the "most loved programming language" in the Stack Overflow Developer Survey.
Two noteworthy events that piqued my interest in Rust were:
- Linus Torvalds' announcement that Rust would be included in Linux 6.1.
- A tweet from Mark Russinovich, Microsoft's CTO of Azure, urging developers to transition away from starting new projects in C/C++ and to adopt Rust for situations requiring a non-GC language.
Beyond systems programming, Rust has also found applications in Blockchain technology, with projects like Reth, a high-performance implementation of the Ethereum protocol.
Moreover, Rust excels in creating compilers and runtimes, with Deno being a prime example. Deno serves as a modern Javascript and Typescript runtime, built on Rust and Tokio.
Challenges of Learning Rust
While Rust is celebrated for its speed and safety, many developers hesitate to dive into it due to its steep learning curve. The approach required to grasp Rust differs significantly from that needed for more beginner-friendly languages like Go, Ruby, and (let's be honest) Python. As a lower-level language akin to C/C++, mastering Rust necessitates a solid understanding of operating systems and system development. Additionally, as a relatively young language, it has fewer educational resources available compared to more established languages.
About the "Talk Rust" Series
I am excited to introduce a new series of articles titled "Talk Rust," which aims to:
- Establish a strong foundation in Rust fundamentals, such as data types, control structures, and structs.
- Delve into more advanced topics, including ownership, pattern matching, and error handling.
- Guide readers in building a project.
Getting Started with Rust
Installing Rust is straightforward. Simply visit the official Rust website and follow the installation instructions relevant to your operating system:
To verify that Rust has been installed correctly, you can run:
rustc --version
Now, you're all set to embark on your Rust journey!
Creating a "Hello World" Program
As is customary when learning a new programming language, our first Rust program will be the classic "Hello World!" To initialize the project, execute the following command in your terminal:
cargo new helloworld
Cargo, which comes bundled with Rust, serves as its package manager, much like NPM for JavaScript and pip for Python.
Next, let's explore the newly created helloworld directory. It contains a Cargo.toml file alongside a src folder housing our source file main.rs. The Cargo.toml file functions similarly to Go's mod file or Python's setup.py, containing crucial package information and dependencies.
The src/main.rs file is quite simple; it serves as our program's entry point, featuring the fn, which denotes a function in Rust. To execute our program, navigate to the helloworld directory and run:
cd helloworld && cargo run
Alternatively, you can compile the project using:
cargo build
This will create a target folder, which contains a debug subfolder where you'll find an executable file named helloworld that you can run directly.
At this point, everything is in place, and we are ready to delve deeper into the world of Rust.
Thanks for reading!
Chapter 2: Enhancing Your Skills with Rust
To further your understanding, check out the following video that discusses optimizing data handling with Rust:
This video titled "Speeding Up Your DataFrames With Polars | Real Python Podcast #140" offers insights into how Rust is revolutionizing data processing.