Topic 3 Computer Programs and Programming Language CSC

































- Slides: 33
Topic 3 : Computer Programs and Programming Language CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 1
Lesson Outcome • Overview of computer program and programming language • Programming Language Paradigms • • Imperative Paradigms Object oriented Paradigms Functional Paradigms Logic Paradigms • Programming Application Domains • • • Scientific Applications Artificial Intelligence Business Applications Systems Programming Web Software CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 2
Overview of computer program and programming language CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 3
Computer Program • A computer program is a set of instructions that the computer needs to follow to process the data into information. • They tell the computer: 1. What actions you want the computer to perform 2. The order those actions should happen in CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 4
Elements of Computer Program STORAGE INPUT • Whatever data that is inserted into a computer using input devices • E. g. Mouse, keyboard PROCESSING • Convert input data into information. • E. g. CPU • Store the data or information for future use (permanently or temporarily) • E. g. Hard disk, memory OUTPUT • Generate the useful information using output devices • E. g. Monitor, printer CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 5
Programming Language • A programming language is a system of signs used to communicate a task/algorithm to a computer, causing the task to be performed. • The task to be performed is call computation, which follows absolutely precise and unambiguous rules. • Contains set of instructions, data and rules that are used to construct a program. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 6
Programming Language Computation Machine Readability • Computation is any process that • For a language to be machinecan be carried out by a readable, it must have a simple computer. enough structure to allow for efficient translation. • Computation includes all kinds of computer operations, • Machine readability is ensured including data manipulation, by restricting the structure of a text processing & information programming language to storage & retrieval. context-free languages. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING Human Readability • It requires that a programming language provide abstractions of the actions of computers that are easy to understand, even by persons not completely familiar with the underlying details of the machine. • Programming languages tend to resemble natural languages. 7
Programming Language • Basically there are 3 levels of Programming Languages: 1. Machine Language ØConsists of individual instructions that will be executed by the CPU one at a time. ØUsing Binary code , since machines/ computer only know "on" and "off". 2. Low Level Language (Assembly Language ) ØDesigned for a specific family of processors (different processor groups/family has different Assembly Language). ØConsists of symbolic instructions directly related to machine language instructions one-for-one and are assembled into machine language. Ømachines/ computer only know "on" and "off". 3. High level Language ØFor example: C, C++, Java and VB ØDesigned to eliminate the technicalities of a particular computer. Statements compiled in a high level language typically generate many low-level CSC 116 - INTRODUCTION TO "on" COMPUTERS instructions machines/ computer only know and AND "off". PROGRAMMING 8
Machine Language • The representation of a computer program which is actually read and understood by the computer. • A program in machine code consists of a sequence of machine instructions. • Instructions: • Machine instructions are in binary code • Instructions specify operations and memory cells involved in the operation Example: Operation Address 0010 0000 0100 0000 0101 0011 0000 0110 CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 9
Assembly Language • A symbolic representation of the machine language of a specific processor. • Is converted to machine code by an assembler. • Usually, each line of assembly code produces one machine instruction (One-toone correspondence). • Programming in assembly language is slow and error-prone but is more efficient in terms of hardware performance. • Mnemonic representation of the instructions and data • Example: Load Add Store Price Tax Cost CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 10
High-level language • A programming language which use statements consisting of English-like keywords such as "FOR", "PRINT" or “IF“, . . . etc. • Each statement corresponds to several machine language instructions (one-tomany correspondence). • Much easier to program than in assembly language. • Data are referenced using descriptive names • Operations can be described using familiar symbols • Example: Cost : = Price + Tax CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 11
Programming Language Paradigms CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 12
Programming Paradigm • A model for a class of programming language that share a common characteristics and its differences CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 13
Common Programming Paradigms Imperative paradigm Ø The sequential execution of instructions Ø The use of variables representing memory locations Ø The use of assignment to change the values of variables Object-oriented paradigm Ø Allow programmers to write reusable code that operates in a way that mimics the behavior of objects in the real world. The functional paradigm Ø Based on the abstract notion of a function as studied in the lambda calculus. The logic paradigm Ø Based on symbolic logic. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 14
Imperative Paradigm • Describe how the computer should achieve solution • Example of languages : C, Pascal, FORTRAN, ALGO 60 & COBOL • Key features: 1. 2. 3. 4. Stored memory Mutable variables Sequencing, selection & iteration Pointers CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 15
Imperative Paradigm Example • C language: Reference : Sebesta, 11 th Edition, 2015 CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 16
Object Oriented Paradigm • Based on imperative / procedural style with added data & code abstraction & encapsulation • A revolutionary concept that changed the rules in computer program development • OOP is organized around objects rather actions, data rather than logic • Example of languages: Smalltalk, C++ & Java • Key features: 1. Abstraction 2. Encapsulation 3. Inheritance 4. Polymorphism CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 17
Object Oriented Paradigm Example • Java : Reference : Sebesta, 11 th Edition, 2015 CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 18
Logic Paradigm A declarative and relational style of programming Example of language : Prolog Concept is based on {Horn clauses} Based on facts & rules known as {clauses} Clauses may contain {logic variables} which take any value necessary to make the fact or the left side of the rule match a goal • Key features: • • • 1. 2. 3. 4. 5. No mutable variables Statements are logical predicates or assertions Every statement can either be succeed or fails Few explicit control constructs Recursion CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 19
Logic Paradigm Example • Prolog: Reference : Sebesta, 11 th Edition, 2015 CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 20
Functional Paradigm • Based on the concept of functions in mathematics • Based on Lambda calculus • Programs written are compact, but run slowly and require a lot of memory • Examples of languages : Haskell, ML, LISP & Scheme • Key features: 1. No mutable variables 2. Everything is an expression 3. Everything is a function 4. No iteration 5. Recursive CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 21
Functional Paradigm Example • Scheme: Reference : Sebesta, 11 th Edition, 2015 CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 22
Programming Application Domains CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 23
Programming languages: Fortran Cobol C ML C++ Java Perl Simula Lisp CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 24
Programming languages: scientific computation Fortran business applications Cobol systems programming C C++ compiler construction ML Perl simulations Java web applications Simula user-interfaces Lisp symbolic computation CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 25
Programming Application Domains Language Scientific Application FORTRAN Business Application COBOL Artificial Intelligence LISP, Prolog System Programming PL/S, BLISS, Extended Algol, C Web Software Javascript, PHP Example application NASA, Biotech Banking Manufacturing, Robotic Operating System Internet application CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 26
Scientific Application • John Backus’s team at IBM developed FORTRAN (for FORmula TRANslator) in 1955 -1957. • While FORTRAN was designed for numerical computation, it included control structures, conditions and input/output. • FORTRAN’s popularity led to FORTRAN II in 1958, FORTRAN IV in 1962, leading to its standardization in 1966, with revised standards coming out in 1977 and 1990. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 27
Business Application • Commercial data processing was one of the earliest commercial applications of computers. • Grace Murray Hopper et. al. at Univac developed FLOWMATIC, an English-like language for business applications. • The U. S. Defense Dept. sponsored the effort to develop COBOL (Common Business-Oriented Language), which was standardized in 1960, revised in 1961 & 1962, re-standarized in 1968, 1974, and 1984. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 28
Artificial Intelligence • Artificial Intelligence deals with emulating human-style reasoning on a computer. • These applications usually involve symbolic computation, where most of the symbols are names and not numbers. • The most common data structure is the list, not the matrix or array as in scientific computing and not the record as in business computing • Artificial intelligence requires more flexibility than other programming domains. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 29
Artificial Intelligence Languages • The first AI language was IPL (International Processing Language, developed by the Rand Corporation. Its low-level design led to its limited use. • John Mc. Carthy of MIT developed LIST for the IBM 704 (which eventually led to Scheme and Common LISP). LISP is a recursion-oriented, list-processing language that facilitated game-playing programs. • Yngve of MIT developed COMIT, a string-processing language, which was followed by AT&T’s SNOBOL. • Prolog was developed by Colmerauer, Roussel and Kowalski based on predicate calculus and mathematical logic. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 30
Systems Programming • Assembly languages were used for a very long time operating systems programming because of its power and efficiency. • CPL, BCPL, C and C++ were later developed for this purpose. • Other languages for systems programming included PL/I, BLISS, and extended ALGOL. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 31
Web Software • Diverse collection of languages: • Markup (e. g. , HTML) – used for annotating a document in a manner that can be distinguished from the text. • Scripting (e. g. , PHP) - the language that enable the script to run these commands and typically include control structures such as if-then-else and while-do. • General-purpose (e. g. , Java) – can be used for a wide range of programming jobs. CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 32
END CSC 116 - INTRODUCTION TO COMPUTERS AND PROGRAMMING 33