Difference between Syntactic and Semantic Error

Syntactic errors also known as compilation errors are caused by violation of the grammar rules of the language. The compiler detects, isolate these errors and give terminate the source program after listing the errors. Some of the common syntactic errors are:
• missing or misplaced.
• missing return type for a procedure.
• missing or duplicate variable declaration.
Semantic errors are logical errors. If there is a semantic error in a program, it will run successfully, in the sense that the computer will not generate any error messages, but it will not do the right thing. The problem is that the meaning of the program (its semantics) is wrong. Identifying semantic errors can be tricky because it requires working backward by looking at the output of the program and trying to figure out what it is doing.
difference between syntax error and semantic error

Difference between Run time error and logical error

Run-time errors: Errors such as mismatch of data types or array out of bound error are known as runtime errors. These errors are generally go undetected by the compiler so programs with run-time error will run but produce erroneous results.

Logical errors: These are the errors related with the logic of the program execution. These errors are not detected by the compiler and are primarily due to a poor understanding of the problem or a lack of clarity of hierarchy of operators. Such errors cause incorrect result.

Difference between  Compiler and Interpreter

These are two types of language translators.A compiler converts the source program (user-written program) into an object code (machine language by checking the entire program before execution. If the program is error free, object program is created and loaded into memory for execution. A compiler produces an error list of the program in one go and all have to be taken care even before the execution of first statement begin. It takes less time for execution.
An interpreter is also a language translator that translates and executes statements in the program one by one. It work on one statement at a time and if error free, executes the instruction before going to second instruction. Debugging is simpler in interpreter as it is done in stages. An interpreter takes more time for execution of a program as compared to a compiler.
Keywords: Syntax error, semantic error, logical error, runtime error, compiler, interpreter.

Leave a Reply

Your email address will not be published. Required fields are marked *