Programming Proverb 9: Get the syntax correct now, not later


 


How often does students say they'll fix the syntax later? They are in such a rush to enter their code that they let "little" syntax errors slide until later. Or worst still they enter code carelessly assuming that the compiler with find and highlight the syntax errors for them. It's a tempting way to write code but it is seriously flawed.


The big problem is that sometimes one syntax error can be masked by another. The problem may show up later as a hard to debug "logic" error. This is not a good situation to be in. Code with lots of syntax errors can make things bad enough that several passes through a compiler will be required to get things to compile. That pretty much guarantees that logic errors have been there somewhere.


A lot of IDEs do syntax checking on the fly as code is entered. I think this is a great thing as it tends makes many errors obvious right away. These features are not perfect though so the programmer is still obligated to pay attention to what they are doing. The ideal should be to have no syntax errors in the first compile. One isn't going to hit that all the time because of typographical errors but it should at least be the goal.


This is the ninth of a series of posts based on the book Programming Proverbs by Henry Ledgard. The index for the series is an earlier post and discussion of the list as a whole is taking place in the comments there. Comments on this "proverb" are of course very welcome here.




Skip to main content