Friday, August 31, 2007

Grammaticalization in text editors?

Syntax highlighting in text editors typically only works for well-defined programming language categories: keywords appear in one color, identifiers (variables) in another, comments in a third, etc. While using the vim editor to edit a Python program today, I added an "XXX" comment to indicate that I wasn't happy with the solution I'd devised for that part of the problem. XXX is a cultural convention, not a feature of the Python language, and in any case it was inside a comment. Still, the vim editor's syntax-highlighting feature flagged the XXX in a bright yellow background, making it more prominent than the rest of the program. Any modification to the XXX turned the highlighting off. In other words, someone working on the vim editor had decided to treat a cultural convention like a syntactic feature of the language. Programming-language textbooks often start by describing programming languages as a simplified version of human languages, but I never expected to see this kind of thing happening! It suggests that grammmaticalization is a strong driving force in our use of language.


FutureNerd said...
This comment has been removed by the author.
FutureNerd said...

Yeah well I would have edited if I knew where the edit button was.

Script files are interpreted by more than one computer grammar. For instance, the first line of many Python programs is a comment in Python, but a line that means "run this with the Python interpreter" to the program loader.

Web pages have Javascript programs inside of html comments. Postscript has a convention for marking page boundaries in Postscript comments.