DEV Community

Artak Avetyan
Artak Avetyan

Posted on

C++ Can Be Easy: Service-Oriented programming with Areg SDK

C++ has a reputation: fast, powerful… but not exactly “easy.”
Especially when it comes to making components talk to each other.

Normally, when you program Inter-Process Communication (IPC) or multithreading, you would have to:

  • Create threads and message queues
  • Open sockets or pipes to send and receive messages
  • Write serialization/deserialization
  • Dispatch messages and call callbacks manually
  • Configure IPC manually

With Areg SDK, you don’t.

Here’s what calling a service looks like:

// Consumer calls Provider as if it were local
consumer.requestData("Hello");
Enter fullscreen mode Exit fullscreen mode

and the message on remove Service Provider running in other thread or other process is triggered automatically:

void ServiceProvider::requestData(const String & data) {
    // do business logic here; if needed, response on call
    responseData(true);
}
Enter fullscreen mode Exit fullscreen mode

That’s it. Behind the scenes:

  • Areg spins up the threads
  • Routes the request (local or remote)
  • Handles synchronization
  • Returns the response asynchronously

You write business logic, not boilerplate. See small C++ working example of multithreading RPC.


Why this matters

  • Easy to learn → Start with one example, and you’re productive.
  • Easy to scale → Works in the same thread, across processes, or even devices.
  • Easy to debug → No fragile wiring to hunt down.

If you can write C++, you can build distributed apps — without touching sockets or race conditions.

👉 Try the 01_minimalrpc example for multithreading and 02_minimalipc. It’s less code than you think.

Top comments (13)

Collapse
 
dyfet profile image
David Sugar • Edited

I have had some time to think about Areg, and I have concluded perhaps the best thing I could do for it is to apache re-license and migrate some of my essential classes into patches for it (like pipelines, buffering, etc), and try to adapt Areg directly for HPX. I do not think I can cross-mix the way I normally vendor C++ libraries and headers directly into my server codebase with the way Areg is structured. Much of my stuff is easier to re-work with or even within Areg, rather than simply adopting Areg into my existing server codebase.

Collapse
 
aregtech profile image
Artak Avetyan

Thanks for considering that approach -- it makes a lot of sense. Areg’s OS-dependent APIs are already separated, so HPX can be integrated under the hood while keeping the public API intact. Adding a compiler option in user.cmake would keep it clean.

Optimizations, extensions, and fixes are always welcome. For any top-level logic changes, let’s sync first since they affect the code generator and embedded efficiency. If you move forward, feel free to open an issue or discussion in the repo. Happy to collaborate!

Collapse
 
dyfet profile image
David Sugar

So I gather this is a distributed C++ workflow engine. That is something I could find interesting. I am curious how it compares with something like say temporal, who sadly did not seem to want to do any of their stuff in C++.

Collapse
 
aregtech profile image
Artak Avetyan

Without diving too deep, both simplify distributed systems and boost reliability. Areg targets C++/embedded/desktop environments with IPC, multithreading, and real-time distributed services, while Temporal focuses on orchestrating long-running workflows in the cloud.

A key difference: Temporal relies on gRPC (client-server style), whereas Areg competes with gRPC by offering a native, lightweight, multitarget messaging and RPC layer.

💡 In short: if you need C++ and embedded-friendly distributed execution, Areg fills that gap where Temporal doesn’t.

Collapse
 
dyfet profile image
David Sugar

This is a great explanation. My use cases historically were in embedded telephone servers. When I look at this, I think I could even be complimentary to things like HPX / HPC computing uses, too, as HPX runtimes are also C++ based, and offers its own replacement for libc++ that gives a new C++ threading model, but don't on it's own fully answer the larger problem of building distributed HPC applications on it's own. Kne thing HPX does do well is it makes very large numbers of threads cheap to create and use in C++, much like in Go. It also uses all core C++ runtime library semantics re-implemented around this.

Thread Thread
 
aregtech profile image
Artak Avetyan

Great point! You’re right -- HPX shines for HPC with threading and massive concurrency, but as you note, it doesn’t fully solve distributed application challenges. That’s exactly where Areg can complement C++ runtimes like HPX, providing a native layer for IPC, coordination, and messaging across nodes.

In other words: HPX scales threads, Areg scales services across threads, processes, or devices -- together, they cover the missing pieces for distributed HPC systems. 🚀

If you’re exploring integration or want a deeper dive into how Areg and HPX could work together, feel free to reach out!

Thread Thread
 
dyfet profile image
David Sugar

If I had my eyesight back, this is precisely the kind of problem I would want to solve, too. One of the last thing I was able to work on, last month, was HiTycho for HPX (github.com/dyfet/hitycho).

Thread Thread
 
aregtech profile image
Artak Avetyan

Thanks for sharing. HiTycho looks really interesting! From what I see, it’s still early in its journey, and I’m not yet familiar with your full plans or design choices. In the early stages of Areg, my focus was on multithreading communication -- local service discovery, messaging protocols, and dispatching -- before extending the same architecture to networked solutions, where the networking model becomes a key decision.

On my side, Areg has a clear separation of OS-dependent APIs. I’ve worked to keep that boundary clean, and I believe it could be adapted to the HPX runtime with relatively little effort -- combining HPX’s threading model with Areg’s asynchronous, service-oriented distributed computing and built-in automation. Do you see potential for Areg and HPX to complement each other? I’d value your insights.

Thread Thread
 
dyfet profile image
David Sugar

HiTycho really was when I first came to learn and appreciate what HPX could mean and do,, which was only in August. It is a subset / port of moderncli / Busuto support that I use to write application services in C++, but those also don't focus much on distributed computing historically. I think mostly in its initial phases, hitycho will simply be bringing more Busuto functionality in, like Busuto zero-copy stream buffer parsing.

But I was already familiar with Temporal, which sadly will not support C++, so it was immediately clear to me what HPX combined with Areg could potentially do.

Thread Thread
 
aregtech profile image
Artak Avetyan

I agree on Temporal, it leaves a clear gap for C++ developers. I also see strong potential in bridging that gap with HPX and Areg together. From your view, what features or use cases should be the first focus if we explore an HPX + Areg integration?

For context, the current Areg version supports a single TCP/IP channel (not secured). If that’s enough, we could already start experimenting. If not, the next version will introduce secured connections and multi-channel communication providing a stronger foundation for integration.

Thread Thread
 
dyfet profile image
David Sugar

I decided to do a post to talk about this some ;). It also better explains what I was doing with my libraries.

Incidentally, I have come to favor meshed kernel level security (wireguard and things like tailscale) rather than overloading every single application stack with clunky user-mode TLS code. In that respect I don't see an issue with insecure TCP channels if the systems themselves offser secure transport (and optimized mesh routing) for you.

Thread Thread
 
aregtech profile image
Artak Avetyan

Great post! I've subscribed to follow the discussions. One small suggestion: since you mentioned HiTycho, Areg, and Busuto, it might help readers if you add repo links so people can dive straight in. Many devs might not know about Areg yet since it’s still young, and links would make it easier for them to explore.

Thread Thread
 
dyfet profile image
David Sugar

Done :)