Chapter 1 Introduction

Posted in: Chapter I Introduction by tommyphen on December 16, 2016

A.Reasons for Studying Concepts of Programming Languages

➢ Increased ability to express ideas.

  • It is believed that the depth at which we think is influenced by the expressive power of the language in which we communicate our thoughts. It is difficult for people to conceptualize structures they can’t describe, verbally or in writing.
  • Language in which they develop software places limits on the kinds of control structures, data structures, and abstractions they can use.

➢ Improved background for choosing appropriate languages.

  • Many programmers, when given a choice of languages for a new project, continue to use the language with which they are most familiar, even if it is poorly suited to new projects.
  • If these programmers were familiar with other languages available, they would be in a better position to make informed language choices.

➢ Greater ability to learn new languages.

  • Programming languages are still in a state of continuous evolution, which means continuous learning is essential.
  • Programmers who understand the concept of OO programming will have easier time learning Java.
  • Once a thorough understanding of the fundamental concepts of languages is acquired, it becomes easier to see how concepts are incorporated into the design of the language being learned.

➢ Understand significance of implementation.

  • Understanding of implementation issues leads to an understanding of why languages are designed the way they are.
  • This in turn leads to the ability to use a language more intelligently, as it was designed to be used.

➢ Ability to design new languages.

  • The more languages you gain knowledge of, the better understanding of programming languages concepts you understand.

➢ Overall advancement of computing.

  • Many believe that ALGOL 60 was a better language than Fortran; however, Fortran was most widely used. It is attributed to the fact that the programmers and managers didn’t understand the conceptual design of ALGOL 60.

B. Programming Domains

  • Scientific applications
    • In the early 40s computers were invented for scientific applications.
    • The applications require large number of floating point computations.
    • Fortran was the first language developed scientific applications.
    • ALGOL 60 was intended for the same use.

 

  • Business applications
    • The first successful language for business was COBOL.
    • Produce reports, use decimal arithmetic numbers and characters.
    • The arrival of PCs started new ways for businesses to use computers.
    • Spreadsheets and database systems were developed for business.

 

  • Artificial intelligence
    • Symbolic rather than numeric computations are manipulated.
    • Symbolic computation is more suitably done with linked lists than arrays.
    • LISP was the first widely used AI programming language.

 

  • Systems programming
    • The operation system and all the programming supports tools are collectively known as its system software.
    • Need efficiency because of continuous use.

 

  • Scripting languages
    • Put a list of commands, called a script, in a file to be executed.
    • PHP is a scripting language used on Web server systems. Its code is embedded in HTML documents.  The code is interpreted on the server before the document is sent to a requesting browser.

