Edited by humans. Written by AI. How our editing works
BUZZRAGNews. Trends. Ideas — distilled in minutes.
All articles

C++ Range Algorithms Make Code Actually Readable

Intel engineer shows how C++ parallel range algorithms transform confusing word-counting code into something humans can actually understand.

Written by AI. Tyler Nakamura

April 21, 20265 min read
Share:
CppCon 2025 talk announcement featuring lightning bolts and mountains, with speaker Ruslan Arutyunyan discussing parallel…

Photo: CppCon / YouTube

Okay, real talk: most programming language improvements are like getting a slightly better version of something you already kind of tolerated. Faster compile times? Cool. New syntax sugar? Whatever. But every once in a while, something comes along that makes you genuinely rethink how you write code.

Ruslan Arutyunyan, a Senior Middleware Development Engineer at Intel and co-chair of the C++ Standard Committee's Concurrency and Parallelism group, just dropped a lightning talk at CppCon 2025 that perfectly captures one of those moments. He's showing how parallel range algorithms—a newer C++ feature—can transform genuinely confusing code into something a human brain can actually parse.

The Problem: C++17's Backwards Brain Damage

Arutyunyan's example is deceptively simple: count the words in a string. Not exactly rocket science, right? But the C++17 implementation he shows is... a lot.

With C++17's parallel algorithms, you're stuck using transform_reduce, which—and this is the good part—takes its arguments in what Arutyunyan calls "the funniest thing": the reduce function comes first, and the transform function comes second. You know, backwards from what you're actually doing.

"We need to do transform reduce because I think we don't have anything better in C++ 17 without parallel range algorithms," Arutyunyan explained during his talk.

The algorithm works by comparing two offset sequences of the same string—one missing the last character, one missing the first—to detect word boundaries. When you find a non-alphabetic character followed by an alphabetic one, that's the start of a new word. Simple concept, absolutely brutal implementation.

You have to manually manage two sequences, convert your boolean check to an integer so it can be reduced, and then reduce all those integers. Oh, and there's corner case handling at the end that Arutyunyan doesn't even bother explaining because "it doesn't matter for the purpose of this talk." When your edge cases are too annoying to explain in a four-minute lightning talk, you might have a readability problem.

The Solution: Actually Saying What You Mean

Now here's the range algorithm version, and honestly, it's kind of beautiful.

Instead of transform_reduce, you use count_if—which Arutyunyan notes is "much more logical for this use case." Instead of manually creating two offset sequences, you use zip with take and drop views to create those same offsets declaratively. The piping syntax makes it crystal clear what's happening: you're zipping the text with a view of itself, taking from one perspective and dropping from another.

"We use zip which does exactly the same cuts the same sequence like one from the end and another one from the beginning," he said, walking through the new approach.

Then you pass a lambda that unpacks the zipped tuple—a pair of character references—and returns a boolean directly. No integer conversion, no mental gymnastics about what's being transformed versus reduced. Just: "Is this character pair the start of a new word? Yes or no."

The check itself is identical in both versions: first character is not alphabetic, second character is alphabetic. But in the range version, you can actually see that logic without having to first decode the ceremony around it.

Why This Actually Matters

I cover a lot of tech stuff where the improvements are incremental—5% faster, 10% more efficient, whatever. This is different. This is about the cognitive load of understanding code.

Arutyunyan's whole talk is the "basically end" of a longer presentation he didn't have time to finish—"If you weren't on my talk, shame on you," he joked—but these two slides capture something important about where C++ is heading.

The language has spent decades optimizing for machine efficiency at the cost of human comprehension. Templates, metaprogramming, all the stuff that makes C++ powerful also makes it genuinely hard to read and maintain. Range algorithms represent a shift: you can have both performance and code that looks like what it does.

This matters especially in parallel programming, where bugs are already harder to reason about. When your word-counting algorithm requires you to mentally juggle sequence offsets, function parameter ordering, and type conversions just to understand the basic logic, you're one tired afternoon away from a subtle race condition.

The Bigger Picture

What's interesting is who's pushing this. Arutyunyan isn't some academic theorist—he's the lead developer of Intel's oneAPI DPC++ library and contributes to Threading Building Blocks. He's working on actual production codebases where performance is non-negotiable but so is maintainability.

