Computer Languages
Variety
This compiler/script classification is actually pointless since
Many languages now exist in both forms.
It gives no indication to the capabilities of the languages.
We do it this way only because it may appear to be the most significant feature to a novice.
Tutorials can be found here:
http://www.findtutorials.com/
Compiler Languages BASIC
(Beginners All purpose Symbolic Instruction Code) A programming language developed by John Kemeny and Thomas Kurtz in the mid 1960s at Dartmouth College. Originally developed as an interactive, mainframe timesharing language, it has become widely used on small computers.
BASIC is available in both compiler and interpreter form. As an interpreter, the language is conversational and can be debugged a line at a time. BASIC is also used as a quick calculator.
BASIC is considered one of the easiest programming languages to learn. Simple programs can be quickly written on the fly. However, BASIC is not a structured language, such as Pascal, dBASE or C, and it's easy to write spaghetti code that's difficult to decipher later.
The following BASIC example converts Fahrenheit to Celsius:
10 INPUT "Enter Fahrenheit "; FAHR
20 PRINT "Celsius is ", (FAHR-32) * 5 / 9
C
A high-level programming language developed at Bell Labs that is able to manipulate the computer at a low level like assembly language. During the last half of the 1980s, C became the language of choice for developing commercial software.
C can be compiled into machine languages for almost all computers. For example, UNIX is written in C and runs in a wide variety of micros, minis and mainframes.
C, as well as C++, are written as a series of functions that call each other for processing. Even the body of the program is a function named "main." Functions are very flexible, allowing programmers to choose from the standard library that comes with the compiler, to use third party functions from other C suppliers, or to develop their own.
Compared to other high-level programming languages, C appears complicated. Its intricate appearance is due to its extreme flexibility. C was standardized by ANSI (X3J11 committee) and ISO in 1989. See Turbo C, Borland C++, Microsoft C and Visual C++.
The Origin of C
C was developed to allow UNIX to run on a variety of computers. After Bell Labs' Ken Thompson and Dennis Ritchie created UNIX and got it running on several PDP computers, they wanted a way to easily port it to other machines without having to rewrite it from scratch. Thompson created the B language, which was a simpler version of the BCPL language, itself a version of CPL. Later, in order to improve B, Thompson and Ritchie created C.
The following C example converts fahrenheit to centigrade:
main() {
float fahr;
printf("Enter Fahrenheit ");
scanf("%f", &fahr);
printf("Celsius is %f\n", (fahr-32)*5/9);
}
The DOS Version in C
Following is the main event loop in the first software engine used for this Encyclopedia. Written in Turbo C, the main loop of an interactive program repeats continuously, testing all possible menu selections, keystrokes and mouse clicks that the user may enter.
The WHILE (1) statement below creates a continuous loop. An instruction at the END OF EVENT LOOP points to the beginning of the loop.
The names with double parentheses are the names of subroutines, for example, bookmark(). When bookmark() is called, the instructions in the bookmark function set the bookmark and control is returned to the BREAK. The BREAK ends the loop in order to start over at the beginning.
/*********** MAIN EVENT LOOP **********/
while (1) /* BEGINNING OF LOOP */
{
while (!charwait()) if (mouse) testMOUSE();
if (mouse)
{
if (mouseDOWNinText)
{
mouseDOWNinText=0;
CLICK=1;
unHighLightALL();
}
}
key1=getch(); /* get keystroke from keyboard */
if (key1==0) /* if 0, a second character is */
{ /* required (key2) */
key2=getch(); /* get second character */
switch (key2) { /* test contents of key2 */
case 59: HelpTopic=NO;
HelpRoutine(); break; /* F1*/
case 68: main_menu(); break; /*F10*/
case 61: PrevHistory(); break; /* F3*/
case 62: NextHistory(); break; /* F4*/
case 63: bookmark(); break; /* F5*/
case 64: findmark(); break; /* F6*/
case 71: home_key(); break;
case 79: end_key(); break;
case 75: left_arrow(); break;
case 77: left_arrow(); break;
case 72: up_arrow(); break;
case 80: down_arrow(); break;
case 73: pageup(); break;
case 81: pagedown(); break;
case 132: ctrl_PgUp(); break;
case 118: ctrl_PgDn(); break;
}
}
else
{
switch (key1) {
case 8: backspace(); break;
case 9: left_arrow(); break; /*Tab*/
case 127: ctrl_bsp(); break;
case 13: return_key(); break;
case 27: escape_key(); break;
case 2: bookmark(); break; /*Ctrl-B*/
case 6: findmark(); break; /*Ctrl-F*/
case 24: alldone(); /*Ctrl-X*/
case 17: alldone(); /*Ctrl-Q*/
default: dataentry(); break;
}
}
} /** END OF EVENT LOOP **/
COBOL
(COmmon Business Oriented Language) A high-level programming language that has been the primary business application language on mainframes and minis. It is a compiled language and was one of the first high-level languages developed. Officially adopted in 1960, it stemmed from Flomatic, a language in the mid 1950s.
COBOL is a very wordy language. Although mathematical expressions can also be written like other programming languages (see example below), its verbose mode is very readable for a novice. For example, multiply hourly-rate by hours-worked giving gross-pay is self-explanatory. COBOL is structured into the following divisions:
Division name Contains
IDENTIFICATION Program identification.
ENVIRONMENT Types of computers used.
DATA Buffers, constants, work areas.
PROCEDURE The processing (program logic).
The following COBOL example converts a Fahrenheit number to Celsius. To keep the example simple, it performs the operation on the operator's terminal rather than a user terminal.
IDENTIFICATION DIVISION.
PROGRAM-ID. EXAMPLE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 FAHR PICTURE 999.
77 CENT PICTURE 999.
PROCEDURE DIVISION.
DISPLAY 'Enter Fahrenheit ' UPON CONSOLE.
ACCEPT FAHR FROM CONSOLE.
COMPUTE CENT = (FAHR- 32) * 5 / 9.
DISPLAY 'Celsius is ' CENT UPON CONSOLE.
GOBACK.
IBM COBOLs
In 1994, IBM dropped support of OS/VS COBOL, which conforms to ANSI 68 and ANSI 74 standards and limits a program's address space to 16 bits. IBM's VS COBOL II (1984) and COBOL/370 (1991) conform to ANSI 85 standards and provide 31-bit addressing, which allows programs to run "above the line."
COBOL/370 is more compliant with AD/Cycle, has more string, math and date functions, including four-digit years, allows development through a PC window and provides enhanced runtime facilities.
FORTRAN
(FORmula TRANslator) The first high-level programming language and compiler, developed in 1954 by IBM. It was originally designed to express mathematical formulas, and although it is used occasionally for business applications, it is still the most widely used language for scientific, engineering and mathematical problems.
FORTRAN IV is an ANSI standard, but FORTRAN V has various proprietary versions. The following FORTRAN example converts Fahrenheit to Celsius:
WRITE(6,*) 'Enter Fahrenheit '
READ(5,*) XFAHR
XCENT = (XFAHR - 32) * 5 / 9
WRITE(6,*) 'Celsius is ',XCENT
STOP
END
LISP
(LISt Processing) A high-level programming language used for developing AI applications. Developed in 1960 by John McCarthy, its syntax and structure is very different than traditional programming languages. For example, there is no syntactic difference between data and instructions.
LISP is available in both interpreter and compiler versions and can be modified and expanded by the programmer. Many varieties have been developed, including versions that perform calculations efficiently. The following Common LISP example converts Fahrenheit to Celsius:
(defun f-to-c (f)
(* (- f 32) (float (/ 5 9)) ) )
(defun convert()
(format t "Enter Fahrenheit ")
(setf fa (read))
(format t "Celsius is ~a" (f-to-c fa) ) )
JAVA
A programming language designed to generate applications that can run on all hardware platforms, small, medium and large, without modification. Developed by Sun, it has been promoted and geared heavily for the Web, both for public Web sites and intranets. Developed by Sun, Java was modeled after C++, and Java programs can be called from within HTML documents or launched stand alone. When a Java program runs from a Web page, it is called a "Java applet." When it is run on a Web server, it is called a "servlet."
Java is an interpreted language. The source code of a Java program is compiled into an intermediate language called "bytecode," which cannot run by itself. The bytecode must be converted (interpreted) into machine code at runtime. Upon finding a Java applet, the Web browser invokes a Java interpreter (Java Virtual Machine) which translates the bytecode into machine code and runs it. This means Java programs are not dependent on any specific hardware and will run in any computer with the Java Virtual Machine software. On the server side, Java programs can also be compiled into machine language for fastest performance, but they lose their hardware independence as a result.
The first Web browsers to run Java applications were Sun's HotJava and Netscape's Navigator 2.0. Java was designed to run in small amounts of memory and provides enhanced features for the programmer, including the ability to release memory when no longer required. This automatic "garbage collection" feature has been lacking in C and C++ and has been the bane of C and C++ programmers for years.
Like other programming languages, Java is royalty free to developers for writing applications. However, the Java Virtual Machine, which executes Java applications, is licensed to the companies that incorporate it in their browsers and Web servers.
Java and JavaScript
Java is a full-blown programming language and is not intended for the casual programmer and certainly not the end user. JavaScript is a scripting language that uses a similar syntax as Java, but it is not compiled into bytecode. It remains in source code embedded within an HTML document and must be translated a line at time into machine code by the JavaScript interpreter. JavaScript is very popular and is supported by all Web browsers. JavaScript has a more limited scope than Java and primarily deals with the elements on the Web page itself.
Java: A Revolution?
Java was originally developed in 1991 as a language for embedded applications such as those used in set-top boxes and other consumer-oriented devices. It became the fuel to ignite a revolution in thinking when Sun transitioned it to the Web in 1994. Unlike HTML, which is a document display format that is continually beefed up to make it do more, Java is a full-blown programming language like C and C++. It allows for the creation of sophisticated applications. Thus far, Java applications have been mildly successful at the client side, but server-side Java applications have become very popular.
Java's "write once-run anywhere" model has been one of the Holy Grails of computing for decades. As CPU speeds increase, they can absorb the extra layer of translation required to execute an interpreted language, and Java is expected by many to become a major computing platform in the 21st Century. See Java platform, servlet, JSP, Java 2, J2EE, Jini, network computer, CaffeineMark and caffeine based.
The following Java example of changing Fahrenheit to Celsius is rather wordy compared to the C example in this database. Java is designed for GUI-based applications, and several extra lines of code are necessary here to allow input from a terminal.
import java.io.*;
class Convert {
public static void main(String[]args)
throws IOException {
float fahr;
StreamTokenizer in=new StreamTokenizer(new
InputStreamReader(System.in));
System.out.print("Enter Fahrenheit ");
in.nextToken();
fahr = (float) in.nval;
System.out.println ("Celsius is " +
2)*5/9);
}
}
Java Is Interpreted
Java is not compiled into machine language for a specific hardware platform like programs written in C or C++ (top). It is compiled into an intermediate language called "bytecode." The bytecode program can be run by any hardware that has a Java Virtual Machine (Java interpreter) available for it. That's the "write once-run anywhere" model that makes Java so appealing.
Java Runs on Clients and Servers
When a Java program has been called by a Web page from the client machine, it is called an "applet." When it runs on the server, it's known as a "servlet." When running stand alone in a network computer (NC), it is known as a Java application rather than an applet.
PASCAL
A high-level programming language developed by Swiss professor Niklaus Wirth in the early 1970s and named after the French mathematician, Blaise Pascal. It is noted for its structured programming, which caused it to achieve popularity initially in academic circles. Pascal has had strong influence on subsequent languages, such as Ada, dBASE and PAL.
Pascal is available in both interpreter and compiler form and has unique ways of defining variables. For example, a set of values can be stated for a variable, and if any other value is stored in it, the program generates an error at runtime. A Pascal set is an array-like structure that can hold a varying number of predefined values. Sets can be matched and manipulated providing powerful non-numeric programming capabilities.
The following Turbo Pascal example converts Fahrenheit to Celsius:
program convert;
var
fahr, cent : real;
begin
write('Enter Fahrenheit ');
readln(fahr);
cent := (fahr - 32) * 5 / 9;
writeln('Celsius is ',cent)
end.
PL/I
(Programming Language 1) A high-level IBM programming language introduced in 1964 with the System/360 series. It was designed to combine features of and eventually supplant COBOL and FORTRAN, which never happened. A PL/I program is made up of procedures (modules) that can be compiled independently. There is always a main procedure and zero or more additional ones. Functions, which pass arguments back and forth, are also provided.
Share with your friends: |