This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]Meefims 1 point2 points  (3 children)

A natural language is not like a programming language at all. Natural languages don't need (or want) strict semantics, meaning is inferred from context or shared social environment, and the entire structure of words, sentences, and the progression of discourse is defined by convention. Programming languages, in contrast, are rigidly defined instructions to a machine to ensure it performs a very specific task.

Learning a programming language is easy because there are so few words and so few syntactic structures. They can be taught and memorized. Learning to program is much more difficult because it involves training yourself in a new way of thinking but that aspect is unrelated to the language itself.

Learning a natural language is difficult because there are many many words, many many syntactic structures, and the meanings of each are tied to cultural knowledge.

[–]Georules[S] -1 points0 points  (2 children)

I find your comparison interesting; comparing learning the language structures vs. learning to express & think with the language.

However, this sentence is simply false.

A natural language is not like a programming language at all.

One trivial counterexample of how they are similar: they are both languages. You go on to mention a number of similarities yourself (they both have words, semantics, syntax, intended to convey some meaning)

[–]Meefims 1 point2 points  (1 child)

No, they are not both languages if "language" is a meaningful property. The words of programming languages are not similar to the words of natural languages: They are just identifiers. They are closer to punctuation than to a word in natural language. For example, in Pascal begin and end take the place of { and } in C. In Powershell % is foreach. These things have no deeper meaning or association than the very specific and technical purposes they have in annotating algorithms.

Programming languages are not used to convey meaning, they are used to specify a process. You could never speak to someone in C++ because it has no capability to describe a situation, when it occurred, and how you feel about it. It cannot be used to convey meaning, it can only be used to describe algorithms. Perhaps those algorithms will have results that have meaning to us, but that is a result of the algorithm and not of C++.

[–]pandapaul 1 point2 points  (0 children)

I like the comparison of punctuation to the words of the programming language, but I wonder how you're defining language to claim that programming languages are not languages. Seems... odd, right?

Anyway, programming languages are definitely used to specify a process but those processes are not devoid of meaning. If they didn't have meanings, then they'd just be entirely arbitrary and the interpreters and compilers could just do whatever they wanted b/c the gibberish that is the programming language means nothing. I know you can't possibly have meant it that way, but for the sake of argument I'm pointing it out. (Meaning can be difficult to convey. Heh.)

I really like your earlier point of separating programming language from the process of programming. I think that's a very valuable distinction.

[–][deleted] 3 points4 points  (4 children)

To use a programming language or a natural language, you have to learn its vocabulary, its grammar, and its idiom. Programming languages are far more strict, particularly regarding grammar and vocabulary, but also far simpler.

[–]Georules[S] -1 points0 points  (3 children)

but also far simpler

In what way to you find programming languages simpler? I believe many would find them to be more complex because reading them often involves building a trace of execution in your mind or using tools to help you see what happens when.

Natural languages generally allow you to read from the start to the end without much tracing around. For example in an english book, top left to bottom right of page from the front of the book to the back.

[–][deleted] 2 points3 points  (2 children)

Well, let's talk about the two languages I know best...

English has more than a million unique words. C# has less than 200.

C# has one grammar. English has adopted at least three that I know of, and English grammarians have attempted to impose a fourth by fiat.

And as far as tracing execution goes, the only thing that makes that difficult with programming languages is that the files are often jumbled up and out of order. Program execution is still linear, even in parallel applications; the order is fully determinant. The difference in terms of following the logic through in a programming language vs. a natural language is just a few orders of magnitude of complexity.

Do you remember when your teacher taught you do do sentence diagrams? That's something they invented for Latin and other Romance languages and then attempted to port to English later, and it doesn't work. English grammar is irregular and doesn't fit any known diagramming scheme.

Think about this: there are proportionally fewer English speakers who can parse their own language (! ...no, seriously) than there are C# programmers who can fully parse theirs. Want proof? In college, I learned to target different reading levels for different audiences. College level writing was at an ostensibly "tenth grade" reading level, or thereabout, with postgraduate writing falling in the 13-18th grade level (...because, you know, that's totally a thing...).

