





















































The ACCU Conference: By Programmers, For Programmers
Running since 1997, ACCU is one of the longest-standing dev conferences—originally C/C++ focused, now covering everything from Python and Rust to Kotlin, Go, and more.
Use code PACKT2025 for 10% off your ticket.
Hi ,
Welcome to a brand new issue of ProgrammingPro.
In today’s Expert Insight, we share an original article by Ferenc-Lajos Deák, coauthor of Debunking C++ Myths, tracing C++ from 98 to 23 with real code and performance benchmarks that reveal how each standard holds up.
News Highlights: GitHub launches AI-powered secret scanning to cut false positives; critical Next.js auth bypass patched in v14+; Claude, Gemini, and OpenAI roll out major AI updates; and Oracle’s ML-optimized GraalVM boosts Java microservice performance by 7.9%.
My top 5 picks from today’s learning resources:
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
Legend:🎓 Tutorial/Course | 💼 Case Study | 💡 Insight/Analysis |
📖Open Access Book or Comprehensive Resource | 🗞️Something New
.__format__()
method, enabling tailored string output logic within your classes.past
and future
—instead of index-based stacks.Clone
, and Copy
derives, with upcoming support for PartialOrd
and PartialEq
.format!()
macros, offering cleaner, {}
-based string formatting with support for positional, named, and padded placeholders.debug.gem
, Ruby LSP, and integrations like Code Lens and RSpec support.by Ferenc-Lajos Deák, coauthor of Debunking C++ Myths
Averaging algorithms are computational techniques used to determine the mean or average value of a set of numbers. They are widely used in machine learning (model optimization), signal processing (noise reduction), finance (trend analysis), and networking (traffic smoothing). Some common averaging algorithms include Arithmetic Mean (Simple Average), Moving Average (Sliding Window Average), Harmonic Mean, and Geometric Mean.
In this article we will explore one of the most common averaging algorithms: the Arithmetic Mean, and its implementation in C++. We will explore how to compute the average of a vector using five different approaches, each corresponding to a major C++ standard, from C++98 to C++23. Additionally, we will benchmark these implementations to analyze their performance and efficiency. Finally, we will dig into the code generated by the two most used compilers on Linux platforms, GCC and Clang, and perform a thorough analysis and see which one comes out the winner.
Readers will gain a deeper understanding of Practical C++ implementation across different standards: you will see how to compute the arithmetic mean of a vector using various C++ techniques and understand the evolution of the language from C++98 to C++23. You will also gain insights into optimizing code for performance, while keeping Modern C++ coding practices in mind and learn how they can be used to write efficient and readable code...
Let us now delve into five versions of a function that calculates the average of a vector of random integers. Each version utilizes a different C++ standard, demonstrating how modern C++ simplifies and makes common programming tasks more readable, but before introducing them, here is the code that generates the vector:
// Initialize random number generator
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> value_dist(1, 100);
// Generate random vector
std::vector<int> numbers(50000);
std::ranges::generate(numbers, [&]() { return value_dist(gen); });
In C++98, we relied on manual iteration using a basicforloop:
// C++98: Classic for-loop approach
double average_cpp98(const std::vector<int>& numbers) {
int sum = 0;
for (size_t i = 0; i < numbers.size(); ++i) {
sum += numbers[i];
}
return static_cast<double>(sum) / numbers.size();
}
This approach was straightforward but lacked modern conveniences like range-based loops or built-in algorithms.
With C++11, we gained access to range-based loops, making iteration more concise and readable:
// C++11: Range-based loop
double average_cpp11(const std::vector<int>& numbers) {
int sum = 0;
for (int num : numbers) {
sum += num;
}
return static_cast<double>(sum) / numbers.size();
}
This improved readability by removing explicit indexing and is one of the many usability improvements introduced in C++11.
C++14 introduced functional-style algorithms such as std::accumulate, which simplified summing the elements:
// C++14: Using std::accumulate
double average_cpp14(const std::vector<int>& numbers) {
auto sum = std::accumulate(numbers.begin(), numbers.end(), 0);
return static_cast<double>(sum) / numbers.size();
}
This approach is more declarative and eliminated the need for a loop. C++14 focused on minor refinements and usability improvements over C++11.
C++17 introducedstd::reduce, which is optimized for parallel execution:
// C++17: Using std::reduce (supports parallel execution)
double average_cpp17(const std::vector<int>& numbers) {
int sum = std::reduce(std::execution::seq, numbers.begin(), numbers.end());
return static_cast<double>(sum) / numbers.size();
}
std::reduceprovides potential performance gains by allowing parallel execution when used withstd::execution::par. C++17 marked a shift towards greater use of parallelism and optimization in the Standard Library.
Author Bio: Ferenc-Lajos Deák is a seasoned software developer with a strong foundation in mathematics and theoretical computer science, currently based in Trondheim, Norway. His career spans roles across diverse domains, including autonomous vehicles, real-time traffic systems, multimedia, and telecommunications. An avid open-source enthusiast, he maintains several live projects
and has authored more than a dozen articles for various technical publications, focusing on one of his passions: programming.
His book Debunking C++ Myths coauthored alongside Alexandru Bolboaca, was published by Packt in December 2024.
That’s all for today.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most usefulhere.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want toadvertise with us.
If you have any suggestions or feedback, or would like us to find you a learning resource on a particular subject, just respond to this email!