Hacker News new | past | comments | ask | show | jobs | submit login

Language syntax is redundant so that compilers can detect errors. If there was no redundancy in a language, every random stream of bytes would be a valid program.

It's like having dual-path redundancy in an airplane avionics system. If they disagree, then it is clear there's a fault in one of them - but it doesn't mean you can tell which one is erroneous. Without redundancy, there's no way to detect faulty operation.

Guessing which parse is correct, or which avionics subsystem is correct, is as bad as no redundancy at all.




> Language syntax is redundant so that compilers can detect errors.

Unfortunately, programming language syntax is not as redundant as we would wish. When the code is in the valid syntax, the compiler can parse it. When the code isn't in the valid syntax, the compiler doesn't even have a valid base to parse any information out of the code. The compiler writer may assume a common cause for certain parsing error and insert some "meaningful" error messages, but that is very different from the compiler knows anything. The "redundant" information is carried in the out-of-band channel (human vocabulary and common patterns) rather than in the syntax.


If the code does not match the grammar for the language, that is redundancy in the grammar.

The compiler can (and does, for error messages and error recovery) guess at what was meant, but it cannot know what was meant.


I think you are thinking of "redundant" in terms of information. A syntax does not carry any information on its own. It is a frame for information to reside in.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: