SlideShare a Scribd company logo
1 of 20
CS 415: Programming
Languages
Chapter 1
Aaron Bloomfield
Fall 2005
The first computers
Scales – computed relative weight of two items
 Computed if the first item’s weight was less than, equal to, or
greater than the second item’s 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 50’s and 60’s
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

1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compilerBarwarBadradin
 
First compailer written
First compailer writtenFirst compailer written
First compailer writtenmicrowoorkers
 
Assembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly LangaugeAssembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly Langaugemustafkhalid
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processingpakboy12
 
Lesson 1-3 Fundamentals of Programming.pptx
Lesson 1-3 Fundamentals of Programming.pptxLesson 1-3 Fundamentals of Programming.pptx
Lesson 1-3 Fundamentals of Programming.pptxDysRobles
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introductionRana Ehtisham Ul Haq
 
Introduction to compiler development
Introduction to compiler developmentIntroduction to compiler development
Introduction to compiler developmentDeepOad
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic conceptsAbdul Khan
 
C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with Cgpsoft_sk
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilersAftab Ahmad
 
Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Danish Alam
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages BakhatAli3
 
Structure-Compiler-phases information about basics of compiler. Pdfpdf
Structure-Compiler-phases information  about basics of compiler. PdfpdfStructure-Compiler-phases information  about basics of compiler. Pdfpdf
Structure-Compiler-phases information about basics of compiler. Pdfpdfovidlivi91
 

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

1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compiler
 
First compailer written
First compailer writtenFirst compailer written
First compailer written
 
SS UI Lecture 1
SS UI Lecture 1SS UI Lecture 1
SS UI Lecture 1
 
Ss ui lecture 1
Ss ui lecture 1Ss ui lecture 1
Ss ui lecture 1
 
01. introduction
01. introduction01. introduction
01. introduction
 
Assembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly LangaugeAssembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly Langauge
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processing
 
Lesson 1-3 Fundamentals of Programming.pptx
Lesson 1-3 Fundamentals of Programming.pptxLesson 1-3 Fundamentals of Programming.pptx
Lesson 1-3 Fundamentals of Programming.pptx
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Introduction to compiler development
Introduction to compiler developmentIntroduction to compiler development
Introduction to compiler development
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with C
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Chapter1 Introduction of compiler
Chapter1 Introduction of compiler
 
Plc part 1
Plc part 1Plc part 1
Plc part 1
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages
 
Structure-Compiler-phases information about basics of compiler. Pdfpdf
Structure-Compiler-phases information  about basics of compiler. PdfpdfStructure-Compiler-phases information  about basics of compiler. Pdfpdf
Structure-Compiler-phases information about basics of compiler. Pdfpdf
 

More from Joel Manio

DLL_TLE_sept.-4-8.docx
DLL_TLE_sept.-4-8.docxDLL_TLE_sept.-4-8.docx
DLL_TLE_sept.-4-8.docxJoel Manio
 
History of computer .ppt
History of computer .pptHistory of computer .ppt
History of computer .pptJoel Manio
 
sss-sickness-notification.pdf
sss-sickness-notification.pdfsss-sickness-notification.pdf
sss-sickness-notification.pdfJoel Manio
 
ProgrammingIntroduction.ppt
ProgrammingIntroduction.pptProgrammingIntroduction.ppt
ProgrammingIntroduction.pptJoel Manio
 
10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptxJoel Manio
 
10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptxJoel Manio
 

More from Joel Manio (7)

DLL_TLE_sept.-4-8.docx
DLL_TLE_sept.-4-8.docxDLL_TLE_sept.-4-8.docx
DLL_TLE_sept.-4-8.docx
 
History of computer .ppt
History of computer .pptHistory of computer .ppt
History of computer .ppt
 
sss-sickness-notification.pdf
sss-sickness-notification.pdfsss-sickness-notification.pdf
sss-sickness-notification.pdf
 
ProgrammingIntroduction.ppt
ProgrammingIntroduction.pptProgrammingIntroduction.ppt
ProgrammingIntroduction.ppt
 
10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx
 
10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx10 ssp Activity simple Payroll.pptx
10 ssp Activity simple Payroll.pptx
 
lecture02.ppt
lecture02.pptlecture02.ppt
lecture02.ppt
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

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 item’s weight was less than, equal to, or greater than the second item’s 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 50’s and 60’s 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