Skip to content

Commit cb08461

Browse files
anarthalsdarwin
authored andcommitted
Proper wording
1 parent 40a6b13 commit cb08461

1 file changed

Lines changed: 44 additions & 36 deletions

File tree

_posts/2026-04-06-Ruben2026Q1Update.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@
22
layout: post
33
nav-class: dark
44
categories: ruben
5-
title: "A postgres library for Boost"
5+
title: "The road to C++20 modules, Capy and Redis"
66
author-id: ruben
77
author-name: Rubén Pérez Hidalgo
88
---
99

10-
## The road to `import boost`: a talk in a wonderful conference
10+
## Modules in using std::cpp 2026
1111

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.
1616

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.
2529

2630
For example:
2731

@@ -69,43 +73,47 @@ class redis_client_impl final : public redis_client { /* ... */ };
6973

7074
```
7175
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.
7680
7781
## `import boost` is upon us
7882
7983
As you may know, I prefer doing to saying, and I've been writing a prototype to support
8084
`import boost` natively while keeping today's header code as is. This prototype has
8185
seen substantial advancements during these months.
8286
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
8895
to verify that the approach works, and to measure compile time improvements.
8996
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.
9299
93100
## Redis meets Capy
94101
95102
If you're a user of Boost.Asio and coroutines, you probably know that there's a new player
96103
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.
98106
99107
Since I maintain Boost.MySQL and co-maintain Boost.Redis, I know the pain of writing
100108
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).
102110
Coroutine code is much simpler to write and understand, and it's what I use whenever I can.
103111
So obviously I'm interested in this project.
104112
105113
My long-term idea is creating a v2 version of MySQL and Redis that exposes a Capy/Corosio
106114
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/).
109117
110118
Some sample code as an appetizer:
111119
@@ -141,7 +149,7 @@ capy::task<void> co_main()
141149
142150
```
143151

144-
## Redis PubSub
152+
## Redis PubSub improvements
145153

146154
Working with PubSub messages in Boost.Redis has always been more involved than in other libraries.
147155
For example, we support transparent reconnection, but (before 1.91), the user had to explicitly
@@ -158,9 +166,9 @@ while (conn->will_reconnect()) {
158166
}
159167
```
160168

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:
164172

165173
```cpp
166174
// Subscribe to the channel 'mychannel'. If a re-connection happens,
@@ -171,14 +179,14 @@ co_await conn->async_exec(req);
171179
```
172180
173181
Boost 1.91 also adds `flat_tree`, a specialized container for Redis messages
174-
with an emphasis in memory-reuse, performance and usability.
175-
This container is specially appropriate for using when dealing with PubSub.
182+
with an emphasis on memory-reuse, performance and usability.
183+
This container is especially appropriate when dealing with PubSub.
176184
We've also added `connection::async_receive2()`, a higher-performance
177185
replacement for `connection::async_receive()` that consumes messages in batches,
178186
rather than one-by-one, eliminating re-scheduling overhead.
179187
And `push_parser`, a view to transform raw RESP3 nodes into user-friendly structures.
180188
181-
With these improvements, code goes from
189+
With these improvements, code goes from:
182190
183191
```cpp
184192
// Loop while reconnection is enabled

0 commit comments

Comments
 (0)