Principles of Programming Languages Asst. Prof. Dr. Ahmet Sayar Spring-2012 Kocaeli University Computer Engineering Department Introduction.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Principles of programming languages 1: Introduction (with a simple language) Isao Sasano Department of Information Science and Engineering.
Names and Bindings.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Compiler Construction by Muhammad Bilal Zafar (AP)
ProgrammingLanguages Programming Languages Language Abstraction and Computational Paradigms.
Computer Software & Software Development H&K Chapter 1 Instructor – Gokcen Cilingir Cpt S 121 (June 20, 2011) Washington State University.
COSC 120 Computer Programming
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 1: Introduction COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
High-Level Programming Languages
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Programming Languages Structure
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Describing Syntax and Semantics
Chapter 6: An Introduction to System Software and Virtual Machines
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
CS 363 Comparative Programming Languages
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Chapter 1 - Introduction
 The design of the imperative languages is based directly on the von Neumann architecture  Efficiency is the primary concern  Low-level specifications:
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
ProgrammingLanguages Programming Languages Language Definition, Translation and Design.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
1-1 An Introduction to Functional Programming Sept
CSC1200 INTRODUCTION TO PROGRAMMING Dr. Maureen Markel
Introduction to OOP CPS235: Introduction.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Chapter 1: Introduction to Computers and Programming.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
Lecture 1b- Introduction
Advanced Computer Systems
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
CS2403 Programming Languages Expressions and Assignment Statements
Introduction to programming languages, Algorithms & flowcharts
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Programming Languages 2nd edition Tucker and Noonan
CMP 131 Introduction to Computer Programming
Principles of Programming Languages
Programming Languages and Paradigms
Reasons To Study Programming Languages
Presentation transcript:

Principles of Programming Languages Asst. Prof. Dr. Ahmet Sayar Spring-2012 Kocaeli University Computer Engineering Department Introduction

Goal of This Course Introducing major principles and concepts underlying all programming languages without concentrating on one particular language. It is not necessary for you to be familiar with all the programming languages. Familiarity from one of them is enough. It would be great if you have some general knowledge of data structures, algorithms and computational processes.

Different Names for the Same Course Formal Languages Programming Languages The Principles of Programming Languages Theory of Computing Computational Theories Fundamentals of Programming Languages

Related Studies in Literature Computer Engineering Computer Science Linguistics – Scientific Study of Human Language – Morphology, syntax and phonology Cognitive Science – Interdisciplinary scientific study of mind and its processes – Intelligence and behavior – How information is represented carried processed within nervous systems (humans and animals) and machines – Consists of multiple disciplines: psychology, artificial intelligence (computer eng and science), philosophy, linguistics, sociology, anthropology

What is a programming language? Programming Languages Programming Language

What is a Programming Language A notation for communicating with a computer what we want it to do. A major advance in computer design occurred in 1940 – Instead of hard-wired jobs – A series of codes stored as data would determine the actions taken by a central processing unit. – Soon, programmers realized attaching symbols to the instruction codes as well as to the memory locations – And assembly language was born.

What is a Programming Language Assembly language are machine dependent. Low- level languages. Hard to read and write High-level languages? Von Neumann model – An area of memory where both programs and data are stored and a separate central processing unit that sequentially executes instructions fetched from memory. New Definition: Notational system for describing computation in machine-readable and human- readable form.

Computation? Any process that can be carried out by a computer. Not necessarily mean mathematical calculations Data manipulation, text processing, information storage retrieval Special purpose languages – Graphics, reports, database General purpose languages – C, JAVA

How many programming languages do you know? – This is a sample list… Why is the number of programming languages so large? – Evolution – Special Purpose – Personal Preference The Number of Programming Languages

