You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/_index.md
+51-16Lines changed: 51 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,43 +10,78 @@ sort_by = "weight"
10
10
11
11
# Announcement
12
12
13
-
I’m excited to announce the release of [**CGP v0.6.0**](/blog/v0-6-0-release/)!
14
-
This version introduces major ergonomic improvements that make provider and context implementations simpler and more intuitive to write.
13
+
I am excited to announce the release of [**cgp-serde**](/blog/cgp-serde-release/), a modular serialization library for Serde that leverages the power of [**Context-Generic Programming**](/).
15
14
16
-
The new `#[cgp_impl]` and `#[cgp_inherit]` macros replace `#[cgp_provider]` and `#[cgp_context]`, offering cleaner syntax and greatly improving the readability of CGP code.
15
+
[Read the announcement blog post](/blog/cgp-serde-release/) to find out more.
17
16
18
-
[Read the announcement blog post](/blog/v0-6-0-release/) to find out more.
17
+
---
19
18
20
-
# Overview
19
+
# Quick Introduction
21
20
22
-
Context-generic programming (CGP) is a new programming paradigm for Rust that allows strongly-typed components to be implemented and composed in a modular, generic, and type-safe way.
21
+
Context-Generic Programming (CGP) is a modular programming paradigm that enables you to bypass the **coherence restrictions** in Rust traits, allowing for **overlapping**and **orphan** implementations of any CGP trait.
23
22
24
-
To learn more about the high level overview of CGP, check out the [overview](/overview) page.
23
+
You can adapt almost any existing Rust trait to use CGP today by applying the `#[cgp_component]` macro to the trait definition. After this annotation, you can write **named** implementations of the trait using `#[cgp_impl]`, which can be defined without being constrained by the coherence rules. You can then selectively enable and reuse the named implementation for your type using the `delegate_components!` macro.
24
+
25
+
For instance, we can, in principle, annotate the standard library’s [`Hash`]([https://doc.rust-lang.org/std/hash/trait.Hash.html]\(https://doc.rust-lang.org/std/hash/trait.Hash.html\)) trait with `#[cgp_component]` like this:
26
+
27
+
```rust
28
+
#[cgp_component(HashProvider)]
29
+
pubtraitHash { ... }
30
+
```
31
+
32
+
This change does not affect existing code that uses or implements `Hash`, but it allows for new, potentially overlapping implementations, such as one that works for any type that also implements `Display`:
33
+
34
+
```rust
35
+
#[cgp_impl(HashWithDisplay)]
36
+
impl<T:Display> HashProviderforT { ... }
37
+
```
38
+
39
+
You can then apply and reuse this implementation on any type by using the `delegate_components!` macro:
40
+
41
+
```rust
42
+
pubstructMyData { ... }
43
+
implDisplayforMyData { ... }
44
+
45
+
delegate_components! {
46
+
MyData {
47
+
HashProviderComponent:HashWithDisplay,
48
+
}
49
+
}
50
+
```
51
+
52
+
In this example, `MyData` implements the `Hash` trait by using `delegate_components!` to delegate its implementation to the `HashWithDisplay` provider, identified by the key `HashProviderComponent`. Because `MyData` already implements `Display`, the `Hash` trait is now automatically implemented through CGP via this delegation.
53
+
54
+
---
25
55
26
56
# Current Status
27
57
28
-
As of 2025, CGP remains in its _early stages_of development. While promising, it still has several rough edges, particularly in areas such as documentation, tooling, debugging techniques, community support, and ecosystem maturity.
58
+
As of 2025, it is important to note that CGP remains in its **formative, early stages**of active development. While the potential is genuinely promising, it still has several inevitable rough edges, particularly in key areas such as comprehensive documentation, mature tooling, streamlined debugging techniques, robust community support, and overall ecosystem maturity.
29
59
30
-
As such, adopting CGP for serious projects comes with inherent challenges, and users are advised to proceed _at their own risk_. The primary risk is not technical but stems from the limited support available when encountering difficulties in learning or applying CGP.
60
+
Consequently, embracing CGP for your mission-critical, serious projects comes with inherent challenges, and you should be advised to proceed **at your own discretion and risk**. The primary risk you face is not strictly technical, but rather stems from the current limited support available when you inevitably encounter difficulties while learning or attempting to apply CGP in production.
31
61
32
-
At this stage, CGP is best suited for early adopters and potential [contributors](/overview/#contribution) who are willing to experiment and help shape its future.
62
+
At this pioneering stage, CGP is an ideal fit for [**early adopters and enthusiastic potential contributors**](/contribute/) who are eager to experiment with the paradigm and actively help to shape its powerful future.
63
+
64
+
---
33
65
34
66
# Getting Started
35
67
36
-
There are several places where you can get started learning and using CGP.
68
+
Even though the CGP project is officially still less than one year old, some of the initial documentation and resources you might find have already become slightly outdated, or they have been gracefully superseded by more intuitive and modern patterns. Nevertheless, this section is an attempt to provide you with the very best and most current guidance on how you can effectively begin to learn more about CGP.
69
+
70
+
## Blog Posts
71
+
72
+
The most accurate and up-to-date resources concerning CGP are currently available in the form of our insightful [blog posts](/blog). Specifically, we recommend that the blog posts starting from the [**v0.6.0 release onward**](/blog/v0-6-0-release/) will give you a significantly more concise and modern explanation of precisely what CGP is all about.
37
73
38
74
## Hello World Tutorial
39
75
40
-
The [Hello World Tutorial](/tutorials/hello)gives a highlevel walkthrough of various CGP features using a hello-world style example.
76
+
The hands-on [Hello World Tutorial](/tutorials/hello)provides a high-level and clear walkthrough of various fundamental CGP features by using a familiar, simple hello-world style example.
41
77
42
78
## Book
43
79
44
-
To better understand CGP, the best approach is to dive into our book, [Context-Generic Programming Patterns](https://patterns.contextgeneric.dev/). It provides a comprehensive guide to understanding and working with CGP.
45
80
46
-
## Applications
81
+
If your preference is to rigorously understand CGP from its **first principles**, without relying on the specific implementations within the [`cgp` crate](https://github.com/contextgeneric/cgp), your best approach is to dive into our comprehensive book, [Context-Generic Programming Patterns](https://patterns.contextgeneric.dev/). This resource provides a deep, thorough guide to understanding the complex inner workings of CGP.
47
82
48
-
You can also explore real-world applications and projects that use CGP, such as [Hermes SDK](https://github.com/informalsystems/hermes-sdk/), to gain a deeper understanding of its practical uses.
83
+
Please note that this book has not been updated for a while, and you might consider skipping the book entirely if your primary goal is to start using CGP quickly with the absolute minimal learning curve!
49
84
50
85
## Resources
51
86
52
-
Check out the [Resources](/resources) page for more materials and learning tools to help you get up to speed with CGP.
87
+
Make sure to check out the dedicated [Resources](/resources) page, which contains more supplementary materials and various learning tools to help you get up to speed with CGP.
0 commit comments