Introduction to Programming Languages PDF
Document Details
Uploaded by WinningDallas
National Chung Cheng University
Nai-Wei Lin
Tags
Related
- Introduction of Programming Languages Lecture PDF
- Introduction of Programming Languages PDF
- Mindoro State University Introduction to Programming Languages PDF
- Unit 1-Introduction To Programming And Computer Science PDF
- DS102 Unit 1 Lesson 1 Introduction to Programming PDF
- Introduction to Programming, Chapter 1, PDF
Summary
This document provides an introduction to programming languages. It covers fundamental concepts and details about different programming language types. Discussion on the levels of programming languages, definition, implementations, abstractions, paradigms and design principles are also included.
Full Transcript
Introduction to Programming Languages https:// Nai-Wei Lin www.tutorialspoint.co Department of Computer Science and Information Engineering m/prolog/prolog_relati National Chung Cheng University ons.htm Chapter 1 Introduction Outline What is a programming language Levels of...
Introduction to Programming Languages https:// Nai-Wei Lin www.tutorialspoint.co Department of Computer Science and Information Engineering m/prolog/prolog_relati National Chung Cheng University ons.htm Chapter 1 Introduction Outline What is a programming language Levels of programming languages Definition of programming languages Implementation of programming languages Abstractions in programming languages Paradigms of programming languages Language design principles 3 What Is a Programming Language A natural language is designed to communicate between human A programming language is designed to communicate between human and computers 4 How we communicate influences how we think, and vice versa. 5 A programming language is a notation for describing computation in computer-readable and 6 Computation Computation is usually defined formally using the mathematical concept of a Turing machine Church’s thesis states that it is not possible to build a machine that is inherently more powerful than a Turing machine 7 Turing Completeness A programming language is Turing complete if it can be used to describe all the computation that a Turing machine can perform A programming language is Turing complete if it has integer variables and arithmetic operators, assignment statements, sequence statements, selection statements, and iteration statements 8 Levels of Programming Languages Machine languages Assembly languages High-level languages 9 Definition of Programming Languages The Syntax of a programming language specifies the structure of programs The Semantics of a programming language specifies the meaning of programs 10 Syntax An if-statement consists of the word “if” followed by an expression inside parentheses, followed by a statement, followed by an optional else part consisting of the word “else” and another statement. 11 Semantics An if-statement is executed by first evaluating its expression, which must have arithmetic or pointer type, including all side effects, and if it compares unequal to 0, the statement following the expression is executed. If there is an else part, and the expression is 0, the statement following the “else” is executed. 12 Formal Definition of Programming Languages The Syntax of a programming language is usually formally defined by context-free grammars The Semantics of a programming language is usually informally defined by human languages. It can be partially defined in a formal language using operational semantics, denotational semantics, or axiomatic semantics 13 Implementation of Programming Languages A compiler is a program that can translate programs written in a language into programs written in another language An interpreter is a program that can understand a language and execute programs written in that language 14 Compilers Source Target Compiler program program Target Input Output program 15 Interpreters Input Source Output Interpreter program 16 Virtual Machines An interpreter can be viewed as a virtual machine that can directly execute a high level programming language Compilers and interpreters are relative concepts. Many programming languages have both a compiler and an interpreter Java has a compiler that translates the Java programs into Java byte codes. The Java virtual machine is an interpreter that can directly execute Java byte codes 17 Abstractions in Programming Languages A programming language provides abstractions of the computation that are easy to understand, even by persons not familiar with the underlying details of the computer 18 Abstract 抽象 摘要 Draw the common properties from all the instances Adopt the essential properties from the whole system 19 Abstractions The set of operation The sequence s of operations associate to be d with processed each data Data Control object Operations 20 Abstractions Data abstractions abstract properties of data, such as numbers, character strings, trees, which are subjects of computation Control abstractions abstract properties of control, such as loops, conditional statements, and procedures 21 Data Abstractions Basic abstractions: basic data types such as integers, floating point numbers, and characters Structured abstractions: structured data types such as arrays and records Unit abstractions: abstract data types such as stacks, queues, trees, and graphs 22 Control Abstractions Basic abstractions: basic statements such as assignment statement and goto statement Structured abstractions: structured statements such as if-statement, while- statement, and procedures Unit abstractions: abstract data types such as stacks, queues, trees, graphs 23 Abstraction of Operations Basic data types Basic statements Structured data typesStructured statements Abstract data types 24 Abstraction of Operations High-Level Languages Abstract Operations Machine Operations Machine Languages 25 Paradigms of Programming Languages Imperative programming – a series of commands: Fortran, Pascal, C, Ada Object-oriented programming – a class of objects: Simula, Smalltalk, C++, Java Functional programming – a collection of mathematical function definitions: Scheme, ML, Haskell Logic programming – a collection of logical predicates: Prolog, Godel 26 Imperative Programming How Imperative Languages and Arch. Imperative languages, e.g., C, C++,Java, which dominate programming, von Neumann architecture 1- Variables memory cells 2- Assignment statements data piping between memory and CPU 3- Operations and expressions CPU executions 27