Computer
Programs, An
Introduction
New Terminology
- machine language
- The binary codes that the
CPU can execute.
- assembly language
- A coded language that can be
interpreted to machine
language - is hardware dependent
- high level language (3rd GL)
- A more "English-like"
language that can be compiled to form
machine language (executable). Examples include Fortran, Cobol, C, and
Java.
- compiler
- A program (or application)
that checks a source file for
syntactic accuracy and produces an executable file (see java for
exception).
- syntax
- The rules of a language. A
program that is syntactically
correct is free of language rule violations.
- semantics
- The logic of a program or
application. A program that is
syntactically correct may not be semantically correct if it does not
work according to its specifications.
- source file
- The file containing the
language instructions. This file
must be "transformed" into machine language.
- object or executable file
- The file that contains the
machine language. This file can
be run directly on the computer.
- class or byte code file
- The file produced by the
java compiler.
- Java
- A programming language. Java
programs compile into machine
independent byte code (.class) files and must be interpreted by machine
dependent interpreters.
- javac
- The java compiler. (You will
see it on your computer as
javac.exe)
- java
- The java interpreter. (You
will see it on your computer as
java.exe)
- virtual
- When virtual was first
introduced in the computational
sense, it applied to things simulated by the computer, like virtual
memory that is, memory that is not actually built into the processor.
(From www.thefreedictionary.com). Now it also applies to real things
that are assisted by the computer...a "virtual" chat in a chat room,
for example.
- java virtual machine
- A CPU dependent java
interpreter which "executes" java byte
code.
- identifier
- Any name which we give to
items in our program.
- keyword
- any word that have special
meaning in a program
- text editor
- Any application that can be
used to edit a source file.
Notepad, Wordpad, JGrasp, Eclipse are all names of programs that can
edit java source files. MS Word is NOT
a
text editor.
Programming specific
structures and terms
- class
- a definition of an
application (program) or sub application
in java
- class header
- introduces the beginning of
a class declaration in java
- { } - curly braces
- block - open curly brace
begins a block of code or a
structure which contains code. close ends the code or structure in java
- method
- complex actions of the program
- method header
- introduces the beginning of
the method in java
- statement
- the term for each action
that a program takes.
- ; - semi-colon
- symbol which ends a java
statement.
- System
- the name of a class
(application) in Java that contains
methods and objects that we can use in our programs.
- System.out
- describes standard or
monitor output in Java.
- System.out.println("whatIwanttoprint");
- Java action that sends the
value in parentheses to the
standard output (usually monitor).
- comment
- any text in a program that
is intended for the human reader
and not the computer reader. Comments are ignored by the compiler.
- /* */ - block comment in java
- these symbols surround
comments or text that will not be
treated as lines of code.
- /** */ - block comment,
javadocs style
- special style of block
comments that can be used to produce
documentation.
- // - inline comment in java
- from the symbol to the end
of that line, all text is
treated as a comment.
- case sensitive
- A language that is case
sensitive will treat identifiers
differently if the letters are the same but the case is different.
pudding and Pudding and PuDDing are all treated as different
identifiers.
- declaration
- A java statement that
explicitly creates a container in a java program.
- constant
- A java container whose
contents cannot be changed once an initial value is given.
- variable
- A java container whose
contents may be changed during program execution.
- literal
- A java container whose value
is used directly within a source file.
- =
- A symbol for the binary
operator, assignment. The value on the right is copied into
the container on the left.
- +
- A symbol for the binary
operators, plus and concatenate.
- String
- A complex data type in java.
Strings have a literal form (using ") or a designation of a
container type.
Class notes
- Computer languages
- Machine - dependent on
the particular CPU we are using
- Assembly - also
processor dependent but used mnemonic
codes
- High-level - "English
like"
- Java
- C
- Fortran
- Compilers - Check for
errors, and then create a machine
code file (except java, see notes later)
- Syntax
- Semantics
- Java byte code - The
compiler produces a machine
independent code which is then interpreted on the "java virtual
machine". The interpreter is CPU dependent.
- Why java -
portability
- javac/java
- Structure of a java program Hello.java
and Style
Guide and ppt
- See your book for a complete
treatment of formatting your output. For example, what does "\n" do?
- Containers in java.
- All variable and constant
containers must be declared.
- Literals may simply be
used.
- All variables and constants
must be declared with ________ and _________ and _________.
- A declaration assumes that
we are creating a variable. The keyword final
denotes a constant container.
- See demo of Hello.java.
- Data types.
- Primitive and complex.
- Complex data types are objects
(declared in classes) out
is a variable with a complex data type.
- Java primitives (Green book page
45 - 51, Purple book page 44 - 54) There are 8. What are
they?
- String's have some specialized properties called methods.
See book chapter 2.9.
- Basic operations
- Demo code:
- IntegerVariables.java
(page 46 (both)
- Sale.java (ppage 47)
- SunFacts.java (page 48)
- Letters.java and Letters2.java (page 49/50)