Monday, April 11, 2011

Computer Languages

Languages are used in everyday life for communication. All of us speak a
native language and, depending on how much we read or write, we can develop
a deep understanding of that language. The important thing about language
is that you use it effectively to communicate your intentions, needs, wishes, or
feelings.


Computer languages are similar to spoken languages in that you must use them
very precisely so that you are not misunderstood by the computer. Each language
has its own grammar, or syntax, which must be followed for the computer to
understand that language.

Consider these examples from spoken languages:

English: Hello, how are you?
French: Bonjour! Ca va bien?
German: Guten tag. Wie geht’s?
Japanese: Konnichi wa. O genki desu ka?

All of these examples mean the same thing: each sentence has a greeting followed
by a question asking how you are. But each example is a completely different
group of words. Unless you know these languages, you would not know that each
means the same thing.
Computer languages are similar in that there are basic tasks that any computer
language must do for a programmer. The programmer just has to learn to
‘‘speak’’ the language. One advantage of a computer language over a spoken
language is that is does not take that long to become fluent in a computer
language! Many programmers learn several languages during their careers.
Computer Languages

Now read these examples from some computer languages:

BASIC if (x > 5) print "greater."
Pascal if x > 5 then writeln (greater.);
C++ if (x > 5) cout << "greater.";
Java if (x > 5) System.out.println ("greater.");

All of these statements accomplish the same task: if the contents in the variable
called x is greater than the number 5, then we will print a message on the
computer screen—the word ‘‘greater.’’