280 likes | 749 Views
Programming Languages. Introduction. Asst. Prof. Dr. Ahmet Sayar Spring-2013 Kocaeli University Computer Engineering Department. Goal of This Course. Introducing major principles and concepts underlying all programming languages without concentrating on one particular language.
E N D
Programming Languages Introduction Asst. Prof. Dr. AhmetSayar Spring-2013 Kocaeli University Computer Engineering Department
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
Programming Language Programming Languages • What is a 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: Von Neumann model • Instead of hard-wired jobs • A series of codes stored as data would determine the actions taken by a central processing unit. • An area of memory where both programs and data are stored and a separate central processing unit that sequentially executes instructions fetched from memory • And assembly language was born.
What is a Programming Language • Assembly language are machine dependent. Low-level languages. Hard to read and write • Low-level and High-level languages? • Abstractions • X = 2 or below two lines • LDA #2 • STA X • 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 • Addition of two numbers • Data manipulation, text processing, information storage retrieval • Special purpose languages • Graphics, reports, database • General purpose languages • C, JAVA
Computation – Turing machine • Computation is defined formally using the mathematical concept of a Turing machine, • Turing machines are known to be able to carry out any computation that current computers are capable of (through certainly not efficiently). • The "Turing" machine was invented in 1936 by Alan Turing • who called it an "a-machine" (automatic machine). • Turing machine is a conceptual tool not a practical computation technology • Turing machines help computer scientists understand the limits of mechanical computation
The Number of Programming Languages • How many programming languages do you know? • This is a sample list… • http://dmoz.org/Computers/Programming/Languages • Why is the number of programming languages so large? • Evolution • Special Purpose • Personal Preference
int sum(int[] x) { int sum = 0; n = 0; while (n < x.length) { sum += x[n]; } return sum; } 00101010101010 10101011111010 11101010101110 00101010101010 ... Abstraction In Programming Languages
Abstraction In Programming Languages • Increases the human readability of programs • Data Abstraction • Abstracts properties of data, such as numbers search trees • Control Abstraction • Abstracts properties of the transfer of control • Ex. Loops, conditional statements and procedure calls • Abstractions also fall into 3 levels • Basic : Localized machine information • Structured: Global information about the structure of the program • Unit: Information about entire pieces of a program
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 different 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 • One advantage of structured control structures is that they can be nested within other control structures. • If else if else if • Structured looping come in many forms • While for do loops in C and C++ • Repeat loops in Pascal • Loop statement in Ada • Procedures: Another structured control mechanism • Name and action to be performed – process declaration – or function
Control Abstraction: Unit • Collection of procedures providing logically related services • Ex. Data management program • Mean, median, and standard deviation • 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
Summary of Abstractions • Almost all abstractions mechanisms are provided for human readability