Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,

Similar presentations


Presentation on theme: "Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,"— Presentation transcript:

1 Programming Language Theory 2014, kkman@sangji.ac.kr 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering, Sangji University Kwangman Ko (kkman@sangji.ac.kr)kkman@sangji.ac.kr

2 Programming Language Theory 2014, kkman@sangji.ac.kr 2 Reading 1, P40. Reading 2, P40

3 Programming Language Theory 2014, kkman@sangji.ac.kr 3 1. Introduction, P41 Why are there so many programming languages? –evolution - we've learned better ways of doing things over time –socio-economic factors: proprietary interests, commercial advantage –orientation toward special purposes –orientation toward special hardware –diverse ideas about what is pleasant to use

4 Programming Language Theory 2014, kkman@sangji.ac.kr 4 Introduction What makes a language successful?, PP42-43. –easy to learn(BASIC, Pascal, LOGO, Scheme) –easy to express things, easy use once fluent, "powerful” C, Common Lisp, APL, Algol-68, Perl, … –easy to implement (BASIC, Forth) –possible to compile to very good (fast/small) code (Fortran) –backing of a powerful sponsor (COBOL, PL/1, Ada, Visual Basic) –wide dissemination at minimal cost (Pascal, Turing, Java)

5 Programming Language Theory 2014, kkman@sangji.ac.kr 5 1.2 Program Language Spectrum, PP45-46. Classified into families based on Model of Computation –Declarative Programming Language focused on WHAT the computer is to do. More higher level, tune with the programmer’s point of view. –Imperative Programming Language focused on HOW the computer should do it. dominate, mainly for performance reasons

6 Programming Language Theory 2014, kkman@sangji.ac.kr 6 Declarative programming language –Functional Scheme, ML, pure Lisp, FP, … –logic, constraint-based: –Prolog, VisiCalc, RPG, … Imperative programming language –von Neumann: Fortran, Pascal, Basic, C, … –object-oriented: Smalltalk, Eiffel, C++, … –scripting languages: Perl, Python, JavaScript, PHP, …

7 Programming Language Theory 2014, kkman@sangji.ac.kr 7 1.3 Why study programming languages?, P47~ Help you choose a language. –for systems programming C vs. Modula-3 vs. C++ –for numerical computations Fortran vs. APL vs. Ada –for embedded systems Ada vs. Modula-2 –for symbolic data manipulation Common Lisp vs. Scheme vs. ML –for networked PC programs Java vs. C/CORBA

8 Programming Language Theory 2014, kkman@sangji.ac.kr 8 Reading, P48. –Understand OBSCURE features: –Choose among alternative ways to express things understand implementation costs –Make good use of debuggers, assemblers, linkers, and related tools –Simulate useful features in languages that lack them

9 Programming Language Theory 2014, kkman@sangji.ac.kr 9 1.4 Compilation vs. Interpretation Compilation vs. Interpretation –not opposites –not a clear-cut distinction Source Program Compiler Input Data Outputs Target Program Source Program Interpreter Input Data Outputs

10 Programming Language Theory 2014, kkman@sangji.ac.kr 10 Compilation vs. Interpretation Pure Compilation –translates the high-level source program into an equivalent target program(typically in machine language). 원시 프로그램 목적 프로그램 Frontend Backend 중간코드 COMPILER

11 Programming Language Theory 2014, kkman@sangji.ac.kr 11 Pure Interpretation –stays around for the execution of the program –the locus of control during execution Reading, P51. –Interpretation Greater flexibility Better diagnostics (error messages) –Compilation Better performance

12 Programming Language Theory 2014, kkman@sangji.ac.kr 12 Most language implementations, ☞ P 51. –a mixture of both compilation and interpretation –compilation or simple pre-processing, followed by interpretation source program translator intermediate program Virtual Machine (interpreter) Input Data Output

13 Programming Language Theory 2014, kkman@sangji.ac.kr 13 source program translator intermediate program Virtual Machine (interpreter) Input Data Output Test.java Java compiler (javac Test.java ) Test.class Java interpreter (java Test.class)

14 Programming Language Theory 2014, kkman@sangji.ac.kr 14 Preprocessor –Removes comments and white space –Groups characters into tokens (keywords, identifiers, numbers, symbols) –Expands abbreviations in the style of a macro assembler –Identifies higher-level syntactic structures (loops, subroutines)

15 Programming Language Theory 2014, kkman@sangji.ac.kr 15 Library of Routines and Linking –Reading, P52. –Compiler uses a linker program to merge the appropriate library of subroutines (e.g., math functions such as sin, cos, log, etc.) into the final program: source program compiler Incomplete machine program LINKER Library Routines machine program

16 Programming Language Theory 2014, kkman@sangji.ac.kr 16 Post-compilation Assembly –Facilitates debugging (assembly language easier for people to read) –Isolates the compiler from changes in the format of machine language files (only assembler must be changed, is shared by many compilers)

17 Programming Language Theory 2014, kkman@sangji.ac.kr 17 The C Preprocessor (conditional compilation) –Preprocessor deletes portions of code, which allows several versions of a program to be built from the same source

18 Programming Language Theory 2014, kkman@sangji.ac.kr 18 Source-to-Source Translation (C++) –C++ implementations based on the early AT&T compiler generated an intermediate program in C, instead of an assembly language:

19 Programming Language Theory 2014, kkman@sangji.ac.kr 19 Bootstrapping

20 Programming Language Theory 2014, kkman@sangji.ac.kr 20 Dynamic and Just-in-Time(JIT) Compilation –Reading, P56. –In some cases a programming system may deliberately delay compilation until the last possible moment. –The Java language definition defines a machine-independent intermediate form known as byte code. Byte code is the standard format for distribution of Java programs. –The main C# compiler produces.NET Common Intermediate Language (CIL), which is then translated into machine code immediately prior to execution.

21 Programming Language Theory 2014, kkman@sangji.ac.kr 21 Compilation vs. Interpretation Tools

22 Programming Language Theory 2014, kkman@sangji.ac.kr 22 1.5 Programming Environments

23 Programming Language Theory 2014, kkman@sangji.ac.kr 23 1.6 An Overview of Compilation, PP59-60.


Download ppt "Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,"

Similar presentations


Ads by Google