Abstraction In Programming Languages int sum(int[] x) { int sum = 0; int sum = 0; n = 0; n = 0; while (n < x.length) { while (n < x.length) { sum += x[n]; sum += x[n]; } return sum; return sum;}

Abstraction In Programming Languages Data Abstraction – Abstracts properties of data Control Abstraction – Abstracts properties of the transfer of control Abstractions fall into 3 levels – Basic – Structured – Unit

Data Abstraction: Basic Abstracts the internal representation of common data values in a computer Locations in computer memory that contain data values are abstracted by giving them names and are called variables. Pascal – var x : integer; C – int x;

Data Abstraction: Structured Abstracting collections of data values that are related – Employee record may contain name, company, salary etc. Each diff type – Group of items having same type In C – int a[10]; In Fortran – INTEGER a(10)

Data Abstraction: Unit Collecting related code into specific locations within a program, either as separate files or as separate language structures Include access conventions and restrictions – Referred to as data encapsulation and information hiding. – Modules in ML and Haskell – Packages in JAVA Unit data abstractions become the basis for language library mechanism – reusability

Control Abstraction: Basic Typical basic control abstraction is the statements in a language that combine a few machine instructions into a more understandable abstract statement. – Assignment statement x = x + 3; Another basic control statement is the GOTO statement – Example from Fortran

Control Abstraction: Structured Divide a program into group of instructions that are nested in the code In C: In Haskell:

Control Abstraction: Structured Structured control – Procedure ADA example for GCD (finding greatest common divisor)

Control Abstraction: Unit It is similar to data unit abstraction. The only difference is here the focus is on the operations rather than the data But goals of the reusability and library building remain the same

Language Definition Language Definition can be loosely divided into two parts – SYNTAX (structure): grammar of a language An if-statement consists of the word “if” followed by an expression inside parentheses, followed by… – SEMANTICS (meaning) 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, ….

Syntax The description of language syntax is one of the areas where formal definitions have gained acceptance, and the syntax of almost all languages is now using context-free grammar Example context-free grammar

Quicksort in Java A programming language is a way of thinking Different people think in a different way

qsort [] = [] qsort (x:xs) = qsort lt_x ++ [x] ++ qsort ge_x where lt_x = [y | y <- xs, y < x] mid = [y | y <- xs, y = x] ++ [x] ge_x = [y | y x] Quicksort in Haskell

Semantics Much more complex than syntax. Meaning can be defined in many ways. No generally accepted method Several notational systems for formal definitions have been developed and are increasingly in use. – Operational Semantics – Denotational Semantics – Axiomatic semantics

Language Translation Translator – Interpreter – Compiler Interpretation is a one-step- process, in which both the program and the input are provided to the interpreter, and the output is obtained

Interpreter

Examples Some examples of interpreted programs are BASIC, QBASIC, and Visual Basic (version 5 of which has both a compiler and interpreter) The Practical Extraction and Reporting Language, or Perl, is a script-based programming language whose syntax parallels that of the C language but is an interpreted language; Perl can optionally be compiled prior to execution into either C code or cross-platform bytecode JavaScript is another example of an interpreted script-based programming language.

Compiler - 1 Compilation is two-step process Original program – source program is the input and new program – target program is output. Target program may then be executed. More commonly target language is assembly language Target program must be translated by an assembler into an object-program Then, linked with other object programs and then, loaded into appropriate memory locations before it can be executed

Compiler - 2

Linking Libraries of subroutines

From Source Code to Executable Code program gcd(input, output); var i, j: integer; begin read(i, j); while i <> j do if i > j then i := i – j; else j := j – i; writeln(i)end. program gcd(input, output); var i, j: integer; begin read(i, j); while i <> j do if i > j then i := i – j; else j := j – i; writeln(i)end. Compilation

Hybrid Implementation System JAVA uses both interpretation and compilation Source code is compiled into byte-code JVM (Java Virtual Machine) runs it as if it is an interpreter

1-33 Compiler vs. Interpretation Compilation – Translate high-level program to machine code – Slow translation – Fast execution Compiler vs. Interpretation – Compiler are better in terms of time efficiency – Interpreters are better in terms of memory usage – Interpreters are better in terms of exception handling