Coffeehouse Post

Single Post Permalink

View Thread: Programming "languages" are not real languages...
  • User profile image

    A year ago I took a course called Intro to the study of language. I decided to take it simply because I really enjoy studying languages but couldn't decide on a specific language to study that semester. I also have a hobby of designing languages and writing compilers for fun. As the course went on I became surprised to see how closely the material of the course began to correspond to the phases of a compiler.

    We first studied phonemes and phones, something that bore similarity to the lexer phase of a compiler. Like natural languages, programming languages only permit certain constructs at their most base level (certain pairings of consonants and vowels simply don't happen in English, and in compilers you aren't permitted to have a non-terminated string literal).

    Then we moved on to parsing, a phase which does essentially the same thing in both compilers and natural language. Given information from the lower-level components, you then build a tree representing words, sentences, paragraphs, etc. Or, in a compiler, you build a tree representing expressions, statements, methods, classes, etc. Just as you can't have a noun phrase in english where a noun precedes an article—"Dog the ran" is an illegal sentence—you can't have a binary operator precede its two sub-expressions in C#—so you can't have "+ 5 3"—even though such a construct is perfectly valid in other languages.

    Next, we moved on to semantics, which again is pretty much the same between natural languages and programming languages. English has rules that prohibit saying things like, "He was happy" unless at some point I said who 'he' was. Likewise, in C# you can't use a variable unless you declare it first.

    It's interesting that the later two segments of the course proved to be very difficult for much of the class, but I had a very easy time thanks to my prior experience with compiler-writing.

    To the question of whether or not programming languages are real languages, I would respond with an enthusiastic, "Hell yes!" Are they natural languages? Obviously not. They are artificial languages, created and optimized for a specific purpose.

    To the idea that 'real languages' allow you to express everything, that seems to me to be a rather fuzzy definition. I'm not actually aware of any sort of 'turing test' to determine whether or not a language can be considered 'complete'. Anyone know of any?

    As a footnote, I've long thought about trying to do something like translate the Bible into Java for the fun of it.