Skip to content

Commit 7a09542

Browse files
committed
Add introduction section
1 parent 0e51a61 commit 7a09542

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

content/_index.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,55 @@ title = "Context-Generic Programming"
66

77
# Introduction
88

9-
Context-generic programming (CGP) is a new programming paradigm for Rust.
9+
Context-generic programming (CGP) is a new programming paradigm for Rust that
10+
allows strongly-typed components to be implemented and composed in a modular,
11+
generic, and type-safe way.
12+
13+
## Modular Component System
14+
15+
CGP makes use of Rust's trait system to define generic component _interfaces_
16+
that decouple code that _consumes_ an interface from code that _implements_ an interface.
17+
This is done by having _provider traits_ that are used for implementing a
18+
component interface, in addition to _consumer traits_ which are used for
19+
consuming a component interface.
20+
21+
The separation of provider traits from consumer traits allows multiple context-generic
22+
provider implementations to be defined, bypassing Rust's trait system original restriction
23+
of forbidding overlapping implementations.
24+
25+
## Expressive Ways to Write Code
26+
27+
With CGP, one can easily write _abstract programs_ that is generic over
28+
a context, together with all its associated types and methods. CGP allows such
29+
generic code to be written without needing to explicitly specify a long list
30+
generic parameters in the type signatures.
31+
32+
CGP also provides powerful _macros_ for defining component interfaces, as well
33+
as providing simple ways to wire up component implementations to be used with
34+
a concrete context.
35+
36+
CGP allows Rust code to be written with the same level of expressiveness,
37+
if not more, as other popular programming paradigms, including object-oriented programming
38+
and dynamic-typed programming.
39+
40+
## Type-Safe Composition
41+
42+
CGP makes use of Rust's strong type system to help ensure that all wiring
43+
of components is _type-safe_, catching any missing dependencies as compile-time
44+
errors. CGP works fully within safe Rust, and does not make use of
45+
any dynamic-typing techniques, e.g. `dyn` traits, `Any`, or reflection.
46+
As a result, developers can ensure that no CGP-specific errors can happen
47+
during application runtime.
48+
49+
## No-Std Friendly
50+
51+
CGP makes it possible to build _fully-abstract programs_ that can be defined
52+
with _zero dependencies_. This allows such programs to be instantiated with
53+
specialized-dependencies in no-std environments, such as on embedded systems,
54+
operating system kernels, or Wasm sandboxes.
55+
56+
## Zero-Cost Abstraction
57+
58+
Since all CGP features work only at compile-time, it provides the same
59+
_zero-cost abstraction_ advantage as Rust. Applications do not have to sacrifice
60+
any runtime overhead for using CGP in the code base.

templates/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ <h3 class="title-text">
99
<span style="color: rgb(8, 155, 8)"></span> <i>Modular</i> component system
1010
</h3>
1111
<h3 class="title-text">
12-
<span style="color: rgb(8, 155, 8)"></span> <i>Expressive</i>
12+
<span style="color: rgb(8, 155, 8)"></span> <i>Expressive</i> ways to write code
1313
</h3>
1414
<h3 class="title-text">
15-
<span style="color: rgb(8, 155, 8)"></span> Type-Safe
15+
<span style="color: rgb(8, 155, 8)"></span> <i>Type-Safe</i> composition
16+
</h3>
17+
<h3 class="title-text">
18+
<span style="color: rgb(8, 155, 8)"></span> <i>No-Std</i> friendly
19+
</h3>
20+
<h3 class="title-text">
21+
<span style="color: rgb(8, 155, 8)"></span> <i>Zero-Cost</i> abstraction
1622
</h3>
1723
</section>
1824
<img class="hero-image" style="width: 50%" src="/rust-logo.svg">

0 commit comments

Comments
 (0)