4 ms·
"Consider a syntax with no redundancy: Any random sequence of characters would then be a valid program. No error messages are even possible. A good syntax needs
by blt 11y ago
"Consider a syntax with no redundancy: Any random sequence of characters would then be a valid program. No error messages are even possible. A good syntax needs redundancy in order to diagnose errors and give good error messages." - Walter Bright, creator of D language (http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488 http://www.drdobbs.com/architecture-and-design/so-you-want-t...)
- cwzwarich 11y agoHis argument doesn't really apply to programming languages, because when people talk about syntactic redundancy they are generally talking about redundancy in the context-free (or close to it) surface syntax of the language. But the actual language of acceptable programs depends on the name resolution rules and the type system, which generally can't even be expressed with a context-sensitive grammar. In a language with a minimally redundant surface syntax you would still get an error if you use an unbound variable or call a function with arguments of the wrong type. The redundancy here helps tremendously for generating diagnostics. It's not even clear how you would eliminate it, because even determining redundancy (e.g. does a given type have a unique inhabitant modulo reduction) is undecidable in most practical settings. Beyond that, a lot of the surface-level syntactic redundancy comes from the desire to match convention, e.g. using actual words as keywords and imitating mathematical notation.
- nailer 11y ago> "Consider a syntax with no redundancy: Any random sequence of characters would then be a valid program. Nobody was proposing sending raw instructions to the CPU. Instead, the higher level things, like how we indent blocks, should not be repeated. I believe you already know this.