Skip to main content C++

r/Cplusplus


“C++26 is done! — Trip report: March 2026 ISO C++ standards meeting (London Croydon, UK)”
“C++26 is done! — Trip report: March 2026 ISO C++ standards meeting (London Croydon, UK)”
News

https://herbsutter.com/2026/03/29/c26-is-done-trip-report-march-2026-iso-c-standards-meeting-london-croydon-uk/

“Reflection is by far the biggest upgrade for C++ development that we’ve shipped since the invention of templates. For details, see my June 2025 trip report and my September 2025 CppCon keynote: “Reflection: C++’s decade-defining rocket engine.” From the talk abstract:”

“C++26 has important memory safety improvements that you get just by recompiling your existing C++ code with no changes. The improvements come in two major ways.”

“No more undefined behavior (UB) for reading uninitialized local variables. This whole category of potential vulnerabilities disappears in C++26, just by recompiling your code as C++26. For more details, see my March 2025 trip report.”

“In C++26, we also have language contracts: preconditions and postconditions on function declarations and a language-supported assertion statement, all of which are infinitely better than C’s assert macro.”

std::execution is what I call “C++’s async model”: It provides a unified framework to express and control concurrency and parallelism. For details, see my July 2024 trip report. It also happens to have some important safety properties because it makes it easier to write programs that use structured (rigorously lifetime-nested) concurrency and parallelism to be data-race-free by construction. That’s a big deal.”

And we still use Visual C++ 2015 because it supports back to Windows XP.


⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅
⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅


I’m building a native Windows IDE for C++ and I need honest feedback
I’m building a native Windows IDE for C++ and I need honest feedback
Feedback

Windows C++ developers: what makes you stay on VS Code or CLion instead of trying smaller native tools?

I’m trying to understand what really matters most in a daily C++ workflow on Windows.

If you use VS Code, CLion, Visual Studio, or another setup, what keeps you there?

- startup speed?

- debugging?

- CMake support?

- extensions/plugins?

- indexing/navigation?

- reliability?

- habit/team constraints?

I’m especially interested in concrete answers from people working on real C++ projects.

If you tried a smaller/lighter C++ tool before and went back, what made you switch back?








⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅


7M Order/Sec through my Order Book
7M Order/Sec through my Order Book
Question

Recently I started implemented order matching engine. And for that I initially created a orderbook which stores ask and bids order using map<int, list<order>> and for order id look up unordered_map<order_id, order_pointer>

For the curiosity, I decided to benchmakr the code, without implementing the engine. So I grnerated orders randomly, and directly feeded it to the Orderbook. Then I benchmarked it using the google bench. According to benchmark, I am getting approx1M/s orders [add + delete + modify] in debug mode and approx 7M/s in the Release Mode.

I think there is something fishy. Till now, I have studied some github repository, and none of them have mentioned more than 2-3M orderes per second.

Github Repo :- https://github.com/naitik-2006/OrderMatcher/

Actually my plan was to optimize the order book first by replacing map with flat map and preallocating memory. But now it seems real bottelnect comes from engine not from the order book.

Any suggestion ?


Do these types of learning materials exist (huge hub-n-spoke diagrams)?
Do these types of learning materials exist (huge hub-n-spoke diagrams)?
Question
Do these types of learning materials exist (huge hub-n-spoke diagrams)?

I want to see huge diagrams with as much information on them as possible, so I can look at C++ from a bird's eye view.

I started making some diagrams - here is the github link.

They cover

  • STL Sequence Containers

  • Associative Containers

  • Container Adaptors

  • STL-Adjacent Reference Materials

  • Iterators

  • STL Algorithms

I am wanting to combine these into one hub-and-spoke diagram, have the individual diagrams there to go deeper into each topic, and keep adding to this.

I think this makes it much easier to learn, but making them is time consuming.

Does something like this already exist?

3 upvotes 8 comments

Easy Virtual Template Functions. C++26
Easy Virtual Template Functions. C++26
Tutorial

Have you ever wanted to use virtual template functions but found existing methods have so much boilerplate? Ever thought that virtual template functions could be done without it? Well, with the new reflection features, it can be!

The main goal was to minimize the amount of code required to use virtual template functions. This has been accomplished. Each base class needs to inherit only one class, and each base virtual template function requires one line of code to provide the minimal information required. This looks a lot nicer as it is very similar to how normal virtual functions are created.

Simple example:

struct D1;
struct D2;

struct Base: VTF::enable_virtual_template_functions<D1,D2>{
    template<typename T>
    Base(T* ptr): enable_virtual_template_functions(ptr){}

    template<typename T>
    int f(int a){
        constexpr auto default_function = [](Base* ptr, int a){ return 99;};
        CALL_VIRTUAL_TEMPLATE_FUNCTION(^^T,default_function,a);
    }
};

struct D1:Base{
    D1():Base(this){}

    template<typename T>
    int f(int a){
        return 11;
    }
};

struct D2:Base{
    D2():Base(this){}
    
    template<typename T>
    int f(int a){
        return 12;
    }
};

int main(){
    using PtrT = std::unique_ptr<Base>;
    PtrT a = std::make_unique<D1>();
    PtrT b = std::make_unique<D2>();
    assert((a->f<int>(1) == 11));
    assert((b->f<int>(1) == 12));
}

Godbolt link






Build Real Interactions, Powered by AI - Try Beta


Is there any relative articles or open source techniques about linux shared memory with tcp likely connection property to realize ultra-low latency between the two different remote hosts?
Is there any relative articles or open source techniques about linux shared memory with tcp likely connection property to realize ultra-low latency between the two different remote hosts?
Question

Help with an c++ app
Help with an c++ app
Answered

Can someone tell me how use the headers in c/c++? It give the possibility to use it, but I seems it don't work. Only work if I include the c file directly, but I'd want to use the headers.

P.S.: The app's name is "cxstudio" (it's android/mobile)

The code below: (2° update)

main.cpp

#include <iostream>
#include "testing.hpp"

int main() {
    testit();
    return 0;
}

testing.cpp

#include <iostream>
#include "testing.hpp"

void testit() {
    printf("Hello world!");
}

testing.hpp

#ifndef TESTING_HPP
#define TESTING_HPP

void testit();

#endif //TESTING_HPP

Makefile

# Kompilator C++
CXX = g++

all: main

main: testing.o main.cpp
	$(CXX) testing.o main.cpp -o main

testing.o: testing.cpp testing.hpp
	$(CXX) -c testing.cpp

clean:
	rm -f *.o main

Terminal (error) (if run main.cpp directly)

Compilling...

Id.lld: error: undefined symbol: testit()
>>> referenced by main.cpp
>>> /data/data/com.alif.ide.cpp/files/usr/tmp/main-a77af4.0: (main)
clang++: error: linker command failed with exit code 1 (use -v to see invo cation)

Terminal (error)

$ Is
Makefile testing.cpp
main.cpp testing.hp

$ make
g++ -c testing.cpp
g++ testing.o main.cpp -o main

$ main
bash: main: command not found

$./main
bash: ./main: Permission denied

$ chmod +x main

$./main
bash: ./main: Permission denied
$

Precompiled Headers (PCH) reduced my C++ build time from ~2m50s to ~1m08s (demo repo included)
Precompiled Headers (PCH) reduced my C++ build time from ~2m50s to ~1m08s (demo repo included)
Discussion

PCH (Precompiled Headers) is something that doesn't get talked about much in the C++ ecosystem, but it can have a huge impact on compilation times.

It becomes especially useful in projects with a large number of source files, such as game engines, complex desktop applications, or projects with many dependencies.

When compiling a C++ project, the compiler processes headers for every translation unit. Even if those headers rarely change, they still get parsed again and again for each .cpp file. This repeated work adds a lot of overhead to build times.

A good real-world example is a game engine + game project setup.
The engine code usually remains relatively stable, while the game code changes frequently. In that case, it makes sense to compile the engine-related headers once and reuse them, instead of recompiling them every time the game changes.

The same logic applies to the STL (Standard Template Library). Since we rarely modify STL headers, they are a great candidate for precompiled headers.

In many professional projects, PCH is typically configured during project setup by build engineers or senior developers. Most developers working on the project simply benefit from the faster build times without directly interacting with the configuration.

I ran a small demo to compare build times with and without PCH.

Results

Without PCH
Build time: ~162 seconds
Total time: ~2m 50s

With PCH
Build time: ~62 seconds
Total time: ~1m 08s

So roughly 2.6× faster compilation just by introducing PCH.