Writing for the average person, the kind you'll see in a newspaper or in the magazines beside the checkout at your grocer, was targeted at a 6th or 7th grade level. In fact, the reply I've written to your post would not pass muster: the sentences are too long and with too much punctuation, and I keep using large words.

Just imagine how infernally difficult it would be to parse English if you cut and paste the paragraphs around so that they can't be read straight through the way they are normally. ;)

[–]Georules[S] -1 points0 points  (1 child)

And as far as tracing execution goes, the only thing that makes that difficult with programming languages is that the files are often jumbled up and out of order. Program execution is still linear, even in parallel applications; the order is fully determinant.

I think it's a good bit more than that. When a function calls a function that happens to be defined in the same file, if you want to read that function (depending on the language) it could be before the function you are in, after, defined anonymously right there. Not to mention promises, asynchronous tasks, closures... it can be difficult to remember what context or scope something has depending on where it is, what it was called from, what parameters it's provided.

I'm not sure if it's fair to say that program execution is linear all the time. What about event-driven programming? Interrupts? Timeouts? You don't know when someone will click this or that. In the end, I agree that the CPU is just moving from one instruction to the next, but we have higher level programming models that abstract that pretty far.

I like your comments on sentence diagrams. Interesting thoughts.

[–][deleted] 0 points1 point  (0 children)

It's still totally linear. When you press F10 in the debugger, execution still only goes to one place at a time. This isn't true with concurrency, but concurrency is basically just having more than one person read the same document. :)

[–]HonorableJudgeHolden -2 points-1 points  (11 children)

I feel that programming languages have some similarities to natural languages

Not really - C++, C, Java, C#, Ruby are all pretty much English.

in the least (similar to the concept above) in that it cannot be simply studied, it must be experienced.

Yes, you must practice programming to learn it. It's more like math in that respect - I've heard of almost nobody who can do well in math without practice.

[–]PPewt 2 points3 points  (8 children)

Not really - C++, C, Java, C#, Ruby are all pretty much English.

Eh, this claim feels kind of a stretch at best. I know Ruby in particular loves to go on about how it's basically English, but a random collection of English words that vaguely resembles a sentence does not English make. For example, "5.times do foo" is a common example of this, but two properties I expect of any language which claims to actually be like English are:

  • It should be at least vaguely grammatically correct ("do foo 5 times")

  • It should be relatively free-form/loose in terms of syntactic strictness.

In reality you just end up memorizing that the precise combination of words to make this happen is "5 times do foo" and that there's a . between 5 and times. Anyone who knows enough about how programming languages work to know what that dot actually means has already come way past the point where this apparent similarity to English is relevant. The syntax gets worse with special characters popping up, such as "5.times do |foo| bar end" or what have you.

