DEV Community

Cover image for Rust For C++ Programmers

Posted on

Rust For C++ Programmers

I would like to make an article about my recent publication Rust For C++ Programmers. This is a book I had started writing in May 2022, and after months of work I am able to show my hard work.

This book is published under BPB Online and I would like to thank the team for giving me this opportunity and the amazing support throughout the publication process.

Rust For C++ Programmers Cover

Who's the Audience?

The audience for this book is mainly C++ programmers looking to broaden their horizons or looking for a memory safety alternative. This book uses C++ semantics better to understand Rust in the beginning/intermediate sections and teaches how to use Rust alongside C/C++ projects in the advanced chapters. An excellent addition I added in this book that isn't particularly found in other books is having a few chapters dedicated to building projects, as listed below:

  • Building a CLI App
    • Gives experience using the structopts crate
  • GTK App
    • Build desktop apps using the GTK framework
  • StdLib for Mufi
    • Integrate Rust into a C project by developing a standard library for a toy language.
  • App in Tauri
    • Learn how to develop cross-platform desktop applications using Tauri (Rust backend, Svelte frontend)

Along with the project, each chapter will contain exercises to help enforce the content each chapter goes through.

Why Rust and C++?

C and C++ are systems programming languages that dominate many different aspects of our systems, such as operating systems, desktop applications, and microservices. Still, they come with their fair share of problems.

The biggest con of using languages like C/C++ is the memory-related bugs they go through, which is the most common kind of exploitation in a program.

The advantage of using a language like Rust is that it was built from the ground up to provide memory and thread safety so that you won't see any segmentation faults, double frees, or data races.

We portrayed this book to provide C++ developers with a way to learn how to integrate Rust into a C++ project so newer features or different components can be written with higher levels of memory safety. This use case can happen in the Linux kernel, which has Rust as its second official language and is already being used for graphics drivers in the Asahi Linux project that aims to bring Linux to Apple silicon.

Where to Purchase?

The book is listed as the following:

  • Kindle: $9.95 USD
  • Paperback: $29.95 USD
  • Paperback + Kindle: $34.95 USD

View BPB Online

Top comments (0)