Chapter 1

Preliminaries

 

REASONS FOR STUDYING PROGRAMMING LANGUAGES

·         Increased capacity to express ideas

-      New language constructs increases the programmers range of software development

                 -      Builds an appreciation for language features and encourages there use

                  -     Allows integration of significant language features from multiple languages

·         Improved background for choosing appropriate languages

                   -    Some languages are more relevant to specific tasks

·         Increased ability to learn new languages

-     Learning fundamentals increases insight into incorporating the concepts of the design of the language being learned

·         Better understanding of the significance of implementation

                   -    Use of language is more intelligent

       -    Knowledge of program bugs allows the programmer to avoid and correct them easier

·         Increased ability to design new languages

-          Overall advancement of computing

                  -     Explains why a particular language became more popular than others

                   -    Those choosing languages may make better decisions if they are better informed

 

PROGRAMMING DOMAINS

·         Different computer applications require different programming languages with very different goals

·         These domains consist of scientific applications, business applications, artificial intelligence, systems programming, scripting languages, and special-purpose languages

·         Scientific applications

-          Have simple data structures like arrays and matrices

-          Have control structures such as counting loops and selections

-          Require large numbers of floating point arithmetic computations

-          Some languages designed for this were FORTRAN, ALGOL 60, and most of ALGOL’s descendants

·         Business Applications

-          Need production of elaborate reports

-          Precise ways describing and storing decimal numbers and character data

-          Have ability to specify decimal arithmetic operations

-          Some languages designed for this were COBOL and SAS

·         Artificial Intelligence

-          Use of linked lists is preferred over arrays

-          Requires more flexibility

-          A language designed specifically for this is LISP

·         Systems Programming

-          Must have execution efficiency

-          Must have low-level features that allow software interfaces to external devices to be written

-          Some languages designed for this were PL/1, BLISS, and C (for UNIX)

·         Scripting Languages

-          Used by putting lists of commands in a file to be executed

-          Generally used for performing utility functions, such as file management and file filtering

-          Add to this variables, control flow statements, functions, and other capabilities and it results in a scripting language like ksh, awk, PERL, and CGI

·         Special-Purpose Languages

-          These are languages created for one special-purpose for which no other languages could probably do as efficiently

-          RPG: used to produce business reports

-          APT: used for instructing programmable machine tools

-          GPSS: used for systems simulation

 

LANGUAGE EVALUATION CRITERIA

·         Readability is the ease of which programs can be read and understood and can be directly related to:

-          The overall simplicity, which can be determined by number of basic components and whether it has one or more ways to accomplish a particular operation   

-          The orthogonality, which is the degree to which a set of primitive constructs can be combined to build the control and data structures of the language

-          The number of control statements in a language

-          The number of data types and structures

-          The syntax or form of the elements of a language.  Three types of syntax affect readability: identifier forms, special words, and form and meaning

·         Writability is a measure of how easily a language can be used to create programs for a chosen problem domain and can be directly related to:

-          Simplicity and orthogonality (defined in readability)

-          Support for abstraction, which is the ability to define and use complicated structures or operations in a way that allows many details to be ignored

-          Expressivity, which is when a language has a convenient way of specifying computations

·         Reliability is when a language performs to its specifications under all conditions and is directly related to:

-          Type checking, which is simply testing for type errors in a program either by the compiler or run-time

-          Exception handling, which is the ability of a program to intercept run-time errors, take corrective action, and then continue on

-          Aliasing, which is having two or more distinct referencing methods or names for the same memory location

-          Readability and Writability

 

INFLUENCES ON LANGUAGE DESIGN

·         Other factors may also influence the design of a programming language

·         Computer architecture

·         Programming methodologies

 

LANGUAGE CATEGORIES

·         Imperative – based on the von Neumann architecture

·         Functional – based on mathematical functions

·         Logic – rule based

·         Object oriented – object based

 

LANGUAGE DESIGN TRADE-OFFS

·         Some of the criteria used to rate languages are themselves conflicting; the increase of one generally means that the other is degenerate, some of these conflicts are as follows

·         Reliability vs. Cost of Execution – if the program is reliable it probably executes slowly and vice versa

·         Readability vs. Writability – if the program is readable it is probably not as writable and vice versa

·         Flexibility vs. Safety – if the program is flexible it is probably not as safe and vice versa

 

IMPLEMENTATION METHODS

·         There are three methods for which languages can be implemented, which are compiler implementations, pure interpretation, and hybrid implementation systems.

·         Compilation, is when programs are translated to machine language, which can then be executed directly to the computer

·         Compilation takes place in several phases:

-          The lexical analyzer, which eliminates comments from the code and separates the program into lexical units

-          The syntax analyzer, which takes the lexical units and uses them to form parse trees

-          The intermediate code generator produces the code in a different language that is somewhere between the source code and the machine language of the computer

-          Optimization, improves the programs by making them smaller (optional)

-          The code generator then translates the optimized code into the machine language code (this step is skipped if optimization doesn’t occur and machine language is generated upon the first pass to the code generator instead)

·         Pure interpretation, is when another program, called the interpreter, interprets the program with no translation

·         Hybrid implementation systems are a comprise somewhere between the compilers and the interpreters, they translate the source code to an intermediate language, which is easier to interpret

 

PROGRAMMING ENVIRONMENTS

·          A collection of tools used in the development of software

·         The minimum collection may consist of a file system, text editor, a linker, and a compiler.  It may also include many more tolls depending on the maker of the environment, but usually does not consist of less