r/Cplusplus • • Aug 22 '25

Discussion I built a Mandelbrot viewer in C++ and put it as my wallpaper

2.7k Upvotes

Written in C++, it can scale up to its 64-bit float precision limit and uses native multithreading+tile parallelization for quick and smooth computation. I used WebAssembly for visualization and to port it on wallpaper. I've also made this wallpaper available for download in my open-source interactive wallpaper app if you're interested: https://github.com/underpig1/octos/

If you want some more technical details on how I actually made it, I wrote a little write-up here: https://github.com/underpig1/octos-community/tree/master/src/fractal#technical-details

Let me know your thoughts/feedback!


r/Cplusplus • • 23d ago

Feedback Finally built something in C++ I’m super proud of! (Goodbye, basic calculator 👋) 🎯

Post image
308 Upvotes

Hey everyone!

​I'm a beginner at C++, and up until now, the only thing I had made was the classic basic calculator that everyone builds when starting out. 😅

​I wanted to step it up a bit and built a Number Guessing Game, and it turned out so much fun! It's the first project I've made that I'm genuinely proud of, so I wanted to show off what it looks like in the terminal 🌸🤭ik it's pretty basic for all u pros but i've started just a week ago..ig that counts for smthing 😋🥲(PS:Open for all constructive feedbacks😌)


r/Cplusplus • • Nov 03 '25

Feedback I made a 3D ASCII Game Engine in Windows Terminal

Post image
294 Upvotes

Github: https://github.com/JohnMega/3DConsoleGame/tree/master

Demonstrasion: https://www.youtube.com/watch?v=gkDSImgfPus

The engine itself consists of a map editor (wc) and the game itself, which can run these maps.

There is also multiplayer. That is, you can test the maps with your friends.


r/Cplusplus • • Oct 22 '25

Discussion Messing with the C++ ABI

Post image
272 Upvotes

This works, at least on g++ 15.1.0 and clang++ 20.1.7 on Windows.

edit: no I don't have any more pixels


r/Cplusplus • • Oct 08 '26

Feedback I built an HTTP server from scratch in C++ using raw TCP sockets

Post image
267 Upvotes

I wanted to understand what actually happens underneath HTTP — not just use a framework that handles it for me.

So I went down to the socket level.

No frameworks. No HTTP libraries. Just C++, TCP sockets, and bytes.

The server creates a TCP socket, binds it to an address and port, starts listening for connections, accepts clients, reads the incoming bytes, and sends back a manually constructed HTTP response.

GitHub: https://github.com/harisahmed05/http-server

If you found it insightful, consider giving the repo a star — it really means a lot and keeps me motivated to build more.


r/Cplusplus • • Nov 16 '25

Discussion C++ named parameters

Post image
264 Upvotes

Unlike Python, C++ doesn’t allow you to pass positional named arguments (yet!). For example, let’s say you have a function that takes 6 parameters, and the last 5 parameters have default values. If you want to change the sixth parameter’s value, you must also write the 4 parameters before it. To me that’s a major inconvenience. It would also be very confusing to a code reviewer as to what value goes with what parameter. But there is a solution for it. You can put the default parameters inside a struct and pass it as the single last parameter.

See the code snippet.


r/Cplusplus • • Sep 04 '25

Question Sorry for being born I guess...

Post image
257 Upvotes

how the hell do I read this?


r/Cplusplus • • Dec 03 '25

Question Why is C++ so huge?

Post image
251 Upvotes

I'm working on a clang/LLVM/musl/libc++ toolchain for cross-compilation. The toolchain produces static binaries and statically links musl, libc++, libc++abi and libunwind etc.

libc++ and friends have been compiled with link time optimizations enabled. musl has NOT because of some incompatibility errors. ALL library code has been compiled as -fPIC and using hardening options.

And yet, a C++ Hello World with all possible size optimizations that I know of is still over 10 times as big as the C variant. Removing -fPIE and changing -static-pie to -static reduces the size only to 500k.

std::println() is even worse at ~700k.

I thought the entire point of C++ over C was the fact that the abstractions were 0 cost, which is to say they can be optimized away. Here, I am giving the compiler perfect information and tell it, as much as I can, to spend all the time it needs on compilation (it does take a minute), but it still produces a binary that's 10x the size.