I also created a small demo repository with the example files and instructions if anyone wants to try it:

https://github.com/theamigoooooo/pch

Curious to hear how others here handle build time optimization in larger C++ projects (PCH, Unity builds, Modules, etc.).


The C++ AI Limbo: I know enough to distrust Copilot, but not enough to code without it. How do you actually "learn by doing" now?
The C++ AI Limbo: I know enough to distrust Copilot, but not enough to code without it. How do you actually "learn by doing" now?
Discussion

Hey everyone,

I’m hitting a strange developmental wall and I’m curious how others—especially those mentoring juniors or currently upskilling—are navigating this.

For context, I work at a Big Tech company and regularly touch a massive C++ codebase. I understand the architecture, I can navigate the legacy decisions, and I know my way around modern C++ paradigms.

But I am completely trapped in the "AI Dependency Loop."

The old adage of "just build things to learn" feels fundamentally broken for me right now. The moment I sit down to architect a side project or tackle a complex feature, the initial friction of setting up boilerplate, dealing with CMake, or resolving a convoluted template error makes me reflexively reach for an LLM.

I am stuck in an incredibly frustrating middle ground:

• The Skeptic: I know enough C++ to look at an AI’s output and immediately suspect it. I can spot when it’s hallucinating an API, ignoring memory safety, or introducing subtle Undefined Behavior. I absolutely cannot trust it blindly.

• The Dependent: Despite knowing it's flawed, I don't possess the sheer muscle memory or encyclopedic knowledge of the standard library to just hammer out the implementation at 100wpm on my own. Without the AI, I feel agonizingly slow.

Because I use AI to bypass the "struggle," I am not building the neural pathways required for true mastery. I'm just an editor of mediocre, machine-generated code.

For those of you mastering C++ in the current era:

  1. How do you force yourself to endure the necessary friction of learning when the "easy button" is ubiquitous?

  2. Have you found a workflow where AI acts as a strict Socratic tutor rather than a crutch that writes the code for you?

  3. How do you build muscle memory when the industry demands velocity?

Any harsh truths or practical frameworks would be greatly appreciated.

Would like to also add that I’m expected at my level to move fast and thus just “learn harder” isn’t gonna cut it for me.



How deeply should a developer understand C++ fundamentals?
How deeply should a developer understand C++ fundamentals?
Question

I’m currently trying to strengthen my understanding of C++, but I’m a bit confused about the right depth of learning.

There are so many topics involved, like classes/objects, memory management, STL, templates, modern C++ features, multithreading, etc. When I study a concept, I often end up wondering how deeply I should go.

For example:
• Should I just understand how to use features like classes, smart pointers, and STL containers?
• Or should I also study internal details like memory layout, compiler-generated functions, move semantics, vtables, etc.?

Sometimes I feel like I’m overthinking the depth instead of learning things systematically.

So my main questions are:

  • How deep should a developer go when learning core C++ concepts?

  • Which topics really require deep internal understanding?

  • What does a “good” understanding of C++ fundamentals actually look like?

  • What resources (books, courses, or articles) helped you understand C++ fundamentals properly?

I’d really appreciate advice from experienced C++ developers on how they approached learning the language properly.



Ask Nerial founder François Alliot & Reigns: The Witcher developers Anything


“Is C++ Dead?”
“Is C++ Dead?”
Discussion

https://deepengineering.substack.com/p/is-c-dead

“According to the January TIOBE Index, C++ is currently the fourth most popular programming language after C and Python. C++ is the main programming language used in many critical systems, including hospitals, cars, and airplanes. But dare I say it: C++ is prone to errors. And in 2024, even the U.S. government chipped in. They dropped the bomb: C and C++ are not memory-safe programming languages. In 2026, might C++ be seeing its last days?”
   https://www.tiobe.com/tiobe-index/
 
https://bidenwhitehouse.archives.gov/wp-content/uploads/2024/02/Final-ONCD-Technical-Report.pdf

No, not even close to starting to die.  New projects are being started in C++ daily.

Lynn


Built a static C++ reference site on top of cppreference
Built a static C++ reference site on top of cppreference
Discussion
Built a static C++ reference site on top of cppreference

I've been experimenting with different ways to navigate C++ reference material and ended up building a static reference site on top of the cppreference offline dump: https://cppdocs.dev

This is NOT a replacement for cppreference. All core reference data comes from it, this is more of a usability/navigation layer.

Things I added:

  • Version filtering (C++11 → C++26)

  • Fully static, minimal JS

  • Fast static search

  • Task-oriented entry points (Ranges, Algorithms, Headers, etc.)

  • Domain-based browsing (memory model, concurrency, compile-time stuff)

  • Built-in bookmarks

  • Spotlight-style page switcher

  • Optional vim-style keybindings (gg, etc.)

The main problem I kept running into was knowing rougly what I needed but not remembering the exact name or header. Cppreference is fantatsic but can feel like a raw dump sometimes. This is an experiment in adding more structure and cross-linking to make it easier to explore

Content is Markdown-first, contributions are just simple PRs. Version metadata comes from cppreference so it's not perfect everywhere yet.

Broken pages, missing stuff, confusing summaries --> issues and PRs welcome.

Repo: https://github.com/cppdocs/cppdocs Hosted on GitHub Pages.

146 upvotes 30 comments


Reducing header include compilation overhead?
Reducing header include compilation overhead?
Question

Hey everybody. I am working on a 2D game engine in C++ using SDL. So far everything has been working fairly well, but one thing I'm running into at around 3000 lines (as if that really means anything) is includes causing slight changes in certain classes to trigger the recompilation of a bunch of other classes.

I have a class called Globals that stores some static variables like debug booleans for certain render overlays. It also contains the default tile width/height and some other things that I would like to store in a single place. This class is completely defined in the header (which I imagine is the issue).

I use the Globals class in a bunch of different code around the code base, so when I set DEBUG_RENDERING to true, every user of Globals.hpp must be recompiled. How do I get around this while still being able to contain all of these members in the same place? I haven't gotten into macros or other preprocessor directives yet, so maybe that could help? Any direction would be appreciated.


Looking to get images of diskettes/CD for Borland C++ or Turbo C++
Looking to get images of diskettes/CD for Borland C++ or Turbo C++
Question

I amn a retired s/w developer. I have loads of C++ source code that I wrote in the 90s and I have a yen to play around with it now that I have the leisure It was written with Turbo C++ and I still have my old copy, manuals + diskettes. But no way of reading the diskettes even if they are readable. I have tried the usual USB diskette readers but they just do not work for me.

I have set up an Oracle VirtualBox environment for DOS 6.22 so it is pretty much what I used in the mid 1990s for personal software development projects. I just need to download the diskettes from somewhere or find a 3.5 diskette drive that actually works. Do they exist?

I have tried internet archive and Embarcadero and just cannot find them. All the links I have found on Redddit and other sites have proved to be defunct

Would appreciate any help in tracking it down Thanks



⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅


How to prepare for 1st C++ OOP Exam?
How to prepare for 1st C++ OOP Exam?
Homework

This is what we will be covering: Major Areas to Study

Major Areas to Study

• Compilation process (editing, preprocessing, compiling, linking, loading)

• Compiled vs interpreted languages

• Data types and variable initialization

• Input/output using cin and cout

• Types of errors (compile-time, run-time, logic)

• Conditionals (if/else, switch)

• Loops (for, while, do-while)

• Tracing loops and nested conditionals

• Functions (pass-by-value vs pass-by-reference)

• Arrays and vectors

• Basic classes (constructors, private/public, getters/setters)

• Exception handling (try/throw/catch)

• Basic string operations


Making a wrapper for SIMD operations
Making a wrapper for SIMD operations
Question

I want to make a simple wrapping library for completing SIMD operations in C++. I want something like this:

size_t SIZE = 1'000'000;
std::vector<float> a(SIZE);
std::vector<float> b(SIZE);

// initialize a and b with some data

std::vector<float> c(SIZE);
foo::add(a, b, c, 0, SIZE);

/*
elements from 0 (inclusive) to SIZE (exclusive) of a and b are added with SIMD operations (see later for how that's done), result stored in c

achieves the same end result as this:
for (size_t i = 0; i < SIZE; i++) {
    c[i] = a[i] + b[i];
}
*/

Upon starting the program, runtime CPU detection will determine what your CPU's SIMD capabilities are. Upon calling foo::add, the library will dispatch the add workload to specialized functions which use SIMD intrinsics to do the work.

