@@ -6,13 +6,13 @@ to be implemented and composed in a modular, generic, and type-safe way.
66
77## What is Context-Generic Programming
88
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.
9+ At its core, CGP makes use of Rust's trait system to build generic
10+ component _ interfaces _ that decouple code that _ consumes _ an interface
11+ from code that _ implements _ an interface.
12+ Through this decoupling, code can be written to be generic over any context,
13+ and then be wired to be used on a concrete context by writing few lines of code.
14+ CGP makes use of Rust's strong type system to help ensure that any such
15+ wiring is _ type-safe _ , catching any unsatisfied dependencies as compile-time errors.
1616
1717CGP shares some similarities with other modular programming patterns, such as
1818OCaml modules, Scala implicits, mixins, and dependency injection. Compared to
@@ -21,6 +21,19 @@ while also being type-safe and concise. With Rust as its host language, CGP
2121also allows high-performance and low-level code to be written in a modular
2222way, without requiring complex runtime support.
2323
24+ CGP is designed to solve a wide range of common problems in programming,
25+ including error handling, logging, encoding, and modular dispatch.
26+ In particular, it allows writing static-typed Rust programs to be almost
27+ as expressive as writing dynamic-typed programs, but with the additional
28+ type safety guarantees.
29+ If you ever feel that Rust's type system is restricting your ability to reuse
30+ code, or be forced to duplicate code through copy-pasting or macros, then
31+ CGP may be of help to solve your problem.
32+
33+ That said, programming in CGP is as expressive, but not as easy,
34+ as dynamic-typed programming. There may be a steep learning curve
35+ in learning how to program in a generic way, and this book aims to help
36+ make that learning process more approachable.
2437Thoughout this book, we will slowly understand how CGP works, and learn about
2538useful design patterns that can be used in any programming situation.
2639
@@ -43,11 +56,11 @@ that covers real world use of CGP.
4356
4457## Chapter Outlines
4558
46- The first section of this book, _ Core Concepts _ , will introduce core concepts of CGP.
59+ The first section of this book, _ Terminology _ , will introduce common terms to be used to understand CGP.
4760We will learn about what is a context, and what are consumer and provider traits.
4861
49- In the next section, _ Basic Patterns _ , we will cover the basic design patterns that enable us to write
50- context-generic code .
62+ In the next section, _ Core Concepts _ , we will cover the core concepts and the Rust-specific
63+ design patterns that we use to enable context-generic programming .
5164
5265Following that, _ Design Patterns_ will introduce general design patterns that are built on top of the
5366foundation of context-generic programming.
0 commit comments