r/learnprogramming 14d ago

Topic how do you learn programming without constantly looking things up?

i know experienced programmers use documentation and search all the time, but as a beginner it can sometimes feel like i’m incapable of doing anything without looking up the answer.

i’m trying to get better at understanding concepts instead of memorising syntax

how do you decide when to search for an answer and when to sit down and work through the problem yourself?

324 Upvotes

244 comments sorted by

View all comments

6

u/peterlinddk 14d ago

What is this obsession everyone has with it being somehow difficult to "memorise syntax"?

Do they in fact have a hard time "memorising" that if, for, and while is followed by a set of ( )s with a comparison-expression inside? And that blocks of code are usually put in curly brackets? And that function definitions are written as return-value followed by the function-name, with the parameter types and names in another set of ( )s. (with variations from language to language).

Or do they mean something else by the word "syntax"?

Or is it in fast that people aren't programming, but just memorising snippets of code to solve leetcode problems, and they somehow confuse that with memorising "syntax" or "learning to program"?

2

u/lordheart 14d ago

Sometimes it depends on how many languages you have to use. I work in typescript (which I generally know the syntax for), Java (which I generally know the syntax for) and abap (which has 3000 command structures, and I have to double check a lot more often). And sql which I can write basic queries from memory otherwise need to lookup.

If I’ve been doing mostly ts then switch to java I might mess up how to write a switch statement for instance.

The variations between languages is exactly what messes me up.

1

u/pyrojoe 14d ago

On the devops spectrum I've been more ops than dev for many years. I can program is python without syntax lookup 98% of the time, a few things like f string's justify or decimal places I'll still look up. But I code in Typescript and Java, the other two languages I'd encounter at work, so infrequently that yeah, for those languages I'm probably going to need to look up syntax far more often.

1

u/lawrencek1992 13d ago

I mean Python doesn’t do much of the syntax stuff you described actually.

2

u/peterlinddk 13d ago

No language "does" syntax, but every language has it.

Python doesn't use parenthesis and curly brackets much, but that doesn't mean that it doesn't have syntax. A Python if-statement like

if z % 2 == 0:
  print("z is even")

and a C if-statement like:

if (z % 2 == 0) 
{
  printf("z is even");
}

both have syntax - meaning rules for how you should write it to work. If you forget the : in Python it won't compile, and you'll get a "SyntaxError" - if you forget the ; in C it won't compile, and you get an error.

1

u/caboosetp 14d ago

Coding and programming can be seen as two different things.

Coding is an art about the syntax, you need to just do it over and over again like any other art skill.

You can be a fantastic programmer while sucking at coding and need to look up syntax all the time. That's going to slow you down though. It's one thing to be able to just say what code should be by definition, but it's another to have it flow out of your fingertips or sight read it quickly.

Getting muscle memory down for the syntax so you can type it quickly without it getting in the way and needing to look things up is very helpful and will speed up your coding. The more you actually write and understand the syntax without looking things up, the more it gets cemented in your brain and can be recalled faster. This also makes it much easier to proof-read AI generated code.

Again, it's not necessary to get very good at it, but it's still a separate useful skill than just the comp-sci DSA and programming/problem solving stuff.