For example, if during runtime, your CPU is determined to have AVX2 support but no AVX512F support, foo::add will do the bulk of the addition calculations with 8 32-bit floats at a time in AVX's 256-bit registers. Once there are fewer than 8 indices left in the vector to add, it will fill in the rest of the last 256-bit batch with 0s and discard the unused data. Same idea happens if you have AVX512F support, it does the calculations 16 at a time in the 512-bit registers.

That's the whole idea. I think it'd be pretty useful, and I don't know why it hasn't been done already. Any thoughts?

(less important) Implementation details so far:

I would want to implement as many operations which are supported by the SIMD hardware as possible, including vertical (operations between multiple vectors, like adding each corresponding element in my example above) and horizontal operations (operations within a single vector, like summing all elements into a single sum value).

I would make heavy use of metaprogramming for writing this since it's a lot of repetition and overloading functions for different datatypes. I'd probably make a whole separate program, probably in JS, just to write the library files.

The easiest way to do this would probably be to have three distinct types of functions called for every operation. I call these the frontend, the dispatcher, and the backend.

The frontend in my example is called foo::add, and takes three array/vector types (whether they be std::vectors, std::arrays, references to fixed-size C-style arrays, or pointers to non-fixed size C-style arrays or heap-allocated arrays), a start index, and an end index*****. These would use templates for fixed-size array sizing, but would be manually overloaded for arrays with elements of specific types (so there'd be a separate foo::add overload for floats, for doubles, for int32_t's, etc). The frontend gathers sizing and index info from each array parameter and passes this data to the dispatcher in the form of pointers to the starting element of each array and size information.

The dispatcher checks some const global bool flag variables (which are initialized with the result of a checker function at the beginning of the program) to see which backend functions it can use to actually complete the operations. I tried to make this a while ago GCC/Clang's [[gnu::target("avx, or something else")]], but I want to check the CPU manually this time since GNU attributes aren't portable, and also I was running into problems, I forget exactly what but I think it had something to do with PE executables not fully supporting the feature and GCC playing better than Clang.

The backend functions use SIMD intrinsics to implement the operations. This is where it gets tricky because most compilers seem to have an all-or-nothing approach to implementing SIMD operations. If you want to use SIMD intrinsics in a C++ program, you have to enable it explicitly with the compiler's flags (like "-msse", "-mavx", "-mavx2", etc for GCC/Clang). This allows you to use the intrinsics******. But, it also allows the compiler to use those instructions for any other reason in its optimization efforts, and the compiler can sprinkle these instructions wherever it wants. This makes isolating AVX instructions only to specific functions (which are only called when the dispatcher is certain that the CPU supports these instructions) difficult without using separate source files for every SIMD version type, which I will have to do. I got this all wrong on my first real attempt on this library, which I posted on this sub along with a link to a GitHub repository which I have since taken down as I work on an improvement.

I want to support ARM SIMD types as well, but I will focus on x86 first. I also want to implement a way to specify which SIMD types to implement when compiling the library, to potentially save executable space by not including certain functions. This would of course also require the dispatch functions to change based on these options.

I wish to eventually expand this into a large parallel computing library for SIMD operations, multithreaded SIMD operations, and GPU computing operations with at least OpenCL and CUDA support, all of which autodetect during runtime to speed up operations.

I also have very little experience making larger C++ projects or libraries or running a GitHub repository (which will host this project). Any tips for new people?

*****I want to implement a way where the start and end index for each of the (in this example, 3) array parameters can be tuned individually. So you can for example add elements 2-12 of array A and elements 100-110 of array B into elements 56-66 of array C. Not sure how I'd do that in an acceptable way.

******GCC seems (?) to allow you to use intrinsics for certain instruction set extensions even if those flags are not passed to the compiler. This is super helpful when I am trying to isolate certain instructions only to parts of the code that run after I check the CPU. But it seems Clang does not have this (it might give a warning or an error, I forget), and I don't know about MSVC or any other compilers.

An unimportant detail about older SIMD instruction set extensions:

I could implement MMX or 3DNow operations in addition to the planned SSE, AVX, and AVX512 (doing an additional batch of 2 indices in the 64-bit registers in my example of adding 32-bit floats) but MMX is deprecated, and 3DNow is actually long gone and no longer included in modern CPUs. Both of these 64-bit SIMD instruction set extensions have their sets of 64-bit registers overlayed on top of the 80-bit x87 FPU registers (with MMX focusing on integer operations and 3DNow implementing FP operations), and using x87 at the same time at MMX or 3DNow without calling explicit state-clearing instructions causes issues (although it seems that completing scalar operations on floats is typically done in SSE registers rather than x87 registers nowadays). Since these dated extensions would really only be used very briefly at the end of an SIMD operation on an array/vector, they would probably just take up excess space in executables for very little performance benefit.

