際際滷

際際滷Share a Scribd company logo
CS 415: Programming
Languages
Chapter 1
Aaron Bloomfield
Fall 2005
The first computers
Scales  computed relative weight of two items
 Computed if the first items weight was less than, equal to, or
greater than the second items weight
Abacus  performed mathematical computations
 Primarily thought of as Chinese, but also Japanese, Mayan,
Russian, and Roman versions
 Can do square roots and cube roots
Stonehenge
Computer Size
ENIAC then
ENIAC today
With computers (small) size does matter!
Why study programming
languages?
Become a better software engineer
 Understand how to use language features
 Appreciate implementation issues
Better background for language selection
 Familiar with range of languages
 Understand issues / advantages / disadvantages
Better able to learn languages
 You might need to know a lot
Why study programming
languages?
Better understanding of implementation issues
 How is this feature implemented?
 Why does this part run so slowly?
Better able to design languages
 Those who ignore history are bound to repeat it
Why are there so many
programming languages?
There are thousands!
Evolution
 Structured languages -> OO programming
Special purposes
 Lisp for symbols; Snobol for strings; C for systems;
Prolog for relationships
Personal preference
 Programmers have their own personal tastes
Expressive power
 Some features allow you to express your ideas better
Why are there so many
programming languages?
Easy to use
 Especially for teaching / learning tasks
Ease of implementation
 Easy to write a compiler / interpreter for
Good compilers
 Fortran in the 50s and 60s
Economics, patronage
 Cobol and Ada, for example
Programming domains
Scientific applications
 Using the computer as a large calculator
 Fortran and friends, some Algol, APL
 Using the computer for symbol manipulation
 Mathematica
Business applications
 Data processing and business procedures
 Cobol, some PL/1, RPG, spreadsheets
Systems programming
 Building operating systems and utilities
 C, PL/S, ESPOL, Bliss, some Algol and derivitaves
Programming domains
Parallel programming
 Parallel and distributed systems
 Ada, CSP, Modula, DP, Mentat/Legion
Artificial intelligence
 Uses symbolic rather than numeric computations
 Lists as main data structure
 Flexibility (code = data)
 Lisp in 1959, Prolog in the 1970s
Scripting languages
 A list of commands to be executed
 UNIX shell programming, awk, tcl, Perl
Programming domains
Education
 Languages designed to facilitate teaching
 Pascal, BASIC, Logo
Special purpose
 Other than the above
 Simulation
 Specialized equipment control
 String processing
 Visual languages
Programming paradigms
You have already seen assembly language
We will study five language paradigms:
 Top-down (Algol 60 and Fortran)
 Functional (Scheme and/or OCaml)
 Logic (Prolog)
 Object oriented (Smalltalk)
 Aspect oriented (AspectJ)
Programming language history
Pseudocodes (195X)  Many
Fortran (195X)  IBM, Backus
Lisp (196x)  McCarthy
Algol (1958)  Committee (led to Pascal, Ada)
Cobol (196X)  Hopper
Functional programming  FP, Scheme, Haskell, ML
Logic programming  Prolog
Object oriented programming  Smalltalk, C++, Python,
Java
Aspect oriented programming  AspectJ, AspectC++
Parallel / non-deterministic programming
Compilation vs. Translation
Translation: does a mechanical translation of the source
code
 No deep analysis of the syntax/semantics of the code
Compilation: does a thorough understanding and
translation of the code
A compiler/translator changes a program from one
language into another
 C compiler: from C into assembly
An assembler then translates it into machine language
 Java compiler: from Java code to Java bytecode
The Java interpreter then runs the bytecode
Compilation stages
Scanner
Parser
Semantic analysis
Intermediate code generation
Machine-independent code improvement (optional)
Target code generation
Machine-specific code improvement (optional)
For many compilers, the result is assembly
 Which then has to be run through an assembler
These stages are machine-independent!
 The generate intermediate code