What's going on?


r/Cplusplus • • Apr 10 '26

Feedback My 1st C++ Project - 12 months in ..

Post image
240 Upvotes

hi - I started c++ programming about 12 months ago and for my 1st project I decided to code a pretty comprehensive gui framework - with only GLFW being the only dependency to manage raw OS calls.

I've learnt a hell of a lot over the past year so if anyone wants some advice on GUI systems then let me know.

In the meantime check out my YouTube channel that has a few basic gui fundamentals videos.


r/Cplusplus • • May 06 '26 Heartwarming

Discussion Beginner C++ Study Guide (What Actually Helped Me)

217 Upvotes

When I started learning C++, I felt quite lost. The language seemed huge and everything I’d heard about the language made it seem impossibly difficult, and like you had to be a genius to use it. I’m sure there are a few posts on here aimed for beginners, but I’d like to share my journey as someone who remembers what being a beginner was like, and what helped me most.

This is the path I took that helped things finally start clicking for me, and landed me a graduate dev role in the EDA industry I’m starting in June, entirely from self study. I thought I’d share because this language is honestly so fascinating and I’d love to be able to help introduce and make the learning experience easier for people who are in the position I was when I started. I also think there’s a massive misunderstanding that C++ is just legacy code that is rarely used in industry, which I dislike as originally this is something I believed. This couldn’t be further from the truth imo and is the main language of choice in many performance critical industries, some being very lucrative such as:

Game dev/Game engine dev
Graphics rendering
Computer vision
HFT/Quant trading systems development
EDA
HPC
AI inference
Database development
Many desktop applications
Medical devices
Performance critical projects in FAANG/MAANG
Simulation
Defence
Real time/embedded systems

This is off the top of my head, but if any of these are industries that interest you, C++ is a must. If you’re a student like me (take this with a pinch of salt as I am not in industry yet, nor do I know the job market inside out), then it’s worth noting that universities are pushing C/C++ less, and a majority of highly skilled/specialised C++ devs are getting closer to retirement, so the Junior/mid C++ talent pool is declining while the demand for C++ devs is increasing in a very compute based era (ai inference, high frequency/quant trading as these companies make an insane amount of money from good devs and seem to be making more and more, defense as gov spending on defense is rising etc.
Again, please take this with a pinch of salt as no one knows what the job market will look like in 5 years with AI and layoffs etc, but I’d also imagine that specialised C++ devs are harder to replace than CRUD/frontend devs, in which there are undoubtedly more jobs, but less differentiating talent. Any devs experienced in industry reading this, I’d love to hear your thoughts on this, so please share your opinion :)

\*\*1. Start with learncpp.com\*\*
Genuinely one of the best resources for beginners.
Don’t rush through chapters. Make sure you actually understand:

references

pointers

memory (stack vs heap, basic understanding of what “memory” actually is at the lower level)

RAII

move/copy semantics

templates (just the basics first, but after you have a good understanding, there’s a lot of awesome and very interesting things you can do with them, such as moving branching logic to compile time as opposed to runtime)

const correctness

The quizzes are useful too, to check your understanding.

\*\*2. Don’t just learn syntax, understand what your machine does with your code\*\*

This was probably the biggest shift for me.
C++ started making far more sense once I began learning:

operating systems

computer architecture

caches/cache lines

concurrency

memory layout

Youll start developing intuition for performance and behaviour instead of just memorising rules.

For example:

why vectors are usually faster than linked lists

why allocations are expensive

why cache locality matters

why copies can hurt performance (and where they won’t have much of an effect)

why in some cases a good memory layout can actually be more performant than a better time complexity. E.g why iterating through a small vector linearly is quicker than binary search.

\*\*3. Implement your own STL features\*\*
This helped me MASSIVELY and specifically made RAII, move/copy ctors/dtors, memory and iterator invalidation click, so don’t skip this even if you’re clueless at first.

Try building simplified versions of:

std::vector

std::string

std::unique\\_ptr

std::shared\\_ptr

You’ll naturally learn:

dynamic allocation

move/copy constructors

iterator invalidation

ownership

RAII

