Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Rust for C++ Developers
  • Table Of Contents Toc
Rust for C++ Developers

Rust for C++ Developers

By : Dan Olson
close
close
Rust for C++ Developers

Rust for C++ Developers

By: Dan Olson

Overview of this book

If you're a C++ programmer curious about the rising popularity of Rust, this book will guide you through the transition with clarity and purpose. Written by a veteran C++ developer who embraced Rust to improve software quality and maintainability, this hands-on guide shows you how to apply your existing knowledge to build efficient and safe systems with Rust. The first half of the book deep dives into Rust’s history, safety guarantees, and development tooling. From there, the book compares Rust and C++ side by side, covering syntax, SIMD instructions, file I/O, object orientation, and data structures. With each chapter, you’ll gain a practical understanding of Rust’s unique approaches—like ownership and borrowing—and how they solve long-standing challenges in C++. Later half of the book tackles performance optimization, multithreading, macros, and foreign function interfaces, culminating in a complete project where you reimplement a C++ program in Rust. By focusing on real-world code and familiar concepts, this book makes Rust accessible and actionable for experienced C++ developers. By the end of Rust for C++ Developers, you’ll be confident in your ability to read, write, and maintain production-grade Rust code, and you’ll have a clear roadmap for integrating Rust into your future projects.
Table of Contents (20 chapters)
close
close
Lock Free Chapter
1
Part 1: Understanding Rust Basics
6
Part 2: Exploring the Rust Standard Library
12
Part 3: Moving into Advanced Rust
18
Index

Improving performance using unsafe Rust code

While we should prefer safe Rust code whenever possible, some optimizations may only present themselves in an unsafe context. Unsafe Rust code is exactly what it sounds like... unsafe. There are many challenges to working with unsafe Rust, and it requires a much greater understanding of the language to use it correctly. We'll only be examining some small parts of the unsafe Rust universe in this section. For a much larger treatment of the subject, the best source of reference is The Rustnomicon, available at https://doc.rust-lang.org/nomicon/.

Dropping into unsafe code to improve performance is not always necessary, but there are a handful of times when it can help push us over the line for a really critical section of code. Armed with our benchmarking setup and matrix multiplication example from the previous section, let's dive into the world of unsafe Rust and examine two specific ways it can help us optimize our code.

...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Rust for C++ Developers
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon