Programming Languages
Objective #1: List several popular high-level programming languages and explain how they are compiled or interpreted into machine code.
- Besides Java, other high-level programming languages are Python, BASIC, Visual Basic, C, C++, Pascal, FORTRAN, and COBOL. A history of computer languages can be found at levenez.com/lang. Here is an interesting look at "hello world" programs in other computer languages.
- Java was created relatively recently in 1991 by James Gosling and Patrick Naughton at Sun Microsystems as a language to be used in consumer devices such as t.v.'s, alarm clocks, etc. Since then the company Oracle bought Sun along with the ownership of the Java language. Java was designed to be non-specific to the hardware of the device it was executed upon. While it never really took off with consumer devices, it did become very popular due to its ability to create applets. Applets are Java programs that execute within Web pages. Since Web pages are meant to be accessed on many different kinds of computers and platforms such as Windows PC's, Macintoshes, Unix computers, etc., Java fulfilled this role while other programming languages could not.
- At the lowest, most basic level, a computer program executes as machine code which is a sequence of binary digits (i.e. 1's and 0's). Binary digits are also called
bits. Different kinds of computer CPU's (e.g. Macintosh, Windows PC's, Sun SPARC, etc.) use different machine code instructions to perform mathematical, graphical, and other common tasks.
A computer program in a high-level computer languages such as C, C++, or BASIC needs to be translated into one set of machine code to execute on a Macintosh computer and a different set of machine
code to execute on a Windows PC. Actually, a special computer language known as Assembly is considered to be a low-level language but different computer CPU's use slightly different
versions of Assembly. You can program directly in Assembly though few people do so today with the popularity and ease of programming in high-level languages such as Visual Basic, C++, and Java.
- The programming language Java however can be used in such a way that one version of a program can be executed on any kind of computer. As long as a Java virtual machine (JVM) has been installed on a computer, a Java program can execute there. JVM's are free and available for virtually every type of computer.
- A Java virtual machine (JVM) is an idealized CPU that can interface with the particular computer that it's installed upon and that computer's specific hardware (i.e. monitor, keyboard,
printers, graphic card, etc.) Java source code is compiled by a Java compiler into bytecode,
not machine code. The JVM then interprets the bytecode into machine code and allows the program to execute. The bytecode is stored in class files and library files. The class files are files that you
create and the library files are obtained from Oracle or other sources.
- Java is different from C++ in a number of ways.
- Java source code may look similar to C++ but only because some of the keywords are the same. On a deeper level, the two languages are quite different semantically.
- The Java language does not support global functions or variables. The skeleton of every Java program is a class definition. However, the entry point of every Java program is its main method. You specify the name of the class that you want to execute and the Java interpreter calls the main method defined within that class.