memory growth strategies

You do NOT need to perfectly recreate the STL. The goal is understanding. Your first implementations won’t be great, and that’s fine. After iterating and learning more about how the STL works, your implementations will improve and you’ll have a better understanding of the language and you’ll gain a stronger intuition for writing correct code.

\*\*4. Learn systems gradually\*\*
OSTEP is a great resource for operating systems.
You do not need to absorb the entire book immediately. Even partial understanding helps.
The goal is building mental models over time.

\*\*5. Watch CppCon talks early\*\*
Even if you don’t understand everything. Initially, I was worried I wouldn’t understand anything and thought these talks were for very experienced engineers only, but even though I wasn’t familiar with everything, they helped me get familiar with:

terminology

engineering vocabulary

modern C++ ideas

performance concepts

Over time, talks that once sounded impossible become understandable. Sometimes you wont even realise you’re learning but you’ll notice that when coming back to a talk you’ve previously watched, you’ll understand a lot more

\*\*6. Use LLMs properly\*\*

LLMs are great for:

explaining concepts

quizzing you

breaking down code

exploring tradeoffs

But don’t just paste code and copy answers blindly.
Use them to deepen understanding. And make to validate anything new you learn from them. I like Claude for this, although I have used ChatGPT to create small snippets of code with UB or poor performance to help me spot bad code and understand why it’s bad.

\*\*7. Accept that C++ is a rabbit hole that you probably will never “master” in the traditional sense\*\*

You’ll constantly discover:

templating techniques

Customer allocators

Different ways of writing multithreaded code

compilers, their differences and what they will optimise for you.

cache behaviour

metaprogramming fun

OS internals

New modern features (new features are added all the time which I did not realise as I was under the assumption that cpp was “legacy”. For example, just recently gcc now lets you use features from C++ 26)

Every topic seems to open 5 more topics, which is my favourite thing about the language

\*\*Final thing\*\*

I honestly think enjoying it matters a lot.
C++ can be frustrating at first, and certain topics can feel overwhelming. Curiosity makes the process much easier to sustain long term.

Also, even if you don’t plan on using C++ full time in your career, learning C++ has made me better at programming in general because it forces you to think about what code is actually doing underneath the abstractions, and strengthens your computer science fundamentals. I hope this is useful to someone :)


r/Cplusplus • • Jul 11 '17

Testing, don't upvote.

180 Upvotes
#include<iomanip>
#include<test>

test

test


r/Cplusplus • • May 04 '24

Discussion "Why Rust Isn't Killing C++" by Logan Thorneloe

164 Upvotes

https://societysbackend.com/p/why-rust-isnt-killing-c

"I can’t see a post about Rust or C++ without comments about Rust replacing C++. I’ve worked in Rust as a cybersecurity intern at Microsoft and I really enjoyed it. I’ve also worked extensively in C++ in both research applications and currently in my role as a machine learning engineer at Google. There is a ton of overlap in applications between the two languages, but C++ isn’t going anywhere anytime soon."

"This is important to understand because the internet likes to perpetuate the myth that C++ is a soon-to-be-dead language. I’ve seen many people say not to learn C++ because Rust can do basically everything C++ can do but is much easier to work with and almost guaranteed to be memory safe. This narrative is especially harmful for new developers who focus primarily on what languages they should gain experience in. This causes them to write off C++ which I think is a huge mistake because it’s actually one of the best languages for new developers to learn."

"C++ is going to be around for a long time. Rust may overtake it in popularity eventually, but it won’t be anytime soon. Most people say this is because developers don’t want to/can’t take the time to learn a new language (this is abhorrently untrue) or Rust isn’t as capable as C++ (also untrue for the vast majority of applications). In reality, there’s a simple reason Rust won’t overtake C++ anytime soon: the developer talent pool."

Interesting.

Lynn


r/Cplusplus • • Nov 09 '25

Discussion C++ for data analysis

Post image
163 Upvotes

I hear a lot that C++ is not a suitable language for data analysis, and we must use something like Python. Yet more than 95% of the code for AI/data analysis is written in C/C++. Let’s go through a relatively involved data analysis and see how straightforward and simple the C++ code is (assuming you have good tools which is a reasonable assumption).

