Document Sample
Languages Powered By Docstoc
					                Computer Languages
I. Variety
This compiler/script classification is actually pointless since

1. Many languages now exist in both forms.

2. 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:

    A. Compiler Languages

         a. 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
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

          b. 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

  /*********** MAIN EVENT LOOP **********/

 while (1)               /* BEGINNING OF LOOP */

    while (!charwait())          if (mouse) testMOUSE();

    if (mouse)
         if (mouseDOWNinText)

  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;
   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;

            c. 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



  77 FAHR PICTURE 999.
  77 CENT PICTURE 999.

  DISPLAY 'Enter Fahrenheit ' UPON CONSOLE.
   COMPUTE CENT = (FAHR- 32) * 5 / 9.

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.

          d. 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

          e. 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

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) ) )

          f. 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.
 class Convert {
   public static void main(String[]args)
    throws IOException {
     float fahr;
     StreamTokenizer in=new StreamTokenizer(new
     System.out.print("Enter Fahrenheit ");
         fahr = (float) in.nval;
         System.out.println ("Celsius is " +

1.         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
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.

         g. 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;


    fahr, cent : real;


     write('Enter Fahrenheit ');


     cent := (fahr - 32) * 5 / 9;

     writeln('Celsius is ',cent)


           h. 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.

         B. Script Languages

           a. AWK

Aho Weinberger Kernighan) A UNIX programming utility developed in 1977 by Alfred Aho,
Peter Weinberger and Brian Kernighan. Due to its unique pattern-matching syntax, awk is
often used in data retrieval and data transformation. Awk is widely used to search for a
particular occurrence of text and perform some operation on it. Awk is an interpreted language,
which has been ported to other computing environments, including DOS. See Gawk.

           b. CGI

(Common Gateway Interface script) A small program written in a language such as Perl, Tcl, C
or C++ that functions as the glue between HTML pages and other programs on the Web server.
For example, a CGI script would allow search data entered on a Web page to be sent to the
DBMS (database management system) for lookup. It would also format the results of that
search as an HTML page and send it back to the user. The CGI script resides in the server and
obtains the data from the user via environment variables that the Web server makes available
to it.

CGI scripts have been the initial mechanism used to make Web sites interact with databases
and other applications. However, as the Web evolved, server-side processing methods have
been developed that are more efficient and easier to program. For example, Microsoft
promotes its Active Server Pages (ASPs) for its Windows Web servers, and Sun/Netscape
nurtures its Java roots with JavaServer Pages (JSPs) and servlets. See ASP, JSP, servlet and
Web Server Evolution
Starting at the top and moving down, this illustration shows Web and application server
processing as it evolved initially using only CGI scripts and later using Java components. The
separation of logic is portrayed here, and the Web server (HTTP server) and application server
may reside in the same or different computers.

         c. JAVAScript

A popular scripting language that is widely supported in Web browsers and other Web tools. It
adds interactive functions to HTML pages, which are otherwise static, since HTML is a display
language, not a programming language. JavaScript is easier to use than Java, but not as
powerful and deals mainly with the elements on the Web page. On the client, JavaScript is
maintained as source code embedded into an HTML page. On the server, it is compiled into
bytecode (intermediate language), similar to Java programs.

JavaScript evolved from Netscape's LiveScript language. First released with Navigator 2.0, it
was made more compatible with Java. JavaScript does not have the programming overhead of
Java, but can be used in conjunction with it. For example, a JavaScript script could be used to
display a data entry form and validate the input, while a Java applet or Java servlet more
thoroughly processes the information. JavaScript is also used to tie Java applets together. See
JScript, Java, Java applet, servlet and VBScript.

         d. Perl
(Practical Extraction Report Language) A programming language written by Larry Wall that
combines syntax from several UNIX utilities and languages. Introduced in 1987, Perl is
designed to handle a variety of system administrator functions and provides comprehensive
string handling functions. It is widely used to write Web server programs for such tasks as
automatically updating user accounts and newsgroup postings, processing removal requests,
synchronizing databases and generating reports. Perl has also been adapted to non-UNIX
platforms. See also PURL.

         e. PHP
(PHP Hypertext Preprocessor) A scripting language used to create dynamic Web pages. With
syntax from C, Java and Perl, PHP code is embedded within HTML pages for server side
execution. It is commonly used to extract data out of a database and present it on the Web
page. The major NT and UNIX Web servers support the language, and it is widely used with
the mSQL database. PHP was originally known as "Personal Home Page." See mSQL

         f. Python

         g. Shells
1. Unix/Linux shells:
a. Bourne shell.

b. Bourne Again SHell.

c. C shell.

d. Korn shell.

2. DOS shell

3. 4DOS, 4OS2.

         h. VBScript

(Visual Basic SCRIPT) A scripting language from Microsoft. A subset of Visual Basic, VBScript
is widely used on the Web for both client processing within a Web page and server-side
processing in Active Server Pages (ASPs). As an ActiveX scripting language, VBScript is also
used with the Windows Script Host (WSH) to perform functions locally on a Windows machine.
See JScript and ASP.

II. Structures
     1. Program: Main, Subprogram.

     2. Order: Preprocessor, Declaration, Statements.

     2. Syntax: Continuation, Case, Comments.

     3. File: external.

     4. Source Files-> Object Files

            a. Executables
             b. Libraries ( Static / Dynamic )

III. Variables

    A. Types
1. Integers.

2. Floating Points.

3. Characters.

4. Bits.

5. Pointers.

    B. Modifiers
Long, short, double, …

    C. Scopes


    D. Duration

    E. Declaration & Allocation

    F. Organized
1. Arrays / Strings.

2. Structures.

3. Classes

IV. Operators

    A. Arithmic
+, -, *, /, % …

    B. Relational
>, <, = =, …

    C. Logic
&&, ||, !

    D. Bitwise
&, |, ^, <<, >>, ~

    E. Miscellaneous
+ +, - -, ? :, …

    F. Precedence

V. Flow Control

    A. Decision
1. IF … THEN … ELSE.


3. GOTO.

    B. Loop
1. FOR.

2. DO … END DO



VI. Functions
Returned value.

Arguments: Call by value, Call by reference.

Variables: local, global, external.

              static, transient.
Entry point, Return point.

Recursive, Variable argument list.

System Calls

VII. Preprocessors






Pipes & Filters


Classes & Objects:

1. Data Encapsulation.

2. Privacy & Friends.
3. Operator Overload.

4. Derivation and Inheritance.

X. Functional Programming

A. Cumming: A Gentle Introduction to ML

XI. Reflection


     A. Visual Basic
A version of the BASIC programming language from Microsoft specialized for developing
Windows applications. When first released in 1991, Visual Basic was similar to Microsoft's
QuickBASIC. By the mid 1990s, it became extremely popular. User interfaces are developed
by dragging objects from the Visual Basic Toolbox onto the application form.

Visual Basic (VB) is widely used to write client front ends for client/server applications. As of
Version 5.0, it is also used to create ActiveX controls for the Web (both EXE's and DLL's).
Visual Basic for Applications (VBA) is a subset that provides a common macro language
included with many Microsoft applications.

Up until VB 5, the Visual Basic compiler only converted the source code written by the
programmer into an intermediate language called "bytecode." Starting with VB 5, native
executable programs can be generated. No matter what the version, in order to run a VB
program, the VB runtime module, must reside in the target computer. This .DLL file, named
VBRUNxxx (up to VB 4) or MSVBVMxx (VB 5 and after), where x is the version number,
contains necessary runtime libraries and also converts programs compiled to bytecode into the
machine language of the computer. The runtime DLLs are widely available and typically
accompany a Visual Basic application. See compiler and VBScript.

Visual Basic Is Interpreted
Visual Basic is similar to Java. It is compiled into an intermediate language called "bytecode."
The bytecode is translated into x86 machine language by the Visual Basic runtime module.
Starting with VB 5, native executable (.EXE files) can also be generated, but the runtime
module, which provides necessary runtime functions, must still reside in the target computer.

     B. Visual C++
A C and C++ development system for DOS and Windows applications from Microsoft. It
includes Visual Workbench, an integrated Windows-based development environment and
Version 2.0 of the Microsoft Foundation Class Library (MFC), which provide a basic framework
of object-oriented code to build an application upon.

Introduced in 1993, the Standard Edition of Visual C++ replaces QuickC for Windows and the
Professional Edition includes the Windows SDK and replaces Microsoft C/C++ 7.0.

     C. VisualAge
A family of object-oriented application development software from IBM that includes VisualAge
for Basic, VisualAge for C++, VisualAge for COBOL, VisualAge for Java, VisualAge for
PacBase and VisualAge for Smalltalk. For example, VisualAge for C++ is a multiplatform
environment for writing C++ applications for OS/2, Windows, AS/400, MVS/ESA, AIX and
Solaris. It is widely used to write an application on one platform that will be used on another.

Today, the skills of a VisualAge programmer are not implicit, as the term refers to several
languages. In the past it implied one or two. The VisualAge name was first used in the late
1980s for Smalltalk, then in 1994 for C++ and later for all the others. Nevertheless, all the
VisualAge languages are themselves written in IBM's Smalltalk. See Smalltalk.

     D. TCL/TK
(Tool Command Language/ToolKit) Pronounced "tickle" or "ticklet," it is an interpreted script
language that is used to develop a variety of applications, including GUIs, prototypes and CGI
scripts. Created for the UNIX platform by John Ousterhout along with students at the
University of California at Berkeley, it was later ported to PCs and Macs. Safe-Tcl is an
enhanced Tcl interpreter that provides a secure, virus free environment.

Tcl also provides an interface into compiled applications (C, C++, etc.). The application is
compiled with Tcl functions, which provide a bi-directional path between Tcl scripts and the
executable programs. Tcl provides a way to "glue" program modules together. The Tk part of
Tcl/Tk is the GUI toolkit, which is used to create graphical user interfaces. Other languages,
including Perl, Python and Scheme, have incorporated Tk as well.

Starting Point: