1 / 51 Introduction to Programming Languages and Evolution of the Major Programming Languages 886340 Principles of Programming Languages 1.

Slides:



Advertisements
งานนำเสนอที่คล้ายกัน
Application Development Overview Nithi Thanon Computer Science Prince of Songkla University.
Advertisements

INTRODUCTION TO C LANGUAGE
โครงสร้างโปรแกรมภาษา C
Object-Oriented Programming
ขั้นตอนการแปลงไฟล์.
การวิเคราะห์ประสิทธิภาพของอัลกอริธึม (Performance Analysis)
โครงสร้างควบคุมการทำงาน
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Java Programming Language.
List ADTs By Pantharee S..
การสร้าง WebPage ด้วย Java Script Wachirawut Thamviset.
Programming & Algorithm
Programming Languages ธนวัฒน์ แซ่เอียบ โฮมเพจรายวิชา
Syntax and Semantics ธนวัฒน์ แซ่เอียบ.
คุณลักษณะของคำสั่งภาษาเครื่อง ชนิดของตัวถูกดำเนินการ
Introduction to Computer Organization and Architecture Flow of Control ภาษาเครื่อง สายงานของการ ควบคุม.
Overview ธนวัฒน์ แซ่ เอียบ. Why Study PL? เขียนโปรแกรมตามแนวคิดที่ออกแบบไว้ชัดเจนขึ้น –Appreciation for valuable laguage features and encourages programmers.
Names, Scopes and Bindings
Introduction to Computer Organization and Architecture Flow of Control ภาษาเครื่อง สายงานของการ ควบคุม.
Names, Scopes and Bindings ธนวัฒน์ แซ่ เอียบ. The Concept of Binding Categories of variables by lifetimes –Static bound to memory cells before execution.
LAB ตัวแปร : Variables ในการเขียนโปรแกรมเราต้องการให้โปรแกรม จดจำค่าต่างๆ ไว้ เช่นเมื่อรับค่าข้อมูลจาก ผู้ใช้ หรือค่าที่ได้จากการคำนวณใดๆ ค่า.
Chapter 10 Arrays Dept of Computer Engineering Khon Kaen University.
Static Libraries ธวัชชัย เอี่ยมไพโรจน์. Static Libraries It is the simplest form of library. It is a collection of object files kept together in a ready-to-use.
Database & DBMS Architecture วรวิทย์ พูลสวัสดิ์. 2 2 ฐานข้อมูล (Database) - Data and its relation - Databases are designed to offer an organized mechanism.
PHP FRAMEWORK – Web Programming and Web Database Asst. Prof. Dr. Choopan Rattanapoka.
Timed Math Quiz. โปรแกรมสุ่มคำนวณเลขแข่งกับ เวลา.
Allocatable Array. Modules A packaging method for data and subprograms. Syntax of the form: A packaging method for data and subprograms. Syntax of the.
1 exit() and break C++ provides a way to leave a program early (before its natural finish) with the exit() function. The format of exit() is as follows:
Collections. Data structures Data Structures ( โครงสร้างข้อมูล ) เกิดจากการ นำข้อมูลขั้นพื้นฐานที่แบ่งแยกไม่ได้ (atomic data type) เช่น int, char, double.
Multimedia Systems รศ. ดร. บุญวัฒน์ อัตชู
Practice File. Our Executive Coaching Program is proven effective. Our customer survey show ROI of coaching can be as high as 3 times the investment value.
Page : Stability and Statdy-State Error Chapter 3 Design of Discrete-Time control systems Stability and Steady-State Error.
คำสั่งควบคุมการทำงาน
สื่อการเรียนรู้ด้วยตัวเอง ชุดฝึกเขียนสรุป (Writing Summary)
บทที่ 1 ภาษาคอมพิวเตอร์และ การโปรแกรม
โครงสร้างโปรแกรมภาษา C
หลักการโปรแกรม อ.ธนากร อุยพานิชย์.
Integrity Constraints
Introduction to VB2010 EXPRESS
13 October 2007
INC 161 , CPE 100 Computer Programming
การจัดการระบบฐานข้อมูล ภาษาที่ใช้ในระบบจัดการฐานข้อมูล
Computer Programming การเขียนโปรแกรมคอมพิวเตอร์
โครงสร้างโปรแกรมภาษา C
ความรู้เบื้องต้นเกี่ยวกับการเขียนโปรแกรม
คำอธิบายรายวิชา การเขียนผังงาน รหัสเทียม ตรรกศาสตร์เบื้องต้น การเขียนโปรแกรมคอมพิวเตอร์แบบโครงสร้าง ชนิดตัวแปร ตัวดำเนินการทางตรรกะ ตัวดำเนินการเปรียบเทียบ.
หน่วยที่ 2 ข้อมูลและสารสนเทศ
STACK สแตก(stack) เป็นโครงสร้างข้อมูลแบบเชิงเส้น ที่มีการใส่ข้อมูลเข้า และนำข้อมูลออกเพียงด้านเดียว ดังนั้น ข้อมูลที่เข้าไปอยู่ใน stack ก่อนจะออกจาก stack.
BC320 Introduction to Computer Programming
Object-Oriented Programming Paradigm
สื่อการสอนรายวิชา ง30204 โปรแกรมภาษาชี ภาษาคอมพิวเตอร์และโปรแกรม
+ Software บทที่ 3 ซอฟต์แวร์ระบบสารสนเทศ Hardware
การออกแบบระบบ System Design.
13 October 2007
Asst.Prof. Dr.Surasak Mungsing
Object-Oriented Programs Design and Construction
Software Engineering ( )
บทที่ 4 ความรู้เกี่ยวกับระบบฐานข้อมูล
Development Strategies
บทที่ 1 ภาษาคอมพิวเตอร์และ การโปรแกรม
Lecture no. 1: Introduction to Computer and Programming
ผู้ช่วยศาสตราจารย์จุฑาวุฒิ จันทรมาลี
แล้วไงเกี่ยวกับความจริง What About Truth?
บทที่ 7 การประมวลผลอาร์เรย์
Control Charts for Count of Non-conformities
บทที่ 2 โครงสร้างข้อมูลแบบแถวลำดับหรืออาร์เรย์ (Array)
การวิเคราะห์โจทย์ปัญหา (Problem Analysis)
กลยุทธ์การทดสอบซอฟต์แวร์ วิศวกรรมซอฟต์แวร์ (Software Engineering)
การวิเคราะห์และออกแบบขั้นตอนวิธี
Dr.Surasak Mungsing CSE 221/ICT221 การวิเคราะห์และออกแบบขั้นตอนวิธี Lecture 12: เทคนิคการออกแบบขั้นตอนวิธีตอนวิธี Dynamic.
ความรู้พื้นฐานเกี่ยวกับคอมพิวเตอร์และการประมวลผลข้อมูล (Introduction to Computer and Data Processing) บทที่ Business Computer & Information.
ใบสำเนางานนำเสนอ:

1 / 51 Introduction to Programming Languages and Evolution of the Major Programming Languages Principles of Programming Languages 1

2 / 51 To gain an understanding of the basic structure of programming languages: - Data types, control structures, naming conventions,... To learn the principles underlying all programming languages: - So that it is easier to learn new languages To study different language paradigms: - Functional (Scheme) - Imperative (C) - Object-Oriented (C++, Java) - Logic (Prolog) So that you can select an appropriate language for a task Course Goals

3 / 51 What is Programming Language?

4 / 51 “a programming language is a notation for communication to a computer what we want to do” Before the middle of the 1940s, computer operators “hardwired” their programs. In the late 1940s, John von Neumann had the idea. Data and programs stored in memory Memory is separate from CPU Instructions and data are piped from memory to CPU Definition of Programming Language I

5 / 51 The von Neumann Architecture

6 / 51 Fetch-execute-cycle (on a von Neumann architecture computer) initialize the program counter repeat forever fetch the instruction pointed by the counter increment the counter decode the instruction execute the instruction end repeat The von Neumann Architecture

7 / 51 At this point, computer operators became the first true programmers. developed software the machine code to solve problems with computers Machine Language and the First Stored Programs

8 / 51 In this program, each line of code contains 16 bits. A line of 16 bits represents either a single machine language instruction or a single data value. Program execution begins with the first line of code, which is fetched from memory, decoded (interpreted), and executed. Machine Language For example, A machine language program

9 / 51 mnemonic symbols for the instruction codes and memory locations A program called an assembler translates the symbolic assembly language code to binary machine code. Assembly language For example, An LC-3 assembly language program that adds two numbers

10 / 51 But…. The programmer must still do the hard work of translating the abstract ideas of a problem domain to the concrete and machine-dependent notation of a program. Computer hardware architecture has its own machine language instruction set, and thus requires its own dialect of assembly language. Low-Level Language Assembly language

11 / 51 “A programming language is a notation system for describing computation in machine-readable and human-readable form” Definition of Programming Language II

12 / 51 กระบวนการ (process) ใดๆที่ คอมพิวเตอร์สามารถทำได้ การคำนวณทางคณิตศาสตร์ การจัดการกับข้อมูล (data manipulation) การประมวลผลข้อความ (text processing) การจัดเก็บและการค้นข้อมูล (information storage and retrieval) Computation

13 / 51 มีโครงสร้างที่เรียบง่าย ภาษาเครื่องที่ผ่านการแปลแล้วต้องมีความ ชัดเจนไม่กำกวม algorithm ที่ใช้แปลต้องมี complexity อยู่ในระดับที่ยอมรับได้ เพื่อให้การแปลมี ประสิทธิภาพ ดังนั้น ภาษาสำหรับเขียนโปรแกรมจึงต้องมี รูปแบบของไวยากรณ์แน่นอน เรียกว่า context free language Machine readability

14 / 51 การทำ abstraction หรือการแทน รายละเอียดของการทำงานของคอมพิวเตอร์ ที่ซับซ้อน เพื่อให้ผู้เขียนโปรแกรมเน้นความสนใจไปที่ งานที่ต้องการแก้ปัญา ดังนั้นภาษาสำหรับเขียนโปรแกรมควรมี โครงสร้างและวิธีการทำงานเป็นแบบ เดียวกับภาษาธรรมชาติ (natural language) Human readability

15 / 51 Abstractions in Programming Languages

16 / 51 Data abstractions การซ่อนรายละเอียดของการจัดเก็บข้อมูล ให้อยู่ในรูปแบบที่ง่ายต่อการใช้งาน เช่น character string, numbers หรือ binary tree เป็นต้น Control abstractions การซ่อนรายละเอียดของการส่งผ่านการ ควบคุม เช่น loops, คำสั่งที่มีเงื่อนไข ในทางปฏิบัติ และการเรียกใช้โปรแกรม ย่อย เป็นต้น Abstractions in Programming Languages

17 / 51 Basic abstraction การ abstract การจัดเก็บข้อมูลพื้นฐานใน หน่วยความจำ การ abstract วิธีการดำเนินการทาง คณิตศาสตร์พื้นฐานกับข้อมูล การ abstract ตำแหน่งที่ใช้เก็บข้อมูลใน หน่วยความจำ ตัวแปร คือ ชื่อของตำแหน่งในหน่วยความจำ และชนิดของข้อมูล ที่เกิดขึ้นจากการประกาศ (declaration) เช่น var x : integer; ในภาษา Pascal หรือ intx; ในภาษา C Data abstractions

18 / 51 Structure abstraction การ abstract กลุ่มของข้อมูลที่มี ความสัมพันธ์กัน (data structure) type declaration กำหนดชื่อของชนิด ข้อมูล เช่น การกำหนดกลุ่มของข้อมูลที่เป็นเลข จำนวนเต็มเป็น array เช่น a : array [ ] of integer; ใน ภาษา Pascal หรือ inta[10]; ในภาษา C Data abstractions

19 / 51 Structure abstraction กำหนดให้มีข้อมูลชนิด record เช่น Data abstractions type date = record day : 1..31; month : 1..12; year: ; end; struct date { intday; intmonth; intyear; }; typedef struct date date; ภาษา Pascal ภาษา C

20 / 51 Unit abstractions การแยกโปรแกรมในส่วนที่ใช้สร้างและการ ใช้งานโครงสร้างข้อมูลออกไว้เป็นสัดส่วน Data encapsulation module และ package Data abstractions

