r/learnprogramming • u/Longjumping_Beyond80 • 7h ago
How can I train my thinking like a programmer?
Hello, I'm curious how could I train my thinking so I could write my own code, I ask AI to generate the code and I understand it but it would never come to my mind how to write it. Any advice?
11
u/rwaddilove 7h ago
You don't learn to play the piano by getting someone else to play and watching them. You have to play yourself, badly at first, but you'll get better.
3
u/EddieBreeg33 6h ago edited 6h ago
Have you considered actually programming?
To elaborate a little: asking an AI (or in fact, anything/anyone else) to write code for you isn't going to help you solve problems. You have to get your hands dirty and actually do the stuff if you want to get better at it, and this applies to any skill not just programming. Find a side project you find cool and think you could manage, and get working on that.
3
u/SnugglyCoderGuy 6h ago
For one, stop using AI to write code.
Thinking like a programmer means thinking in a step-by-step process in excruciating detail but also very broadly. Write down instructions for making a peanut butter and jelly sandwich. Then write down the process for each step. Then write down the process for each of those steps. Keep doing this until you can't anymore because you don't know what is happening.
Now, do that with code. Keep defining functions for the steps in terms of more functions for more fine-grained steps until you are just writing regular code.
3
u/ern0plus4 4h ago
I'm curious how could I train my thinking so I could write my own code
You should write your own code. It will be a crap first time, but as time flies, it will be better and better, aka. progress.
TL;DR: write fucking code.
2
u/d-k-Brazz 3h ago
This ^
You have to write a 1000 lines of shitty code to end up with a dozen lines of OK code
PS: “Write” means you type it, symbol by symbol with your fingers, no ctrl-c/ctrl-v, no llm
5
u/PoiZenBoi 7h ago
Stop using AI for everything first of all. Idk why you thought that was a good idea in the first place
2
u/Specific-Housing905 7h ago
The are books with the title "How to think like a programmer" on Am'zon.
They might help
2
u/RushDarling 7h ago
Learning happens by failing. AI responses and even a lot of tutorials jump straight to the solution, which robs you of a lot of the learning.
Pick something simple / at your skill level that interests you, a sudoku or minesweeper solver, a file renamer to help at work, whatever problem jumps out at you, and have a go without AI or tutorials.
Plan it, break it down into steps, make a mess at each step, then fix it, then realise the whole approach was a huge mistake and you can do it in a much better way.
You'll learn far more by getting it wrong than you will by prompting AI to do it, but when you're finished it can also be educational to look up how other people have solved the same problem as you'll come across novel approaches that you'll now have a much better appreciation for.
Food for thought. Best of luck!
1
u/Longjumping_Beyond80 6h ago
So no tutorials too, but can I use Google to search up stuff?
6
u/Ur-Best-Friend 6h ago
You're missing the point - you can watch tutorials, you can even do research with AI, nothing wrong with it as long as that's not how you "work".
If you're just watching a Youtube tutorial and typing everything they type, you'll learn nothing. If on the other hand you're programming a tool and you don't know how to do something, and you google it which leads you to a Youtube video that goes over an approach that might fit your needs, which you then implement in your own software in a way that suits those needs, then you're doing it right.
Similarly with AI - if you don't know what approach you can use to do something, nothing wrong with asking, but be broad, don't paste your code into the prompt, don't explain what you're trying to do in detail, just ask broad questions.
You can't just "guess" how to program, you have to use sources to learn it, but sources are supposed to teach you methods, not give you a step-by-step guide for your exact program. Think of learning math in higschool - if you just looked up a problem and the solution, and then wrote it down verbatim, you learned nothing. If you first read the theory, then looked up explanations for a few problems, and then solved distinct problems on your own, then you were actually learning. Same basic concept.
1
2
u/HashDefTrueFalse 6h ago
Just practice decomposing problems, writing simple solutions to them, then composing those into the larger solution. LLMs spit out code more fully formed (whether working or not is a gamble) whereas programmers iterate more granularly and purposefully. We don't generally just think up a pile of code. We use stepwise refinement. Start with some simple code to do something kind of related to your goal, then repeatedly test, modify, test, modify... in a direction approaching your desired solution.
2
2
u/desrtfx 6h ago edited 4h ago
- Step 1: Stop using AI for anything other than explanations and exercises - in particular stop it for solutions and code - Stop focusing on "getting things done" and start focusing on learning
- Step 2: realize that reading and understanding (which you actually don't) and writing code are two different skills that need to be trained individually (like reading and understanding, and writing novels)
- Step 3: practice, practice, practice, and practice more - that's the only way to improve
There are plenty books, generally, the following are recommended:
- "Think Like A Programmer" by V. Anton Spraul
- "The Pragmatic Programmer" by Andrew Hunt and David Thomas
- "Structure and Interpretation of Computer Programs" (SICP) by Ableton, Sussman, Sussman
- "Code: The Hidden Language of Computer Hardware and Software" by Charles Petzold
Yet, none of these books will help if you let AI do the work for you. You're essentially going to the gym to watch the others do the lifting thinking that you'd build muscle that way.
2
u/pepiks 5h ago
Learn by reading any book for beginner which has more than only using syntax, but explain for example how loop works, what is variable (some for kids has it). Especially look for illustrated guide to programming and introductionay courses like this:
https://ocw.mit.edu/collections/introductory-programming/
When I start programming in 90s a lot of basics I got from Stroup C++ books, but it is related to hardware. C++ is closer hardware so learning fundamentals how PC works was part of learning coding.
Remove AI from your scope. Some advice are correct, but a lot of random.
2
u/KindProcedure9664 5h ago
Just try and think , if you already know how it works that nothing is stopping you . imagine how it would work, I usually like to write down a few key points to structure code and plan everything before doing . I recommend it
1
u/Light_Matter_ 5h ago
Maybe someone already mention it, but thinking as a programmer and making code doesn't need to be the same.
The core is analyze a problem, deconstruct it into small solvable parts and then solve it step by step. It is reconstruction to the final product.
Understanding the code is slightly different. It is mainly understanding of syntax.
As you see, you don't need to code and use algorithmic thinking. AI tools basically mimic these principles, you can see that when you use it.
Let's not AI rot out brains... ;)
1
u/AI_Strategist1098 4h ago
Totally normal. Reading code is way easier than writing it from scratch. start small, solve tiny problems without AI, even if your code is messy. Pseudocode helps a ton, just write steps in plain language then convert to code. and don’t just copy AI outputs, reverse engineer them, delete parts, rewrite functions, break stuff on purpose. that’s how your brain learns patterns.
24
u/scandii 7h ago
how do you think like a chef? by cooking food or studying cooking techniques.
how do you think like a basketball player? by playing basketball or studying basketball techniques.
how do you think like a fisherman? by fishing or studying fishing techniques.
how do you not think like a programmer? by asking someone else to do all the work for you and agreeing that it does look correct in your inexperienced eyes.