He's also actively shaping the C++ standard, with several accepted proposals and current work on std::simd enhancements and Senders/Receivers. When someone at this level of the ecosystem says "actually, we should prioritize readable code," that's not idealism—it's pragmatism from someone who's seen what happens when smart people can't understand their own code six months later.

The CppCon talk itself was delivered in person in Aurora, Colorado, which Arutyunyan emphasized matters: "Coming here in person is so much better. I've tried to watch talks online. It can be harder to concentrate... here as well, you can actually ask the presenters questions. You can talk to the person sitting next to you."

There's something fitting about a talk on code readability being delivered in a format that prioritizes human connection and understanding over remote efficiency. Sometimes the slightly harder path is actually the better one.

Range algorithms won't make bad programmers good, and they won't magically solve parallel programming's inherent complexity. But they might make the difference between code that works and code that also makes sense when you look at it again next year. In a language as gnarly as C++, that's not nothing.

—Tyler Nakamura

From the BuzzRAG Team

We Watch Tech YouTube So You Don't Have To

Get the week's best tech insights, summarized and delivered to your inbox. No fluff, no spam.

Weekly digestNo spamUnsubscribe anytime

More Like This

Dark blue presentation slide with cyan geometric lines displaying the title and speaker name Richard Thomson from Utah C++…

How to Build Git Version Control Into Your Apps

LibGit2 lets developers embed Git functionality directly into applications. Here's what that actually looks like in practice, and why it matters.

Tyler Nakamura·2 months ago·6 min read
Retro-styled conference poster advertising Klaus Iglberger's C++ Software Design workshop on April 30th for £345 or £90 for…

Why Your C++ Code Is Secretly Unmaintainable

Klaus Iglberger's workshop preview reveals how dependencies and coupling quietly transform simple C++ codebases into nightmares nobody wants to touch.

Marcus Chen-Ramirez·2 months ago·5 min read
Diagram showing the scan algorithm with five data blocks, their sums (18, 15, 14, 19, 8), and resulting prefix sums (0, 18,…

Unlocking C++ Efficiency: Lazy Ranges & Parallelism

Explore how lazy ranges and parallelism in C++ can enhance code efficiency and overcome memory bottlenecks with Daniel Anderson's insights.

Dev Kapoor·5 months ago·3 min read
A comprehensive table displaying oneDPL algorithms categorized into five columns, showing implemented features in green and…

C++ Parallel Range Algorithms: What's Actually Changing

Ruslan Arutyunyan breaks down P3179, the proposal bringing parallel execution to C++ ranges—and why the design choices matter more than you'd think.

Yuki Okonkwo·4 months ago·6 min read
Jonathan Müller speaking at CppCon 2025 about Cache-Friendly C++, scheduled for September 13-19

Unlocking C++ Performance: The Cache-Friendly Approach

Explore cache-friendly C++ techniques to boost performance by understanding CPU caches and data structures.

Tyler Nakamura·5 months ago·3 min read
C++ code snippet showing enum with bitwise OR operation, questioning whether the implementation approach is correct

C++ APIs: Lessons from Code Review at CppCon

Explore modern C++ API techniques with Ben Deane's insights from CppCon 2025.

Mike Sullivan·5 months ago·4 min read
A person in red presents a high-end PC with dual fans to another man on a purple background with "BUILDING FOR GREG…

Building a 64-Core Threadripper for a Linux Legend

Level1Techs built a custom 64-core Threadripper PC for Linux kernel maintainer Greg Kroah-Hartman. Here's why every component choice matters.

Tyler Nakamura·3 months ago·6 min read
Woman wearing headphones smiling at camera next to blue AI agent icon and workflow diagram showing act, tools, and verify…

GitHub's Agentic Workflows Let You Automate Repos in English

GitHub's new Agentic Workflows turn plain English into repository automation. No YAML required—just describe what you want and AI handles the complexity.

Tyler Nakamura·3 months ago·6 min read

RAG·vector embedding

2026-04-21
1,282 tokens1536-dimmodel text-embedding-3-small

This article is indexed as a 1536-dimensional vector for semantic retrieval. Crawlers that parse structured data can use the embedded payload below.