21 / 51 Basic abstractions การรวมคำสั่งภาษาเครื่องหลายคำสั่ง เข้าเป็นคำสั่ง ในภาษาระดับสูงคำสั่งเดียว เช่น คำสั่งกำหนดค่า (assignment statement) ในภาษา Pascal เช่น x := x + 3; มีความหมายในคำสั่งภาษา Assembly ของ 80x86 ดังต่อไปนี้ เมื่อกำหนดให้ x เป็นตัวแปร ขนาด 16 บิต และมีตำแหน่งในหน่วยความจำเป็น 1000 movdx, 1000 movax, [dx] movbx, 3 addax, bx mov[dx], ax Control abstractions

22 / 51 Structured abstractions การซ้อน (nested) คำสั่งหรือกลุ่มของคำสั่งไว้ ภายใต้เงื่อนไขการทดสอบ เช่น คำสั่ง if, switch case, while, for ในภาษา C Control abstractions IF x > 0.0 THEN numSolns := 2; r1 := sqrt(x); r2 := -r1; ELSE numSolns := 0; END; if ( x > 0.0 ) { numSolns = 2; r1 = sqrt(x); r2 = -r1; } else numSolns = 0; ภาษา Modula-2 ภาษา C If x > 0.0 then begin numSolns := 2; r1 := sqrt(x); r2 := -r1; end else numSolns := 0; ภาษา Pascal

23 / 51 Structured abstractions การทำโปรแกรมย่อย เรียกว่า procedure หรือ subprogram หรือ subroutine หรือ function การรวมคำสั่งในภาษาหลายคำสั่งเข้าด้วยกัน เป็นเสมือนหนึ่งคำสั่งเดียว มีองค์ประกอบ 2 ประการ procedure declaration procedure activation Control abstractions

24 / 51 Structured abstractions ตัวอย่าง เช่น Control abstractions function gcd(u, v : integer) : integer; var t : integer; begin while v > 0 do begin t := v; v := u mod v; u := t; end; gcd := u; end; int gcd ( int u, int v ) { int tmp; while ( v > 0 ) { t = v; v = u % v; u = t; } return u; } ภาษา Pascal ภาษา C

25 / 51 Unit abstractions ภาษาโดยทั่วไปจะมีกลไกในการรวม โปรแกรมย่อยที่มีการทำงานคล้ายคลึงกัน เข้าเป็นกลุ่มเพื่อสะดวกต่อการใช้งาน เช่น การ module ในภาษา Modular-2 และ package ในภาษา Ada function ในภาษา C เป็นต้น ในภาษา C, header file เป็นส่วนกำหนด โครงสร้างและชนิดของข้อมูล Control abstractions

26 / 51 Computational Paradigms

27 / 51 A way of looking at a problem and seeing a program – What kind of parts do you look for? Problem: Print a “large X” of size n. – E.g., size 5 is X X X X X X What is a Paradigm?

28 / 51 Imperative Paradigm Functional Paradigm Logic Programming Paradigm Object-Oriented Paradigm Paradigm

29 / 51 A program is: A sequence of state-changing actions Manipulate an abstract machine with: – Variables that name memory locations – Arithmetic and logical operations – Reference, evaluate, assign operations – Explicit control flow statements Fits the Von Neumann architecture closely Key operations: Assignment and “Go To” Imperative Paradigm

30 / 51 Example: Imperative Paradigm

31 / 51 A program is: Composition of operations on data Characteristics (in pure form): – Name values, not memory locations – Value binding through parameter passing – Recursion rather than iteration Key operations: Function Assignment, Function Application, and Function Abstraction– Based on the Lambda Calculus Functional Paradigm

32 / 51 Example: Functional Paradigm

33 / 51 A program is: Formal logical specification of problem Characteristics (in pure form): – Programs say what properties the solution must have, not how to find it – Solutions are obtained through a specialized form of theorem-proving Key operations: Unification and NonDeterministic Search – Based on First Order Predicate Logic Logic Programming Paradigm

34 / 51 Example: Logic Programming Paradigm

35 / 51 A program is: Communication between abstract objects Characteristics: – “Objects” collect both the data and the operations – “Objects” provide data abstraction – Can be either imperative or functional (or logical) Key operation: Message Passing or Method Invocation Object-Oriented Paradigm

