A Brief Lesson

The CPU is designed to process, calculate, and/or maniputlate data. A computer program is a list of machine instructions for the CPU to carry out or execute, one at a time and in a given order.

The job of a programmer is to write a to-do list of instructions for the CPU, choosing the appropriate instructions and putting them in the proper order to accomplish the desired result.

Hierarchy of Languages

The CPU's built-in set of instructions is also known as its machine language or machine code. The machine language instructions are written in the form of binary numbers (1's and 0's), which are translated to the on-off states of the CPU's transistors.

While it is possible to write a program with machine code, it's not easy. A machine language usually has a corresponding Assembly language that puts each machine language instruction into a form that's a bit easier for people to read.
ADD AX,14
means add 14 to the contents of register AX


Assembly uses commands like ADD, STORE and RECALL followed by memory addresses within he computer. While easier than machine code, assembly's still a pain to use. Most programers use high-level languages to write their programs. The syntax (rules and structure) of high-level languages is closer to English than both assembly and machine code.

Some of the best-known high-level languages are:
FORTRAN (Formula Translator is used by scientists and engineers)
BASIC (a good first language to learn)
COBOL (COmmon Business Oriented Language designed to write data processing applications for business)
C++ (a general all-purpose language and along with C, the most widely used program today)
Java (designed for networking computing and the Internet)

A typical instruction in a high-level language might look like this:
if(theLight=="red"){
    theBrake="on";
 }

Each high-level language has its own syntax. Programs are typically typed into the computer in the form of text files and then run through a special program referred to as an Interpreter or a Compiler.

Interpreters and Compilers

Once a program has been created using a high-level language, it must then be translated into terms that the CPU can understand. The translation process, turning the source-code into machine code, is carried out by another computer program.

There are two basic ways a translator program can work:
  1. Intrerpreting— The program takes the source code and translates one line at a time into machine code and then executes the resulting machine code before moving on to the next high-level instruction.

  2. Compiling— A compiler takes the high-level source code and translates all of it into machine language before executing or running any of it.

Structured and Object-Oriented

Programs can also be catagorized as structured or Object-Oriented. Structured languages are designed so that programs may be built up out of smaller modules or sub-programs (sub-routines, functions, and or proceedures). This modularization makes it easier to debug programs and or modify them at a later date.

In the OOP approach, programmers build programs out of self-contained software objects, which are made up of data and code. C++ and Java are examples of OOP languages.

Scripting vs. Programming

A programming language may be used to create stand-alone applications, while a scripting language is usually built into a specific application, and cannot be used outside of that application. A script is essentially a mini-program that runs within the confines of the application.

In 1995 Netscape decided to include javaScript in the Navigator browser, in order to add interactivity to web pages.

A JavaScript interpreter is built into most browsers. When the source document containing JavaScript is loaded by a browser, the browser translates the HTML code from top to bottom. If it finds JavaScript instructions along the way, then the built-in interpreter translates and executes the code line by line.

JavaScript is not Java, it is not even a stripped down version of Java. However, it is similar to Java in much of its structure and syntax, and learning to use it will make learning Java easier.


JavaScript