-
Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels
Sydney C++ Talk - Dont Fear the Alligators
IMC is hosting a C++ meetup at our Sydney office on Thursday 25 June.
This session: Don't Fear the Alligators, is a practical deep dive with Chris Kohlhoff into allocators in modern C++.
We'll explore what problems allocators actually solve, when they genuinely help, and how they shape API and system design in performance-critical low-latency systems.
The evening schedule starts at 6pm Sydney AEST:
1. 6:00pm – Check-in, grab a drink and some pizza
2. 6:30pm – Don't Fear the Alligators
2. 7:15pm – Q&A
Food, drinks, tech goodies, and a lucky draw included.
The meetup is open to engineers at all experience levels and usually attracts a strong mix of experienced systems engineers and developers interested in modern C++.
For those unable to attend in person, the session will be filmed and published including slide on YouTube after the event.
Register here: https://www.imc.com/ap/events/engineering-deep-dives-imc-meetup
https://redd.it/1tlu0tg
@r_cpp
Building a C++ Neural Network Library from Scratch (Because I Couldn't Stand Python)
Hey everyone,
I wanted to introduce GradientCore, my open-source machine learning library written from scratch in C++.
GradientCore is my attempt at building a lightweight ML framework with a focus on performance and understanding how things work under the hood. It currently includes:
- Tensor operations with efficient memory management
- Autograd (automatic differentiation)
- Basic optimizers
- Neural network module
The project started because I personally struggle to think clearly when coding in Python. I wanted something built in C++ that I could actually understand and extend.
It began as a learning project inspired by Magicalbat’s “Coding a Machine Learning Library in C from Scratch” YouTube series. After a few failed attempts (including one very messy AI-assisted branch), I restarted clean and built it step by step.
The library is still early stage — nowhere near PyTorch level — but it’s becoming usable. All testing so far has been on my local machine, so feedback and bug reports are very welcome.
Links :-
github - https://github.com/spandan11106/GradCore-Tensor
docs - https://spandan11106.github.io/GradCore-Tensor/
blog - https://spandan11106.github.io/GradCore-Tensor/blog
I’m looking for contributors who are interested in C++ and machine learning. Even small contributions (bug fixes, documentation improvements, examples, etc.) would be greatly appreciated.
Would love to hear your thoughts or suggestions!
Thanks!
https://redd.it/1tlq21k
@r_cpp
Latte: a single-header latency measurement for quick insights
Hey /r/cpp, I've been working on a single-header latency measurement lib. Not meant for bottleneck detection or replacing Tracy/OpenTelemetry/perf/callgrind, but just for situations where I needed simple and trustable latency numbers during development.
\## The pitch:
* **2.5x faster per call than chrono** (RDTSC: \~60 cycles vs \~154 cycles)
* **Built-in statistics** (mean, median, stddev, skew, min, max, range, outliers)
* **Thread-safe** (per-thread ring buffers, zero contention)
* **Header-only** - nothing to do except placing monitoring beacons
\## Basic usage:
```cpp
Latte::Fast::Start(__func__);
DoWork(); // block of logic to measure
Latte::Fast::Stop(__func__);
// For loops/toroidal events:
for (;;) {
// ... work ...
LATTE_PULSE("MyLoop"); // records delta between successive calls
}
Technical implementation:
Three capture modes with different serialization guarantees:
\- Fast: __rdtsc
\- Mid: __rdtscp
\- Hard: _LFENCE+__rdtscp
Storage model:
\- Per-thread std::map<const char*, RingBuffer> (keys compared by pointer address, not string content)
\- Each ring buffer: alignas(64) for cache-line isolation, fixed 65k samples (configurable via BUFFER_PWR)
\- Zero allocations in hot path, ring buffers overwrite on wrap
\- Supports 64-deep nesting via per-thread SoA stack (stores ID, timestamp, capture mode)
Statistical cleaning:
Before computing stats, samples are bucketed (groups of 1000), bucket-max is recorded, then IQR filtering is applied to the maxima. This is more robust against long-tail outliers than raw IQR on samples.
Calibration:
When using Parameter::Calibrated, the framework measures and subtracts instrumentation overhead for each Start/Stop mode combination (e.g., Fast→Mid, Hard→Hard). Mixed-mode nesting is handled by storing the capture mode on the stack.
Example output:
| Component Samples Avg Median StdDev Min Max Range Outliers |
|--------------------------------------------------------------------------------------------|
| DoWork 10000 0.82 ms 0.81 ms 0.05 ms 0.79 ms 1.20 ms 0.41 ms 12 |
| InnerLoop 50000 0.15 ms 0.14 ms 0.02 ms 0.12 ms 0.35 ms 0.23 ms 3 |
With overhead correction enabled, it also dumps a calibration table showing measured overhead for each mode permutation.
Design decisions I’m curious about:
[0\] Pointer-as-key: Using const char* directly (string literals) as map keys to skip hashing. Feels hacky but saves cycles. Better alternatives?
[1\] Thread-local maps: Each thread owns its own std::map for ID→RingBuffer lookups. O(log N) per Stop(), but N is typically small. Considered flat_map but insertion cost for new IDs felt worse. Any thoughts ?
[2\] No RAII wrapper: Deliberately avoided RAII (Latte::Scope s("id")) to allow mixing Start/Stop modes and finer control. Trade-off worth it ?
Caveats:
\- x86_64 only (needs RDTSC/RDTSCP)
\- C++17
\- DumpToStream() not thread-safe - call only after workers stop
\- IDs must be string literals or stable static const char* (pointer comparison)
Nothing extravagant. Use case might be niche, I personally find it very useful for HFT/gamedev/tooling work where I just want to have quick insights without the measurement distorting results.
What do you think? Any obvious optimizations or design flaws I’m missing?
https://github.com/MoonFlowww/Latte
\##Bench
\### **ASM**
| Function | Avg (cycles) | Median (cycles) | StdDev (cycles) | Min (cycles) | Max (cycles) | Δ Min-Max (cycles) |
|:-----------------|-------------:|----------------:|----------------:|-------------:|-------------:|-------------------:|
| __rdtsc | 30.1 | 29.9 | 0.4 | 29.7 | 31.2 | 1.5 |
| __rdtscp | 57.7 | 57.5 | 0.9 | 57.3 | 62.6 | 5.2 |
| _LFENCE |
Interesting talk about profiles semantics and mechanisms in using std::cpp 2025
https://youtu.be/Z6Nkb1sCogI?si=iaBEB63D2ApUuPJ8
https://redd.it/1tlbmq0
@r_cpp
Building a Fast Lock-Free Queue in Modern C++ From Scratch
https://jaysmito.dev/blog/blog/04-fast-lockfree-queues/
https://redd.it/1tkx59y
@r_cpp
Low-level coding dataset
Disclaimer: this is a repost from something I put in LocalLLaMA, but with some tweaks for the r/cpp crowd - the version over there is more ML focused, this is more code focused
Hi all,
I've recently been thinking about putting together a community sourced coding dataset for finetuning models, with a heavy focus on cpp and systems programming.
My goal is to eventually have a model (say a finetune of Qwen3.6-27b) that is good at stuff like memory ownership, thread safety, optimization concepts, etc. Right now I feel like the coding knowledge of most locally runnable models is restricted to high-level langs like py and js.
Right now I'm thinking a jsonl file with categories like this:
\- generation: basic prompt/code output
\- optimization: heres slow/bloated code, make it better
\- debugging: im getting this error pls fix
\- organization: code review, interface design, restructuring, tradeoff decisions
\- tool_calling: exercises involving tool use and interpreting results
Does anyone have any ideas for things I'm missing? Curious to see what the people over here think about this kind of thing. Are there any knowledge gaps you guys feel current models have that we can maybe try to improve with this?
Thanks in advance for all the help!
https://redd.it/1tk9dgh
@r_cpp
From NIC to P99: Engineering Low-Latency C++ Trading Systems in 2026
https://deepengineering.substack.com/p/from-nic-to-p99-engineering-low-latency
https://redd.it/1tjxc8m
@r_cpp
Exploring ref qualifiers in C++
https://meetingcpp.com/blog/items/Exploring-ref-qualifiers-in-Cpp.html
https://redd.it/1tjni1x
@r_cpp
[RFC] Open Access to Standards Documents - LLVM Project
https://discourse.llvm.org/t/rfc-open-access-to-standards-documents/90856
https://redd.it/1tjb8kf
@r_cpp
FluxUI — write your C++ UI once, run on Windows, Linux, and Android natively
FluxUI — write your C++ UI once, run on Windows, Linux, and Android natively
Most C++ UI frameworks drop the ball on Android. FluxUI doesn't — same C++20 codebase, all three platforms. The framework handles all platform-specific details under the hood so you never have to think about them.
The API is Flutter-inspired (declarative widgets, reactive state), and there's a CLI to scaffold and run projects in two commands.
Just tagged v0.1.0. It's early but the core is solid.
GitHub: https://github.com/HeyItsBablu/flux
Feedback welcome — especially from anyone who's tried cross-platform C++ UI and given up.
https://redd.it/1tj6vin
@r_cpp
(Maybe) All The Contract Papers
https://a4z.noexcept.dev/blog/2026/05/20/The-Contract-Papers.html
https://redd.it/1tisbs2
@r_cpp
Should I continue learning C++?
I’m not sure if this is the right subreddit, but I just needed to put this somewhere. My ex (M20) and I (F20) broke up about 2 weeks ago. Before our breakup, he was teaching me C++, his favourite language. I also code, but only in Python, so C++ felt pretty different to me and I was still at a very beginner stage. The thing is, I still want to keep learning it on my own, as I find it pretty interesting. But now, every time I try to write C++, I immediately think of him and end up feeling weirdly emotionally loaded for no particular reason. It feels a bit ridiculous because it’s literally just C++. At this point I'm not sure if I should keep going with C++ or just pick up another language.
https://redd.it/1tir7yz
@r_cpp
Qt Creator 20: faster clangd
https://www.qt.io/blog/qt-creator-20-faster-clangd
https://redd.it/1tilatn
@r_cpp
Introducing Sample Profile Guided Optimization in MSVC
https://devblogs.microsoft.com/cppblog/introducing-sample-profile-guided-optimization-in-msvc
https://redd.it/1tig36r
@r_cpp
C++26: More function wrappers
https://www.sandordargo.com/blog/2026/05/20/cpp26-copyable-function
https://redd.it/1tic32u
@r_cpp
Coding puzzles in C++
https://codequizz.com
https://redd.it/1tltfpg
@r_cpp
14.7 | 14.7 | 0.1 | 14.7 | 15.3 | 0.6 |
\### **Latte**
| Function | Avg (cycles) | Median (cycles) | StdDev (cycles) | Min (cycles) | Max (cycles) | Δ Min-Max (cycles) |
|:-----------------|-------------:|----------------:|----------------:|-------------:|-------------:|-------------------:|
| Fast::Start+Stop | 60.1 | 60.0 | 0.1 | 59.9 | 60.4 | 0.5 |
| Mid::Start+Stop | 119.8 | 119.7 | 0.4 | 119.9 | 122.7 | 2.8 |
| Hard::Start+Stop | 148.5 | 148.4 | 0.5 | 147.9 | 150.4 | 2.5 |
| LATTE_PULSE | 29.9 | 29.8 | 0.1 | 29.7 | 30.3 | 0.6 |
\### **Chrono**
| Function | Avg (cycles) | Median (cycles) | StdDev (cycles) | Min (cycles) | Max (cycles) | Δ Min-Max (cycles) |
|:-----------------|-------------:|----------------:|----------------:|-------------:|-------------:|-------------------:|
| std::chrono::now | 153.9 | 153.4 | 0.4 | 153.1 | 156.9 | 3.3 |
https://redd.it/1tldryd
@r_cpp
Run CMake executable targets via the cmake command
https://a4z.noexcept.dev/blog/2026/05/23/CMake-Run-Targets.html
https://redd.it/1tlcna0
@r_cpp
I built a minimalist, lightweight Linux Task Manager in modern C++ (reading directly from /proc) — Looking for architecture feedback!
Hey everyone,
I wanted to dive deeper into Linux internals and system-level programming, so I built **LTM (Linux Task Manager)**. It’s a minimalist CLI tool written in C++17 that interacts directly with the kernel by parsing the `/proc` filesystem.
**Key Features:**
* **Ultra-lightweight:** Uses standard `dirent.h` for bare-metal file navigation and maximum memory efficiency.
* **Zero external dependencies:** Pure Modern C++ code.
* **Clean Architecture:** Properly structured with separated `src/` and `include/` layouts.
**What's next on the Roadmap:**
* Refactoring the file parsing logic to use `std::getline` for safer, dynamic text tokenization.
* Adding real-time CPU usage calculation per process.
* Implementing a sorting algorithm (via `std::vector`) to sort processes by highest RAM usage.
* Building a GUI frontend using `QtWidgets`.
The codebase is fully open-source, clean, and documented. I would love to get your feedback on the architecture, code quality, or any low-level optimizations you suggest!
**Check it out here:**[https://github.com/sudoRebel/linux-task-manager](https://github.com/sudoRebel/linux-task-manager)
If you like the approach, feel free to drop a ⭐ to support the project! Happy coding!
https://redd.it/1tl93xp
@r_cpp
I built a SQL-like relational database engine in C++ from scratch
Hey r/cpp,
I’ve been learning systems programming and database internals, so I started building **Ark** — a SQL-like relational database engine written entirely from scratch in C++.
Current features include:
* Handwritten tokenizer ( lexer )
* Recursive descent parser
* CRUD operations
* INNER / LEFT / RIGHT / FULL joins
* Aggregate functions
* `ALTER TABLE` support
* File persistence
* Custom diagnostics system
Everything is implemented manually:
* no parser generators
* no embedded SQL engines
* no external dependencies
One of the most challenging parts so far has been handling joins, schema evolution, and persistence consistency cleanly.
GitHub:
[https://github.com/kashyap-devansh/Ark](https://github.com/kashyap-devansh/Ark)
I’d especially appreciate feedback around architecture, parser design, query execution, or persistence design.
https://redd.it/1tkrhxq
@r_cpp
Why yes; Yes I will be watching this! 🙂
https://youtu.be/NXwTRzywDSk
edit: I remember playing with Cfront and then finally Borland C++ made me put Pascal aside and C++ has been my absolute favorite ever since. 😄
STL, Boost, variadic template meta-programming, MFC, been a fantastically fun time since it was always my favorite language. Don't get me wrong I love all the other grammars too. The compilers for them? C++
But no Scott Meyers?! That is surprising but then again the language has had a lot of heroes.
https://redd.it/1tk8iuy
@r_cpp
Kodsnack 703 - The subset needs to fit you
https://kodsnack.se/703/
https://redd.it/1tjpwn7
@r_cpp
Is cppreference.com compiler support up to date again?
https://en.cppreference.com/cpp/compiler_support
https://redd.it/1tjej6t
@r_cpp
C++ profiles: a chance to fix some annoying defaults? Brainstorming and ideas.
Hello everyone,
Lately I have been thinking about the opportunity that profiles could give to C++ for "better defaults" and "cleanups".
Which profiles would you like to see in an eventually profile-enforced version as "standard" or "enabled by default" that you think can be fit reasonably?
I will start:
- ununitialized variables: must use [indeterminate]
- [nodiscard] by default? Would that be possible? Maybe this changes the meaning.
- hardened std lib guarantee?
- type safety/bounds safety (in user code)
https://redd.it/1tja9zr
@r_cpp
reflection-first ORM using C++ 26
C++ 26 reflection got me excited about what future library APIs could look like, so I experimented with a small reflection-first ORM using annotations
https://github.com/swordfatih/reflect
https://redd.it/1tiw81e
@r_cpp
Coroutines, part I: Co-operators and Promises
https://www.youtube.com/watch?v=wmrW6AkRo3c
https://redd.it/1tiu1ry
@r_cpp
Conex – single-header C++20 library for condition-based binary pattern matching
I built a small single-header library called Conex for binary pattern matching with lambda conditions.
The idea: instead of hard-coded byte signatures, you express each match condition as a lambda that inspects the raw bytes. The pattern syntax is regex-style — (c0:4)(c1:8)\* means "4 bytes satisfying lambda 0, followed by zero or more 8-byte groups satisfying lambda 1".
// Find a struct by its signature + page-aligned address fields
auto result = conex::search_first(blob, "(c0:4)(c1:8)*",
[](std::span<const uint8_t> s) {
uint32_t sig; std::memcpy(&sig, s.data(), 4);
return sig == 0xDEADBEEF;
},
[](std::span<const uint8_t> s) {
uint64_t addr; std::memcpy(&addr, s.data(), 8);
return (addr & 0xFFF) == 0; // page-aligned
}
);
Useful for reverse engineering, game modding, firmware analysis, or anywhere you're scanning binary blobs for structures you can identify semantically but not by fixed offsets.
Single header, no dependencies, C++20.
[https://github.com/DanielCohen197/Conex](https://github.com/DanielCohen197/Conex)
Happy to hear feedback!
https://redd.it/1tiny5t
@r_cpp
IPC benchmark: ~3M msg/s and ~7 GB/s on macOS. Missing bare-metal Linux numbers
I've been optimizing the IPC layer of areg-sdk, an open-source C++ framework I maintain. Here are the numbers and methodology.
**What was measured**:
Numbers are taken at `mtrouter` (the framework's message router), which sees both directions simultaneously and is more accurate point in the pipeline.
* **macOS (Apple M3 Pro, LPDDR5):** \~2.5–3.0M msg/s at \~0.5 KB payload, \~6.5–7.0 GB/s at \~3 MB payload
* **Windows 11 (Intel i7-13700H, DDR4):** \~1.0–1.2M msg/s at \~0.5 KB payload, \~2.4–2.6 GB/s at \~3 MB payload
* **WSL2 (Intel i7-13700H, DDR4):** \~450–520K msg/s at \~0.5 KB payload, \~5.0–5.6 GB/s at \~3 MB (after network tuning)
* **Linux VM on macOS:** results close to macOS native
*What is included in these numbers:* TCP `localhost` loopback, 1:1 (provider -> mtrouter -> consumer). The stack includes: event creation, multithreading, event queuing, event dispatching, and socket communication. Service discovery, automatic framing, and thread dispatch are all active.
*Note:* the benchmark example (`23_pubdatarate`) is optimized for throughput pressure. It pre-builds messages to maximize network load.
*What is not included:* The consumer has a lower stable dispatch ceiling before its internal queue grows unbounded and memory climbs: *\~300–400K msg/s* on Windows, *\~500–600K msg/s* on macOS. Above those rates the dispatch thread becomes the bottleneck. I'm working on improving it.
**Missing: bare-metal Linux**
All Linux measurements so far come from VMs (WSL2 and a Linux VM on macOS). VM overhead varies too much to extrapolate confidently. Based on macOS results, bare-metal x86-64 Linux should be (estimated) \~*6.0–7.5 GB/s* for large payloads and \~*2.0–3.0M msg/s* for small payloads, *\~500K msg/s* stable dispatch.
The benchmark is self-contained. If anyone runs it on bare-metal Linux, the results would be interesting to compare. README has exact commands to set:
[https://github.com/aregtech/areg-sdk/tree/master/examples/23\_pubdatarate](https://github.com/aregtech/areg-sdk/tree/master/examples/23_pubdatarate)
**Useful data points:**
* distro/kernel
* CPU model and class (mobile/desktop/server)
* RAM type (DDR4/DDR5/LPDDR5)
* measured msg/s and data rate per recipe
* stable consumption before memory growth starts.
Happy to answer questions about methodology or implementation.
P.S. About areg-sdk: C++17 Service-oriented framework with ORPC for distributed development. Targets: Linux/Windows/macOS; RTOS is the next step. GitHub: [https://github.com/aregtech/areg-sdk](https://github.com/aregtech/areg-sdk)
https://redd.it/1til14z
@r_cpp
Hey, Anybody intrested in a Remote Robotics Simulation Engineer Job? $180/hr - $200/hr
DM me for more
# What You'll Do
Design and implement high-fidelity robot models (URDF/MJCF) with accurate kinematics, dynamics, and contact properties
Build and maintain simulation environments using MuJoCo, NVIDIA Isaac Sim, and/or Gazebo
Develop end-to-end simulation pipelines for robot training, testing, and validation
Tune physics parameters — friction, damping, inertia, actuator models — to maximize sim-to-real transfer
Integrate simulations with ROS2 for perception, planning, and control workflows
Write clean, performant code in Python and/or C++ to support simulation infrastructure
Collaborate asynchronously with robotics researchers and engineers on model accuracy and environment design
Profile and optimize simulation performance for large-scale or parallelized runs
Document simulation configurations, model parameters, and pipeline architecture
# Requirements
Strong hands-on experience with at least one major robotics simulator: MuJoCo, NVIDIA Isaac Sim, or Gazebo
Proficient in Python and/or C++ in a robotics or scientific computing context
Solid understanding of rigid-body dynamics, contact mechanics, and control theory
Experience creating and validating robot models (URDF, MJCF, or SDF formats)
Familiarity with ROS2 and its integration with simulation environments
https://redd.it/1tic2i0
@r_cpp
Virtual dispatch isn't always the slowest, and std::variant isn't always the fastest
https://shubhankar-gambhir.github.io/posts/four-ways-to-dispatch-a-runtime-selected-strategy-in-cpp/
https://redd.it/1thyi97
@r_cpp