Title: Computer Languages
1Computer Languages
2Machine Languages
- It is the only language the computer understands.
- It is made of 0s and 1s.
- They must be in 0s and 1s because the internal
circuit of a computer is made up of switches,
transistors, and other electronic devices that
can be either on or off (1 or 0 respectively).
- Example of Machine Language (on page167)
- 1 00000000 00000100 0000000000000000
- 2 01011110 00001100 11000010 0000000000000010
- 3 11101111 00010110 0000000000000101
3Symbolic Languages
- Developed by Grace Hopper, a mathematician for US
Navy in 1950s - It uses symbols or mnemonics to represent machine
language - A program called an assembler is used to
translate symbolic code into machine language - Theyre also known as assembly languages because
they have to be assembled
4Symbolic Languages Contd.
Example multiplication program page 168 1 entry
main, mltr2gt 2 sub12 12, sp 3 jsb CMAIN_ARGS 4
movab CHAR_STRING_CON 5 6 pushal -8(fp) 7
pusal (r2) 8 calls 2, read 9 pushal
-12 (fp) 10 pushal 3 (r2) 11 calls 2,
read 12 mull3 -8 (fp), -12 (fp), - 13pusha
6 (r2) 14 calls 2, print 15 clrl r0 16 ret
5High-Level Languages
- Developed to improve programmer efficiency from
symbolic languages to change focus from the
computer to the problem being solved - Theyre portable to different computers
- They still need to be converted to machine
languages in a process called compilation - Examples include
- BASIC
- COBOL
- Pascal
- Ada
- C
6Natural Languages
- These include the language that people speak in
their daily lives - These can include
- English
- Spanish
- German
- French
- Italian
- The idea is to use ones natural language to give
the computer orders - This has only limited use today
7Building a Program
- Writing and Editing Programs
- Use a text Editor to write programs
- When youre done you save your program to the
disk (known as a source file) and it will be
input to the compiler - Compiling Programs
- Translates inf in a source file into machine
language - Made of 2 separate programs the preprocessor
the translator - Preprocessor reads the source code and prepares
it for the translator. While preparing the code
it scans for special commands (preprocessor
directives) that tell it to look for special code
libraries, make substitution in the code, other
ways to prepare the code for translation into
machine language. The result of this processing
is called the translation unit. - Translator converts the translation unit into
machine language. This code in machine language
is called the object module - Linking Programs
- A high-level language has many subprograms, some
of which are written in the program some exist
elsewhere and have to be attached to the program
(ex I/O processes) - The linker assembles all of these functions into
the final executable function.
8Program Execution
- Use the Operating System (OS) command (ex. run)
to load the program into primary memory execute
it. - Loader it is an OS program responsible for
loading the program into the memory - Program reads data for processing either from the
user or from a file - After the program processes the data it prepares
the output to either the monitor or to a file - When the program is finished it tells the OS,
which removes the program from memory
9Categories of Languages
10Procedural (Imperative) Languages
- Procedural Language a set of instructions that
are executed one-by-one from beginning to end
unless an instruction forces the control
elsewhere - Each instruction either manipulates data items or
is a control execution. - Examples
- FORTRAN
- COBOL
- Pascal
- C
- Ada
11FORTRAN
- FORmula TRANslation
- Designed by a group of IBM engineers was
commercially available in 1957 - First high-level language
- Features
- High-precision arithmetic
- Capability of handling complex numbers
- Exponentiation computation (ab)
12COBOL
- COmmon Business-Oriented Language
- Designed by US Navy computer scientists
- Designed to be used as a business programming
language - Fast access to files and databases
- Fast updating of files and databases
- Large amounts of generated reports
- User-friendly formatted output
13Pascal
- Invented by Nikalus Wirth in 1971 in Zurich,
Switzerland - Named after Blaise Pascal, the 17th century
French mathematician philosopher who invented
the Pascaline calculator - Designed to teach programming to novices by
emphasizing the structured programming approach
14C Ada
- C language developed by Dennis Ritchie at Bell
Laboratories - Originally designed for writing Operating Systems
- Later became popular among programmers
- Ada was named after Augusta Ada Byron, the
daughter of Lord Byron the assistant to Charles
Babbage - Created by US Department of Defense to be a
uniform language used by all Department of
Defense contractors
15Object-Oriented Languages
- The objects (a data item) the operations to be
applied to them are tied together - Programmer first defines and object the types
of operations that can be applied to this object
can use this combination invokes some or all
of the operations defined to solve a problem - The objects are active
- Example
- C
- Java
16C
- Developed by Bjarne Stroustrup at Bell
Laboratories - Uses classes to define general characteristics of
similar objects the operations that can be
applied to them - 3 principles encapsulation, inheritance,
polymorphism - Encapsulation the idea of hiding the data some
operations that can be performed on the data
inside the object - Inheritance an object can inherit from another
object - Polymorphism you can define several operations
with the same name that can do different things
in related classes
17Java
- Developed by Sun Microsystems, Inc.
- Based on C C
- Its totally class oriented
- Program can be either an application or an applet
- Application stand-alone program
- Applet embedded in HTM language, stored on a
server, run by a browser - Class Library a collection of classes
- Multithreading a thread is a sequence of actions
executed one after the other, Java allows for
multithreading
18Functional Languages
- A program is considered a mathematical function
- A function is a black box that maps a list of
inputs to a list of outputs - It does the following
- It predefines a set of primitive (atomic)
functions that can be used by any programmer - It allows the programmer to combine primitive
functions to create new functions - Advantages over procedural language
- It encourages modular programming
- Allows the programmer to make new functions our
of existing ones - Examples
- LISP
- Scheme
19LISP Scheme
- LISt Programming
- Designed by researchers at MIT in the early 1960s
- Everything is considered a list
- Scheme
- Version of LISP developed by MIT in 1970s
- Defines a set of primitive functions that solves
problems
20Declarative (Logic) Languages
- Uses the principle of logical reasoning to answer
queries - Based on formal logic defined by Greek
mathematicians later developed into what is
called first-order predicate calculus - Logical reason is based on deduction
- One problem a program is specific to a
particular domain because collecting all the
facts into one programming makes it huge - Example
- Prolog
21Prolog
- PROgramming in LOGic
- Developed by A. Colmerauer in France in 1972
- Program is made of facts and rules
22Special Languages
23HTML
- Hypertext Markup Language
- Pseudolanguage that includes marks that serve as
formatting hints links tags - HTML file is made of texts tags
- Tagenclosed in 2 angle brackets usually come
in pairs marks that are embedded into the text
it can have a list of attributes , each of which
can be followed by an equal sign value
associated with the attribute - HTML file (page) is stored on the server can be
downloaded by a browser - Browser removes the tags interprets them as
either formatting hints or links to other files - Allows you to embed formatting instructions in
the file itself are stored in the text - 2 parts
- Head the first part that contains the title of
the page other parameters that the browser will
used - Body the actual contents of a page includes the
text tags text is the actual info contained in
a page tags define the appearance of the page
24HTML
25PERL
- Practical Extraction Report Language
- High-level language with a syntax similar to the
C language but more efficient - Its power is in its well-designed use of regular
expressions that allow the programmer to parse a
string of characters into its components
extract the needed info
26SQL
- Structured Query Language
- Used to answer queries about databases
27Overview
- Types of languages
- Machine, Symbolic, High-Level, Natural
- Building a program
- Writing editing
- Compiling
- Linking
- Categories of Languages
- Procedural (ex FORTRAN)
- Object-Oriented (ex C)
- Functional (ex LISP)
- Declarative (ex Prolog)
- Special (ex HTML)