The document provides an overview of an introductory programming course titled "Principles of Programming CP 111". The summary is: The course covers basic programming concepts like data types, program structure, algorithms, and decision and loop structures. It includes 3 tests, 3 quizzes, 9 lectures, and tutorials. Students will learn about programming languages, their history and uses in different domains like science, business and AI. The course also discusses compilation, interpretation, and different programming paradigms.
Principles of Programming (CP 111) includes course outline, activities like reading, tests, quizzes, tutorials, lectures, and university examination.
Overview of programming languages; defines programming languages as systems for communication with machines and expressing computation.
Explains six primary reasons to study programming languages: idea expression, language selection, learning new languages, implementation understanding, better language usage, and new language design.
Describes various application domains for programming such as scientific applications, business applications, AI, system programming, and web software.
Discusses methods of implementing programming languages: Compiler, pure interpretation, and hybrid systems; outlines stages of compilation.
Identifies levels of programming languages and categorizes them into five generations with specific characteristics.
Outlines four programming categories: Imperative, Object-Oriented, Logic/Declarative, and Functional programming with examples.
Identifies types of special programming languages such as scripting, command, and text processing languages.
Examines key characteristics determining a good programming language: readability, writability, reliability, including error handling and type checking.
Discusses various costs associated with programming languages including training, development, execution, and maintenance costs.
Defines the programming environment as the set of tools for program creation, testing, and design.
Final slide inviting questions, signaling end of the presentation.
COURSE OUTLINE ● Anoverview of programming languages ● Basic Concepts ● Names, Bindings, and Scopes ● Data Types ● Expressions and Assignment Statements ● Basic Program Structure and the Integrated Development Environment ● Algorithm Development Using Pseudocode ● Decision structures ● Loop Structures
What is programminglanguage ● A programming language is a set of rules that provides a way of telling a computer what operations to perform. ● A programming language is a notational system for describing computation in a machine-readable and human-readable form. ● A programming language also has words, symbols and rules of grammar.
6.
What is programminglanguage ● Tool for instructing machine ● Means for communicating between programmers ● Vehicle for expressing high level design ● It acts as a tool for experiment ● Controlling computerized devices
7.
Why study programminglanguage ? There are various reason regarding the study of programming languages but following are six main reasons
8.
Why study programminglanguage 1. Increased capacity to express ideas. ● The depth at which people can think is heavily influenced by the expressive power of their language. ● Example use of drawings have helped people express themselves.
9.
Why study programminglanguage 2. Improved background for choosing appropriate languages. ● Many professional programmers have a limited formal education in computer science, limited to a small number of programming languages. ● They are more likely to use languages with which they are most comfortable than the most suitable one for a particular job. ● If these programmers were familiar with a wider range of languages and language constructs, they would be better able to choose the language with the features that best address the problem.
10.
Why study programminglanguage 3. Increased ability to learn new languages. ● Computer science is considered as a ever growing discipline especially most software technologies ● programming languages are not yet mature. Therefore, they are still evolving. ● The understanding of programming language design and implementation makes it easier to learn new languages.
11.
Why study programminglanguage 4. Better understanding of the significance of implementation.. ● It is often necessary to learn about language implementation; it can lead to a better understanding of why the language was designed the way that it was. ● Fixing some bugs requires an understanding of implementation issues.
12.
Why study programminglanguage 5. Better use of languages that are already known. ● Some languages are better for some jobs than others. (i) FORTRAN and APL for calculations, COBOL and RPG for report generation, LISP and PROLOG for AI, etc. ● By understanding how features are implemented, you can make more efficient use of them.
13.
Why study programminglanguage 6. To make it easier to design a new language ● Designing a new language require prior knowledge of previous one to make it effective, efficient and convenient to users. ● The previous knowledge as well as concepts are usual to design a new language irrespective of their work domains.
14.
Programming Domains ● Computershave been applied to different areas, from controlling nuclear power plants to providing video games in mobile phones. ● great diversity in computer use, programming languages with very different goals have been developed.
15.
Programming Domains ● ScientificApplication (1940s and early 1950) ● Business Application (1950) ● Artificial Intelligence (1959) ● System Programming (1960s and 1970s) ● Web Software
16.
Compilation ● A programscan be translated into machine language, which can be executed directly on the computer ● Programming languages can be implemented by three general methods. ○ Compiler implementation ○ Pure interpretation ○ Hybrid Implementation Systems
18.
Compiler Interpretation ● Veryfast program execution, once the translation process is complete ● The language that a compiler translates is called the source language ● The process of compilation and program execution takes place in 4 phases. ○ Lexical Analyzer ○ Syntax Analyzer ○ Intermediate code generator / semantic analyzer ○ Code Generator
19.
Compiler interpretation phases 1.Lexical Analyzer ● Gathers the characters of the source program into lexical units. ● The lexical units of a program are identifiers, special words, operators, and punctuation symbols. 2. Syntax Analyzer ● Takes the lexical units from the lexical analyzer and uses them to construct hierarchical structures called parse trees.
20.
Compiler interpretation phases 3.Intermediate code generator & semantic analyzer ● produces a program in a different language, at an intermediate level between the source program and the final output of the compiler: the machine language program. ● The semantic analyzer checks for errors, such as type errors, that are difficult, if not impossible, to detect during syntax analysis. 4. Code Generator ● translates the optimized intermediate code version of the program into an equivalent machine language program.
Pure Interpretation ● Aprograms is interpreted by another program called an interpreter, with no translation ● It allows easy implementation of many source-level debugging operations, because all run-time error messages can refer to source-level units.
23.
Hybrid implementation system ●It translate high-level language programs to an intermediate language designed to allow easy interpretation. ● This method is faster than pure interpretation because the source language statements are decoded only once. ● Instead of translating intermediate language code to machine code, it simply interprets the intermediate code
Preprocessors ● is aprogram that processes a program immediately before the program is compiled. ● Preprocessor instructions are embedded in programs. ● Preprocessor instructions are commonly used to specify that the code from another file is to be included.
Types of ProgrammingLanguage ● First Generation Languages ● Second Generation Languages ● Third Generation Languages ● Fourth Generation Languages ● Fifth Generation Languages
28.
Reading assignment ! Ineach programming language generation,write its characteristics, limitations and at least three examples of programming language in that generation.
30.
Language Categories Programming languagesare often categorized into four bins: ● Imperative Programming (C) ● Object-Oriented Programming (C++) ● Logic/Declarative Programming (Prolog) ● Functional/Applicative Programming (Lisp)
31.
Imperative Programming Imperative languagesare command-driven or statement-oriented languages. The basic concept is the machine state (the set of all values for all memory locations). A program consists if a sequence of statements and the execution of each statement changes the machine state. Programs take the form: Statement1; statement2;
32.
Object-Oriented Programming It isbased on classes of objects. An object has variable components and is equipped with certain operations. Only these operations can access the object’s variable components. A class is a family of objects with similar variable components and operations. Eg C++, Java
33.
Logic/Declarative Programming It isbased on a subset of predicate logic. Programs in logic programming languages are collections of facts and rules. Sometimes called a Rule-based or declarative languages It execute checking to see if a particular condition is true and if so, perform the appropriate actions. Example condition1 -> action 1 condition2 -> action 2 PROLOG was the ancestral logic language, and is still the most popular.
34.
Functional/Applicative Programming An functionalprogramming language looks at the function that the program represents rather than the state changes as each statement is executed. The key question is: What function must be applied to our initial machine and our data to produce the final result? The ancestral functional language was LISP, ML and HASKELL are modern functional languages. it does support variables and assignment. Statements take the form: function n(function1, function2, … (data)) … )
35.
Special Programming Languages ScriptingLanguages ◦ JavaScript and VBScript ◦ Php and ASP ◦ Perl and Python Command Languages ◦ sh, csh, bash Text processing Languages ◦ LaTex, PostScript
Readability The quality ofa language that enables a programmer to understand and comprehend the nature of a computation easily and accurately. Simplicity: ● Multiplicity features - that is, having more than one way to accomplish a particular operation. (count = count + 1, count += 1, count++, ++count) ● Operator overloading- a single operator symbol has more than one meaning. Orthogonality: The quality of a language that features provided have as few restrictions as possible and be combinable in any meaningful way
38.
Readability Data Types: The presenceof adequate facilities for defining data types and data structures in a language is another significant aid to readability. Eg timeOut = 1 does not make sense as timeOut = true for a boolean case. Syntax Design: Special words. If and endif, loop and endloop
39.
Writability A measure ofhow easily a language can be used to create programs for a chosen problem domain. Simplicity: If a language has a large number of different constructs, some programmers might not be familiar with all of them Orthogonality: A smaller number of primitive constructs and a consistent set of rules for combining them (that is, orthogonality) is much better than simply having a large number of primitives.
40.
Writability Support for Abstraction:the ability to define and then use complicated structures or operations in ways that allow many of the details to be ignored. Expressivity: it means that there are very powerful operators that allow a great deal of computation to be accomplished eg. Loops (for and while), increments (count++ easier than Count= Count + 1)
41.
Reliability A program issaid to be reliable if it performs to its specifications under all conditions Type Checking: Simply testing for type errors in a given program, either by the compiler or during program execution. ● run-time type checking is expensive, compile-time type checking is more desirable. ● failure to type check, at either compile time or run time, has led to countless program errors eg C in variable mis-match.
42.
Reliability Exception Handling: Theability of a program to intercept run-time errors (as well as other unusual conditions detectable by the program), take corrective measures, and then continue is an obvious aid to reliability Eg. C++, Java, Ada, C# but practically nonexistent in many widely used languages, including C and Fortran. Aliasing: having two or more distinct names that can be used to access the same memory cell. Eg two pointer pointing to one cell.
43.
Reliability Readability and Writability: ●Programs that are difficult to read are difficult both to write and to modify. ● The easier a program is to write, the more likely it is to be correct.
44.
Cost ● The costof training programmers to use the language (simplicity and orthogonality) ● The cost of writing programs in the language (writability) ● The cost of compiling programs ● The cost of executing programs (run time type checking prohibits fast code execution) ● The cost of the language implementation system A language whose implementation system is either expensive or runs only on expensive hardware will have a much smaller chance of becoming widely used. ● The cost of maintaining programs
Programming Environment ● Itrefers to the environment in which programs are created, designed and tested. ● It consist of a set of support tools and command language for invoking them.