Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Functional Programming in Rust

You're reading from   Hands-On Functional Programming in Rust Build modular and reactive applications with functional programming techniques in Rust 2018

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788839358
Length 249 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Andrew Johnson Andrew Johnson
Author Profile Icon Andrew Johnson
Andrew Johnson
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Functional Programming – a Comparison 2. Functional Control Flow FREE CHAPTER 3. Functional Data Structures 4. Generics and Polymorphism 5. Code Organization and Application Architecture 6. Mutability, Ownership, and Pure Functions 7. Design Patterns 8. Implementing Concurrency 9. Performance, Debugging, and Metaprogramming 10. Assessments 11. Other Books You May Enjoy

What this book covers

Chapter 1, Functional Programming – a Comparison, introduces functional programming in Rust. Comparisons are drawn between functional style and other paradigms that are prevalent or influential to Rust. The chapter also serves as a brief outline of topics that will appear later in the book.

Chapter 2, Functional Control Flow, introduces Rust control flow structures while explaining how they are relevant to the functional style of programming. The expression-centric nature of functional programming and Rust is illustrated through examples. Limiting as it may be, the chapter also begins an ongoing project using only the procedural expression style of programming.

Chapter 3, Functional Data Structures, introduces the reader to the various, highly expressive data types available in Rust. Notably, the enum type is introduced, which holds particular significance in functional programming. The project continues to grow to incorporate a variety of these data types.

Chapter 4, Generics and Polymorphism, explains the concepts of parameterization of data (generics) and parameterization of control flow (polymorphism). Parameterization and its natural interaction with traits reduces the programmer's burden, but the syntax can become overwhelming. Some approaches to reduce or mitigate parameter explosion are introduced. The ongoing project again grows to incorporate these features.

Chapter 5, Code Organization and Application Architecture, talks about some architectural concerns, recommendations, and best practices. Designing and managing the implementation of a software project is not formulaic. No project is the same, and few are highly similar, thus no engineering procedure can capture the nuances of software development. In this chapter, we provide the best tools available, and specifically, the best that functional programming has to offer.

Chapter 6, Mutability, Ownership, and Pure Functions, digs into some of the more unique features in Rust. This chapter introduces the concepts of ownership and lifetimes, which are common stumbling blocks when learning Rust. The functional concepts of immutability and pure functions are also introduced to help untangle some of the spaghetti that a naive Rust programmer might generate when attempting to circumvent the rules of ownership in Rust.

Chapter 7, Design Patterns, lists as many functional programming cheat codes that can fit into a single chapter. The concept of functors and monads are explained with examples and some casual definitions. The chapter also briefly introduces the style of functional reactive programming and uses it to build a quick and dirty web framework.

Chapter 8, Implementing Concurrency, explains how to do multiple things at the same time. Most of the chapter is spent clarifying the differences and relative strengths and weaknesses between subprocesses, forked processes, and threads. The Rust thread concurrency model is then assumed and more information is provided to clarify Rust-specific logic regarding threads. Toward the end of the chapter, the actor model of concurrency is introduced, which is a robust model of concurrency that can adapt to most situations and programming paradigms.

Chapter 9, Performance, Debugging, and Metaprogramming, wraps up the book with some miscellaneous tips for programming in Rust. The performance tips are not particularly functional, but rather concerned primarily with language-specific details, general advice, or relevant bits of computer science. Debugging introduces many tips on how to prevent bugs. Also, how to use an interactive debugger is explained through examples. Metaprogramming explains precisely how Rust macros and procedural macros work. This is a great feature of Rust, but is not documented well, so it might be scary to approach.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image