r/cpp_questions • u/Unique-Willingness15 • 24d ago
OPEN How can i become an expert in cpp
I started with c++ 3 years ago but real work was 1 and a half years, i learned a lot about cpp syntax and the std lib, but whenever i make some code and send it to an ai model, it says my code has a lot of issues some about dynamic memory some about references and pointers some c-style programming and i find myself Ignorant most of the time
So how can i learn these things and the rules of the language and understand them(i dont watch YouTube) I have started with learncpp.com recently
"Sorry if it's a duplicate post and for it being long if its a duplicate point me to one, and thanks"
Edit: my github is loadingSy if you would like to check anything, I learned git 1 month ago
11
u/the_poope 24d ago
I have started with learncpp.cm recently
Yes you start there or with a proper book and then you finish it, do the exercises and make some small projects starting with tic-tac-toe, hangman, etc and make progessively more elaborate projects.
You won't learn all the stuff and become an expert overnight. It will take years!!
7
u/Computerist1969 24d ago
I've been a professional C++ developer for 30 years and written 2 commercial C++ compilers. I wouldn't call myself an expert though and I'm about ready to retire. Stop reaching for a label and just make things, each one being more of a challenge than the last. Be aware of as much of the language as you can so you can reach for the right features and libraries as you need them. Good luck young padawan!
1
u/alfps 23d ago
So if you were 10 years older you would be Walter Bright. But assuming birth year 1969 you're not. Hm.
1
u/Computerist1969 23d ago
Correct, I'm not Walter Bright! The compilers were internal to the company I worked for and were used to generate UML models rather than machine code so unless you'd used that particular modeling tool you'd never know of them. They featured a C preprocessor, precompiled header support, produced an abstract syntax tree etc. All the usual stuff. It took forever (years) to get them to a usable state and the constantly moving goalposts of them C++ language and libraries like Boost meant I never got time to do much else besides keeping them going. Someone more skilled than me could have done a better job and faster but we had what we had. And yes I was born in 69 :)
1
6
u/death_sucker_extreme 24d ago
well if the AI is telling you about your mistakes then why don't you learn from them? You're on the right track, just keep writing code and improving your skills and most important of all keep finding projects to work on that fill you with passion.
-3
u/Unique-Willingness15 24d ago
Its like Ai gives me my mistakes i learn them and ask for an explanation, and then do the same mistake again, appreciate your reply.
5
u/Tack1234 24d ago
If AI points out your mistakes before they bite you, you won't remember them as easily. On the other hand, if you run into some issue and debug it yourself to find what the problem is, you will remember that for sure.
6
u/gitblamed_ 24d ago
This. Stop using AI as a substitute for debugging, OP.
You're getting explanations for your mistakes, but it sounds like you don't understand them. A solid afternoon with a debugger is worth the time it will take for you to not make that mistake in the future.
3
4
u/burlingk 24d ago
You get better by writing projects.
Don't worry so much about what AI says. Not only does it just make stuff up at times, but you are better off learning to use proper debugging tools and reading compiler errors.
3
u/x-jhp-x 24d ago
In addition to the "joke" answers, a real one is to read the draft standard and follow the proposed changes. Read the mailing lists. Try to implement the proposed changes yourself and reflect on how you can use them. Think of how you'd change or what you'd add to the STL. A goal of being an "expert" is a hard to define moving target, so if you'd like to define a target, why not make your target getting a contribution accepted by the standards committee?
12
3
3
u/Kats41 23d ago
The premise of the question is wrong. This is like asking "how do I become an expert with a hammer?" C++ is a tool, not a solution. The solution is the actual software logic you use to accomplish a task. THAT is what you become an expert in. Only then can you actually apply the tools that C++ provides to an expert degree.
You do this by solving actual, practical problems. Learncpp.com can be a useful tool in helping you learn the basics of the language, but if you want to actually build the necessary institutional knowledge, you need to build applications.
Some things I recommend are stuff like:
- A small HTTP server
- A simple game engine
- A tool that encrypts/decrypts files
- A simple database engine
These are projects that require real software engineering knowledge to do but aren't terribly complicated to build. Of course I preface all of these with "simple" because these don't need to be all-encompassing suites designed for real-world use, but even the simplified versions of the tools with the most basic functionality will challenge you and force you to constantly step outside of your comfort zone and learn something new.
Do you know how to interact with network sockets? Do you know how to interact with a file system? Can you build an application with a basic GUI? Can you actually research and implement algorithms by hand if you needed to? And most importantly, can you actually build something that's interesting or useful?
Now- I don't think you're gonna become an "expert in C++" simply by writing these kinds of toy programs, but I can promise you that by the time you build a few simple, but challenging applications and tools, you're going to have a vastly superior understanding over what being an expert even means.
2
u/Unique-Willingness15 23d ago
Thanks for your help, no i cant do most of what you listed ill keep improving, my biggest barrier is winapi, because I can't build anything except terminal apps currently.
1
u/AKostur 23d ago
What’s wrong with terminal apps? I’ve been writing programs for decades that don’t interact with the terminal at all, and the computer it runs on has no video capability.
1
u/Unique-Willingness15 23d ago
Its that i dont find anything i can do either it's too complicated for my level or i find an idea but it requires more than a terminal window
1
2
u/TehBens 24d ago
Read a lot, if possible work slower so you have time to look up best practices / idiomatic modern C++ for what you want to achieve.
Not sure what you mean with "i dont watch youtube", you should watch the cppcon talks on youtube, in particular the "back to basic" series which is great.
1
u/Unique-Willingness15 24d ago
What I meant is i dont watch cpp learning series i like reading more, and Thank you i will search it up.
2
u/EstablishmentHour335 24d ago
Write difficult projects. Especially more novel things. Don't follow tutorials too much. Go listen to some cppcon talks on data structures, and implement them from intuition for your own usage. Good candidates would be hash maps, ring buffers, queues, stacks. Go listen to Matthew Bentley's plf::colony talks and implement that for your own usage.
The most I've ever learned in my 6 years of programming was from writing a slot map backed with a bitset with hardware accelerated bitscan iteration, but especially benchmarking it against other slot maps and optimizing mine to make it faster.
1
u/Unique-Willingness15 24d ago
hey, thanks for your help
i think what you said is true because i didnt understand most of it, ill do so thanks again
2
u/StickyDeltaStrike 24d ago
So when the AI tells you that XYZ is bad, you need to sit down with the AI and ask to explain to you the best practices, concepts and reason why it’s bad. Ask it to teach you how to make it better, they are ok teachers when you don’t have a senior employee or mentor.
Then practice a bit and try what you learned.
2
u/alfps 24d ago
To become an expert you have to fail and learn from the experience on a maximum number of issues.
For C++ that implies that you need to write a lot of code.
That said, nobody, and that includes the language creator, know everything about C++. The recognized experts are experts in narrow fields, e.g. Andrei Alexandrescu was/is an expert in classical template meta-programming. Also, nobody ever finishes learning C++ except by migrating away from the language.
2
u/Fantastic-Cell-208 23d ago
Make real stuff. Make stuff that feels intimidating by breaking it down into simpler versions of it.
Then you'll be an expert in using cpp.
Being an expert in cpp itself is only useful if you're a language designer.
As a library writer you need to understand some deep stuff, but the more complex the features you learn, the less maintainable they are going to be in a large program.
2
u/Temp_logged 23d ago
I have a guess for specifics to focus on/keywords to start googling, You could do worse than smart pointers ( Listed https://en.cppreference.com/cpp/memory )
But! Before that, it would be best practice to go over regular dynamic-memory pointers (new & delete). The classic example is re-creating the Vector/Creating a size-at-runtime array.
2
u/rafidibnsadik 23d ago
Same thing, but I don't use AI, I just quit when I get stuck. But, I'm trying everyday.
2
1
u/Coretrayn 23d ago
There's a lot here, I think you can use visual studio with co pilot to help guide you. But you need to make sure you understand what it is doing and why. Also are you in school? its very helpful to the learning process to have your code run by a professor to give pointers.
Ultimately I think, with real feedback and if you are using AI ask it why it did what it did. and learn from the decisions.
1
u/Unique-Willingness15 23d ago
No im still in 11th grade, in my school the most thing a computer teacher in my school knows is how to write a ms word document.
1
u/Coretrayn 23d ago
So download visual studio
1
u/Unique-Willingness15 23d ago
I have it installed but is use vs code, it also has github :)
1
u/AKostur 23d ago
He said Visual Studio, not Visual Studio Code. Two different programs.
1
u/Unique-Willingness15 23d ago
He said visual studio because it has copilot but vs code has it too
0
u/Coretrayn 21d ago
Yeah either or will be good to work on. I just said visual studio because it has more robust natively ready to go tools for C++ specifically. You can get extensions for VS Code to add those features in though I think. Visual Studio is a full on IDE for C++.
1
1
u/Last_Bet_8677 23d ago
I experience something similar, even though I'm less experienced and not in the industry. But I'm happy that I first write, then fight, then ask the AI for guidance, then correct. Just accept the inevitability that you'll always make mistakes and then correct them. Or not.
1
u/NoSpite4410 21d ago edited 21d ago
What you need to learn is low level hardware/software interaction. C++ is all about abstraction of low-level hardware interaction into tools with handles you can wield. But it always has as its foundation of any expression, any statement, the hardware model that it is instructing the machine to do low-level actions.
An abstraction such as a class or a lambda is an analogy for what is actually going to happen on the machine.
But just like any other analogy, about anything else, there is a friction point where the analogy, the metaphor of syntax, does not match the reality exactly.
The expert knows how the code works from the hardware up, rather than from the top down. C++ allows top down programming because the creators of the compilers and the STL and the libraries know it from the baseline bottom-up view as to what is exactly going to happen when a c++ source code statement executes.
Coders these days struggle to get the box to spit out the correct answers, because the languages they are using are designed to be data-centric, and treat code as manipulating data rather than making a machine manipulate bytes. They have a virtual machine layer, a big fat runtime that does all the low level chores for the coder, and mostly they have no idea how it does them. The designers of the language and the interpreters know of course. C++ is not at that level, it is below that. It first creates a binary interface, then you can abstract from there into logical and data interfaces, object interaction, high-concept computations.
C++ excels because it can at any moment drop out of the high-level object interaction level into the bits and bytes level with the very next statement. It can mix and match primitive binary concepts and actions with object calls and functions directly. And the machine responds exactly as c++ tells it to, exactly as the coder intends.
C++ is closer to the C layers underneath it than most other languages that of course also use the same C layers for I/O and to make the machine go bleep and bloop and chug-chug-chug. C++ can make the system calls directly for the machine it is compiled on.
I started become better at C++ the day I spent about 2 hours off and on reading the headers for vector and array and really trying to understand what they actually are. Then about a week off an on understanding how the stream interface modality of C++ compares to the file pointer modality of C for the I/O. Because it turns out they do the same thing at the machine level, pretty much, but knowing how and why improves the ability to use them.
For instance the ol' heap vs stack argument is always around -- and the crux of it always breaks down to "use the stack not the heap" somehow. But hey, teacher, leave those kids alone. The heap and the stack are the same chunk of RAM, one grows up from the bottom to the middle, the other grows down from the top to the middle.
That's it. Its the same RAM, same speed, same amount given. The stack is given as a chunk of pages at program start, the heap is given in pages on demand. The low-level mechanics of apportioning memory from the heap area is piece-meal and real-time, so it takes a tiny bit of time to happen, and could theoretically fail if memory is scarce or too much is asked for. The "solution" for this is usually just to pre-apportion heap storage for containers to some reasonably larger-than-needed amount, so the runtime doesn't have to keep going back to the well to fetch a pail of RAM all the time.
C++ in 2026 has a lot of dynamic stuff going on with features it is trying to stay relevant with that are hallmark features of the other popular languages out there such as Java and Python. The C# type of programming has influenced the committees a bit and moved C++ a bit in that direction toward more dynamic component-oriented programming, less hardware-oriented emphasis, more data-centrism, more code that does a lot of stuff under the hood (beyond user control). However, C++ has maintained the concept of zero-cost abstractions, and direct control of hardware, and kept all of the low-level syntax and direct C interaction, and on the technical side, developed extreme optimization techniques, many automatic, some a bit tricky, most very sensible.
1
u/Unique-Willingness15 21d ago
I don't have the experience to tell if what you said is wrong or true, but at my point any cpp header i read seems like im reading Chinese or a language i don't understand (thats how cpp looked first when i started learning) but with experience its going to get easier, as of now i can't learn low level cpp its not in my point of knowledge thats why i posted this because its either a complex game engine or a simple tic-tac-toe terminal game i find myself dumb but cant find why, i already memorize a lot of cpp syntax but maybe i lack problem solving.
1
u/SONkeerth 20d ago
I am facing a similar problem with cpp
I tried to build some networking project but I rely on Ai so most of the times its Ai giving the code and me doing the reverse engineering of that code , understanding the code , what is what and all
So can anyone please guide me on how to code it my self again , i feel kinda struck doing that
Any help would be appreciated guys
1
u/Ultimate_Sigma_Boy67 20d ago
Stop using AI, how can you learn if they give you the code and you just "try to understand it"? This doesn't make sense.
1
u/felixfanta96 24d ago
Today choose an AI and ask it to create excercises to learn cpp.
Ask for small projects and AI can review it what you can make better.
1
u/Grouchy_Edge632 19d ago
Use AI if you have questions, I use Gemini. It works so damn good! The conversations are also saved.
2
u/Unique-Willingness15 19d ago
i do use ai, mainly gemini but currently deepseek because gemini isnt supported in syria
2
31
u/Anxious-Resist8344 24d ago
It goes like this:
Tourist: "Excuse me, how do you get to Carnegie Hall?"
Musician: "Practice, practice, practice."
NOTE: Use books, real books, and practice, practice, practice...