the evolution of major programming languages
DESCRIPTION
The Evolution of Major Programming Languages. Concepts of Programming Languages. Objectives. Learn about the language of a computer Learn about the evolution of programming languages Examine high-level programming languages Discover what a compiler is and what it does. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/1.jpg)
1
The Evolution of MajorProgramming Languages
Concepts of Programming Languages
![Page 2: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/2.jpg)
2
Objectives
• Learn about the language of a computer• Learn about the evolution of programming
languages• Examine high-level programming languages• Discover what a compiler is and what it
does
![Page 3: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/3.jpg)
3
An Overview of the History of Computers
• 1950s: Very large devices available to a few • 1960s: Large corporations owned computers• 1970s: Computers get smaller and cheaper• 1990s: Computers get cheaper and faster and
are found in most homes
![Page 4: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/4.jpg)
4
Elements of a Computer System
• A computer has 2 components
– Hardware– Software
![Page 5: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/5.jpg)
5
Hardware Components of a Computer
• Central Processing Unit (CPU)• Main Memory
![Page 6: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/6.jpg)
6
Central Processing Unit
• Control Unit (CU)• Arithmetic Logic Unit (ALU)• Program Counter (PC)• Instruction Register (IR)• Accumulator (ACC)
![Page 7: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/7.jpg)
7
Main Memory
• Ordered sequence of cells (memory cells)• Directly connected to CPU• All programs must be brought into main
memory before execution• When power is turned off, everything in
main memory is lost
![Page 8: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/8.jpg)
8
Main Memory with 100 Storage Cells
![Page 9: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/9.jpg)
9
Secondary Storage
• Provides permanent storage for information
• Examples of secondary storage:
– Hard Disks– Floppy Disks– ZIP Disks– CD-ROMs– Tapes
![Page 10: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/10.jpg)
10
Input Devices
• Definition: devices that feed data and computer programs into computers
• Examples:– Keyboard– Mouse– Secondary Storage
![Page 11: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/11.jpg)
11
Output Devices
• Definition: devices that the computer uses to display results
• Examples:– Printer– Monitor– Secondary Storage
![Page 12: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/12.jpg)
12
Hardware Components of a Computer
![Page 13: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/13.jpg)
13
Software
• Software consists of programs written to perform specific tasks
• Two types of programs– System Programs– Application Programs
![Page 14: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/14.jpg)
14
System Programs
• System programs control the computer
• The operating system is first to load when you turn on a computer
![Page 15: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/15.jpg)
15
Operating System (OS)
• OS monitors overall activity of the computer and provides services
• Example services:– memory management– input/output– activities– storage management
![Page 16: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/16.jpg)
16
Application Programs
• Written using programming languages• Perform a specific task• Run by the OS
• Example programs:– Word Processors– Spreadsheets– Games
![Page 17: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/17.jpg)
17
Language of a Computer
• Machine language: the most basic language of a computer
• A sequence of 0s and 1s • Every computer directly understands its
own machine language• A bit is a binary digit, 0 or 1• A byte is a sequence of eight bits
![Page 18: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/18.jpg)
18
Evolution of Programming Languages
• Early computers programmed in machine language
• Assembly languages were developed to make programmer’s job easier
• In assembly language, an instruction is an easy-to-remember form called a mnemonic
• Assembler: translates assembly language instructions into machine language
![Page 19: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/19.jpg)
19
Instructions in Assembly and Machine Language
![Page 20: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/20.jpg)
20
Evolution of Programming Languages
• High-level languages make programming easier
• Closer to spoken languages• Examples:
– Basic – FORTRAN– COBOL– C/C++– Java
![Page 21: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/21.jpg)
21
Evolution of Programming Languages
To run a Java program:
1. Java instructions need to be translated into an intermediate language called bytecode
2. Then the bytecode is interpreted into a particular machine language
![Page 22: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/22.jpg)
22
Evolution of Programming Languages
• Compiler: A program that translates a program written in a high-level language into the equivalent machine language. (In the case of Java, this machine language is the bytecode.)
• Java Virtual Machine (JVM) - hypothetical computer developed to make Java programs machine independent
![Page 23: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/23.jpg)
23
Processing a Java Program
• Two types of Java programs: applications and applets
• Source program: Written in a high-level language
• Linker: Combines bytecode with other programs provided by the SDK and creates executable code
• Loader: transfers executable code into main memory
• Interpreter: reads and translates each bytecode instruction into machine language and then executes it
![Page 24: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/24.jpg)
24
Processing a Java Program
![Page 25: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/25.jpg)
25
Problem-Analysis-Coding-Execution Cycle
• Algorithm: A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time
![Page 26: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/26.jpg)
26
Problem-Solving Process
1. Analyze the problem: outline solution requirements and design an algorithm
2. Implement the algorithm in a programming language (Java) and verify that the algorithm works
3. Maintain the program: use and modify if the problem domain changes
![Page 27: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/27.jpg)
27
Problem-Analysis-Coding-Execution Cycle
![Page 28: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/28.jpg)
28
Programming Methodologies
• Two basic approaches to programming design:
– Structured design – Object-oriented design
![Page 29: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/29.jpg)
29
Structured Design
1. A problem is divided into smaller subproblems
2. Each subproblem is solved3. The solutions of all subproblems are then
combined to solve the problem
![Page 30: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/30.jpg)
30
Object-Oriented Design (OOD)
• In OOD, a program is a collection of interacting objects
• An object consists of data and operations
• Steps in OOD:1. Identify objects2. Form the basis of the solution3. Determine how these objects interact
![Page 31: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/31.jpg)
31
Programming Language Dilemma
• How to instruct computer what to do?– Need a program that computer can execute– Must be written in machine language
• Unproductive to code in machine language
• Design a higher level language• Implement higher level language
– Alternative 1: Interpreter– Alternative 2: Compiler
![Page 32: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/32.jpg)
32
Compilation As Translation
Generated Program in
Machine Language
Source Program in Some Programming
Language
Compiler
Starting Point
EndingPoint
![Page 33: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/33.jpg)
33
Starting Point
Programming language (Java, C, C++)• State
– Variables, – Structures, – Arrays
• Computation– Expressions (arithmetic, logical, etc.)– Assignment statements– Control flow (conditionals, loops)– Procedures
![Page 34: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/34.jpg)
34
How are Languages Implemented?
• Two major strategies:– Interpreters (older, less studied)– Compilers (newer, much more studied)
• Interpreters run programs “as is”– Little or no preprocessing
• Compilers do extensive preprocessing
![Page 35: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/35.jpg)
35
Language Implementations
• Batch compilation systems dominate– E.g., gcc
• Some languages are primarily interpreted– E.g., Java bytecode
• Some environments (Lisp) provide both– Interpreter for development– Compiler for production
![Page 36: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/36.jpg)
36
The Structure of a Compiler
1. Lexical Analysis2. Parsing3. Semantic Analysis4. Optimization5. Code Generation
The first 3, at least, can be understood by analogy to how humans comprehend
English.
![Page 37: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/37.jpg)
37
Lexical Analysis
• First step: recognize words.– Smallest unit above letters
This is a sentence.
• Note the– Capital “T” (start of sentence symbol)– Blank “ “ (word separator)– Period “.” (end of sentence symbol)
![Page 38: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/38.jpg)
38
More Lexical Analysis
• Lexical analysis is not trivial. Consider:ist his ase nte nce
• Plus, programming languages are typically more cryptic than English:
*p->f ++ = -.12345e-5
![Page 39: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/39.jpg)
39
And More Lexical Analysis
• Lexical analyzer divides program text into “words” or “tokens”
if x == y then z = 1; else z = 2;
• Units: if, x, ==, y, then, z, =, 1, ;, else, z, =, 2, ;
![Page 40: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/40.jpg)
40
Parsing
• Once words are understood, the next step is to understand sentence structure
• Parsing = Diagramming Sentences– The diagram is a tree
![Page 41: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/41.jpg)
41
Diagramming a Sentence
This
line is a longer sentence
verbarticle noun article adjective noun
subject object
sentence
![Page 42: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/42.jpg)
42
Parsing Programs
• Parsing program expressions is the same• Consider:
If x == y then z = 1; else z = 2;• Diagrammed:
if-then-else
x y z 1 z 2==
assignrelation assign
predicate else-stmtthen-stmt
![Page 43: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/43.jpg)
43
Semantic Analysis
• Once sentence structure is understood, we can try to understand “meaning”– But meaning is too hard for compilers
• Compilers perform limited analysis to catch inconsistencies
• Some do more analysis to improve the performance of the program
![Page 44: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/44.jpg)
44
Semantic Analysis in English
• Example:Jack said Jerry left his assignment at home.
What does “his” refer to? Jack or Jerry?
• Even worse:Jack said Jack left his assignment at home?
How many Jacks are there?Which one left the assignment?
![Page 45: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/45.jpg)
45
Semantic Analysis in Programming
• Programming languages define strict rules to avoid such ambiguities
• This C++ code prints “4”; the inner definition is used
{int Jack = 3;{
int Jack = 4;cout << Jack;
}}
![Page 46: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/46.jpg)
46
More Semantic Analysis
• Compilers perform many semantic checks besides variable bindings
• Example:Jack left her homework at home.
• A “type mismatch” between her and Jack; we know they are different people– Presumably Jack is male
![Page 47: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/47.jpg)
47
Examples of Semantic Checks
• Variables defined before used• Variables defined once• Type compatibility• Correct arguments to functions• Constants are not modified• Inheritance hierarchy has no cycles
![Page 48: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/48.jpg)
48
Optimization
• No strong counterpart in English
• Automatically modify programs so that they– Run faster– Use less memory– In general, conserve some resource
![Page 49: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/49.jpg)
49
Optimization Example
X = Y * 0 is the same as X = 0
NO!
Valid for integers, but not for floating point numbers
![Page 50: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/50.jpg)
50
Examples of common optimizations
• Dead code elimination• Evaluating repeated expressions only once• Replace expressions by simpler equivalent
expressions• Evaluate expressions at compile time• Move constant expressions out of loops
![Page 51: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/51.jpg)
51
Code Generation
• Produces assembly code (usually)
• A translation into another language– Analogous to human translation
![Page 52: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/52.jpg)
52
Intermediate Languages
• Many compilers perform translations between successive intermediate forms– All but first and last are intermediate languages
internal to the compiler– Typically there is 1 Intermediate Language
• IL’s generally ordered in descending level of abstraction– Highest is source– Lowest is assembly
![Page 53: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/53.jpg)
53
Intermediate Languages (Cont.)
• IL’s are useful because lower levels expose features hidden by higher levels– registers– memory layout
• But lower levels obscure high-level meaning
![Page 54: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/54.jpg)
54
Issues
• Compiling is almost this simple, but there are many pitfalls.
• Example: How are erroneous programs handled?
• Language design has big impact on compiler– Determines what is easy and hard to compile– Course theme: many trade-offs in language
design
![Page 55: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/55.jpg)
55
Compilers Today
• The overall structure of almost every compiler adheres to our outline
• The proportions have changed since FORTRAN– Early: lexing, parsing most complex, expensive
– Today: optimization dominates all other phases, lexing and parsing are cheap
![Page 56: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/56.jpg)
56
Trends in Compilation
• Compilation for speed is less interesting. But:– scientific programs– advanced processors (Digital Signal Processors,
advanced speculative architectures)
• Ideas from compilation used for improving code reliability:– memory safety– detecting concurrency errors (data races)
![Page 57: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/57.jpg)
57
Compilers and Optimization
What makes a compiler good?What makes a compiler different?
![Page 58: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/58.jpg)
58
What’s in an optimizing compiler?
Front End Optimizer
High-level language
(C, C++, Java)
Low-level languageCode
Generator
Compilation Stages
![Page 59: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/59.jpg)
59
What are compiler optimizations?
Optimization: the transformation of a program P into a program P’, that has the same input/output behavior, but is somehow “better”.
• “better” means:– faster – or smaller – or uses less power– or whatever you care about
• P’ is not optimal, may even be worse than P
![Page 60: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/60.jpg)
60
An optimizations must:
• Preserve correctness– the speed of an incorrect program is irrelevant
• On average improve performance– P’ is not optimal, but it should usually be better
• Be “worth the effort”– 1 person-year of work, 2x increase in
compilation time, a 0.1% improvement in speed?
– Find the bottlenecks– 90/10 rule: 90% of the gain for 10% of the work
![Page 61: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/61.jpg)
61
CompilerHigh-level language
C, C++, Java
Low-level languagemc68000
LexicalAnalyzer
Parser IR Code
Generator Optimizer
m/c CodeGenerator
tokens IRIR
IR: Intermediate Representation
Compiler Phases (Passes)
![Page 62: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/62.jpg)
62
Lexers & Parsers
• The lexer identifies tokens in a program• The parser identifies grammatical
phrases, or constructs in the program• There are freely available lexer and parser
generators…• The parser usually constructs some
intermediate form of the program as output
![Page 63: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/63.jpg)
63
Intermediate Representation (IR)
• The representation or language on which the compiler performs it’s optimizations
• There are as many IRs as compiler suites • Some IRs are better for some optimizations
– different information is maintained– easier to find certain types of information
![Page 64: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/64.jpg)
64
Why Use an IR?
IRJava
Fortran
C
C++
Voss++
MIPS
Sun SPARC
IA32 / Pentium
IA64 / Itanium
PowerPC
• Good Software Engineering– Portability – Reuse
![Page 65: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/65.jpg)
65
Compiling a C program
A Simple Compilation Example
![Page 66: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/66.jpg)
66
Writing C Programs
• A programmer uses a text editor to create or modify files containing C code.
• Code is also known as source code.
• A file containing source code is called a source file.
• After a C source file has been created, the programmer must invoke the C compiler before the program can be executed (run).
![Page 67: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/67.jpg)
67
Invoking the gcc Compiler
At the prompt, type gcc -ansi -Wall pgm.c where pgm.c is the C program source file.• -ansi is a compiler option that tells the compiler
to adhere to the ANSI C standard.• -Wall is an option to turn on all compiler
warnings (best for new programmers).
![Page 68: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/68.jpg)
68
The Result : a.out
• If there are no errors in pgm.c, this command produces an executable file, which is one that can be executed (run).
• The gcc compiler names the executable file a.out
• To execute the program, at the prompt, type
a.out• Although we call this process “compiling a
program,” what actually happens is more complicated.
![Page 69: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/69.jpg)
69
Stages of Compilation
Stage 1: Preprocessing
– Performed by a program called the preprocessor – Modifies the source code (in RAM) according to
preprocessor directives (preprocessor commands) embedded in the source code
– Strips comments and whitespace from the code
– The source code as stored on disk is not modified.
![Page 70: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/70.jpg)
70
Stages of Compilation (con’t)
Stage 2: Compilationo Performed by a program called the compilero Translates the preprocessor-modified source
code into object code (machine code)o Checks for syntax errors and warningso Saves the object code to a disk file.
o If any compiler errors are received, no object code file will be generated.
o An object code file will be generated if only warnings, not errors, are received.
![Page 71: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/71.jpg)
71
Stages of Compilation (con’t)
The Compiler consists of the following sub-systems:
– Parser - checks for errors
– Code Generator - makes the object code
– Optimizer - may change the code to be more efficient
![Page 72: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/72.jpg)
72
Stages of Compilation (con’t)
Stage 3: Linkingo Combines the program object code with other
object code to produce the executable file.o The other object code can come from the Run-
Time Library (a collection of object code with an index so that the linker can find the appropriate code), other libraries, or object files that you have created.
o Saves the executable code to a disk file. On a Linux/Unix system, that file is called a.out.
o If any linker errors are received, no executable file will be generated.
![Page 73: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/73.jpg)
73
Program Development Using gcc
Source File pgm.c
Program Object Code File pgm.o
Executable File a.out
Preprocessor
Modified Source Code in RAM
Compiler
Linker
Other Object Code Files (if any)
Editor
![Page 74: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/74.jpg)
74
The Programming Language Family Tree
Concepts of Programming Languages
![Page 75: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/75.jpg)
75
A Family Tree
http://merd.net/pixel/language-study/diagram.html
![Page 76: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/76.jpg)
76
Plankalkul
• Developed by Konrad Zuse (1945)• Never implemented• Advanced data structures (floating point,
arrays, records)• Odd notation:
– To code A[7] = 5 * B[6] | 5 * B => A V | 6 7 (subscripts) S | 1.n 1.n (data types)
![Page 77: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/77.jpg)
77
Pseudocodes
• Machine code had many negatives:– Poor readability, writability, modifiability– Low-level machine operations had deficiencies,
including no indexing or floating point
• Example: Short Code – Developed by Mauchly in 1949 for the BINAC– Expressions coded from left to right– Operations included:
• 1n => (n+2)nd power (e.g., 12 represented the 4th power)
• 2n => (n+2)nd root• 07 => addition
![Page 78: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/78.jpg)
78
FORTRAN I (1957)
• Designed for IBM 704, which had– Index registers– Floating point hardware
• Development environment– Computers small and unreliable– Applications were scientific – There was no programming methodology or
tools– Machine efficiency was of primary importance
![Page 79: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/79.jpg)
79
FORTRAN I
• Impact of development environment– Needed good array handling and counting loops– No need for
• Dynamic storage• String handling• Decimal arithmetic• Powerful input/output operations
![Page 80: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/80.jpg)
80
FORTRAN I
• First implemented version of FORTRAN– Names could have up to 6 characters– Posttest counting loop (DO statement)– Formatted input/output– User-defined subprograms– 3-way selection statement (arithmetic IF)– No data typing statements– Released in 1957 after 18 worker/years effort– Programs larger than 400 lines rarely compiled
correctly (704 was unreliable)– Code was fast;– FORTRAN I quickly became widely used
![Page 81: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/81.jpg)
81
FORTRAN IV (1960-62)
• Added features– Explicit type declarations– Logical IF statement– Subprogram names could be parameters
![Page 82: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/82.jpg)
82
FORTRAN 77 (1978)
• Character string handling• Logical loop control statement• IF-THEN-ELSE statement
![Page 83: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/83.jpg)
83
FORTRAN 90 (1990)
• Modules• Dynamic arrays• Pointers• Recursion• CASE statement• Parameter type checking
![Page 84: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/84.jpg)
84
LISP (1959)
• LISt Processing language• Designed by John McCarthy at MIT• Designed to meet AI research needs
– Process data in lists, not arrays– Symbolic computation, rather than numeric
• Two data types: atoms and lists• Syntax based on lambda calculus• Pioneered functional programming
– No need for variables or assignment– Control via recursion and conditional expressions
• COMMON LISP and Scheme are dialects
![Page 85: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/85.jpg)
85
ALGOL 58 (1958)
• Development Environment– FORTRAN just developed for IBM 704– Many other machine-specific languages were
being developed– There were no portable languages– There was no universal language for
communicating algorithms
![Page 86: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/86.jpg)
86
ALGOL 58
• Goals for the language– Close to mathematical notation– Good for describing algorithms– Must be translatable to machine code
• Notes:– Not meant to be implemented, but variations
were (MAD, JOVIAL)– IBM was initially enthusiastic, but dropped
support by mid 1959
![Page 87: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/87.jpg)
87
ALGOL 58 Features
• Type concept was formalized• Names could have any length• Arrays could have any number of subscripts• Parameters had mode (in/out)• Subscripts were placed in brackets• Compound statements (begin..end)• Semicolon used as statement separator• Assignment operator was :=• if statement had an else-if clause
![Page 88: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/88.jpg)
88
ALGOL 60 (1960)
• New features included– Block structure (local scope)– Two parameter passing methods– Subprogram recursion– Stack-dynamic arrays
• Still lacked– Input/output– String handling
![Page 89: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/89.jpg)
89
ALGOL 60
• Successes– Standard for publishing algorithms for more
than 20 years– Basis for all subsequent imperative languages– First machine-independent language– First language whose syntax was formally
defined (BNF was used)
![Page 90: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/90.jpg)
90
ALGOL 60
• Failures– Never widely used, especially in U.S.– No I/o– Too flexible, making it hard to implement– FORTRAN was firmly entrenched– Formal syntax description (BNF considered
strange at the time)– Lack of support by IBM
![Page 91: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/91.jpg)
91
COBOL (1960)
• Based on UNIVAC FLOW-MATIC– Names up to 12 characters, with embedded hyphens– English names for arithmetic operators– Data and code were completely separate– Verbs were the first word in every statement
• Design Goals– Must look like simple English– Ease of use more important than powerful features– Broaden base of computer users– Must not be biased by current compiler problems
![Page 92: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/92.jpg)
92
COBOL
• Contributions– First macro facility in HLL– Hierarchical data structures (records)– Nested selection statements– Long names (up to 30 characters)– Data Division
• Notes– First language required by DoD– Still the most widely used business application
language
![Page 93: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/93.jpg)
93
BASIC (1964)
• Kemeny & Kurtz (Dartmouth)• Design goals
– Easy to learn and use (non-science students)– Fast turnaround for homework– Free and private access– User time more important than computer time
• Current dialects– QuickBASIC, Visual BASIC
![Page 94: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/94.jpg)
94
PL/I (1965)
• Designed by IBM and SHARE for scientific and business computing
• Contributions– First unit-level concurrency– First exception handling– Switch-selectable recursion– Pointer data type– Array cross sections
• Notes:– Many features were poorly designed– To large and complex– Still used for scientific and business applications
![Page 95: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/95.jpg)
95
Early Dynamic Languages
• Characterized by dynamic typing and dynamic storage allocation– APL (A Programming Language) 1962
• Designed a hardware description language• Many operators for scalars and arrays • Programs are difficult to read
– SNOBOL (1964)• String manipulation language (Bell Labs)• Powerful pattern matching operators
![Page 96: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/96.jpg)
96
ALGOL 68 (1968)
• Not really a superset of ALGOL 60• Design based on orthogonality• Contributions
– User-defined data structures– Reference types– Dynamic (flex) arrays
• Notes– Even less usage than ALGOL 60– Strong influence on Pascal, C, and Ada
![Page 97: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/97.jpg)
97
Pascal (1971)
• Designed by Wirth (quit ALGOL 68 committee)
• Intended to be used for teaching structured programming
• Small, simple, introduced nothing new• Widely used for teaching programming in
college, but is being supplanted by C++ and Java
![Page 98: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/98.jpg)
98
C (1972)
• Designed for systems programming (Bell Labs, Dennis Richie)
• Evolved from B and ALGOL 68• Powerful set of operators• Poor type checking• Initially spread via UNIX
![Page 99: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/99.jpg)
99
Other Descendants of ALGOL
• Modula-2 (Wirth, mid-1970s)– Pascal plus modules and low-level features for systems
programming
• Modula-3 (late 1980s)– Modula-2 plus classes, exception handling, garbage
collection, and concurrency
• Oberon– Adds OOP support to Modula-2
• Delphi (Borland)– Pascal plus OOP features– More elegant, safer than C++
![Page 100: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/100.jpg)
100
Prolog (1972)
• Developed by Comerauer, Roussel, Kowalski
• Based on formal logic• Non-procedural• Can be described as being an intelligent
database system that uses an inferencing process to infer the truth of given queries
![Page 101: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/101.jpg)
101
Ada (1983)
• Huge design effort• Contributions
– Packages support data abstraction– Elaborate exception handling– Generic program units– Concurrency through the tasking model
• Ada 95– OOP support through type derivation– New concurrency features for shared data
![Page 102: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/102.jpg)
102
Smalltalk (1972-1980)
• Developed at Xerox PARC (Alan Kay)• First full implementation of an object-
oriented language– Data abstraction– Inheritance– Dynamic type binding
• Pioneered the graphical user interface
![Page 103: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/103.jpg)
103
C++ (1985)
• Bell Labs (Stroustrup)• Evolved from C and SIMULA 67 (class)• Facilities for OOP were added to C• Also has exception handling• Supports both procedural and OO programming• Large and complex• Eiffel (1992), a related language that supports
OOP– Not directly derived from any other language– Smaller and simpler than C++
![Page 104: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/104.jpg)
104
Java (1995)
• Developed at Sun in early 1990s• Based on C++
– Significantly simplified– Supports only OOP– Has references, but not pointers– Includes support for applets and a form of
concurrency (threads)
![Page 105: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/105.jpg)
105
Scripting Languages
• JavaScript (1995)– Originally LiveScript, developed jointly by
Netscape and Sun Microsystems– Used as an HTML-embedded client-side scripting
language, primarily for creating dynamic HTML documents
• PHP (1995)– Developed by Rasmus Lerdorf– An HTML-embedded server side scripting
language– Provides support for many DBMS
![Page 106: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/106.jpg)
106
C# (2002)
• Based on C++ and Java, with ideas from Delphi and Visual Basic
• A language for component-based development in the .NET Framework
• Likely to become very popular because of Microsoft’s huge effort to push .NET
![Page 107: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/107.jpg)
107
A Family Tree
http://merd.net/pixel/language-study/diagram.html
![Page 108: The Evolution of Major Programming Languages](https://reader036.vdocuments.site/reader036/viewer/2022081520/56814ac8550346895db7dbcf/html5/thumbnails/108.jpg)
108
The End
Read Chapters 1 and 2 in the Textbook