r/AskProgrammers • • 4d ago

To become fluent in C++

Hello, fellow coders. I want to write code as I think of the logic at the same time. I have seen my friends do this. Are you someone who can now confidently write code as you think. If you can do give the tips and steps that you did to achieve this fluency.

I know practice is a must. But doing the right practice is what I want. Everytime I try to do learn and implement, I don't get results and this has become frustrating really.

Do share your thoughts. Thanks for reading..

5 Upvotes

15 comments sorted by

3

u/sastuvel 4d ago

I've literally used c++ for 30 years and I still feel like a noob some days.

1

u/DrVanMojo 4d ago

Working with a broad variety of code. It's not enough to give yourself toy problems. Start fixing bugs in large repos. I didn't know how anyone could push themselves that hard unless it's a job requirement. And speaking as someone who can think in C++, it's not a high value skill anymore.

1

u/_utkarsho 4d ago

I wanted to contribute in open source repo, but I do not know where to start and find the right one. Could you share some beginner friendly repos, that you know of??

2

u/Anonymous_Coder_1234 4d ago

People can do a GitHub advanced search to find a repo:

https://github.com/search/advanced

You can also look for issues tagged good-first-issue or label:"good first issue". Those tend to be set aside for newbies.

1

u/Available_Safe1818 4d ago

You could have spent the time coding more instead of writing your post.

Look at what this guy did: https://www.reddit.com/r/learnprogramming/comments/1y6p8u1/hi_i_started_learning_cpp_by_myself_since_about_2/

0

u/_utkarsho 4d ago

Thanks for the suggestion

3

u/ButchDeanCA Staff Systems Programmer - 20yoe 4d ago

The way that I became so fluent was to practice, not just the same problems but a variety of them. It’s a bit like learning a spoken language, you can’t learn it by saying the exact same thing over and over, you have to be able to express yourself in different scenarios to become fluent.

So practice over a variety of different problems and refuse to give up. Also bear in mind that with a language like C++ you can’t learn it all, but that was not the crux of your question.

2

u/sububi71 4d ago

It's super simple. You code. And you code some more, and you work hard and evaluate your work, and you improve. That's all.

2

u/Tight-Book-7533 4d ago

Learn to break down the logic first, on paper or in your head then start coding when it’s clear how to solve the problem. When it’s a complex problem, I often write comments, each outlining a step before I write the code. 

1

u/buzzon 4d ago

You are focusing on the wrong thing. Before you can write fluently you should learn to write at all. So take your time to think, then write, then think, then write. It will only become automatic once you have written a lot.

1

u/dld2517 4d ago

I always use pseudocode. I just write what I want to happen. It’s no different than writing an outline. It’s always rough. But it is the framework. If there is a question or if you need to outline a section very roughly you do it the same way.

From your rough-in, you can go back and modularize the code, building your file or project structure as needed. Comment every line of the pseudocode because this could easily be copied and be added to a file header. You build compiler declarations like this as well.

If you have ever watched a builder, a plumber, or a sheet metal fabricator work; they all work this way. Why would a coder not as well? You must first create rough structures. Then you get more detailed. Then more detailed. Eventually you have code segments that work.

This is the way. Create the function and write pass or return 1; then build its bones. If you have another idea while you are building its bones you can easily jump away to another part without losing your ideas.

1

u/Technical_Ideal_5439 4d ago

Write the top level of what the program is doing then just refine each step making more functions, classes, etc as needed where it makes sense.

For C++ you dont even need normally do to the above because you are using some framework which requires a top level design. You are just filling in the details.

I keep a bit of paper where I note what I am working on in the code, and occasionally as I loose what I am working on as I get stuck into a bug. I also like to leave something not compiling when it is not work, so I can jump back in if I leave it for a few hours or more.

Additionally you should be using TDD/BDD.

1

u/dinanomartin 4d ago

breaking problems into smaller steps first helps more than trying to write perfect code immediately.

1

u/SemanticMap 4d ago

Regardless of programming language, it helps to have mental model of some kind of state machine with memory behind the programming language where statements in the programming language correlate to state changes in the state machine and memory model.

Then understand multi-threaded execution, shared memory, and concurrency. Race conditions, synchronizations and types of locks.

Understand byte level representation and translating data between representations.

Understand recursion and dynamic programming solutions.

Understand synchronous and asynchronous executions and message passing paradigms.

Knowing how to write a toy operating system is powerful, which is why they teach it.

1

u/darkol_2020 4d ago

Lol, you have decades? A good basis is probably the best you will get…