Introduction to Programming Languages - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Introduction to Programming Languages

Description:

... Lin. Department of Computer Science and Information Engineering ... Language Definitions. The Semantics of a programming language specifies the ... Definitions ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 30
Provided by: xbeanCs
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Programming Languages


1
Introduction to Programming Languages
  • Nai-Wei Lin
  • Department of Computer Science and Information
    Engineering
  • National Chung Cheng University

2
Introduction
3
Programming Languages
  • Natural languages are designed to facilitate the
    communication between human
  • Programming languages are designed to facilitate
    the communication between human and computers

4
How we communicate influences how we think, and
vice versa.
5
Study programming languages affects the way we
think about computers and computation.
6
A programming language is a notation for
describing computation in computer-readable and
human-readable form
7
Computation
  • Computation is usually defined formally using the
    mathematical concept of a Turing machine
  • Churchs thesis states that it is not possible to
    build a machine that is inherently more powerful
    than a Turing machine

8
Levels of Programming Languages
  • Machine languages
  • Assembly languages
  • High-level languages

9
Computer-Readability
  • An interpreter is a program that can understand a
    language and execute programs written in that
    language
  • A compiler is a program that can translate
    programs written in a language into programs
    written in another language

10
Interpreters
Input
Source program
Output
Interpreter
11
Compilers
Source program
Target program
Compiler
Target program
Output
Input
12
Language Definitions
  • The Syntax of a programming language specifies
    the structure of programs 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.

13
Language Definitions
  • The Semantics of a programming language specifies
    the meaning of programs 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.

14
Language Definitions
  • 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

15
Human-Readability
  • A programming language provides abstractions of
    the actions of computers that are easy to
    understand, even by persons not familiar with the
    underlying details of the machine

16
Abstract
  • Disassociated from any specific instance (??)
  • A summary of points (??)

17
Abstractions
Data
Control
Operations
18
Abstractions
  • Data abstractions abstract properties of data,
    such as numbers, character strings, trees, which
    are subjects of computation
  • Control abstractions abstract properties of the
    transfer of control, that is, the modification of
    the execution path of a program based on the
    situation at hand. Examples are loops,
    conditional statements, and procedure calls

19
Data Abstractions
  • Basic abstractions basic data types such as
    integers, floating point numbers, characters
  • Structured abstractions structured data types
    such as arrays and records
  • Unit abstractions abstract data types such as
    stacks, queues, trees, graphs

20
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

21
Abstraction of Operations
Basic data types
Basic statements
Structured data types
Structured statements
Abstract data types
22
Abstraction of Operations
High-Level Languages
Abstract Operations
Machine Operations
Machine Languages
23
Programming Paradigms
  • Imperative programming a series of commands
    Fortran, Pascal, C, Ada
  • Functional programming a collection of
    mathematical functions Lisp, ML, Haskell
  • Logic programming a collection of logical
    declarations Prolog, Godel
  • Object-oriented programming a collection of
    objects Simula, Smalltalk, C, Java

24
Imperative Programming
int gcd(int u, int v) int t while (v
! 0) t u v u v
v t return u
How
25
Functional Programming
gcd u 0 u gcd u v gcd (v (u mod
v)) gcd u v if v 0
then u else gcd(v (u
mod v))
What
26
Logic Programming
gcd(U, V, U) - V 0. gcd(U, V, X) - not
(V 0), Y is U mod V, gcd(V, Y, X).
What
27
Object-Oriented Programming
public class IntWithGcd private int
value public IntWithGcd(int val) value
val public int intValue() return value
public int gcd(int v) int z
value int y v while (y ! 0)
int t u v z y y t
return z
How
28
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

29
Contents
  • History
  • Language design principles
  • Syntax
  • Imperative programming
  • Functional programming
  • Logic programming
  • Object-oriented programming
Write a Comment
User Comments (0)
About PowerShow.com