FIRST ISSUE: What syntax is available.
Memorization is the way to go here.
For example, write this in C, and you look like a moron:
foo();
while (bar()) {
foo();
}
... as well as violating DRY and thus producing less maintainable code, etc., etc., because you can do it this way: do {
foo();
} while (bar());
But if you don't already know that C has a loop construct with the test at the end, then you'll never write the second version.SECOND ISSUE: Exactly how the syntax is put together.
Maybe this needs to be memorized, and maybe not.
Consider the above example. I write a "do-while" loop maybe a couple of times a year (?). If I forget exactly how to type it in (semicolor at the end, or not?), then I can look it up. So I figure, as long as I know that "do-while" exists, I can look up the details when I need them.
On the other hand, I write a "for" loop once a week, at least. If I hadn't memorized the pattern
for (INIT; COND; INCR) { ... }
then I would waste huge amounts of time looking it up every time I needed it.However, I don't really need to predict in advance exactly what syntax I need to memorize the details of. If I find myself looking something up more than once in a week/month/whatever, then it's probably time to memorize that.
Disclaimer: If you're taking a college class, and the instructor says to memorize something, then you'd better know it, at least until the final exam is over.
A Computer Science professor is unusually likely to use the word "syntax" very precisely.