Compilation: Scanner
Recognizes the tokens of a program
 Example tokens: ( 75 main int { return ; foo
Lexical errors are detected here
 More on this in a future lecture
Compilation: Parser
Puts the tokens together into a pattern
 void main ( int argc , char ** argv ) {
 This line has 11 tokens
 It is the beginning of a method
Syntatic errors are detected here
 When the tokens are not in the correct order:
 int int foo ;
 This line has 4 tokens
 After the type (int), the parser expects a variable
name
Not another type
Compilation: Semantic analysis
Checks for semantic correctness
A semantic error:
foo = 5;
int foo;
In C (and most languages), a variable has to be
declared before it is used
 Note that this is syntactically correct
As both lines are valid lines as far as the parser is concerned
Compilation: Intermediate code
generation (and improvement)
Almost all compilers generate intermediate code
 This allows part of the compiler to be machine-
independent
That code can then be optimized
 Optimize for speed, memory usage, or program
footprint
Compilation: Target code
generation (and improvement)
The intermediate code is then translated into the
target code
 For most compilers, the target code is assembly
 For Java, the target code is Java bytecode
That code can then be further optimized
 Optimize for speed, memory usage, or program
footprint

More Related Content

Similar to 02-chapter-1.ppt (20)

PPTX
2ProgrammerViewOfComputerAndInstructionCycle.pptx
Nnoor1
PPTX
Chapter 2 : Theory of programming languages
LaraibSaeed4
PPTX
CD U1-5.pptx
Himajanaidu2
PPT
Cd unit i
Abhimanyu Mishra
PPT
01. Introduction.ppt
ReshmaR57
PDF
1 introduction to compiler
BarwarBadradin
DOCX
First compailer written
microwoorkers
PPTX
Lecture際際滷s_1Fundamhehehehehheentals.pptx
asharma37be24
PPTX
SS UI Lecture 1
Avinash Kapse
PPTX
Ss ui lecture 1
Avinash Kapse
PPT
01. introduction
babaaasingh123
PPT
Assembly Langauge Assembly Langauge Assembly Langauge
mustafkhalid
PPT
introduction to computer vision and image processing
pakboy12
PPTX
Lesson 1-3 Fundamentals of Programming.pptx
DysRobles
PPT
Compiler Construction introduction
Rana Ehtisham Ul Haq
PDF
Introduction to compiler development
DeepOad
PPT
cd-greeshma (1).ppt compiler design unit 1
vrawat4
PPT
cd-greeshma.ppt online downloaded for study
yashashreeg2307
PPT
Ch1 (1).ppt
MDSayem35
2ProgrammerViewOfComputerAndInstructionCycle.pptx
Nnoor1
Chapter 2 : Theory of programming languages
LaraibSaeed4
CD U1-5.pptx
Himajanaidu2
Cd unit i
Abhimanyu Mishra
01. Introduction.ppt
ReshmaR57
1 introduction to compiler
BarwarBadradin
First compailer written
microwoorkers
Lecture際際滷s_1Fundamhehehehehheentals.pptx
asharma37be24
SS UI Lecture 1
Avinash Kapse
Ss ui lecture 1
Avinash Kapse
01. introduction
babaaasingh123
Assembly Langauge Assembly Langauge Assembly Langauge
mustafkhalid
introduction to computer vision and image processing
pakboy12
Lesson 1-3 Fundamentals of Programming.pptx
DysRobles
Compiler Construction introduction
Rana Ehtisham Ul Haq
Introduction to compiler development
DeepOad
cd-greeshma (1).ppt compiler design unit 1
vrawat4
cd-greeshma.ppt online downloaded for study
yashashreeg2307
Ch1 (1).ppt
MDSayem35

More from Joel Manio (7)

DOCX
DLL_TLE_sept.-4-8.docx
Joel Manio
PPT
History of computer .ppt
Joel Manio
PDF
sss-sickness-notification.pdf
Joel Manio
PPT
ProgrammingIntroduction.ppt
Joel Manio
PPTX
10 ssp Activity simple Payroll.pptx
Joel Manio
PPTX
10 ssp Activity simple Payroll.pptx
Joel Manio
PPT
lecture02.ppt
Joel Manio
DLL_TLE_sept.-4-8.docx
Joel Manio
History of computer .ppt
Joel Manio
sss-sickness-notification.pdf
Joel Manio
ProgrammingIntroduction.ppt
Joel Manio
10 ssp Activity simple Payroll.pptx
Joel Manio
10 ssp Activity simple Payroll.pptx
Joel Manio
lecture02.ppt
Joel Manio
Ad

Recently uploaded (20)

PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
DOCX
DLL english grade five goof for one week
FlordelynGonzales1
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
DOCX
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
PPTX
How to use _name_search() method in Odoo 18
Celine George
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
Photo chemistry Power Point Presentation
mprpgcwa2024
DLL english grade five goof for one week
FlordelynGonzales1
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
How to use _name_search() method in Odoo 18
Celine George
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
VCE Literature Section A Exam Response Guide
jpinnuck
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
Peer Teaching Observations During School Internship
AjayaMohanty7
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
Ad

02-chapter-1.ppt

  • 1. CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005
  • 2. The first computers Scales computed relative weight of two items Computed if the first items weight was less than, equal to, or greater than the second items weight Abacus performed mathematical computations Primarily thought of as Chinese, but also Japanese, Mayan, Russian, and Roman versions Can do square roots and cube roots
  • 4. Computer Size ENIAC then ENIAC today With computers (small) size does matter!
  • 5. Why study programming languages? Become a better software engineer Understand how to use language features Appreciate implementation issues Better background for language selection Familiar with range of languages Understand issues / advantages / disadvantages Better able to learn languages You might need to know a lot
  • 6. Why study programming languages? Better understanding of implementation issues How is this feature implemented? Why does this part run so slowly? Better able to design languages Those who ignore history are bound to repeat it
  • 7. Why are there so many programming languages? There are thousands! Evolution Structured languages -> OO programming Special purposes Lisp for symbols; Snobol for strings; C for systems; Prolog for relationships Personal preference Programmers have their own personal tastes Expressive power Some features allow you to express your ideas better
  • 8. Why are there so many programming languages? Easy to use Especially for teaching / learning tasks Ease of implementation Easy to write a compiler / interpreter for Good compilers Fortran in the 50s and 60s Economics, patronage Cobol and Ada, for example
  • 9. Programming domains Scientific applications Using the computer as a large calculator Fortran and friends, some Algol, APL Using the computer for symbol manipulation Mathematica Business applications Data processing and business procedures Cobol, some PL/1, RPG, spreadsheets Systems programming Building operating systems and utilities C, PL/S, ESPOL, Bliss, some Algol and derivitaves
  • 10. Programming domains Parallel programming Parallel and distributed systems Ada, CSP, Modula, DP, Mentat/Legion Artificial intelligence Uses symbolic rather than numeric computations Lists as main data structure Flexibility (code = data) Lisp in 1959, Prolog in the 1970s Scripting languages A list of commands to be executed UNIX shell programming, awk, tcl, Perl
  • 11. Programming domains Education Languages designed to facilitate teaching Pascal, BASIC, Logo Special purpose Other than the above Simulation Specialized equipment control String processing Visual languages
  • 12. Programming paradigms You have already seen assembly language We will study five language paradigms: Top-down (Algol 60 and Fortran) Functional (Scheme and/or OCaml) Logic (Prolog) Object oriented (Smalltalk) Aspect oriented (AspectJ)
  • 13. Programming language history Pseudocodes (195X) Many Fortran (195X) IBM, Backus Lisp (196x) McCarthy Algol (1958) Committee (led to Pascal, Ada) Cobol (196X) Hopper Functional programming FP, Scheme, Haskell, ML Logic programming Prolog Object oriented programming Smalltalk, C++, Python, Java Aspect oriented programming AspectJ, AspectC++ Parallel / non-deterministic programming
  • 14. Compilation vs. Translation Translation: does a mechanical translation of the source code No deep analysis of the syntax/semantics of the code Compilation: does a thorough understanding and translation of the code A compiler/translator changes a program from one language into another C compiler: from C into assembly An assembler then translates it into machine language Java compiler: from Java code to Java bytecode The Java interpreter then runs the bytecode
  • 15. Compilation stages Scanner Parser Semantic analysis Intermediate code generation Machine-independent code improvement (optional) Target code generation Machine-specific code improvement (optional) For many compilers, the result is assembly Which then has to be run through an assembler These stages are machine-independent! The generate intermediate code
  • 16. Compilation: Scanner Recognizes the tokens of a program Example tokens: ( 75 main int { return ; foo Lexical errors are detected here More on this in a future lecture
  • 17. Compilation: Parser Puts the tokens together into a pattern void main ( int argc , char ** argv ) { This line has 11 tokens It is the beginning of a method Syntatic errors are detected here When the tokens are not in the correct order: int int foo ; This line has 4 tokens After the type (int), the parser expects a variable name Not another type
  • 18. Compilation: Semantic analysis Checks for semantic correctness A semantic error: foo = 5; int foo; In C (and most languages), a variable has to be declared before it is used Note that this is syntactically correct As both lines are valid lines as far as the parser is concerned
  • 19. Compilation: Intermediate code generation (and improvement) Almost all compilers generate intermediate code This allows part of the compiler to be machine- independent That code can then be optimized Optimize for speed, memory usage, or program footprint
  • 20. Compilation: Target code generation (and improvement) The intermediate code is then translated into the target code For most compilers, the target code is assembly For Java, the target code is Java bytecode That code can then be further optimized Optimize for speed, memory usage, or program footprint