C. Language Evaluation Criteria

  • Readability
    • Language constructs were designed more from the point of view of the computer than the users.
    • Because ease of maintenance is determined in large part by the readability of programs, readability became an important measure of the quality of programs and programming languages. The result is a crossover from focus on machine orientation to focus on human orientation.
    • The most important criteria “ease of use”
    • Orthogonality
      • Makes the language easy to learn and read.
      • Meaning is context independent. Pointers should be able to point to any type of variable or data structure.  The lack of orthogonality leads to exceptions to the rules of the language.
      • A relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language.
      • Every possible combination is legal and meaningful.
      • The more orthogonal the design of a language, the fewer exceptions the language rules require.
      • The most orthogonal programming language is ALGOL 68. Every language construct has a type, and there are no restrictions on those types.
      • This form of orthogonality leads to unnecessary complexity.

 

  • Writability
    • It is a measure of how easily a language can be used to create programs for a chosen problem domain.
    • Most of the language characteristics that affect readability also affect writability.
  • Simplicity and orthogonality
    • A smaller number of primitive constructs and a consistent set of rules for combining them is much better than simply having a large number of primitives.
  • Support for 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.
    • A process abstraction is the use of a subprogram to implement a sort algorithm that is required several times in a program instead of replicating it in all places where it is needed.
  • Expressivity
    • It means that a language has relatively convenient, rather than cumbersome, ways of specifying computations.
  • Reliability
    • A program is said to be reliable if it performs to its specifications under all conditions.
  • Type checking: is simply testing for type errors in a given program, either by the compiler or during program execution.
    • The earlier errors are detected, the less expensive it is to make the required repairs. Java requires type checking of nearly all variables and expressions at compile time.
  • Exception handling: the ability to intercept run-time errors, take corrective measures, and then continue is a great aid to reliability.
  • Aliasing: it is having two or more distinct referencing methods, or names, for the same memory cell.
    • It is now widely accepted that aliasing is a dangerous feature in a language.
  • Readability and writability: Both readability and writability influence reliability.
  • Cost
  • Categories
    • Training programmers to use language
    • Writing programs “Writability”
    • Compiling programs
    • Executing programs
    • Language implementation system “Free compilers is the key, success of Java”
    • Maintaining programs: Maintenance costs can be as high as two to four times as much as development costs.
    • Portability “standardization of the language”
    • Generality (the applicability to a wide range of application

 D.Influences on Language Design

Computer architecture: Von Neumann

  • We use imperative languages, at least in part, because we use von Neumann machines
    • Data and programs stored in same memory
    • Memory is separate from CPU
    • Instructions and data are piped from memory to CPU
    • Results of operations in the CPU must be moved back to memory
    • Basis for imperative languages
      • Variables model memory cells
      • Assignment statements model piping ✓Iteration is efficient

pic 1

  • Program Design Methodologies
    • New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages
  • Programming methodologies
    • 1950s and early 1960s: Simple applications; worry about machine efficiency
    • Late 1960s: People efficiency became important; readability, better control structures
      • Structured programming
      • Top-down design and step-wise refinement
    • Late 1970s: Process-oriented to data-oriented
      • data abstraction
    • Middle 1980s: Object-oriented programming
      • Data abstraction + inheritance + polymorphism

 

E. Language Categories

  • Imperative
    • Central features are variables, assignment statements, and iteration
    • C, Pascal
  • Functional
    • Main means of making computations is by applying functions to given parameters
    • LISP, Scheme
  • Logic
    • Rule-based
    • Rules are specified in no special order
    • Prolog
  • Object-oriented
    • Encapsulate data objects with processing
    • Inheritance and dynamic type binding
    • Grew out of imperative languages
    • C++, Java

 

F. Implementation Methods

  • Compilation
    • Programs are translated into machine language; includes JIT systems
    • Use: Large commercial applications
  • Pure Interpretation
    • Programs are interpreted by another program known as an interpreter
    • Use: Small programs or when efficiency is not an issue

➢Hybrid Implementation Systems

  • A compromise between compilers and pure interpreters
  • Use: Small and medium systems when efficiency is not the first concern

 

Layered View of Computer

pic 2

Compilation

  • Translate high-level program (source language) into machine code (machine language)
  • Slow translation, fast execution
  • Compilation process has several phases:
    • lexical analysis: converts characters in the source program into lexical units
    • syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program
    • Semantics analysis: generate intermediate code
    • code generation: machine code is generated

 

 

The Compilation Process

pic 3

➢Pure Interpretation

  • No translation
  • Easier implementation of programs (run-time errors can easily and immediately be displayed)
  • Slower execution (10 to 100 times slower than compiled programs)
  • Often requires more space
  • Now rare for traditional high-level languages
  • Significant comeback with some Web scripting languages (e.g., JavaScript, PHP)

 

Pure Interpretation Process

pic 4

➢Hybrid Implementation Systems

  • A compromise between compilers and pure interpreters
  • A high-level language program is translated to an intermediate language that allows easy interpretation
  • Faster than pure interpretation
  • Examples
    • Perl programs are partially compiled to detect errors before interpretation
    • Initial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has a byte code interpreter and a run-time system (together, these are called Java Virtual Machine)

Hybrid Implementation Process

pic 5

 

Tags: