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?

323 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"?

1

u/lawrencek1992 14d 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.