Ask HN: memorization of syntax

3 points by nazgulnarsil ↗ HN
A professor at my college that has helped me out with projects before has said that he thinks memorization of syntax is important for first year programming students to learn. This was sort of a WTF moment for me. Is this a common position? It's not how I learned and it sounds harmful. If HN agrees, what should I say to convince him otherwise?

11 comments

[ 3.9 ms ] story [ 46.4 ms ] thread
How did you learn syntax?
by writing code, not by being quizzed on what parameters some random function needs to be passed.
What do the parameters of some random function have to do with the syntax of a language?

A Computer Science professor is unusually likely to use the word "syntax" very precisely.

You've gotta know the syntax or you'll spend so much time looking things up that you'll never get anything done.
I doubt he meant that you should memorize the syntax through, say, flashcards. Rather, he probably meant that you need to program enough in something so that you memorize the syntax as an incidental benefit. Once you've memorized - internalized - the syntax, there will be significantly less friction when you program.
Until you're comfortable enough with the syntax that you can hand-write code out on a blank sheet of paper, you don't really know the language. How you learn the syntax is up to you, but especially for your first language spending time that's specifically dedicated to learning the syntax is very helpful.
(comment deleted)
(comment deleted)
(comment deleted)
(comment deleted)
It seems to me that a couple of different issues are being conflated here.

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.