r/learnprogramming • u/Fictoriuss • 4h ago
How to write?
I am learning c++ for 3 years now on. I can write hundreds lines of code in a row without any errors. But unfortunately I still can't write a normal project. When I try something serious I am getting lost in my own code. I built few simple games, few simple neural networks and a lot of simulations/emulations. I used ai only in visual libraries that I don't understand.
My 15 years old laptop runs on arch linux. For code writing I using micro and nano text editors and g++ for compilation.
How to write a real project? Not just core of a programm but really big peace of code that works properly?
5
u/fixermark 4h ago
Start from the opposite side.
If you want to write a game engine... Okay, what is a game engine? Well, it's a system that does graphics, sound, user input, the game (which is rules and scripts and actors and AI logic)... And coordinates all of that.
Now, those pieces create more questions. What is a graphics layer? Well, it turns the concept of what's in the world to pictures on the screen, using a graphics library... Well, what's in the world? Okay, I need a model representing things that can be seen and things that act... okay, how do I lay that model out?
The only trick to writing something big is to keep writing those questions down and answering them, one by one, until you get one small enough that your brain says "Okay, I think I could write code to do that." Repeat for a year. ;) When I wrote a game engine ages ago, it was a project involving a core team of 5 engineers and we were at it for about 4 years (you can get there faster depending on how simple you want to project to be), and about 30% of the work was code; the rest was design and answering those questions.
The only tricks are staying organized (some of those questions will interconnect - for example, the model touches graphics, sound, input, and game logic all at once), not losing track of your questions, and the hardest part: not giving up. It'll feel like climbing a mountain and for a long time the questions will generate more questions. Trust that the mountain has another side, and recognize that you're not trying to get to the top of it, you're trying to get over it and come down the other side.
Also, there's no shame at all if you're trying to build something like something else in looking at open-source examples. If I were writing a game engine right now, I wouldn't start with what I just described. I'd look at Godot, or Unity, and understand their architecture. They already solved the hard parts.
2
u/Paxtian 2h ago
I think an important bridge is to not feel like you need to design something completely original and implement that. Instead, pick something you use regularly and rebuild that thing. So for example, just build your own version of a calculator app. Consider what you need:
And so on. Break them down into their smallest constituent parts, build those parts, then assemble them into a whole.
For GUIs you're typically better off using an existing framework, like Qt. You can even use Godot. While Godot isn't meant for stand alone apps per se, it's an option for learning. You can turn on things like low processor mode so it's not burning up GPU cycles every frame.
1
u/_curious_man 4h ago
I think this is a hard part. Personally, the biggest projects which I did were:
My typical advice, would be to look for a task. Maybe "I want to practice trading - let's make a simulator which would pull some news, run small llm and then fill params to check the upcoming 2/3 days". Obviously this is just something which I've come up rn. You might want to do something totally different.
I guess, unless you are trying to solve something which requires a lot of cases (ex. build a 3d engine), project grows if you need to do more things. So maybe you should look for stuff which you would like to make.
1
u/light_switchy 3h ago
There isn't any shortcut but to write more code. Push yourself a little bit.
1
u/Substantial_Job_2068 3h ago
Sounds like you need a goal. If you just try to build "a big piece of code" without clear vision what you want to build, you will get stuck. It's also a weird goal to want to build a large project, the smaller and simpler you can keep something the better.
0
u/CrAIzy_engineer 4h ago
Install Claude, let it teach you how to design systems. Specially if you can do tactical programming your just lacking one level of abstraction, strategical programming and Claude can be a hell of a teacher running directly in your project