Java Programming:: From The Ground Up
Java Programming:: From The Ground Up
Java Programming:: From The Ground Up
What is a Computer?
A computer is a machine that performs computations, logical operations, or more generally, data manipulation according to some prescribed sequence of instructions called a computer program.
The physical components of a computer are termed hardware and the programs software.
The Hardware
The major hardware components:
The central processing unit (CPU) Primary or random access memory (RAM) Secondary or long term memory Input and output devices (I/O devices)
The ALU performs calculations, billions per second The CU controls or coordinates which calculations the ALU performs The CPU clock determines how frequently the computer hardware executes instructions. Asystemshardwarecomponentsare synchronized with the clock. Every time the clock ticks, another hardware action occurs.
When the CPU executes a program, the program instructions, along with relevant data, are stored in primary memory.
Primary memory is also known as random access memory (RAM) because data may be retrieved or accessed in random, rather than sequential, order.
You can conceptualize RAM as a collection of storage cells or boxes, each capable of holding just a single byte of information. A unique number, or memory address, identifies each such storage cell.
Secondary Memory
Secondary memory devices: hard disks tapes CDs flash memory sticks.
Secondary Memory
The programs that you use every day such as word processors, spreadsheets, and games are permanently stored on secondary storage devices.
Compared to RAM, secondary memory is, in general, cheaper (per bit), slower, larger, electromechanical rather than electronic, and persistent: secondary memory devices do not lose their values when you turn off the computer.
Input/Output Devices
Standard input devices:
Output devices:
The Software
The programs that run on a computer are collectively known as software. Word processors, internet browsers, editors, database management systems, computer games, and spreadsheets are all part of your computer's software library. When you turn on or boot your computer, a program called the operating system automatically runs. This special program provides an interface between you and your computer.
Machine Language
Each CPU executes instructions encoded in its own unique native machine language.
A hypothetical instruction for adding one number to another might have the form: 10010010 00000001 00000001 10101101
Machine Language
In the 1960s, the first high-level language, FORTRAN, was invented and no longer were programmers forced to devise programs with binary instructions. FORTRAN instructions use an English-like syntax.
Today, hundreds of high-level languages are available, with dozens in mainstream use, including: Fortran 2003, COBOL, Lisp, Visual BASIC, C, C++, C#, Java, Perl, Python, PHP, and Javascript.
Machine Language
The Compiler
The program must be translated into the machine language of that computer.
Accepts a program written in a high-level language and produces a translation into the target machine language.
Java
General-purpose language developed by Sun Microsystems in the early 1990s. Three main goals for their new language:
Platform Independence - Java programs should be capable of running on any computer.
Security - Java programs should not be susceptible to hackers' code and dangerous viruses.
Reliability - Javaprogramsshouldnot"crash.
In order to make Java a cross-platform programming language, Java's creative team designed an abstract computer implemented in software called the Java Virtual Machine (JVM). You install software on your computer that simulates a JVM computer. The machine language of the JVM is called bytecode. Java programs are first compiled into bytecode, and then executed.
The Java interpreter, which is part of the JVM, executes each bytecode instruction, one by one.
Once a Java program is translated into bytecode, the bytecode can run on any computer that has installed the JVM. A Java program needs to be compiled into bytecode just once.
An algorithm is a finite, step-by-step procedure for accomplishing some task or solving a problem.
The study of algorithms is a cornerstone of computer science.
A programming language is your tool, a tool that you can use to investigate and implement algorithms.