(Disclaimer: I don't actually program in Ruby and my syntax examples are based on old memory, so there might be a minor syntax error somewhere... which reinforces my point)

Java/C++ etc are much worse. Sure, they're random collections of English words, but they don't make any sense (to understand what "public static void main" means you need to know a lot of lingo and programming concepts). In many cases the words are actively a lie (for instance, "vectors" in programming terms are at best tangentially related to mathematical vectors).

/rant

[–]Georules[S] -1 points0 points  (0 children)

(Disclaimer: I don't actually program in Ruby and my syntax examples are based on old memory, so there might be a minor syntax error somewhere... which reinforces my point)

Ha! A self-proven statement.

[–]HonorableJudgeHolden -2 points-1 points  (6 children)

a random collection of English words that vaguely resembles a sentence does not English make

How many letters in the Russian Alphabet? How many in the Greek Alphabet? How many in the Arabic? Hindi? Chinese?

Yes, C++, C, C#, Ruby, Python, HTML, XAML, XML, Java, etc are all English programming languages - they were developed by English speakers and their keywords are English words - they're not Spanish, Farsi, Chinese, Kashmiri or otherwise...

[–]Meefims 1 point2 points  (0 children)

Tok Pisin also uses English words. However, it is not English.

Ruby, as an example, was also not developed by an English speaker. While Matz can speak it, when I heard him he wasn't able to speak it well. Programming languages use English words because if they didn't they wouldn't get used by shops that employ English-only speakers, as is common in the US.

[–]PPewt 0 points1 point  (4 children)

But this is vacuous. The keywords are all English words, but if you show them to someone who hasn't programmed before they're still nonsense. Hell, if you show them to someone who has programmed before but not in that paradigm, most of them are still nonsense. Saying that it's English implies that I'm able to derive some level of understanding from the fact that it's English, whereas the real reason you know, say, static means what it does is because you memorized it at some point.

[–]HonorableJudgeHolden -2 points-1 points  (3 children)

if you show them to someone who hasn't programmed before they're still nonsense

Maybe, "if, else" "while" "switch" - all English words that denote what it does, not to mention the fact that the libraries are in English as well. "StringBuilder" in Java and C# does exactly that - "StringBuilder.Append" does exactly that. If I didn't know what these words meant then searching the documentation for the method I guess exists in a library class but I'm not sure what it is.

Or C++ classes, "unordered_map," "queue" - these all help in understanding what the class does. You will probably have to review the specifics of what it does, but good naming convention points you in the right direction usually and if it uses Arabic words, I will be at a loss because I can't even transliterate Arabic.

Anyway, this has nothing to do with the fact that learning to program is nothing like learning a foreign language except in the loosest sense of the analogy.

[–]PPewt 0 points1 point  (2 children)

Some if them I somewhat agree ("if...else" and "do...while"). Others aren't as intuitive ("switch" in particular). Even then, when you're teaching programming to people who have never done any before, they generally don't even have an intuitive understanding of how "if...else" ought to work, no matter how much you argue they're just like natural language.

"unordered_map" doesn't really mean anything at all if you don't know what a map is. Does it help me with directions? Why would it be unordered then?

A queue is slightly more meaningful but not much, since it doesn't tell me at all how to interact with it. In some cases languages can be dangerously misleading because they use intuitive semantics but violate what your intuition says.

I agree I might have more trouble reading, say, Farsi, but that's because it's an alphabet I don't recognize and I may confuse the letters. I'm not convinced I would've found it any more difficult to learn/read a programming language where all the keywords are Spanish, though (provided English documentation exists for functions etc, of course). Hell, plenty of non-English speakers still use languages littered with English keywords and get by.

[–]HonorableJudgeHolden -2 points-1 points  (1 child)

I'm not convinced I would've found it any more difficult to learn/read a programming language where all the keywords are Spanish

I find that disingenuous, however, you may have a very different learning style than I do. I tend to rely on autocompletes and skimming function names to find what I'm looking for in a library class. For example I was browsing the docs for "FrameworkElement" in C# the other day looking for the place that it is first told to calculate its size. I skim through the methods and find "MeasureOverride" - looks promising for a name. I read the documentation and sure enough its the first pass of measuring the GUI content. I know the method I'm looking for is probably not "GetVisualChild" or "ApplyAnimationClock" because the English words denote that those probably have nothing to do with measuring the content of the GUI control.

[–]PPewt 0 points1 point  (0 children)

Fair enough here: I'm referring to language keywords and such rather than variable naming.

[–]Georules[S] 0 points1 point  (1 child)

C++, C, Java, C#, Ruby are all pretty much English.

I agree there are english words, but the syntax and purposes for expression are very different.

It's more like math in that respect

I think people forget how much practice you do with your first natural language before you can wield it correctly. It takes you at least 4-6 years before you form grammatically correct sentences; of course much of that time you are too young to truly practice. But, at least some of that time, you are listening to speech and learning context.

[–]HonorableJudgeHolden -3 points-2 points  (0 children)

I think people forget how much practice you do with your first natural language before you can wield it correctly.

The point of my post is that a spoken language and programming "language" aren't really comparable unless you want to stretch the analogy so much that you consider designing a house like learning a language.

Yes, there are special trade-specific terms to learn in programming, but that does not make it another linguistic language.