36 / 51 Example: Object-Oriented Paradigm Java

37 / 51 Scientific applications Large numbers of floating point computations; use of arrays >> Fortran Business applications Produce reports, use decimal numbers and characters >> COBOL Artificial intelligence Symbols rather than numbers manipulated; use of linked lists >> LISP Systems programming Need efficiency because of continuous use >> C Web Software Eclectic collection of languages: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) Programming Domains

38 / 51 History of Programming Languages Click here

39 / 51 Prehistory 300 B.C. Greece, Euclid invented the greatest common divisor algorithm - oldest known algorithm ~ England, Charles Babbage invented two mechanical computational devices - difference engine - analytical engine - Countess Ada Augusta of Lovelace, first computer programmer Precursors to modern machines ’s United States, ENIAC developed to calculate trajectories ’s United States, first high-level PLs invented History of Programming Languages

40 / 51 Fortran , John Backus (IBM on 704) designed for numerical scientific computation fixed format for punched cards implicit typing only counting loops, if test versus zero only numerical data 1957 optimizing Fortran compiler translates into code as efficient as hand-coded History of Programming Languages

41 / 51 Algol , designed by international committee for numerical scientific computation [Fortran] block structure with lexical scope free format, reserved words while loops, recursion explicit types BNF developed for formal syntax definition Cobol , designed by committee in US, manufacturers and DoD for business data processing Records focus on file handling English-like syntax History of Programming Languages

42 / 51 APL Ken Iverson, (IBM on 360, Harvard) designed for array processing functional programming style LISP , John McCarthy (MIT on IBM704,Stanford) designed for non-numerical computation uniform notation for program and data recursion as main control structure garbage collection Snobol , Farber, Griswold, Polansky (Bell Labs)designed for string processing powerful pattern matching History of Programming Languages

43 / 51 PL/I , IBM designed for general purpose computing [Fortran, Algol60, Cobol] user controlled exceptions multi-tasking Simula , Dahl and Nygaard (Norway) designed as a simulation language [Algol60] data abstraction inheritance of properties Algol , designed for general purpose computing [Algol60] orthogonal language design interesting user defined types History of Programming Languages

44 / 51 Pascal 1969, N. Wirth(ETH) designed for teaching programming [Algol60] 1 pass compiler call-by-value semantics Prolog 1972, Colmerauer and Kowalski designed for Artificial Intelligence applications theorem proving with unification as basic operation logic programming History of Programming Languages

45 / 51 Recent C 1974, D. Ritchie (Bell Labs) designed for systems programming allows access to machine level within high-level PL efficient code generated Clu , B. Liskov (MIT) designed for simulation [Simula] supports data abstraction and exceptions precise algebraic language semantics attempt to enable verification of programs History of Programming Languages

46 / 51 Smalltalk mid-1970s, Alan Kay (Xerox Parc), considered first real object-oriented PL, [Simula] encapsulation, inheritance easy to prototype applications hides details of underlying machine Scheme mid-1970s, Guy Steele, Gerald Sussman (MIT) Static scoping and first-class functions History of Programming Languages

47 / 51 Modula 1977 N. Wirth (ETH), designed language for large software development [Pascal] to control interfaces between sets of procedures or modules real-time programming Ada 1979, US DoD committee designed as general purpose PL explicit parallelism – rendezvous exception handling and generics (packages) History of Programming Languages

48 / 51 C , Bjorne Stroustrup (Bell Labs) general purpose goal of type-safe object-oriented PL compile-time type checking templates Java ~1995, J. Gosling (SUN) aimed at portability across platform through use of JVM - abstract machine to implement the PL aimed to fix some problems with previous OOPLs¨ multiple inheritance¨ static and dynamic objects ubiquitous exceptions thread objects History of Programming Languages

49 / 51 So you can choose the right language for a given problem – If all you have is a hammer, every problem looks like a nail Why learn more than one PL?

50 / 51 So you can learn a new language more easily later – As your job changes, you may need to used different languages – As our understanding of programming improves, new languages are created To learn new ways of thinking about problems – Different languages encourage you to think about problems in different ways – “Paradigms” Why learn more than one PL?

51 / 51 Conclusion and Question