How do you actually remember code without just looking everything up constantly?
Posted by kutahead@reddit | learnprogramming | View on Reddit | 39 comments
I have been learning programming for a few months now. I understand concepts like loops, functions, and classes. I can read code and explain what it does. But when I sit down to write something from scratch, I freeze. I forget the exact syntax for things I have used before. I end up looking up the same basic stuff over and over. People say just use it or lose it and that looking things up is normal. But I feel like I am not actually learning if I have to google how to write a simple for loop every time. How do you build real recall without constantly relying on documentation or past code? Do experienced programmers actually remember most syntax or are they just good at knowing what to search for?
illuminarias@reddit
You will remember the common syntax, or remember enough to stumble your way into a working solution, most of the time.
But honestly a huge part of this job is googling, finding examples, documentation, etc. And yes, knowing how to search, what to search, etc, is a skill too. It's a skill that you gain with experience.
Fit-Original1314@reddit
I get that, and honestly that’s kinda reassuring. I think what frustrates me is I can recognize the code when I see it, but can’t actually write it from scratch. Feels like it should be in my brain somewhere but it’s not 😅
RegisterConscious993@reddit
What helped me early on was writing sudo code. In my case, trying to remember syntax and write code at the same time would trip me up and make me freeze.
Fit-Original1314@reddit
That’s a good point. I’ve been jumping straight into code and then getting stuck on tiny syntax things. Pseudocode might help me stay on track instead of freezing.
illuminarias@reddit
That's alright, that's pretty normal. Just keep at it and you'll build up the muscle memory for it. I feel the same way when transitioning to a new language too, but the "trick" is to just keep playing around with it and build that feel/intuition for the tool/language/framework, as you're constantly testing your knowledge and expectations.
PeterPook@reddit
My problem (after many years of coding) is language mixing. I move between JavaScript, VBA, PHP, Python, Rust, Java, C and get them all mixed up. Yes, I do a lot of looking up, and get Claude to remind me at other times. Don't worry about it.
rizzo891@reddit
Because of c# mg JavaScript is a mess of unneeded semicolons
Philluminati@reddit
The sytax is actually easy to remember. IDE's with autocomplete give you the library methods you need and AI can make tutorials for you, for anything else that you can hand-craft into your apps
glandix@reddit
Practice
Imaginary_Top_1383@reddit
I used to keep huge documents of examples of everything I had learned. Now AI replaced the need for that.
MeLittleThing@reddit
if you forget basic things and you need to look up the documentation, you're on the good tracks. It's ok to forget, what matters is finding the information efficiently
InspectionFamous1461@reddit
you are learning a good lesson that when you sit down to write something you need a plan or outline. If you know all the classes or functions a program will need you can just give them names. Then put the control flow together. then fill in the small parts. And if you dont remember something just look it up. I usually just write a bunch of function names then fill in the logic and data afterwards. Easy as pie.
Gnaxe@reddit
We do look things up constantly. I mean, the language grammar is pretty well memorized by now, and so are some of the very common functions. This is a lot easier in some languages than others, because they vary more than you'd think in grammar complexity. Maybe you need to use a simpler language. Scheme is about as simplistic as it gets and Smalltalk comes close. I don't think anyone masters all of C++. It's too complicated.
You should be able to write a basic for loop from memory. But even a lot of the standard library I still have to look up. I have a vague sense of what's in there, so I know what to look for, but I'd get details wrong without checking first.
TheBigTreezy@reddit
You'll remember common syntax but everything else you'll look up.
wackycats354@reddit
Try handwriting it. It activates different parts in your brain.
TheNewJoesus@reddit
I am looking up code constantly. The parts that feels like memory is really my IDE telling me where specific functions are within objects. I spend most of my day thinking about who does what and how.
Visual-Apartment1612@reddit
This is the difference between "knowledge" and "skill." Knowledge, you can learn in a book or a video. Skill, you can only learn by practice.
It will get easier. If there is something you look up 5x per day, write it on a stickey note, or keep a .md file on your computer with these notes.
"A few months" of learning translates to maybe.. 100-200 hours of practice? That's fine. When you hit the 2000 hour mark and look back, you will see how much your proficiency has increased. And when you hit the 10,000 hour mark, you'll look back at your code from 2000 hrs and wonder what you were thinking.
Lost_Madness@reddit
I tend towards lots of reference guides, or reviewing applications I feel have done what I am aiming to do or close enough. From there, it is lookups and documentation.
A good way to do things is to avoid copy and paste with code. Type it out, even if you are just copying something. It helps really ground it into memory more imo.
Moldat@reddit
That's the neat part, you don't
Windyvale@reddit
Do it so much that it's no different than remembering actual language.
reputable-sprite@reddit
I've been coding for 30 odd years, and I still have to look things up. It goes from the point of knowing the syntax of a command in your first language, then having to look the syntax up because you need to remember the nuances of the same function with slightly different syntax across multiple languages. As an example look up string manipulation methods across .net / java / php / javascript / SQL / python etc. :-)
QVRedit@reddit
You just need to remember enough to find things, So like where to look for documentation, or perhaps reference files you previously worked on.
ShoulderPast2433@reddit
you remember syntax, you remember most commonly used classess and methods, for less often used you remember that _something that does the thing_ exist and you know how to fins it fast in documentation ;)
Rinktacular@reddit
I don't. I didn't need to memorize entire text books to get an A in classes, just portions that we are tested on. Same applies to your hobby/job. You learn what you need at the time you need it and save those resources you learned from for later. Refer to them as needed. It is exceptionally rare for people to be completely fluent in a language without relying on any resources. That changes based on experience, the type of roles you are in, the culture of your org, or simply how well you yourself retain information compared to others. So everyone is different. Don't let youtubers or streamers who code make you think you need to be as fast as they are or you are "failing" or "bad." compare only against yourself and how much you have improved from a prior point in time. That's how you know if you are improving.
There's a reason why the quote "Comparison is the theft of joy" for a reason - it only harms you and make your feel bad about really impressive things you have accomplished. In the end, after doing this for 11+ years now, I google daily to make sure I am doing as well as I can be rather than assume my old brain remembers everything correctly or what was common 4 years ago is still the way to implement features.
AdmiralKong@reddit
I look things up constantly. Usually not the syntax for a for loop but plenty of other stupid things I feel like I should have memorized by now. Like the syntax in C++ for various types of template specialization. Or the correct way to do argument parsing in python. Or basically every single thing about centering content in CSS.
Don't feel like a fraud for looking things up, just look up what you need and get in lots of practice.
cgoldberg@reddit
Repetition. You'll never remember every bit of syntax or every built-in class/method/function available, but when you work with something for many hours a day, writing similar things, over and over, for years... you tend to remember quite a lot without needing to look anything up. Also, autocomplete helps.
troisieme_ombre@reddit
Comes naturally with practice. How do you actually remember english without just looking up every word constantly ? Well same thing, practice enough and it'll come naturally. mostly^1
^1 : we all regularly look up dumb stuff because we can't remember the exact syntax or the order of the arguments or whatever, that's normal. You wouldn't believe how often i look up Array.split() on MDN.
jajajajaj@reddit
It's a blend between practice, and getting good at looking things up quickly. the things i can most reliably look up quickly, I will purposefully not try so hard to remember except as something that exists, to look up as needed.
there's a pretty big difference between looking things up slowly and looking up things fast.
stuff I know
stuff I remember exactly where to find (bookmarks to reference materials, including specific location bar searches other than just Google, like making "py argparser" into one click instead of two)
2b: The IDE should cover a lot of this stuff. self destructively, I don't really use one, but my quick references are only marginally slower, considering how brief the actual new code writing sessions are.
scifishortstory@reddit
That’s the fun part - you don’t!
No_Report_4781@reddit
You’ll start to remember concepts as you keep using them. Then you’ll forget and look it up
high_throughput@reddit
This is extremely common.
It's true for natural language as well: foreign language learners discover that it's a thousand times easier to read a sentence than to write one.
It's mostly just a matter of practice. It just sucks because it feels like a huge step back to struggle for hours to print a triangle, when you were just easily following an intermediate level tutorial for a fancy todo app.
throwaway6560192@reddit
If you have to google how to write for loops, you simply haven't written nearly enough for loops yet. Write more programs, look things up if you have to, and they will stick with sheer repetition. After the 10000th time writing a loop you will not have to look up the syntax.
mrwishart@reddit
Lots of practice. Plus, if you end up working on an existing codebase, you'll have the code around you to learn from
WarPenguin1@reddit
I memories what is possible. I know that if I want to do the same thing multiple times I memorized that a loop is required for that problem. If I haven't written a loop in a long time I would then look up the various types of loops and how they are used.
ShardsOfSalt@reddit
I'm pretty sure I have the worst memory in the world.
But for a while I was really good at python syntax because I did leetcode in python and I never had to look up how to run a for loop or other simple stuff. I even remembered how to use the heapq module haha.
If I slack off though I have to look things up again.
UnnecessaryLemon@reddit
Remember? Code? Man, it's 2026, we just vibe it out ..
Lurn2Program@reddit
Basically repetition. Some things even feel like muscle memory, like CLI commands, shortcut keys, etc. But there's nothing wrong with looking up functions and commands. I look up stuff all the time, and it's just part of the job.
I think the only exception here might be for interviews. You can tell your interviewer you know a certain function or method exists but you can't remember what it was called, and they might tell you or tell you to make up the function/method name. But in general, it's best to avoid this as much as possible because it might tell the interviewer that you aren't well versed in the given programming language
Ad3763_Throwaway@reddit
At some point you just know. If you learn a foreign language you also don't have to look up words anymore at some point.
LearnerBurner93@reddit
Honestly just repetition. The more you do it, the more you read it, the more it'll stick. Something you do once or twice a day will end up sticking easier than something you do once a project.
If there's something you really wanna commit to memory, make a project where you have to use that knowledge frequently. Or make multiple small projects to get the knowledge stuck in your head. And try to use it every once in awhile to refresh your memory and make it stick a bit more. Frequency + Time is the key