Price: $49.99 - $32.60
(as of Sep 12, 2024 03:05:08 UTC – Details)
Get a fundamental understanding of asynchronous programming and Rust’s futures by working through examples that show you how everything really works
Key Features
– Master asynchronous Rust through examples focusing on key concepts
– Build a solid understanding of concepts such as coroutines, fibers, futures, and callbacks
– Explore Rust’s futures, craft your own runtime, and excel in handling stacks, ABIs, syscalls, and inline assembly
– Purchase of the print or Kindle book includes a free PDF eBook
Book Description
Step into the world of asynchronous programming with confidence by conquering the challenges of unclear concepts with this hands-on guide. Using functional examples, this book simplifies the trickiest concepts, exploring goroutines, fibers, futures, and callbacks to help you navigate the vast Rust async ecosystem with ease.
You’ll start by building a solid foundation in asynchronous programming and explore diverse strategies for modeling program flow. The book then guides you through concepts like epoll, coroutines, green threads, and callbacks using practical examples. The final section focuses on Rust, examining futures, generators, and the reactor-executor pattern. You’ll apply your knowledge to create your own runtime, solidifying expertise in this dynamic domain. Throughout the book, you’ll not only gain proficiency in Rust’s async features but also see how Rust models asynchronous program flow.
By the end of the book, you’ll possess the knowledge and practical skills needed to actively contribute to the Rust async ecosystem.
What you will learn
– Explore the essence of asynchronous program flow and its significance
– Understand the difference between concurrency and parallelism
– Gain insights into how computers and operating systems handle concurrent tasks
– Uncover the mechanics of async/await
– Understand Rust’s futures by implementing them yourself
– Implement green threads from scratch to thoroughly understand them
Who this book is for
This book is for programmers who want to enhance their understanding of asynchronous programming, especially those experienced in VM’ed or interpreted languages like C#, Java, Python, JavaScript, and Go. If you work with C or C++ but have had limited exposure to asynchronous programming, this book serves as a resource to broaden your knowledge in this area.
Although the examples are predominantly in Rust, the intricacies of Rust’s futures are covered in detail. So, anyone with a keen interest in learning Rust or with working knowledge of Rust will be able to get the most out of this book.
Table of Contents
– An Introduction to Asynchronous Programming
– Epoll, Kqueue and IOCP
– Epoll example
– Different strategies for modelling asynchronous program flow
– Stackfull Coroutines/Green Threads/Fibers [Example]
– Callbacks and promises [Example]
– Futures in Rust
– Coroutines and async/await
– Runtimes, Wakers, and the Reactor-Executor Pattern
– Coroutines, Self-Referential Structs, and Pinning
– Creating Your Own Runtime
From the Publisher
What makes this book different from other books on asynchronous programming in Rust?
Two key aspects set this book apart: the way it enables readers to build an understanding of Rust principles and its focus on experiments and examples. This book truly embodies the saying “Give someone a fish and you feed them for a day; teach them how to fish and you feed them for a lifetime.” I’ve always viewed knowledge as atomic building blocks that help you find solutions to new problems based on prior knowledge. This book provides many such building blocks relevant to asynchronous programming.
Moreover, dedicating just two weeks to this book can save readers months, or even years, spent on navigating the learning curve. It enables them to become proficient with relative ease, preparing them to find working solutions to most problems and technical difficulties encountered in async Rust. This knowledge will remain useful for years, even if substantial changes occur in the current ecosystem.
How has your background helped you write this book?
My background is somewhat untraditional. I studied business and specialized in strategy and finance. I’ve been programming since I was young, but it was only when I started using that knowledge for data analysis and financial modeling that I discovered the true power of programming. For the last 20 years, programming has been both a part of my work and a hobby, allowing me to create diverse software, ranging from user interfaces and data integration pipelines to embedded devices.
I love how programming combines creativity and technology in a way that makes it possible to create, emulate, or simulate almost anything you can imagine, and I find this especially true when programming in Rust. When researching topics that I found inaccessible or poorly explained, I decided to write small books and articles to make it easier for others to gain that knowledge. Some of these books became very popular, which kickstarted my career as a writer.
Which parts of the book are your favourites and why?
The part of the book I’m most excited about is the last few chapters of the book which cover Rust futures and runtimes. I’m especially happy about chapter 9, which covers pinning in Rust. I’ve written about pinning several times before but never felt like I succeeded in making it easy to understand until now. In this chapter, readers will see exactly what pinning does and why we need it.
They will be able to make the most of theory and diagrams to understand the abstraction properly before using it to solve real-world problems. This way, type theory and programming language design take a back seat, which I think is beneficial when trying to get a good working understanding of the subject. Finally, a piece of advice for readers is to sync their codebase with the code in the accompanying repository when starting each chapter. This is essential to avoid errors that persist with the evolving codebase.
What kind of real-world applications are covered in the book?
The book centers around examples and experiments written in Rust, each created with a specific purpose. For example, by understanding the epoll API, readers can create their own event queue and build an abstraction over it that closely resembles mio.
Later, readers will go on to develop their version of async Rust so they can observe the coroutine transformations and the traits involved. Additionally, by creating their own runtimes, they will understand how runtimes work, how they differ, and what to consider when using them. This hands-on approach ensures that readers will know what to do, or at least have a good intuition of what to do, when they encounter the unavoidable rough edges when using asynchronous Rust.
Publisher : Packt Publishing (February 9, 2024)
Language : English
Paperback : 306 pages
ISBN-10 : 1805128132
ISBN-13 : 978-1805128137
Item Weight : 1.19 pounds
Dimensions : 9.25 x 7.52 x 0.64 inches