230 likes | 244 Views
This chapter introduces the origin and evolution of programming languages, as well as the factors that contribute to their success. It also explores the different families of programming languages and why studying them is important. The chapter covers topics like compilation vs. interpretation and the use of preprocessors and source-to-source translation.
E N D
Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering, Sangji University KwangmanKo (kkman@sangji.ac.kr)
Reading 1, P40. • Reading 2, P40
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
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)
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
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, …
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
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
1.4 Compilation vs. Interpretation • Compilation vs. Interpretation • not opposites • not a clear-cut distinction Input Data Compiler Target Program Source Program Outputs Source Program Interpreter Outputs Input Data
Compilation vs. Interpretation • Pure Compilation • translates the high-level source program into an equivalent target program(typically in machine language). COMPILER 원시 프로그램 Frontend 중간코드 Backend 목적 프로그램
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
Most language implementations, ☞ P 51. • a mixture of both compilation and interpretation • compilation or simple pre-processing, followed by interpretation source program translator Virtual Machine (interpreter) intermediate program Output Input Data
source program Test.java Java compiler (javac Test.java ) translator Virtual Machine (interpreter) Java interpreter (java Test.class) Test.class intermediate program Output Input Data
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)
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 Library Routines LINKER machine program
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)
The C Preprocessor (conditional compilation) • Preprocessor deletes portions of code, which allows several versions of a program to be built from the same source
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:
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.
Compilation vs. Interpretation • Tools