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: _posts/2026-04-06-Ruben2026Q1Update.md
+44-36Lines changed: 44 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,30 @@
2
2
layout: post
3
3
nav-class: dark
4
4
categories: ruben
5
-
title: "A postgres library for Boost"
5
+
title: "The road to C++20 modules, Capy and Redis"
6
6
author-id: ruben
7
7
author-name: Rubén Pérez Hidalgo
8
8
---
9
9
10
-
## The road to `import boost`: a talk in a wonderful conference
10
+
## Modules in using std::cpp 2026
11
11
12
-
-C++20 modules have been in the standard for 6 years already, but we're not seeing widespread adoption.
13
-
- At the moment, the ecosystem is still getting ready. As a quick example,`import std`, an absolute blessing
14
-
for compile times, requires build system support, and this is still experimental as of CMake 4.3.1.
15
-
Just an instance of what it is.
12
+
C++20 modules have been in the standard for 6 years already, but we're not seeing
13
+
widespread adoption. The ecosystem is still getting ready. As a quick example,
14
+
`import std`, an absolute blessing for compile times, requires build system support,
15
+
and this is still experimental as of CMake 4.3.1.
16
16
17
-
- Something I've realized is that writing module-native applications is really enjoyable. The system is well-thought and allows for better encapsulation,
18
-
just as you'd write in a modern programming language. (TODO: example).
19
-
- I've been using my Servertech Chat project (a webserver that uses Boost.Asio and companion libraries) to have a taste of what modules really look like in real code.
20
-
In case you're curious: https://github.com/anarthal/servertech-chat/tree/feature/cxx20-modules
21
-
- When writing this, I saw clearly that having big dependencies that can't be consumed via import is a big problem.
22
-
With the scheme I used, compile times got 66% worse instead of improving. This is because when writing modules, you tend to have
23
-
a bigger number of translation units. These are supposed to be much more lightweight, but if you're relying on includes
24
-
for third-party libraries, they're not!
17
+
And yet, I've realized that writing module-native applications is really enjoyable.
18
+
The system is well-thought and allows for better encapsulation,
19
+
just as you'd write in a modern programming language.
20
+
I've been using my [Servertech Chat project](https://github.com/anarthal/servertech-chat/tree/feature/cxx20-modules)
21
+
(a webserver that uses Boost.Asio and companion libraries) to get a taste
22
+
of what modules really look like in real code.
23
+
24
+
When writing this, I saw clearly that having big dependencies that can't be consumed
25
+
via `import` is a big problem. With the scheme I used, compile times got 66% worse
26
+
instead of improving. This is because when writing modules, you tend to have
27
+
a bigger number of translation units. These are supposed to be much more lightweight,
28
+
but if you're relying on `#include` for third-party libraries, they're not.
25
29
26
30
For example:
27
31
@@ -69,43 +73,47 @@ class redis_client_impl final : public redis_client { /* ... */ };
69
73
70
74
```
71
75
72
-
I analyze this in much more depth in the talk I've had the pleasure to give at using std::cpp this March in Madrid.
73
-
https://youtu.be/hD9JHkt7e2Y for the entire talk.
74
-
75
-
The TL;DR is that supporting `import boost` natively is very important for any serious usage of Boost in the modules world.
76
+
I analyze this in much more depth in
77
+
[the talk I've had the pleasure to give at using std::cpp](https://youtu.be/hD9JHkt7e2Y)
78
+
this March in Madrid. The TL;DR is that supporting `import boost` natively
79
+
is very important for any serious usage of Boost in the modules world.
76
80
77
81
## `import boost` is upon us
78
82
79
83
As you may know, I prefer doing to saying, and I've been writing a prototype to support
80
84
`import boost` natively while keeping today's header code as is. This prototype has
81
85
seen substantial advancements during these months.
82
86
83
-
I've developed a systematic approach for modularization, which I summarize here: https://github.com/anarthal/boost-cmake/blob/feature/cxx20-modules/modules.md.
84
-
We've settled for the ABI-breaking style, with compatibility headers.
85
-
I've added support for the remaining compiler, gcc, to the core libraries that we used to support (Config, Mp11, Core, Assert, ThrowException, Charconv).
86
-
And I've added modular bindings for (variant2, compat, endian, system, type_traits, optional, container_hash, io and asio).
87
-
These are only tested under clang yet - it's part of a discovery process. Idea is modularizing the flagship libraries
87
+
I've developed a [systematic approach for modularization](https://github.com/anarthal/boost-cmake/blob/feature/cxx20-modules/modules.md),
88
+
and we've settled for the ABI-breaking style, with compatibility headers.
89
+
I've added support for GCC (the remaining compiler) to the core libraries
90
+
that we already supported (Config, Mp11, Core, Assert, ThrowException, Charconv),
91
+
and I've added modular bindings for Variant2, Compat, Endian, System, TypeTraits,
92
+
Optional, ContainerHash, IO and Asio.
93
+
These are only tested under Clang yet - it's part of a discovery process.
94
+
The idea is modularizing the flagship libraries
88
95
to verify that the approach works, and to measure compile time improvements.
89
96
90
-
Still lots to do before things become functional. I've received helpful feedback from many community
91
-
members.
97
+
There is still a lot to do before things become functional.
98
+
I've received helpful feedback from many community members, which has been invaluable.
92
99
93
100
## Redis meets Capy
94
101
95
102
If you're a user of Boost.Asio and coroutines, you probably know that there's a new player
96
103
in town - Capy and Corosio. They're a coroutines-native Asio replacement which promise
97
-
a range of benefits, from improved expressiveness, saner compile times, without performance loss.
104
+
a range of benefits, from improved expressiveness to saner compile times,
105
+
without performance loss.
98
106
99
107
Since I maintain Boost.MySQL and co-maintain Boost.Redis, I know the pain of writing
100
108
operations using the universal Asio model. Lifetime management is difficult to follow,
101
-
testing is complex, things must be remained header-only (and usually heavily templatized).
109
+
testing is complex, and things must remain header-only (and usually heavily templatized).
102
110
Coroutine code is much simpler to write and understand, and it's what I use whenever I can.
103
111
So obviously I'm interested in this project.
104
112
105
113
My long-term idea is creating a v2 version of MySQL and Redis that exposes a Capy/Corosio
106
114
interface. As a proof-of-concept, I migrated Boost.Redis and some of its tests.
107
-
Still some polishment needed, but - it works!
108
-
You can see the full report: https://lists.boost.org/archives/list/boost@lists.boost.org/thread/FSX5H3MDQSLO3VZFEOUINUZPYQFCIASB/
115
+
Still some polishing needed, but - it works!
116
+
You can read the [full report on the Boost mailing list](https://lists.boost.org/archives/list/boost@lists.boost.org/thread/FSX5H3MDQSLO3VZFEOUINUZPYQFCIASB/).
109
117
110
118
Some sample code as an appetizer:
111
119
@@ -141,7 +149,7 @@ capy::task<void> co_main()
141
149
142
150
```
143
151
144
-
## Redis PubSub
152
+
## Redis PubSub improvements
145
153
146
154
Working with PubSub messages in Boost.Redis has always been more involved than in other libraries.
147
155
For example, we support transparent reconnection, but (before 1.91), the user had to explicitly
@@ -158,9 +166,9 @@ while (conn->will_reconnect()) {
158
166
}
159
167
```
160
168
161
-
Boost 1.91 has added pubsub state restoration. A fancy name but an easy feature.
162
-
Established subscriptions are recorded. When a reconnection happens,
163
-
the subscription is re-established:
169
+
Boost 1.91 has added PubSub state restoration. A fancy name but an easy feature:
170
+
established subscriptions are recorded, and when a reconnection happens,
171
+
the subscription is re-established automatically:
164
172
165
173
```cpp
166
174
// Subscribe to the channel 'mychannel'. If a re-connection happens,
0 commit comments