Monday, December 04, 2006

Types of programming errors

Programs often contain errors which may cause the program not to run or, even worse, to run but yield incorrect results. Much of the task of programming is to locate and correct these errors to produce a program that runs correctly.

There are two main classes of errors : syntax (or grammatical) errors and semantic (or logical) errors :

Syntax errors

This first class of errors that can be made are relatively easy to detect, in the first case by a human and in the second case by a compiler at compile-time. It's just like a grammar error in a language. For example in English : "I is hungry" instead of "I am hungry".

Semantic errors

This second class of errors that can be made are much harder to detect for humans and in general impossible for the compiler to pick up (obviously the computer does not know what the programmer intended). If we keep the example of the English language, it's like if you tell somebody : "Let's meet tomorrow at 8am" but you meant 8pm.

No comments: