|
1 | 1 | # Introduction |
2 | 2 |
|
3 | | -This book covers the design patterns for _context-generic programming_ (CGP), a new programming paradigm for Rust. |
4 | | - |
5 | | -At its core, context-generic programming allows us to write _modular_ code that are _generic_ over different _contexts_. |
6 | | -Thoughout the book, we will slowly uncover what that really means. |
| 3 | +This book covers the design patterns for _context-generic programming_ (CGP), |
| 4 | +a new programming paradigm for Rust that allows strongly-typed components |
| 5 | +to be implemented and composed in a modular, generic, and type-safe way. |
| 6 | + |
| 7 | +## What is Context-Generic Programming |
| 8 | + |
| 9 | +At its core, CGP makes use of Rust's trait system to build generic _interfaces_ |
| 10 | +decouple code that _consumes_ an interface from code that _implements_ an |
| 11 | +interface. Through this decoupling, code can be written to be generic over |
| 12 | +any context, and then be wired to be used on a concrete context by writing |
| 13 | +few lines of code. CGP makes use of Rust's strong type system to help ensure |
| 14 | +that any such wiring is _type-safe_, catching any unsatisfied dependencies |
| 15 | +as compile-time errors. |
| 16 | + |
| 17 | +CGP shares some similarities with other modular programming patterns, such as |
| 18 | +OCaml modules, Scala implicits, mixins, and dependency injection. Compared to |
| 19 | +these other patterns, CGP has a unique advantage that it enables high modularity |
| 20 | +while also being type-safe and concise. With Rust as its host language, CGP |
| 21 | +also allows high-performance and low-level code to be written in a modular |
| 22 | +way, without requiring complex runtime support. |
| 23 | + |
| 24 | +Thoughout this book, we will slowly understand how CGP works, and learn about |
| 25 | +useful design patterns that can be used in any programming situation. |
7 | 26 |
|
8 | 27 | ## Work In Progress |
9 | 28 |
|
|
0 commit comments