Programming languages

Early languages

Programming languages are the languages in which a programmer writes the instructions that the computer will ultimately execute. The earliest programming languages were assembly languages, not far removed from the binary-encoded instructions directly executed by the machine hardware. Users soon (beginning in the mid-1950s) invented more convenient languages.

FORTRAN

The early language FORTRAN (Formula Translator) was originally much like assembly language; however, it allowed programmers to write algebraic expressions instead of coded instructions for arithmetic operations. As learning to program computers became increasingly important in the 1960s, a stripped down “basic” version of FORTRAN called BASIC (Beginner’s All-Purpose Symbolic Instruction Code) was written by John G. Kemeny and Thomas E. Kurtz at Dartmouth College, Hanover, New Hampshire, U.S., to teach novices simple programming skills. BASIC quickly spread to other academic institutions, and, beginning about 1980, versions of BASIC for personal computers allowed even students at elementary schools to learn the fundamentals of programming.

COBOL

At roughly the same time as FORTRAN was created, COBOL (Common Business-Oriented Language) was developed to handle records and files and the operations necessary for simple business applications. The trend since then has been toward developing increasingly abstract languages, allowing the programmer to think and communicate with the machine at a level ever more remote from machine code.

Imperative versus functional languages

COBOL, FORTRAN, and their descendants, such as Pascal and C, are known as imperative languages, since they specify as a sequence of explicit commands how the machine is to go about solving the problem at hand; this is not very different from what takes place at the machine level. Other languages are functional, in the sense that programming is done by calling (i.e., invoking) functions or procedures, which are sections of code executed within a program. The best-known language of this type is LISP (List Processing), in which all computation is expressed as an application of a function to one or more “objects.” Since LISP objects may be other functions as well as individual data items (variables, in mathematical terminology) or data structures (see the section Data structures and algorithms), a programmer can create functions at the appropriate level of abstraction to solve the problem at hand. This feature has made LISP a popular language for artificial intelligence applications, although it has been somewhat superseded by logic programming languages such as Prolog (Programming in Logic). These are termed nonprocedural, or declarative, languages in the sense that the programmer specifies what goals are to be accomplished but not how specific methods are to be applied to attain those goals. Prolog is based on the concepts of resolution (akin to logical deduction) and unification (similar to pattern matching). Programs in such languages are written as a sequence of goals. A recent extension of logic programming is constraint logic programming, in which pattern matching is replaced by the more general operation of constraint satisfaction. Again, programs are a sequence of goals to be attained, in this case the satisfaction of the specified constraints.

Recent developments

Object-oriented languages

An important trend in programming languages is support for data encapsulation, or object-oriented code. Data encapsulation is best illustrated by the language Smalltalk, in which all programming is done in terms of so-called objects. An object in Smalltalk or similar object-oriented languages consists of data together with the procedures (program segments) to operate on that data. Encapsulation refers to the fact that an object’s data can be accessed only through the methods (procedures) provided. Programming is done by creating objects that send messages to one another so that tasks can be accomplished cooperatively by invoking each others’ methods. This object-oriented paradigm has been very influential. For example, the language C, which was popular for engineering applications and systems development, has largely been supplanted by its object-oriented extension C++. An object-oriented version of BASIC, named Visual BASIC, is available for personal computers and allows even novice programmers to create interactive applications with elegant graphical user interfaces (GUIs).

In 1995 Sun Microsystems, Inc., introduced Java, yet another object-oriented language. Applications written in Java are not translated into a particular machine language but into an intermediate language called Java Bytecode, which may be executed on any computer (such as those using UNIX, Macintosh, or Windows operating systems) with a Java interpretation program known as a Java virtual machine. (See Program translation below.) Thus Java is ideal for creating distributed applications or Web-based applications. The applications can reside on a server in Bytecode form, which is readily downloaded to and executed on any Java virtual machine. In many cases it is not desirable to download an entire application but only an interface through which a client may communicate interactively with the application. Java applets (small chunks of application code) solve this problem. Residing on Web-based servers, they may be downloaded to and run in any standard Web browser to provide, for example, a client interface to a game or database residing on a server.

Concurrency

Concurrency refers to the execution of more than one procedure at the same time (perhaps with the access of shared data), either truly simultaneously (as on a multiprocessor) or in an unpredictably interleaved manner. Languages such as Ada (the U.S. Department of Defense standard applications language from 1983 until 1997) include both encapsulation and features to allow the programmer to specify the rules for interactions between concurrent procedures or tasks.

High-level languages

At a still higher level of abstraction lie visual programming languages, in which programmers graphically express what they want done by means of icons to represent data objects or processes and arrows to represent data flow or sequencing of operations. As of yet, none of these visual programming languages has found wide commercial acceptance. On the other hand, high-level user-interface languages for special-purpose software have been much more successful; for example, languages like Mathematica, in which sophisticated mathematics may be easily expressed, or the “fourth generation” database-querying languages that allow users to express requests for data with simple English-like commands. For example, a query such as “Select salary from payroll where employee = ‘Jones,’ ” written in the database language SQL (Structured Query Language), is easily understood by the reader. The high-level language HTML (HyperText Markup Language) allows nonprogrammers to design Web pages by specifying their structure and content but leaves the detailed presentation and extraction of information to the client’s Web browser.

Program translation

Computer programs written in any language other than machine language must be either interpreted or compiled. An interpreter is software that examines a computer program one instruction at a time and calls on code to execute the operations required by that instruction. This is a rather slow process. A compiler is software that translates a computer program as a whole into machine code that is saved for subsequent execution whenever desired. Much work has been done on making both the compilation process and the compiled code as efficient as possible. When a new language is developed, it is usually at first interpreted. If the language becomes popular, it becomes important to write compilers for it, although this may be a task of considerable difficulty. There is an intermediate approach, which is to compile code not into machine language but into an intermediate language that is close enough to machine language that it is efficient to interpret—though not so close that it is tied to the machine language of a particular computer. It is use of this approach that provides the Java language with its computer-platform independence