Suppose you have a time series, and you want to find the seasonality in your data. Or more precisely you want to find the length of the seasons in your data. Seasons mean any repeating pattern in your data. It doesn’t have to correspond to natural seasons. To do that you must know your data well. If there are no seasons in the data, the following method may give you misleading clues. You also must know other things (mentioned below) about your data. These are the steps you must go through that is also reflected in the code snippet.

  1. Find a suitable tool to organize your data and run analytics on it. For example, a DataFrame with an analytical framework would be suitable. Now load the data into your tool.

  2. Optionally detrend the data. You must know if your data has a trend or not. If you analyze seasonality with trend, trend appears as a strong signal in the frequency domain and skews your analysis. You can do that by a few different methods. You can fit a polynomial curve through the data (you must know the degree), or you can use a method like LOWESS which is in essence a dynamically degreed polynomial curve. In any case you subtract the trend from your data.

  3. Optionally take serial correlation out by differencing. Again, you must know this about your data. Analyzing seasonality with serial correlation will show up in frequency domain as leakage and spreads the dominant frequencies.

  4. Now you have prepared your data for final analysis. Now you need to convert your time-series to frequency-series. In other words, you need to convert your data from time domain to frequency domain. Mr. Joseph Fourier has a solution for that. You can run Fast Fourier Transform (FFT) which is an implementation of Discrete Fourier Transform (DFT). FFT gives you a vector of complex values that represent the frequency spectrum. In other words, they are amplitude and phase of different frequency components.

  5. Take the absolute values of FFT result. These are the magnitude spectrum which shows the strength of different frequencies within the data.

  6. Do some simple searching and arithmetic to find the seasonality period

As I said above this is a rather involved analysis and the C++ code snippet is as compact as a Python code -- almost. Yes, there is a compiling and linking phase to this exercise. But I don’t think that’s significant. It will be offset by the C++ runtime which would be faster.


r/Cplusplus • • Feb 04 '26

Question What C++ coding "knowledge" you just discovered that blew you mind away?

162 Upvotes

For me it was that 'private','public' and 'protected' keywords are only compile time and

class Foo{
private:
int Bar;

};

&

class Foo{
public:
int Bar;

};

produce the same binary


r/Cplusplus • • Apr 08 '24

Discussion Hm..

Post image
153 Upvotes

I'm just starting to learn C++. is this a normal code?


r/Cplusplus • • 12h ago

News Day 1 of C++

Thumbnail
gallery
145 Upvotes

What a easy startup to my first language. Got to know about data types , variable , strings , comments , Boolean seems fun and can't wait to find out more . Anyone got any beginner tips for me , would love to have some as a beginner


r/Cplusplus • • Nov 22 '25

Discussion One flew over the matrix

Post image
145 Upvotes

Matrix multiplication (MM) is one of the most important and frequently executed operations in today’s computing. But MM is a bitch of an operation.

First of all, it is O(n3) --- There are less complex ways of doing it. For example, Strassen general algorithm can do it in O(n2.81) for large matrices. There are even lesser complex algorithms. But those are either not general algorithms meaning your matrices must be of certain structure. Or the code is so crazily convoluted that the constant coefficient to the O
notation is too large to be considered a good algorithm.  ---

Second, it could be very cache unfriendly if you are not clever about it. Cache unfriendliness could be worse than O(n3)ness. By cache unfriendly I mean how the computer moves data between RAM and L1/L2/L3 caches.

But MM has one thing going for it. It is highly parallelizable.

Snippetis the source code for MM operator that uses parallel standard algorithm, and
it is mindful of cache locality. This is not the complete source code, but you
get the idea.


r/Cplusplus • • Sep 25 '25

Question What would you consider advanced C++?

135 Upvotes

I considered myself well-versed in C++ until I started working on a project that involved binding the code to Python through pybind11. The codebase was massive, and because it needed to squeeze out every bit of performance, it relied heavily on templates. In that mishmash of C++ constructs, I stumbled upon lines of code that looked completely wrong to me, even syntactically. Yet the code compiled, and I was once again humbled by the vastness of C++.

So, what would you consider “advanced C++”?


r/Cplusplus • • Apr 24 '26