But, since I plan on implementing a way to choose which SIMD types are actually implemented when compiling the library, I could easily implement these older types, and just have them disabled by default (so they won't be taking up space in executables). The user of my library could explicitly enable these when targeting older systems.



Modern binary file handling in C++?
Modern binary file handling in C++?
Discussion
Modern binary file handling in C++?

I am wondering what is the currently best/most modern/idiomatic way of handling binary files in C++? The streaming interface seems really focused on text files wanting to read multiple diffrent structs look like a pain. Then there is C stdio but what is... well a C API. I know this is not a easy topic because of casting and lifetimes but I want to know what gets used currently for this. For now I build a lite ressource managing class around std::FILE * but error checking and access is still very verbose like known from C APIs.

EDIT: To give a usage example: I do have an ELF file loader and executor for a embedded like device.

13 upvotes 22 comments

C++ typedef vs using
C++ typedef vs using
Discussion

In modern C++, small improvements in readability can make a big difference in long-term maintainability.
One simple example is replacing typedef with using for type aliases.
In the example below, it’s not immediately obvious that Predicate is the name of the function type that returns bool and takes an int when written with typedef. You have to mentally parse the syntax to understand it. With using, the intent is much clearer and easier to read. (And yes… saying “using using” is a bit funny 😄)
Since C++11, using has become the preferred approach. It’s cleaner, more expressive, and most importantly, it supports template aliases, something typedef simply cannot do. That’s why you’ll see using widely adopted in modern codebases, libraries, and frameworks.
While typedef still works, there’s very little reason to choose it in new projects today.
Are you consistently using using in your C++ code, or do you still come across typedef in your projects?


Tiny-gpu-compiler: An educational MLIR-based compiler targeting open-source GPU hardware
Tiny-gpu-compiler: An educational MLIR-based compiler targeting open-source GPU hardware
Discussion
Tiny-gpu-compiler: An educational MLIR-based compiler targeting open-source GPU hardware

I built an open-source compiler that uses MLIR to compile a C-like GPU kernel
language down to 16-bit binary instructions targeting tiny-gpu, an open-source GPU written in Verilog.

The goal is to make the full compilation pipeline from source to silicon
understandable. The project includes an interactive web visualizer where you
can write a kernel, see the TinyGPU dialect IR get generated, watch register
allocation happen, inspect color-coded binary encoding, and step through
cycle-accurate GPU execution – all in the browser.

Technical details:

  • Custom tinygpu MLIR dialect with 15 operations defined in TableGen ODS, each mapping directly to hardware capabilities (arithmetic, memory, control flow, special register reads)

  • All values are i8 matching the hardware’s 8-bit data path

  • Linear scan register allocator over 13 GPRs (R0-R12), with R13/R14/R15 reserved for blockIdx/blockDim/threadIdx

  • Binary emitter producing 16-bit instruction words that match tiny-gpu’s ISA encoding exactly (verified against the Verilog decoder)

  • Control flow lowering from structured if/else and for-loops to explicit basic blocks with BRnzp (conditional branch on NZP flags) and JMP

The compilation pipeline follows the standard MLIR pattern:

.tgc Source --> Lexer/Parser --> AST --> MLIRGen (TinyGPU dialect)
--> Register Allocation --> Binary Emission --> 16-bit instructions

The web visualizer reimplements the pipeline in TypeScript for in-browser
compilation, plus a cycle-accurate GPU simulator ported from the Verilog RTL.

Github Link : https://github.com/gautam1858/tiny-gpu-compiler

Links:

45 upvotes 2 comments



Used poorly, AI can make applicants seem generic. Used well, it can help them stand out.




SpaceX: Satellite Beam Planning (Optimization, Latency, C/C++)
SpaceX: Satellite Beam Planning (Optimization, Latency, C/C++)
Question

Hello!

I am a recruiter at SpaceX and I am on the hunt for talented low-latency C++ programmers.

The Satellite Beam Planning Team is fully onsite in Redmond, WA and they work on optimizing our constellation. They tackle fascinating challenges involving the beams being cast down to earth, and how satellites communicate via laser links amongst themselves. This is a massive latency/optimization problem we are solving!

What sets top performers apart is rock-solid fundamentals that we can build upon.

Key topics that align well:

•            Computer Architecture

•             C++ (performance-focused, beyond OOP)

•             Algorithms (with emphasis on Linear Algebra and Trigonometry)

•             3D Geometry and Vector Math

•             Assembly and x86

If you are interested, apply!!




Need to learn C++ in 1 day(there is a catch)
[deleted]
Need to learn C++ in 1 day(there is a catch)
Question

I need to be able to answer very simple questions. There will be no coding questions.

- How does the object oriented programming differ from structured programming?

- With example, explain the multiple inheritance and function overloading in OOP. Also, list the operators which cannot be overloaded.

- Why is inheritance required in OOP? Explain different types of inheritances with suitable diagrams

-  How does ambiguity arise in Multipath inheritance? How can you remove this type of ambiguity? Illustrate it with suitable example

- Explain constructor and destructor call sequence in single and multiple inheritance in CPP.

Questions are of this level. So you get the gist. I want a proper book which covers these topics. I tried robert lafore cpp book but it was not to the point.



インテル® Core™ Ultra 7 搭載 Intel vPro®のThinkPad X13 Gen 6は、約933gの超軽量設計。持ち運びしやすく、ハイブリッドワークにも最適なバランスを実現し、どこでも快適に作業できるAI PCです。


What about a "swift" attribute for switch statements?
What about a "swift" attribute for switch statements?
Question

In this thread I learned how the Swift language has changed things with switch statements and I was wondering if others would like a "swift" attribute that could precede the switch keyword.

This documentation page for switch says:

attr (optional) switch ( init-statement (optional) condition) statement

But I didn't see any attributes in the following page that would be a different name for "swift" or that make sense to use prior to the switch keyword.

Attribute specifier sequence (since C++11) - cppreference.com

An example of the code would be:

[[swift]] switch (rc){
case 3:

case 4:

default:
}

Where only one case is executed and break statements aren't needed. Support for something like this would help me get rid of a number of lines of code. Thanks in advance.


Webinar on how to build your own programming language in C++ from the developers of a static analyzer
Webinar on how to build your own programming language in C++ from the developers of a static analyzer
Tutorial

PVS-Studio presents a series of webinars on how to build your own programming language in C++. In the first session, PVS-Studio will go over what's inside the "black box". In clear and plain terms, they'll explain what a lexer, parser, a semantic analyzer, and an evaluator are.

Yuri Minaev, C++ architect at PVS-Studio, will talk about what these components are, why they're needed, and how they work. Welcome to join




In-process app-layer cache (gRPC + REST/JSON): which requirement matters most? (Poll)
In-process app-layer cache (gRPC + REST/JSON): which requirement matters most? (Poll)
Feedback

Hi everyone. I’m doing requirement analysis for a graduate capstone. The project is a backend/application-layer caching component intended for services that expose both gRPC (protobuf) and REST/JSON.

I’m collecting quick input to prioritize requirements and define acceptance criteria (performance, correctness, operability). I’m not looking for code just what experienced engineers would rank as most important. If you can, comment with one real incident you’ve seen (stale data, stampede, debugging nightmare, security issue, etc.).

Poll: If you could prioritize only ONE requirement area first, which would it be?

Poll closed 8 votes
Invalidation correctness (avoid stale/incorrect responses)
3
Stampede protection (single-flight / request coalescing)
0
Observability & debugging (why hit/miss/stale; key/entry inspection)
3
Security controls (redaction + admin endpoint access control)
1
Performance targets (p95 latency / DB load reduction)
1
Integration ergonomics (easy adoption across gRPC + REST)
0
Core contributors
All

Looking for recommendations for modern standards (C++20 and beyond)
Looking for recommendations for modern standards (C++20 and beyond)
Question

Hello everyone.

I'm currently working on a ~10 years old software written in C++, with a team (including myself) that is used to work mostly with C++17 features, and a tiny sprinkle of C++20 here and there (mostly ranges and basic coroutines).

I come here looking for recommendations on resources, be it online content, books, or personal wisdom, that can ignite sparks of curiosity and desires to push for modern coding C++ practices in my team. Starting from C++20 itself.

I know I can go and browse all new features for major versions, but I would love to read about their real-world impact on your projects.

What content have you read that left you like "wait, can I do that!?"?

What feature or trick has proven to be more useful for you in the last couple of years?

What helped you in your latest refactoring of legacy code?

Any piece of advice is highly appreciated. Thanks.



Is your child gifted? Find out free (2 min)




Created a C++ 14 Mqtt 5 client library for open source - KMMqtt
Created a C++ 14 Mqtt 5 client library for open source - KMMqtt
Discussion

Hey,

Interested in feedback and generally just sharing this library if anyone wants to try use MQTT in their project.

I come from a game dev background and recently had to work with MQTT, so I decided to write my own MQTT 5 C++ client library in my spare time as a way to learn what it’s like to design and ship a library end-to-end.

I’ve tried to keep the design game-dev friendly and cross-platform (with future console support in mind). I started this early last year, working on it in small chunks each week, and learned a lot about library architecture and portability along the way.

There are still things I plan to improve when I got a bit more time from my next hobby project, for example:

  • Abstracting threading/timing instead of relying directly on std::thread / std::chrono (similar to how sockets are handled)

  • Supporting custom memory allocators

  • Removing a couple of unnecessary heap allocations

Uses:

  • MQTT 5

  • C++14 compatible

  • CMake for builds

Testing is currently unit tests + a sample app (no real-world integration).

Thought I'd share it here, I'm happy to receive feedback, and feel free to use it:
https://github.com/KMiseckas/kmMqtt

Thanks






⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅




(early-2000s-style 3D game dev help) OSMesa 6.5 is not rendering 3D graphics in the software fallback mode but it works in hardware mode
(early-2000s-style 3D game dev help) OSMesa 6.5 is not rendering 3D graphics in the software fallback mode but it works in hardware mode
Question

I am trying to make a 3D game using 20-year-old software (Mesa & OSMesa 6.5, SDL 1.2.15, OpenGL 1.5, MSVC++2005 on XP SP3) that runs on 20+-year-old hardware. I have gotten up to the point where I have gotten a spinning cube to spin in place in a window. I have also tried to do some video API abstraction (i.e. putting abstracted calls to the Mesa/SDL functions into platform_win32_sdl.h). The hardware mode uses SDL to create an OpenGL window and draws to that, but the software fallback I wrote uses the regular Win32 APIs (because I wasn't able to blit the OSMesa framebuffer to an SDL window) and OSMesa (software rendering to just a raw bitmap framebuffer in RAM). The hardware mode works great and runs on OSes as old as Win98SE if I install the Windows Installer 2.0 (the program that installs MSI files, not the program that installs Windows itself) and the MSVC++2005 redist. but the software mode (which I only implemented just in case I need it when I port the game to other platforms) will only render the glClearColor but not any of the 3D cube. I find it interesting that it is rendering the background clear color (proving that OSMesa is infact working) but the 3D cube won't render, how do I fix that?

Download the code and the compiled EXE using https://www.dropbox.com/scl/fi/smgccs5prihgwb7vcab26/SDLTest-20260202-001.zip?rlkey=vo107ilk5v65htk07ne86gfb4&st=7v3dkb5e&dl=0 The SDLTest.exe in the debug folder does not work correctly but the SDLTest.exe in the release folder works correctly, and I have put all the required DLLs minus the VC redists in there for you. The options.txt in the same directory as the SDLTest.exe will allow you to switch between hardware OpenGL and the currently non-functional software OSMesa modes by editing the first line of the text file to "renderMode=hw_opengl" or "renderMode=sw_osmesa".

I went over the code several times and never found anything wrong, and none of ChatGPT's advice was able to help me either. If you have any more questions or comments about my build setup, feel free to ask!


Scoped enums: a weaker version of C++'s enum classes emulated in C23.
Scoped enums: a weaker version of C++'s enum classes emulated in C23.
Feedback
Scoped enums: a weaker version of C++'s enum classes emulated in C23.

Tinkering around with constexpr structs, I came up with this:

#include <stdio.h>


#define concat_aux(a, b) a##b
#define concat(a, b) concat_aux(a, b)


#define have_same_type(obj_1, obj_2)        \
        _Generic                            \ 
        (                                   \
            (obj_1),                        \
                                            \
            typeof_unqual(obj_2): 1,        \
            default      : 0                \
        )


#define decl_enum_scoped(name, underlying_type, ...)            \
        typedef struct                                          \
        {                                                       \
            /* Assuming this "trait" is defined somewhere: */   \
            static_assert(is_integral(underlying_type));        \ 
            underlying_type int_const_value;                    \
        } name;                                                 \
                                                                \
        typedef struct                                          \
        {                                                       \
            name __VA_ARGS__ /* optional:*/ __VA_OPT__(,) END;  \
        } concat(name, _entries);                               \         
        constexpr concat(name, _entries) concat(name, _)


// This is necessary for getting the wrapped integer constant: 
#define V(e) (e).int_const_value 


#define enum_scoped_eq(e_1, e_2)                            \
        ({                                                  \
            static_assert(have_same_type(e_1, e_2),         \
            "Enum types do not match");                     \
            V(e_1) == V(e_2);                               \
        })


// Non GNU C version: 
/*
#define enum_scoped_eq(e_1, e_2, ret)                           \
        do  {                                                   \
                static_assert(have_same_type(e_1, e_2),         \
                "Enum types do not match");                     \
                *ret = V(e_1) == V(e_2);                        \
            } while (0)
                                                                */


// The last item is just for counting (defaults to zero, if not directly initialized):                       
decl_enum_scoped(Color, char, RED, GREEN, BLUE, YELLOW) = {0, 1, 2, 3, 4};
decl_enum_scoped(Direction, char, UP, DOWN, LEFT, RIGHT) = {0, 1, 2, 3, 4};


int main(void)
{
    Color c_1 = Color_.BLUE;
    Color c_2 = Color_.YELLOW;
    Direction d_1 = Direction_.UP;
    // Would fail: Direction d_2 = Color_.GREEN;


    switch( V(c_1) )
    {
        case V(Color_.RED): puts("Red"); break;
        case V(Color_.GREEN): puts("Green"); break;
        case V(Color_.BLUE): puts("Blue"); break;
    }


    // Would fail: enum_scoped_eq(c_1, d_1); 


    bool res = enum_scoped_eq(c_1, c_2);
    res ? puts("true") : puts("false");


    return 0;
}

It is definitely not as powerful as C++'s enum classes, but I think it is pretty close (at, least, without resorting to absurd macro magic).

Currently, it only works with GCC (version 15.2 - tested here). Clang (21.1.0) has a bug which causes constexpr structs not to yield integer constants. They are already aware of it, though, so it should be fixed at some point.

19 upvotes 6 comments


Why aren't partial classes supported on C++?
Why aren't partial classes supported on C++?
Discussion
Why aren't partial classes supported on C++?

Is there a specific design reason for not to? Because it seems like a pretty useful feature. For example, if you have pre-compiled some big-ass code but just want to add a little tinker to a class, you have to edit the original code and compile it all over again? Seems like unnecessary overhead. Besides, breaking big code over small files (if well-done, obviously) tends to make it so much better organized, in comparison to a single giant file.



Migaku helps you learn 1,000 words in 90 days, mastering foreign conversations. Start learning now.


Have a ML compiler interview
Have a ML compiler interview
Discussion

Hello everyone 👋🏼,I have an ML compiler interview scheduled in a week. I've already completed the initial coding assessment and a coding interview. The recruiter mentioned the next round will focus mainly on C++. I have a basic idea of what to expect, but I'm unsure about the depth they'll go into. If anyone has recently gone through this interview process and can share their experience, it would be really helpful!



A question for template experts
A question for template experts
Answered

A question for template experts, regarding the deducing of function argument types. I'm making a function similar to std::format, it should accept a constant string literal and a set of arguments for substitution as input. During compilation, it is necessary to parse the string and prepare an array with a description of the substitution parameters. And for this, I would like to get both the length of the substitution string and the number of arguments as compile-time constants in one parameter during compilation. But I can't describe the parameter in such a way that the compiler can deduce the required type. It only works if I duplicate the substitution string twice:

template<typename T> struct const_lit;

template<size_t N>
struct const_lit<const char(&)[N]> {
    enum {Count = N};
};

template<size_t PatternLen, typename ...Args>
struct param_info {
    // Information about a portion of the pattern - this is either a piece of the pattern of length `len`, starting from `from`, or an argument with index `from`.
    struct portion {
        portion() = default;
        unsigned from: 16 = 0;
        unsigned len: 15 = 0;
        unsigned is_param: 1 = 0;
    };
    // A string of length PatternLen can have a maximum of 1 + (PatternLen - 2 * 2 / 3) portions (PatternLen includes 0)
    // For example "-{}-{}-{}-" - one portion of one character at the beginning of the string and two portions for every three characters.
    // PatternLen == 11, portions: [0, 1] [p0] [3, 1] [p1] [6, 1] [p2] [9, 1]
    portion portions_[1 + (PatternLen - 2 * 2 / 3)];
    unsigned actual_used_{}; // Here we will save how many portions actually turned out during pattern parsing

    consteval param_info(const char(&pattern)[PatternLen]) {
        // parse pattern, fill portions_ and set actual_used_
        .....
    }
};

template<typename T, typename...Args>
constexpr auto subst(T&& dummy_for_deduce, const param_info<const_lit<T>::Count, std::type_identity_t<Args>...>& pattern, Args&&...args) {
    /// We take the pre-calculated portions_ from the pattern and fill the result based on the information in them
    ......
}

#define SUBST(par) par, par

void test() {
    // This works
    subst(SUBST("test {2}, {1}"), 1, 2); // Expands into the construct -> subst("test {2}, {1}", "test {2}, {1}", 1, 2);
    // Based on the first "test {2}, {1}" - Count = 14 is deduced, based on 1, 2 - int, int is deduced.
    // Then all the types for the second parameter become known, and the second "test {1}, {2}" is converted to
    // param_info<14, std::type_identity_t<int>, std::type_identity_t<int>>
}

Is it possible to achieve the same, but using the pattern only once? The point is that I need to know the length of the pattern string as a compilation constant in order to use it to calculate the maximum size of the array of portions of information about the pattern. One solution is to simply ignore the length of the pattern, and either just take a large size in advance array:

    portion portions_[128];

which leads to unnecessary waste of memory, or focus on the number of arguments:

    portion portions_[sizeof...(Args) * 2 + 1];

but this will not work with patterns like "{1}-{1}-{1}-{1}".

I made an option with using the pattern once, as in std::format, where at the compilation stage the template string is only checked for correctness, and then at runtime it is parsed again every time, but this loses in execution time by about two times, judging by benchmarks (the last and penultimate option)


Micro-optimizations to its madness
Micro-optimizations to its madness
Answered

Hey everyone,

A friend and I were joking about premature optimization in hobby projects that will never see the light of day. You know, scaling projects for 0 reason or trying to get the fastest algorithm for the simples of the problems. The joke lead us conversation converged into the next question: What is the theoretically fastest way to calculate the square root of an integer in the range [0, 100]?

A friend suggested [Square Root Decomposition](https://cp-algorithms.com/data_structures/sqrt_decomposition.html), but that a huge algorithmic solution for such an small data problem. I’m looking for something that is better at this. I know some of you are way smarter and come up with solutions to this kind of problems that are way better. The only constraint is that you can not precompute all the solutions before hand, that would make the problem extremely easy.

Good luck with this! We are not smart enough or know enough math to come to a good solution, but I was wondering if any of you could give a better solution than the above. Thanks for reading! :D



Need Help Learning or For Homework?
Need Help Learning or For Homework?
Homework

Do you need some help learning C++ or help with a beginner or intermediate homework coding assignment with C++ (or potentially other coding languages depending)? Just to add, for homework assignments and such, I obviously can't do it for you, but I can guide you and answer questions. I am newly graduated with a CS degree from U of M. I really miss the basics. So if you need some help, let me know! (Just to add, this isn't like for money or anything.)

PS- Perhaps it's an odd offer, I just had a lot of fun helping an online friend when he has questions or is working on an project, as he's learning to code with c++ for funsies and in prep for an upcoming class that he'll be starting soon.

THIS IS NOT FOR MONEYS. This is because I need a distraction and think it is fun to help with stuff and miss the basics.



Download maps, track your hike, and journal your journey on ePaper.




I'm confused, I need advice! Codex or Claude?
I'm confused, I need advice! Codex or Claude?
Question

Hi! From time to time, I develop simple programs for personal needs and beyond in C++ (more as an architect than a programmer). Usually, they are about 2-3 thousand lines of code, sometimes more. Essentially, it involves various audio and image processing, etc. In other words, these are tasks of medium complexity - not rocket science, but not a simple landing page either.

In general, I usually use Gemini Pro, and when it starts acting up (it often likes to skip a block, delete a block, or mess with other parts of the code while fixing one specific part, etc.), I go to Microsoft Copilot (as far as I know, it uses ChatGPT 5+). If that doesn't work either, as a last resort (which helps in 90% of cases), I go to Claude. Sonnet 4.5 handles what I need perfectly.

Now I’ve decided to buy a subscription, but I saw a lot of complaints about Claude - there was some kind of outage or glitch. On the other hand, I know that Codex exists. And it’s unclear to me which product would suit me better. Unfortunately, you can't try Codex anywhere before buying.

Essentially, I need the following:

  1. To write code based on manuals and instructions as the primary vector.

  2. To be able to discuss project details in plain human language, not just technical terms (since I am less of a programmer than the AI and don't have instant access to all the world's knowledge).

  3. To avoid the issues Gemini Pro sometimes has (laziness, deleting code blocks, modifying unrelated parts of the project... it really likes to break things sometimes).

I use the web interface (since the frameworks I use usually allow me to edit a maximum of 3-4 code files), if that’s important. It might seem funny to real professional programmers, but nevertheless.

The question is-which one would actually suit my tasks and requests better, after all? Sometimes I hear that Codex is more accurate, while there are complaints about Claude; but on the other hand-despite the technical issues (at times) - I feel comfortable with Claude. I can't afford two subscriptions right now. So, what should I choose?

Please share your experience (especially if you have used or are currently using both products).

P.S.: What version of ChatGPT is used in MS Copilot? And is this version far from Codex in terms of programming knowledge? How far?


Exploring what it means to embed CUDA directly into a high-level language runtime
Exploring what it means to embed CUDA directly into a high-level language runtime
Discussion

Over the past months I’ve been experimenting with something that started as a personal engineering challenge: embedding native CUDA execution directly into a high-level language runtime, specifically PHP, using a C/C++ extension.

The motivation wasn’t to compete with existing ML frameworks or to build a production-ready solution, but to better understand the trade-offs involved when GPU memory management, kernel compilation and execution scheduling live inside the language VM itself instead of behind an external runtime like Python or a vendor abstraction such as cuDNN.

One of the first challenges was deciding how much abstraction should exist at the language level. In this experiment, kernels are compiled at runtime (JIT) into PTX and executed directly, without relying on cuDNN, cuBLAS or other NVIDIA-provided high-level components. Each kernel is independent and explicit, which makes performance characteristics easier to reason about, but also pushes more responsibility into the runtime design.

Another interesting area was memory ownership. Because everything runs inside the PHP VM, GPU memory allocation, lifetime, and synchronization have to coexist with PHP’s own memory model. This raised practical questions around async execution, stream synchronization, and how much implicit behavior is acceptable before things become surprising or unsafe.

There’s also the question of ergonomics. PHP isn’t typically associated with numerical computing, yet features like operator overloading and attributes make it possible to express GPU operations in a way that remains readable while still mapping cleanly to CUDA semantics underneath. Whether this is a good idea or not is very much an open question, and part of the reason I’m sharing this.

I’m curious how others who have worked with CUDA or language runtimes think about this approach. In particular, I’d love to hear perspectives on potential performance pitfalls, VM integration issues, and whether keeping kernels fully independent (without cuDNN-style abstractions) is a sensible trade-off for this kind of experiment.

For reference, I’ve published a working implementation that explores these ideas here:
https://github.com/lcmialichi/php-cuda-ext

This is still experimental and very much a learning exercise, but I’ve already learned a lot from pushing GPU computing into a place it doesn’t normally live.


Learning programming by teaching it in short explanations — does this actually help?
Learning programming by teaching it in short explanations — does this actually help?
Discussion

While learning DSA and backend fundamentals, I noticed something interesting: I understand concepts much better when I try to explain them in very simple terms.

Recently, I’ve been experimenting with short explanations (30–60 seconds), focusing more on intuition and common mistakes than full code.

I wanted to ask:

  • Does learning by teaching work for you?

  • Do short explanations help, or do you prefer long tutorials?

I started sharing these explanations publicly to stay consistent. The page is called CodeAndQuery (not promoting—just context).

Would really appreciate thoughts from people who’ve been learning programming for a while.



We analyzed the European IT job market: salaries, hiring trends, and career insights 2025
We analyzed the European IT job market: salaries, hiring trends, and career insights 2025
Discussion

We published a 64-page report about the European IT job market. It’s based on survey answers from over 15'000 IT professionals and data from 23'000 job posts across Europe.

It covers salary benchmarks in seven European countries, including C/C++, as well as recruitment realities, AI’s impact on careers, and the challenges junior developers face when entering the industry.

Check out the full report (No paywalls, no gatekeeping): https://static.germantechjobs.de/market-reports/European-Transparent-IT-Job-Market-Report-2025.pdf


⚔️ Full Blown RPG in your browser: No Downloads ❌ Just Click and Go! ✅




C++ is the first language in which I had to use books, I had to literally study it like I study for school, and memorise such deep concepts.
C++ is the first language in which I had to use books, I had to literally study it like I study for school, and memorise such deep concepts.
Discussion

Well I learnt a bit of python in the past, and used to do web dev(all of this is as a hobby since i'm still in HC), and even went further and learnt react and nextjs, till I really got burnt out since it was pretty much mostly UI, which can sometimes be frustrating(people who do web dev can def relate).

But honestly, I'm QUITE ENJOYING IT. I finally feel that I'm actually programming, I feel that i'm understanding how actually code works, I feel I'm actually learning and being productive, and it's just satisfying. It's been only about 2-3 months, but I've got to say I went quite a long way, and since then, it's been a stable part of my day. And I never imagined I would ever have to read A BOOK to learn a programming language, and yeah sometimes stuff is frustrating, but when it finally clicks, it's just awesome.


Wood Boiler Controller
Wood Boiler Controller
Discussion
Wood Boiler Controller

I have been working on a central controller for a wood boiler system I will be building this summer. I have posted a few questions in separate posts and rather than creating post after post - I figure I will make one that I can add and update to as I build and stumble.

The Basics:

  • A box housing fire which will heat unpressurized glycol. Not being pressurized will simplify the build and won't need pressure vessel design consideration. Temperature probe will monitor glycol temp. K-type thermocouple will monitor flue temps. And a pressure probe to monitor/confirm no pressurizing of the system

  • A servo actuated damper will regulate the rate of combustion air into the fire box, a draft fan blowing up into the flue pipe will aid in draft flow and reducing flue gas temperature.

  • Glycol and flue temperatures are used in a control loop to adjust damper position and PWM duty cycle to draft fan.

  • A while loop utilizes Glycol pressure and both temperatures to initiate a safety procedure if any exceed their safety setpoint. A siren and strobe light are activated, damper and draft are closed, and heat is dumped to all heating zones.

  • Two zone loops: First loop heats house via heat exchanger installed in existing furnace, and DHW is heated via glycol-water heat exchanger. Second loop supplies glycol-air heat exchangers in two shops.

  • A control box at the boiler will house Arduino pro mini, 128x64 display, relays, power supplies, etc required.

The Code:

// INCLUDE ANY LIBRARIES HERE


#include "Servo.h"
#include "max6675.h"
#include <OneWire.h>
#include <DallasTemperature.h>


#define OWbus A0
OneWire oneWire(OWbus);
DallasTemperature sensors(&oneWire);


int flueDO = 7;
int flueCS = 8;
int flueCLK = 9;


MAX6675 thermocouple(flueCLK, flueCS, flueDO);


int sensorA0 = A0;   //Boiler glycol temp probe
int sensorA2 = A2;   //Boiler glycol pressure probe


int sensorvalueA0 = 0;  // Initial variable to store the value coming from the sensor
int sensorvalueA1 = 0;  // Initial variable to store the value coming from the sensor
int sensorvalueA2 = 0;  // Initial variable to store the value coming from the sensor


int maxpointA0 = 100; //Upper safe temp and alarm set point for Boiler GLYCOL (right now in degC)
int minpointA0 = 25; //Lower runnin temp for Boiler GLYCOL below which indicates flame out (right now in degC)
int maxpointA1 = 500; //Upper safe temp and alarm set point for Boiler FLUE temperature degC
int minpointA1 = 25; //Lower runnin temp for Boiler FLUE below which indicates flam out degC
int maxpointA2 = 1024; //Upper safe pressure and alarm set point for Boiler GLYCOL


int idealminA0 = 50; //Ideal minimum GLYCOL temperature in boiler
int idealmaxA0 = 70; //Ideal maximum GLYCOL temperature in boiler
int idealminA1 = 120; //Ideal minimum FLUE temperature in boiler
int idealmaxA1 = 275; //Ideal maximum FLUE temperature in boiler


const int alarm = A1; // alarm buzzer


unsigned long previousmils = 0;  // will store last time flue temp was updated
const long interval2 = 6000;  // interval at which to check flue temp - reset to 500 after testing


Servo Damper; // creates servo object to control
unsigned long previoussec = 0;  // will store last time Damper was updated
const long interval = 6000;  // interval at which to adjust damper (miliseconds) - reset to 60,000 after testing
int val = 180; // initial servo position


int PWM = 125; // fan duty cycle - sets blower fan initial speed


//=================================================================//
//                  SETUP                                          //
//=================================================================//
void setup() {
 
//start serial connection
  Serial.begin(9600);
  sensors.begin();


Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);


// configure i/o pins 
pinMode(13, INPUT_PULLUP); //Shop thermostst
pinMode(12, INPUT_PULLUP); //House thermostat
pinMode(11, INPUT_PULLUP); //DHW thermostat
pinMode(10, INPUT_PULLUP); //Big shed thermostat
pinMode(6, OUTPUT); //Boiler blower PWM
Damper.attach(5);   // attaches the servo on pin 5 to the Servo object //Boiler damper
pinMode(4, OUTPUT); //Shop fan relay
pinMode(3, OUTPUT); //House furnace fan relay
pinMode(2, OUTPUT); //Big shed fan relay
pinMode(1, OUTPUT); //Pump-1 relay
pinMode(0, OUTPUT); //Pump-2 relay


pinMode(A5, OUTPUT); // Red lamp relay
pinMode(A4, OUTPUT); // Amber lamp relay
pinMode(A3, OUTPUT); // Green lamp relay
pinMode(A1, OUTPUT); // Siren relay
}


//=================================================================//
//                  LOOP                                           //
//=================================================================//
void loop() {
  
// First read boiler temp and pressures 
unsigned long currentmils = millis();


  if (currentmils - previousmils > interval2) {
   previousmils = currentmils;
   sensorvalueA1 = thermocouple.readCelsius();
   sensors.requestTemperatures(); // Send command to all sensors on the one-wire bus
   sensorvalueA0 = sensors.getTempCByIndex(0);
   sensorvalueA2 = analogRead(sensorA2);


   Serial.print(sensorvalueA0);
   Serial.print("Glycol Temp  ");
   //Serial.print(sensorvalueA1);
   //Serial.print("Flue Temp  ");
   //Serial.print(sensorvalueA2);
   //Serial.print("Glycol Pressure  ");
   //Serial.print(val);
   //Serial.print("Damper position  ");
  }


// This block of code to control status lights and alarm


while (sensorvalueA0 > maxpointA0 || sensorvalueA1 > maxpointA1 || sensorvalueA2 > maxpointA2) {
  ALARM();
  }
  digitalWrite(alarm, LOW);
  digitalWrite(A5, LOW); 


if (sensorvalueA0 < minpointA0 || sensorvalueA1 < minpointA1 ) {
  digitalWrite(A4, HIGH); // TYurn LED AMBER on 
  } else { 
    digitalWrite(A3, HIGH); // Turn LED GREEN on
    digitalWrite(A4, LOW); 
  }


// add code here for i2c display
  //display: welcome on start up (this will be coded in void-setup)
  //         glycol temp, flue temp, ambient temp, glycol pressure, components running....
  //         "ALARM" pressure, flue T and glycol T (this will be coded in void-alarm)



// This block of code will control boiler
// if sensorvalueA0 < idealmin --increas val
// if sensorvalueA0 > idealmax -- decrease VAL
// if between -- val no change
unsigned long currentsec = millis();


  if (currentsec - previoussec > interval) {
   previoussec = currentsec;
    if (sensorvalueA0 < idealminA0) {
      val += 5;
      PWM += 5; 
    }else if (sensorvalueA0 > idealmaxA0) {
      val -= 5;
      PWM -= 5; 
  }
  }


Damper.write(val); //sets damper servo position
analogWrite(6, PWM); //sets blower speed





// This block of code to control zone-1 Shop heat House furnace and DHW
  
  int house = digitalRead(12); // Read thermostat for House
  int DHW = digitalRead(11); // Read thermostat for DHW
    if (house == LOW || DHW == LOW) { // Call for heat by either house or DHW 
     digitalWrite(1, HIGH); // Turn on pump-1 feeding House & DHW
     } else {
      digitalWrite(1, LOW);
    }
    if (house == LOW) { // Turn on House furnace blower
      digitalWrite(3, HIGH);
    } else {
      digitalWrite(3, LOW);
    }



// This block of code to control zone-2 Shop and Big shed


  int big = digitalRead(10); // Read thermostat for big shed
  int shop = digitalRead(13); // Read thermostat for shop
    if (big == LOW || shop == LOW) { // Call for heat by either Big shed or Shop
     digitalWrite(0, HIGH); // Turn on pump-1 feeding Big shed & Shop
     } else {
      digitalWrite(0, LOW);
    }
    if (big == LOW) { // Turn on Big shed furnace blower
      digitalWrite(2, HIGH);
    } else {
      digitalWrite(2, LOW);
    }
    if (shop == LOW) { // Turn on Shop furnace blower
      digitalWrite(4, HIGH);
    } else {
      digitalWrite(4, LOW);
    }


  


}



void ALARM() {
digitalWrite(A5, HIGH); //Need to recode to turn RGB LED RED
digitalWrite(A4, LOW);
digitalWrite(A3, LOW);
digitalWrite(1, HIGH); //Turn heating loop1 on
digitalWrite(0, HIGH); //Turn heating loop2 on
digitalWrite(2, HIGH); //Dump heat into Big shed
digitalWrite(4, HIGH); //Dump heat into shop
digitalWrite(3, HIGH); //Dump heat into house
Damper.write(0);       //Close boiler damper
digitalWrite(6, LOW);  //Turn off boiler blower
digitalWrite(alarm, HIGH);
           
}



void summer() {
// maybe setting summer-specific loops focusing on DHW and reduced boiler load



}




void winter(){
// maybe setting winter-specific loops focusing on ballanced heat distribution and "safety" prioritizing house loop as T lowers



}
5 upvotes 12 comments

Is there any good plotting library in C++ ?
Is there any good plotting library in C++ ?
Question

Hey folks! I've been assigned into a project where I have to make a lot of plots on some algorithms. After reviewing the implementation I have found a huge bottleneck between executing the algorithm and generating the animation that visualizes the execution.

The current implementation is writing all the generated data when executing the algorithms into a JSON file. Then reading this JSON file from a python script that uses maptlotlib to generate the plots to eventually construct a video animation with FFmpeg.

Not only this 3 step process slows down the execution by a lot but also ends ups generating huge JSONs that occupy 11MB per file (the algorithm uses a lot of matrixes). I have already tried to use the GNU libraries for plotting but I don't find the results really good. I have already checked the library wrappers for matplotlib in C++ such as matplotlib-cpp but I don't like the idea of them using python under the hood, as it is essentially doing the same thing but removing the JSON storage part.

Any recommendations for optimizing this pipeline ? There has to be a better way of plotting this. Extra points if someone discovers how to do the ffmpeg thing while the algorithm is executing.

Extra question: Is there any better format of storing this information ?



Next steps to programming
Next steps to programming
Question
Next steps to programming

Hello, Im a 16 year old student that loves to program. Ive learned python in the past and I know the fundamentals to C++, or at least I think (I know how to work with OOP pretty decently).

Thing is, now that i have this bunch of info, I want to take it up a level, either learning web development or game dev, but I have no idea on how to start.

I've looked everywhere, but everyone says to learn fundamentals about API's or other stuff that heavily confuses me.

Im willing to genuinely put effort into my autonomous studying, but I want to create projects aswell: I think that the main problem behind this confusion is that I dont really have a precise goal, I just love programming.

What can I do? Im honestly lost, but I really want to pursue this passion of mine

4 upvotes 13 comments

The Expanse. Wishlist the new sci-fi RPG 🚀





C++ roles paying from 90K GBP in UK: what level of competition to expect?
C++ roles paying from 90K GBP in UK: what level of competition to expect?
Question
C++ roles paying from 90K: what level of competition to expect?

I am an experienced dev willing to transition to C++ as my main language. I have working knowledge of it and some experience using it commercially in niche settings (CUDA kernels, native Node.js modules, small custom 3D manipulation tools, etc.) I have a CS degree and some postgraduate research experience, so I am probably better than an average JS/Python coder at algorithms/maths/low-level stuff. But I do not consider myself a quant dev material. I am now trying to understand what caliber of roles I can realistically aim for and how much more I need to prepare. I know there are companies like Bloomberg who will hire for such roles without requiring to really know C++ (I cleared their tech rounds some years ago, then failed HR). But normally, you will be tested on language knowledge. I thought I know it well enough to answer almost any question, but playing with cppquiz.org made me doubt it. Is there anyone (on either side of interviews) who can sched some light on what level of C++ language knowledge is generally expected mid/senior position in a non-finance org or a junior-level role in finance?

6 upvotes 17 comments


Should I bite the bullet and start using a switch here?
Should I bite the bullet and start using a switch here?
Question

The following is the event loop of the middle tier of my code generator. It's 53 lines long and uses a number of else ifs. I think switch helps to convey the big picture, but it would add 8 lines to my event loop. Would usingswitch be a good idea here? Thanks in advance.

  ::std::deque<::cmwRequest> requests;
  for(;;){
    auto cqs=ring->submit();
    for(int s2ind=-1;auto const* cq:cqs){
      if(cq->res<=0){
        ::syslog(LOG_ERR,"%d Op failed %llu %d",pid,cq->user_data,cq->res);
        if(cq->res<0){
          if(::ioUring::SaveOutput==cq->user_data||::ioUring::Fsync==cq->user_data)continue;
          if(-EPIPE!=cq->res)exitFailure();
        }
        frntBuf.reset();
        ::front::marshal<udpPacketMax>(frntBuf,{"Back tier vanished"});
        for(auto& r:requests){frntBuf.send(&r.frnt.addr,r.frnt.len);}
        requests.clear();
        cmwBuf.compressedReset();
        ring->close(cmwBuf.sock);
        ::login(cmwBuf,cred,sa);
      }else if(::ioUring::Recvmsg==cq->user_data){
        ::Socky frnt;
        int tracy=0;
        try{
          auto spn=ring->checkMsg(*cq,frnt);
          ++tracy;
          auto& req=requests.emplace_back(ReceiveBuffer<SameFormat,::int16_t>{spn},frnt);
          ++tracy;
          ::back::marshal<::messageID::generate,700000>(cmwBuf,req);
          cmwBuf.compress();
          ring->send();
        }catch(::std::exception& e){
          ::syslog(LOG_ERR,"%d Accept request:%s",pid,e.what());
          if(tracy>0)ring->sendto(s2ind,frnt,e.what());
          if(tracy>1)requests.pop_back();
        }
      }else if(::ioUring::Send==cq->user_data)ring->tallyBytes(cq->res);
      else if(::ioUring::Recv9==cq->user_data)ring->recv(cmwBuf.gothd());
      else if(::ioUring::Recv==cq->user_data){
        assert(!requests.empty());
        auto& req=requests.front();
        try{
          cmwBuf.decompress();
          if(giveBool(cmwBuf)){
            req.saveOutput();
            ring->sendto(s2ind,req.frnt);
          }else ring->sendto(s2ind,req.frnt,"CMW:",cmwBuf.giveStringView());
          requests.pop_front();
        }catch(::std::exception& e){
          ::syslog(LOG_ERR,"%d Reply from CMW %s",pid,e.what());
          ring->sendto(s2ind,req.frnt,e.what());
          requests.pop_front();
        }
        ring->recv9();
      }else ::bail("Unknown user_data %llu",cq->user_data);
    }
  }


Diversify your portfolio with gold, which often moves independently of equities and bonds.


Looking for a open source project to Contribute
Looking for a open source project to Contribute
Discussion
Looking for a open source project to Contribute

Hi everyone! I’m looking to get into open source and want to start contributing to a project. My main skills are in C++ and Python(but I am open in any language), and I’d love to work on something where I can learn new technologies and improve my coding skills.

If you know any repositories or projects that are welcoming to new contributors, I’d really appreciate any suggestions or pointers. Thanks a lot!

9 upvotes 10 comments




Could you guys help me with something?
Could you guys help me with something?
Question

Heya! It's me again! I'm currently working on a complete refactor of my old DND game I had made now a year ago. At the time, I had just started programming and barely knew anything (not that I'm an expert or even mediocre now, I'm still a novice). I'm having a bit of a conundrum. I'll simplify the problem (there are many more variables in actuality, but the core of the issue can be explained with barely 2).

struct Base_weapon {
    string name;
    string power_suffix
    int damage;
    Base_weapon(string name, string power_suffix, int damage)
        : name(name), power_suffix(power_suffix), damage(damage) {}
    virtual void weapon_ability() = 0;
};

so I have a basic struct, from which I have 2 derivates.

Common_weapon {
    using Base_weapon::Base_weapon;
    void weapon_ability() override { std::cout << "nothing"; }
};
struct Flaming_weapon {
    using Base_weapon::Base_weapon;
    void weapon_ability() override { std::cout << "flames"; }
};

Base_weapon will be inserted in another struct

struct Player {
    Base_weapon* weapon1 = nullptr;
    Base_weapon* weapon2 = nullptr;
    Base_weapon* weapon3 = nullptr;
    Player(Base_weapon* w1, Base_weapon* w2, Base_weapon* w3) :
        weapon1(w1), weapon2(w2), weapon3(w3) {}
    void special_abilty() = 0;
};

aaand Player has a derivate, Mage

struct Mage : Player {
    using Player::Player;
    void special_ability() override { //here lays the problem }
};

This is the core of the conundrum. The Mage's ability is to "enchant" a weapon, AKA making it go from Common_weapon to Flaming_weapon. The only problem is that I've got no idea how to do this. Say I have a Common_weapon sword("sword", " ", 3) , how do I turn it into a Flamig_weapon flaming_sword("sword", "flaming", 4) while it's actively weapon1 in Player?

Is it even possible to do such a thing?




Laptop Magazine's "Best Overall Docking Station" for 2025


I built a C++ CLI tool that instantly finds and opens your GitHub projects (wiff git)
I built a C++ CLI tool that instantly finds and opens your GitHub projects (wiff git)
Discussion
I built a C++ CLI tool that instantly finds and opens your GitHub projects (wiff git)

I just finished a small but useful (to me) CLI tool written in C++, and I’d love some real feedback from people who live in the terminal. Currently only works for linux users.

Usage:

> wiff git <project-name> [opener]

Install is super easy:

  1. Download the .deb for your arch here:
    https://github.com/ChrisEberleSchool/Wiff/releases/tag/v1.1.2

  2. In terminal run this command:

arm64:

> sudo apt install ./wiff-1.1.2-Linux-arm64.deb

x86_64

> sudo apt install ./wiff-1.1.2-Linux-x86_64.deb

It now works system wide with wiff.

12 upvotes 6 comments

Open Source Low-Latency C++ Order Book Engine
Open Source Low-Latency C++ Order Book Engine
Feedback
Open Source Low-Latency C++ Order Book Engine

Hey r/highfreqtrading,
I’m a first-year CS student and super interested in HFT. I’ve been working on a fast order book engine and wanted to share it here to get some feedback and maybe connect with people in the industry.

Main goal was to make it as fast and low-latency as possible. I wrote everything in C++, built my own data structures for orders and prices, and tried to keep things really efficient. I also set up a bunch of tests and benchmarks to see how it performs.

Structures I used: chunked bitmap, vector-backed node pool and an intrusive index-based linked list.

The benchmarks I achieved are latencies p50=42ns, p99=250ns and p99.9=334ns on an order book with 100k orders inside.

Some of the optimizations I did: Cache-aware data layouts, custom memory pooling to eliminate allocation jitter, CPU affinity tuning and targeted profiling of hot paths.

Here’s the repo.

Happy to answer any questions or discuss implementation details! Would also love any feedback or advice on breaking into HFT.

104 upvotes 34 comments