1 / 79

CIS 317 Concepts of Programming languages Ismail Hmeidi hmeidi@just.jo Chapter 1

CIS 317 Concepts of Programming languages Ismail Hmeidi hmeidi@just.edu.jo Chapter 1. Reasons to study concepts of PLs. List of potential benefits of studying language concepts :- 1. Increased capacity to express programming concepts 2. Improved background for choosing

cvilla
Télécharger la présentation

CIS 317 Concepts of Programming languages Ismail Hmeidi hmeidi@just.jo Chapter 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 317Concepts of Programming languagesIsmail Hmeidihmeidi@just.edu.joChapter 1

  2. Reasons to study concepts of PLs List of potential benefits of studying language concepts :- 1. Increased capacity to express programming concepts 2. Improved background for choosing appropriate languages 3. Increased ability to learn new languages 4. Understanding the significance of implementation 5. Increased ability to design new languages 6. Overall advancement of computing

  3. The most popular language is not necessary the best one

  4. FORTRAN AND ALGOL60. • ALGOL60 failed although it is better than FORTRAN. • ALGOL60 description is difficult. Block structure, has recursion, and well-structured control statements

  5. Programming Domains In this section, we briefly discuss a few of the areas of computer applications and their associated Languages : 1. Scientific applications 2. Business applications 3. Artificial intelligence 4. Systems programming 5. Scripting languages 6. Special purpose languages

  6. Scientific applications needs • data structure ( arrays, matrices,…) and • control structures( counting loops, selection,…..)

  7. Business applications • COBOL : • appeared 60’s • standardized in 85 • Spreadsheet • DB

  8. Artificial Intelligence (AI) Use of symbolic rather than numeric computations - LISP : appeared in 59 - Prolog - Scheme : ( a dialect of LISP ).

  9. Artificial Intelligence • Use symbolic rather than numeric computation. • Symbolic computation means that symbols, consisting of names rather than numbers, are manipulated

  10. System Programming • The (OS) and all of the programming support tools of a computer System are collectively known as its system software • Unix OS is written in C. • Some consider it flexible. • Some consider it dangerous.

  11. Scripting languages • A scripting language is used by putting a list of commands, called a script, in a file to be executed • The first language was: sh (For shell) • sh began as a small collection of commands that were interpreted as calls to system subprograms that performed utility functions

  12. Scripting languages • ksh : one of the most powerful and widely known of these is ksh (bolsky and korn,1995),which was developed by david korn at bell laboratories • awk : report generator then more general purpose language • Tcl : is an extensible scripting language developed by Johan ousterhout at the university of California at berkeley now is combined with (tk) a language that provides a method of building X Windows applications • Perl: was a combination of sh and awk.

  13. Scripting languages • Perl is popular because it is ideal language for Common Gateway interface (CGI). • Scripting languages contributed a little to the development of programming languages

  14. Special-Purpose Languages • A host of special-purpose languages have appeared over the past 40 years. • RPG : Report Generation • APT : Used for instructing programmable machine tools • GPSS: • Simulation

  15. Language Evaluation Criteria The purpose of this book is to examine carefully the underlying concepts of the various constructs and capabilities of programming languages . • we will also evaluate these features , focusing on their impact on development (Including maintenance) process. 1. Readability : one of the most important criteria for judging language is the ease with which programs can be read and Understood - The most important criterium - Factors: characteristics that contribute to the readability of a programming language

  16. Language Evaluation Criteria - Overall simplicity - Too many features is bad - Multiplicity of features is bad Ex. In C m a user can increment a simple integer variable in four different ways: 1. count = count +1 2. count++ 3. count += 1 4. ++count - Orthogonality - Makes the language easy to learn and read - Meaning is context independent - Control statements : use of goto statements severely reduces program readability - Data type and structures - Syntax considerations

  17. Language Evaluation Criteria 2. Writability - Factors: - Simplicity and orthogonality - Support for abstraction - Expressivity 3. Reliability - Factors: - Type checking - Exception handling - Aliasing - Readability and writability

  18. Evaluation criteria (continued) 4. Cost - Categories - Programmer training - Software creation - Compilation - Execution - Compiler cost - Poor reliability - Maintenance 5. Others: portability, generality, well-definedness

  19. Orthogonality • Orthogonality in a programming language means that a relative small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the languages. • Every possible combination of primitives is legal and meaningful. Ex. Consider data types , suppose a language has four primitive data types , integer , float , double , and character , and two type operators , array and pointer. if the two type operators can be applied to themselves and the four primitive data types , a large number of data structure can be defined , however , if pointers were not allowed to point to arrays , many of these possibilities would be eliminated • The lack of orthogonality leads to exception to the rules of the language

  20. An Example As an example, the add instruction on IBM and VAX machine. Assembly languages IBM A reg1, memory_cell AR Reg1, Reg2; VAX ADDL operand_1, Operand2

  21. Give an example of lack of orthogonality in high-level languages ? • - In C, arrays and records ( struct ). The records can be returned from functions, but arrays can not. • - An array element can be any data type • except void.

  22. Lack or orthogonality or too much orthogonality can cause problems.

  23. The most orthogonal Programming language was Algol68. • For example, every language construct has a type, and there are no restriction on those types.

  24. Simplicity • Simplicity in a language ,therefore, is at least in part the result of a combination of relatively small number of primitive constructs and a limited use of the concepts of orthogonality • Some believe that functional languages offer a good combination of simplicity and orthogonality . A functional language ,such as lisp , is one in which computations are needed primarily by applying functions to given parameters. • In contrast , in imperative languages such as C , C++ , and Java , Computations are usually specified with variables and assignment statements • Functional languages offer potentially the greatest overall simplicity because thy can accomplish everything with a single construct , the function call , witch can be combined with other function calls in simple ways .

  25. Control Statements • use of goto reduce the program readability • In FORTRAN 77, goto is necessary for while loop • Some restrictions on goto a- They must precede their target. b- Their targets must never be too distinct c- Their numbers must be limited.

  26. BASIC and FORTRAN in early 19770s laced the control statements that allow strong restrictions on the use of goto

  27. Data types and structures • The presence of adequate facilities for defining data types and data structures in a language in another significant aid to readability. • Which is more clear ?? flag = 1; // in language where there is no boolean or • flag = true; // in language contain boolean

  28. Data types In FORTRAN 77 an array of employee records might be stored in the following: CHARACTER ( LEN = 30) NAME( 100) INTEGER AGE(100), EMPLOYEE_NO( 100) REAL SALARY ( 100) Here we have 4 arrays with the same subscript value. This is not good.

  29. Syntax Consideration • Restricting identifiers and special words form of a language, and designing statements so that their appearance indicates their purpose for more readable program • The syntax, or form of the elements of a language has a significant effect on the readability of programs. • Three things of syntax consideration. They are: a- identifier forms b- Special words c- Form and meaning

  30. Syntax Consideration A- identifier forms: restricting identifiers to very short lengths detracts (reduces) from readability. - The length of the variable. - In Fortran, it is 6 characters. - In original Basic. It is one letter followed by one or more digits.

  31. Syntax Consideration B- Special word : program appearance and thus program readability are strongly influenced by the forms of a language’s special words: (for example while, class ,and for statements) - C uses { and } . - Fortran 90 and Ada uses end if and end loop. • In Fortran 90, some special words such as DO and END are legal variable names (can be very confusing )

  32. Syntax Consideration C- Form and meaning : designing statements so that their appearance at least partially indicates their purpose is an obvious aid to readability - Semantics or meaning, should follow directly from syntax or form. - This is violated in some languages. For example, in C, the word static has two meaning ( variable that is created at compile time, or the variable is visible only in the file in which its definition appears).

  33. Syntax Consideration • Another example: Unix commands (Shell commands of Unix) • to copy we use cp • to view a list of the files in a directory we use ls

  34. 2 - Writability • Writability is a measure of how easily a language can be used to create programs for chosen problem domain. • Most of the languages charactaristcs that affect readability also affect writability • COBOL is not good for creating two- dimensional arrays while APL is the opposite.

  35. 2 - Writability • The factors that affect writability are : - Simplicity and orthogonality - Support of abstraction - Expressivity

  36. Support of Abstraction • Abstraction means the ability to define and then use complicated structures or operations in ways that allow many of the details to be ignored. • - PL can support two kinds of abstraction: process and data. • - An example of process abstraction is the subroutine.

  37. Support of Abstraction • An example of data abstraction is binary tree that stores integer data in its nodes. • In Fortran 77, you need to do a 3-Dimensional array to define a binary tree, while in C++ and JAVA, you declare a tree • node of two pointers and an integer.

  38. Expressivity • Expressivity in a language can refer to several different characters. • In a language like APL. It means that there are very powerful operators that allow a great deal of computation to be accomplished with a very small program. • APL  A programming language that was developed by IBM in 1960

  39. Expressivity • In C count ++ is easier than count = count + 1; • In Ada short circuit is good Also , the AND then Boolean operator in Ada is a convenient way of specifying short-circuit evaluation of a Boolean expression

  40. 3 - Reliability • A program is said to be reliable if it performs to its specifications under all conditions.

  41. 3 - Reliability • The following features have significant effect on reliability: a- Type checking b- Exception handling c- Aliasing d- Readability and Writability

  42. Type checking • Type checking is simply testing for type of errors in a given program. • run-time error type checking is expensive, thus compile-time error type checking is desirable.

  43. Type checking • This reduce the errors. • Ada requires checks of the types of nearly all variables and expressions at compile time, except when the user explicitly states that type checking is to be suspended.

  44. Type checking • In original C language, there is no checking for the formal parameter against the actual parameter. • Another example of type checking is checking the range of the subscripts of the array.

  45. Exception Handling • The ability of a program to intercept run-time errors, take corrective measures, and then continue. • C++, JAVA, and Ada have it. • C and FORTRAN dose not have it.

  46. Aliasing • Having two or more distinct referencing methods or names, for same memory cell. • - It is dangerous. • - In C: Union members and pointers set to point to the same variable in C.

  47. Readability and Writability • Both readability and Writability influence reliability. • The easier the program is to write, the more likely it is to be correct. • Readability affects reliability in both the writing and maintenance phases of the life cycle.

  48. 4 - Cost Cost : the ultimate total cost of a programming language is a function of many of its characteristics 1 - Training programmers. 2 - Writing programs 3 - Compiling programs 4 - Cost of execution programs written in a language is influenced by the language design ( many type checking prohibit fast execution).

  49. 4 - Cost 5 - language implementation system (like free compiler). 6 - The cost of poor reliability ( fail in critical system ). 7 – Maintenance : includes both corrections and modifications to add new capabilities the cost of software maintenance depends on a number of language characteristics but primarily readability . Because maintenance is often done by individuals other than the original author of the software ,poor readability can make the task extremely challenging . Maintenance costs can be as high as to four times as much as development cost

  50. Primary influences on language design 1. Computer architecture - We use imperative languages, at least in part, because we use von Neumann machines 2. Programming methodologies - Late 1950s and early 1960s: Simple applications; worry about machine efficiency - Late 1960s: People efficiency became important; readability, better control structures - Late 1970s: Data abstraction - Middle 1980s: Object-oriented programming

More Related