Tutorial Modernizing 37 Years of C++ Expertise: 34 Design Patterns released on GitHub

133 Upvotes

I am excited to share a project that represents a lifetime of learning and coding. I started my journey with C++ back when it translated to C (Cfront), and today I’ve finalized a comprehensive repository of 38 Design Patterns and C++ Idioms updated to C++17/20/23 standards.

This repository is designed as a masterclass in software architecture. It focuses on clean code, modern memory management (RAII), and high-performance techniques like Static Polymorphism.

Key Highlights:

  • 38 patterns from Creational to Behavioral.

  • Modern C++ features: std::variant, std::visit, if constexpr, and smart pointers.

  • Educational tracing: I use a "Rule of Seven" approach to visualize object lifecycles.

  • A deep dive into OO Principles (SOLID, DIP, Law of Demeter).

This is an open educational resource. You are free to use it, and I would appreciate a mention or a link back if you find it helpful for your own work or teaching.

Explore the full repository here:

https://github.com/MarioGalindoQ/Modern-CPP-Design-Patterns

If you find it useful, feel free to give it a ⭐ on GitHub!

The code in this repository was programmed years ago, when there was no help from AI, so it may have human-related shortcomings. Any feedback that helps improve the coding is welcome

#cpp #programming #designpatterns #moderncpp #softwareengineering #opensource #cpp20 #cpp23


r/Cplusplus • • Dec 31 '25

Discussion "Software taketh away faster than hardware giveth: Why C++ programmers keep growing fast despite competition, safety, and AI" by Herb Sutter

130 Upvotes

https://herbsutter.com/2025/12/30/software-taketh-away-faster-than-hardware-giveth-why-c-programmers-keep-growing-fast-despite-competition-safety-and-ai/

"Before we dive into the data below, let’s put the most important question up front: Why have C++ and Rust been the fastest-growing major programming languages from 2022 to 2025?"

"Primarily, it’s because throughout the history of computing “software taketh away faster than hardware giveth.” Our demand for solving ever-larger computing problems consistently outstrips our ability to build greater computing capacity, with no end in sight. Every few years, people wonder whether our hardware is just too fast to be useful, until the future’s next big software demand breaks across the industry in a huge wake-up moment of the kind that iOS delivered in 2007 and ChatGPT delivered in November 2022. AI is only the latest source of demand to squeeze the most performance out of available hardware."

The world’s two biggest computing constraints in 2025"

"Quick quiz: What are the two biggest constraints on computing growth in 2025? What’s in shortest supply?"

"Take a moment to answer that yourself it before reading on…"

— — —

"If you answered exactly “power and chips,” you’re right — and in the right order."

This is why I want to convert my calculation engine from Fortran to C++. C++ has won the war for programmers.

Lynn


r/Cplusplus • • Feb 11 '25

Discussion A C++ class for working with very large objects. 'Number' is a class that behaves like an integer. It can scale up to about 2^8^9999-1 digits in theory. The calculation in the image ran in 1 second. I've posted the link to this project before.

Post image
129 Upvotes

r/Cplusplus • • Oct 02 '25

Feedback My first C++ project, a simple webserver

128 Upvotes

I decided to go all out and give this thing the whole 9 yards with multi threading, SSL encryption, reverse proxy, yaml config file, logging.

I think the unique C++ aspect of this is the class structure of a server object and inheritance of the base HTTP class to create a HTTPS class which overrides methods that use non SSL methods.

Feel free to ask about any questions regarding the structure of the code or any bugs you may see.

Repo: https://github.com/caleb-alberto/nespro


r/Cplusplus • • Mar 19 '24

Answered The Random function generates the same number every time

Post image
123 Upvotes

So for a code I need a random number But every time I run the code, The numbers generated are the exact same. How do I fix it so that the numbers are different every time the code boots up?


r/Cplusplus • • 27d ago

Discussion How it feels learning a new language.

Thumbnail
gallery
122 Upvotes

Am i the only one who feels this way?

Yes, i started learning C++ and i'm comfortable with it

*For now*

I started yesterday, and i'm not having any trouble, but scared of one thing.. Pointers, people make it sounds so scary like it's gonna haunt me.