Declarative C++
"What" - Express intent directly
Declarative C++ is about working with the "what" i.e. the high-level intent.
Being declarative ensures:
- correctness-by-construction which is
- relatively bug-free and
- easy to understand/maintain.
I exclaimed while presenting at a company's Annual Event I was invited to:
> "I do not write code. I just express my intent and the compiler writes the code for me"
Note, I'd called upon the compiler to write the code for me and not an LLM :P. The compiler-generated code will be correct & optimal and devoid of any hallucinations! The clarity of such Declarative code greatly helped my team be very clear of the intent and helped them own & comfortably maintain the code.
How C++ enables being declarative
This talk expands on specifying the "what" in declarative-style. It explores how C++ has enabled us to move away from baby sitting the processor through the "how", i.e. exact steps, in typical imperative programming fashion. We explore how close we can get to being declarative and expressing intent using various language & library facilities.
Declarative Code Beyond The Language Facilities
We also discuss how we can help ourselves being more declarative with our C++ beyond the language facilities. We review & understand the techniques employed by some well-known declarative libraries. In addition, we explore concrete, real-life implementation of (1) a statically, infinitely-recursive expression tree of any depth, and, (2) a protocol stack of telecom/networking encoders and how it resembles a typical diagrammatic representation of a protocol stack which efficiently encodes messages layer-by-layer with zero-copy:
//A protocol stack just how we draw by assembling the layers
auto my_http_stack = protocol_stack_encoder<http_encoder,
tcp_encoder,
ip_encoder,
ethernet_encoder>();
auto http_message = my_http_stack.encode(request_content);
Ankur Satle
Ankur is an avid (natural) language learner, but C++ is his mother tongue!
He architects high-performance, scalable, cloud-native, mission-critical products. He enjoys working in constrained environments.
If you bump into him, do ask him how he & his team achieved a low 1 defect/year outcome!
His mantra is: "Effective, Efficient & Elegant". He leverages the power of the small to build large-scale systems. Correct-by-construction is his way of being in the software world.
Check out his talks from CppCon, CppIndiaCon and other conferences.
He has been the Organizer & Host of CppIndiaCon since inception. He hosted hosted the AMA with Bjarne Stroustrup! He is a Core Organizer at CppIndia, India's C++ User Group.
