Chapter 1 l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 93

Chapter 1 PowerPoint PPT Presentation


Chapter 1. Preliminaries. Purpose of This Book. To examine carefully the underlying concepts of the various constructs and capabilities of programming languages. Chapter 1 Topics. Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria

Download Presentation

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Chapter 1 l.jpg

Chapter 1

Preliminaries


Purpose of this book l.jpg

Purpose of This Book

  • To examine carefully

    • the underlying concepts of the various constructs and capabilities of programming languages


Chapter 1 topics l.jpg

Chapter 1 Topics

  • Reasons for Studying Concepts of Programming Languages

  • Programming Domains

  • Language Evaluation Criteria

  • Influences on Language Design

  • Language Categories

  • Language Design Trade-Offs

  • Implementation Methods

  • Programming Environments


Reasons for studying concepts of programming languages 1 l.jpg

Reasons for Studying Concepts of Programming Languages (1)

  • Increased ability to express ideas

    • The depth at which people can think is influenced by the expressive power of the language in which they communicate their thoughts

    • The language in which programmers develop software places limits on the kinds of control structures, data structures, and abstraction they can use

    • Awareness of a wider variety of programming language features can reduce such limitations in software development

    • Languages constructs can be simulated in other languages that do not support those constructs directly; however, the simulation is often less elegant, more cumbersome, and less safe.


Reasons for studying concepts of programming languages 2 l.jpg

Reasons for Studying Concepts of Programming Languages (2)

  • Improved background for choosing appropriate languages

  • Increased ability to learn new languages

    • According to TIOBE, Java, C, and C++ were the three most popular languages in use in Jan. 2007.


Reasons for studying concepts of programming languages 3 l.jpg

Reasons for Studying Concepts of Programming Languages (3)

  • Better understanding of significance of implementation

    • Program bugs

    • Performance

  • Better use of languages that are already known

  • Overall advancement of computing

    • Those in positions to choose languages wer not sufficiently familiar with programming language concepts


Programming domains 1 l.jpg

Programming Domains (1)

  • Scientific applications

    • Large number of floating point computations

    • Simple data structures

    • Fortran

      • Originally developed by IBM in the 1950s

  • Business applications

    • Facilities for

      • producing elaborate reports,

      • Storing decimal numbers and character data

      • The ability to specify decimal arithmetic operations

    • COBOL

      • The initial version appeared in 1960

  • Artificial intelligence

    • Symbols, consisting of names rather than numbers, are manipulated

    • LISP

      • Appeared in 1959


Programming domains 2 l.jpg

Programming Domains (2)

  • Systems programming

    • The operating system and all of the programming support tools of a computer system are collectively known as its systems software.

      • Systems software is used almost continuously and so must be efficient.

    • A language for this domain must provide

      • fast execution

      • having low-level features that allow the software interfaces to external devices to be written

    • C

      • The UnixOS is written almost entirely inC


Programming domains 3 l.jpg

Programming Domains (3)

  • Web Software

    • Eclectic collection of languages: markup (e.g., XHTML), scripting (e.g., PHP), general-purpose (e.g., Java)


Language evaluation criteria l.jpg

Language Evaluation Criteria

  • Readability: the ease with which programs can be read and understood

  • Writability: the ease with which a language can be used to create programs

  • Reliability: conformance to specifications (i.e., performs to its specifications)

  • Cost: the ultimate total cost


Why readability is important l.jpg

Why Readability Is Important

  • Maintenance was recognized as a major part of the software life cycle, particularly in terms of cost.

  • Ease of maintenance is determined in large part by the readability of programs.


Characteristics contributing to the readability simplicity l.jpg

Characteristics Contributing to the Readability - Simplicity

  • Overall simplicity

    • A manageable set of features and constructs

      • Readability problems occur whenever the program’s author has learned a different subset from that subset with which the reader is familiar.

    • Few feature multiplicity (methods of doing the same operation)

      • For example, in Java the following ways could be used to increase a integer variable

        count = count + 1

        count += 1

        count++

        ++count

    • Minimal operator overloading (a single operator symbol has more than one meaning)

      • Overloading may simplify a language by reducing the number of operators; however, it can lead to reduced readability if users are allowed to create their own overloading and do not do it sensibly.


Excessive simplicity l.jpg

Excessive Simplicity

  • Simplicity improves readability; however, excessive simplicity may also reduce readability.

    • For example:

      • The form and meaning of most assembly language statements are models of simplicity.

      • This very simplicity, however, makes assembly language programs less readable. Because they lack more complex control statements, program structure is less obvious.


Characteristics contributing to the readability orthogonality l.jpg

Characteristics Contributing to the Readability - Orthogonality

  • Orthogonality

    • A relatively small set of primitive constructs can be combined in a relatively small number of ways

    • Every possible combination is legal and meaningful

    • e.g.

      • Suppose a language has four primitives 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 structures can be defined.


Influence of lacking orthogonality l.jpg

Influence of Lacking Orthogonality

  • The lack of orthogonality leads to exceptions to the rules of the language.

    • For example:

      • Pointers should be able to point to any type of variable or data structure.

      • If pointers were not allowed to point to arrays, many of those possibilities would be eliminated.


Orthogonality example l.jpg

Orthogonality Example

  • IBM

    A Reg1, memory_cell

    AR Reg1, Regs

    [corresponding Semantics]

    Reg1 <- contents(Reg1)+ contents(memory_cell)

    Reg1 <- contents(Reg1)+ contents(Reg2)

  • VAX( instruction design is ortogonal)

    ADDL operand_1, operand_2

    [corresponding Semantics]

    Operand_2 <- contents(operand_1)+contents(opernad_2)


Orthogonality vs simplicity l.jpg

Orthogonality vs. Simplicity

  • Orthogonality is closely related to simplicity

  • The more orthogonal the design of a language, the fewer exceptions the languages rules require.

  • Fewer exceptions mean a higher degree of regularity in the design, which makes the language easier to learn, read, and understand.


Is orthogonality always good l.jpg

Is Orthogonality Always Good?

  • Too much orthogonality can also cause problems, because they make a programming language too complicated.

  • Example:

    • ALGOL 68

      • Every language construct in ALGOL 68 has a type

      • There are no restrictions on those types

      • Most construct produce values


Characteristics contributing to the readability control statements l.jpg

Characteristics Contributing to the Readability – Control Statements

  • The presence of well-known control structures (e.g., while statement)

  • A program that can be read from top to bottom is much easier to understand than a program that requires the reader to jump from one statement to some nonadjacent statement in order to follow the execution order.


Characteristics contributing to the readability data types and structures l.jpg

Characteristics Contributing to the Readability - Data Types and Structures

  • The presence of adequate facilities for defining data structures

  • Example:

    • If a language doesn’t have a Boolean type, then it may need to use a numeric type as an indicator flag

      timeOut =1

    • Comparing with a language providing Boolean type, the following state is much more readable

      timeOut = true


Characteristics contributing to the readability syntax considerations 1 l.jpg

Characteristics Contributing to the Readability - Syntax Considerations (1)

  • Identifier forms: flexible composition

    • Restricting identifiers to very short lengths detracts form readability


Characteristics contributing to the readability syntax considerations 2 l.jpg

Characteristics Contributing to the Readability - Syntax Considerations (2)

  • Special words

    • Program appearance and thus program readability are strongly influenced by the forms of a language’s special words

    • Whether the special words of a language can be used as names for program variables?

  • methods of forming compound statements

    • C and its descendants use braces to specify compound statements.

    • All of these languages suffer because statements groups are always terminated in the same way, which makes it difficult to determine which group is being ended when and end or } appears.


Characteristics contributing to the readability syntax considerations 3 l.jpg

Characteristics Contributing to the Readability - Syntax Considerations (3)

  • Form and meaning: self-descriptive constructs, meaningful keywords


Evaluation criteria writability l.jpg

Evaluation Criteria: Writability

  • Writability 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 readibility also affect writability.

    • This follows directly from the fact that the process of writing a program requires the programmer frequently to reread the part of the program that is already written


Writability comparison between two different languages l.jpg

Writability Comparison between Two Different Languages

  • It is simply not reasonable to compare the writability of two languages in the realm of a particular application when one was designed for that application and the other was not.


Characteristics contributing to the writability simplicity and orthogonality l.jpg

Characteristics Contributing to the Writability -Simplicity and Orthogonality

  • Few constructs, a small number of primitives, a small set of rules for combining them

    • A large number of different constructs may lead to a misuse of some features and a disuse of others hat may be either more elegant of more efficient, or both, than those that are used

  • On the other hand, too much orthogonality can be a detriment to writability

    • Errors in programs can go undetected whennearly any combination of primitives is legal


Characteristics contributing to the writability support for abstraction l.jpg

Characteristics Contributing to the Writability - Support for Abstraction

  • Abstraction - the ability to define and usecomplex structures or operations in ways that allow details to be ignored

  • Programming languages can support two distinct categories of abstraction:

    • Process

    • Data


Process abstraction l.jpg

Process Abstraction

  • A simple example of process abstraction is the use of a subprogram to implement a sort of algorithm that is required several times in a program.


Data abstraction l.jpg

Data Abstraction

  • A binary tree

    • Fortran 77 – use parallel integer arrays to implement

    • C++ and Java – use a class with two pointers (or references) and an integer


Characteristics contributing to the writability expressivity l.jpg

Characteristics Contributing to the Writability - Expressivity

  • A set of relatively convenient ways of specifying operations

    • Example:

      • the inclusion of for statement in many modern languages makes writing counting loops easier than with the use of while.


Evaluation criteria reliability l.jpg

Evaluation Criteria: Reliability

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


Characteristics contributing to the reliability type checking l.jpg

Characteristics Contributing to the Reliability – Type Checking

  • 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

    • The earlier errors in programs are detected, the less expensive it is to make the required repairs

    • Example

      int foo(unsigned int a, int b)

      { …

      }

      void bar()

      {

      w=foo(-1,2);

      }


Characteristics contributing to the reliability exception handling l.jpg

Characteristics Contributing to the Reliability – Exception Handling

  • Exception handling

    • Intercept run-time errors and take corrective measures and then continue the corresponding program’s execution


Characteristics contributing to the reliability aliasing l.jpg

Characteristics Contributing to the Reliability – Aliasing

  • Presence of two or more distinct referencing methods for the same memory location

  • It is now widely accepted that aliasing is a dangerous feature in a programming language

  • Most programming languages allow some kind of aliasing – for example, two pointers set to point to the same variable.


Characteristics contributing to the reliability readability and writability l.jpg

Characteristics Contributing to the Reliability – Readability and Writability

  • Readability and writability

    • A language that does not support “natural” ways of expressing an algorithm will necessarily use “unnatural” approaches, and hence reduced reliability


Evaluation criteria cost l.jpg

Evaluation Criteria: Cost

  • Training programmers to use language

  • Writing programs Compiling programs

  • Executing programs

  • Language implementation system: availability of free compilers

  • Reliability: poor reliability leads to high costs

  • Maintaining programs


Evaluation criteria others l.jpg

Evaluation Criteria: Others

  • Portability

    • The ease with which programs can be moved from one implementation to another

  • Generality

    • The applicability to a wide range of applications

  • Well-definedness

    • The completeness and precision of the language’s official definition


Influences on language design l.jpg

Influences on Language Design

  • Computer Architecture

    • Languages are developed around the prevalent computer architecture, known as the von Neumann architecture

  • Programming Methodologies

    • New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages


Von neumann architecture l.jpg

Von Neumann Architecture

  • Most of the popular languages of the past 50 years have been designed around the prevalent computer architecture: Von Neumann architecture

  • These language are called imperative languages.

    • Data and programs are stored in the same memory

    • Memory is separate from CPU

    • Instructions and data are transmitted from memory to CPU

    • Results of operations in the CPU must be moved back to memory

  • Nearly all digital computers built since the 1940s have been based on the von Neumann architecture


The motherboard of a computer l.jpg

The Motherboard of a Computer


The von neumann architecture l.jpg

The von Neumann Architecture


Central features of imperative languages l.jpg

Central Features of Imperative Languages

  • Variables: model memory cells

  • Assignment statements: model piping

  • Iteration is fast on von Neumann computers because instructions are stored in adjacent cells of memory and repeating the execution of a section of code requires only a simple branch instruction


Program execution on a von neumann computer l.jpg

Program Execution on a Von Neumann Computer

  • The execution of a machine code program on a von Neumann architecture computer occurs in a process called the fetch-execute cycle.

  • Each instruction to be executed must be moved from memory to the processor.

  • The address of the next instruction to be executed is maintained in a register called the program counter.


Fetch execute cycle on a von neumann architecture l.jpg

Fetch-execute-cycle (on a von Neumann Architecture)

initialize the program counter

repeat forever

fetch the instruction pointed by the counter

increment the counter

decode the instruction

execute the instruction

end repeat

P.S.: the ``decode the instruction’’ step in the algorithm means the instruction is examined to determine what action it specifies.


Functional language programs executed on a von neumann machine l.jpg

Functional Language Programs Executed on a Von Neumann Machine

  • A functional language is one in which the primary means of computation is applying functions to given parameters.

  • Programming can be done in a functional language without the kind of variables that are used in imperative languages, without assignment statements, and without iteration.

  • Although many computer scientists have expounded on the myriad benefits of functional languages, it is unlikely that they will displace the imperative language until a non-von Neumann computer is designed that allows efficient execution of programs in functional languages


Evolution of programming methodologies 1 l.jpg

Evolution of Programming Methodologies (1)

  • 1950s and early 1960s:

    • Simple applications

    • worry about machine efficiency

  • 1970s:

    • Hardware costs decreased

    • programmer costs increased

    • Larger and more complex problems were being solved by computers

    • Emphasis:

      • structured programming

      • top-down design and step-wise refinement

    • Deficiency:

      • Incompleteness of type checking

      • Inadequacy of control statements

        • Requiring the extensive use of gotos


Evolution of programming methodologies 2 l.jpg

Evolution of Programming Methodologies (2)

  • Late 1970s:

    • shift from procedure-oriented to data-oriented

    • Emphasize data design, focusing on the use of abstract data types to solve problems

    • Most languages designed since the late 1970s support data abstraction

  • Middle 1980s: Object-oriented programming

    • data abstraction

      • encapsulates processing with data objects

      • controls access to data

    • Inheritance

      • Enhances the potential reuse of existing software, thereby providing the possibility of significant increases in software development productivity

    • dynamic method binding

      • Allow more flexible use of inheritance


Object oriented programming and languages l.jpg

Object-oriented Programming and Languages

  • First language supporting its concepts: Smalltalk.

  • Support for object-oriented programming is now part of most popular imperative language, including

    • Ada 95, Java, and C++

  • Object-oriented concepts have also found their way into

    • Functional programming in CLOS

    • Logical programming in Prolog++


Slide49 l.jpg

All of the evolutionary steps in software development methodologies led to new language constructs to support them.


Programming language categories l.jpg

Programming Language Categories

  • Imperative

    • Central features are variables, assignment statements, and iteration

    • Examples: C, Pascal

  • Functional

    • Main means of making computations is by applying functions to given parameters

    • Examples: LISP, Scheme

  • Logic

    • Rule-based (rules are specified in no particular order)

    • Example: Prolog

  • Object-oriented

    • Data abstraction, inheritance, late binding

    • Examples: Java, C++


Should languages support object oriented programming form a separate language category l.jpg

Should Languages Support Object-oriented Programming Form a Separate Language Category?

  • The author of this book claimed that he does not consider languages that support object-oriented programming to form a separate category of language, because, both imperative languages and function languages support object-oriented programming.


Subcategories of imperative languages l.jpg

Subcategories of Imperative Languages

  • Visual languages:

    • e.g. Visual BASIC and Visual BASIC .NET

    • These languages include capabilities for drag-and-drop generation of code segments.

    • Once called fourth-generation Languages

    • Provide a simple way to generate graphical user interfaces to programs.

  • Scripting Languages

    • e.g. Perl, JavaScript, and Ruby


A typical session in microsoft visual basic 6 l.jpg

A Typical Session in Microsoft Visual Basic 6


Execution order of programs l.jpg

Execution Order of Programs

  • In an imperative language, an algorithm is specified in great detail, and the specific order of execution of the instructions or statements must be included.

  • In a rule-based language, however, rules are specified in no particular order

    • The language implementation system must choose an execution order that produces the desired result.


Markup programming hybrid languages l.jpg

Markup Programming hybrid languages

  • not a programming language, but used to specify the layout of information in Web documents

    • examples: XHTML, XML

    • However, some programming capability has crept into some extensions to XHTML and XML


Benefits of modular design l.jpg

Benefits of Modular Design

  • Modular design brings with it great productivity improvements.

    • First of all, small modules can be coded quickly and easily.

    • Secondly, general purpose modules can be re-used, leading to faster development of subsequent programs.

    • Thirdly, the modules of a program can be tested independently, helping to reduce the time spent debugging.


Language design trade offs l.jpg

Language Design Trade-offs

  • The programming language evaluation criteria provide a framework for language design; however, that framework is self-contradictory.


Instances of language design trade offs l.jpg

Instances of Language Design Trade-Offs

  • Reliability vs. cost of execution

    • Conflicting criteria

    • Example: Java demands all references to array elements be checked to ensure that the index is in it legal ranges but that leads to increased execution costs

  • Readability vs. writability

    • Another conflicting criteria

    • Example: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poorreadability

  • Writability (flexibility) vs. reliability

    • Another conflicting criteria

    • Example: C++ pointers are powerful and very flexible but not reliably used


Primary components of a computer l.jpg

Primary Components of a Computer

  • Internal Memory

    • Used to store data and program

  • Processor

    • a collection of circuits that provides a realization of a set of primitive operations, or machine instructions, such as those for arithmetic and logic operations.


The machine language of a computer l.jpg

The Machine Language of a Computer

  • Is its set of instructions.

  • Is the ONLY language that the hardware of the computer can understand directly.

  • Provide the most commonly needed primitive operations.

  • Programs written by high level languages require system software (language implementation systems) to translate them into corresponding machine language versions.


Operating systems l.jpg

Operating Systems

  • Supply Higher-level primitives than those of the machine language.

  • These primitives provide

    • system resource management

    • input and output operations

    • a file management system

    • text and/or program editors

    • a variety of other commonly needed functions


Language implementation systems and an operating systems l.jpg

Language Implementation Systems and an Operating Systems

  • Because language implementation systems need many of the operating system facilities,

    • they interface to the operating system or utilize the operating system to do their work rather than directly to the processor (in machine language).


Virtual computers l.jpg

Virtual Computers

  • An operating system and language implementations are layered over the machine language interface of a computer.

  • These layers can be thought of as virtual computers, providing interface to the user at higher levels.

    • e.g. an OS and a C compiler provide a virtual C computer

  • Most computers provide several different virtual computers.


Layered view of computer l.jpg

Layered View of Computer

The operating system and language implementation are layered over

Machine interface of a computer


Implementation methods l.jpg

Implementation Methods

  • Compilation

    • Programs are translated into machine language, which can be executed directly on the computer

  • Pure Interpretation

    • Programs are interpreted by another program known as an interpreter

  • Hybrid Implementation Systems

    • A compromise between compilers and pure interpreters


Compilation l.jpg

Compilation

  • Translate high-level program (source language) into machine code (machine language)

  • Slow translation, fast execution


Phases of compilation process l.jpg

Phases of Compilation Process

  • lexical analysis: gathers the characters of the source program into lexical units.

    • lexical units: identifiers, special words, operators and punctuation symbols

  • syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program

  • intermediate code generation: translate a source program into an intermediate language one

    • semantics analysis: check for errors that are difficult if not impossible to detect during syntax analysis, such as type errors.

  • code generation: machine code is generated


Optimization l.jpg

Optimization

  • Improve programs (usually in their intermediate code version) by making them smaller or faster or both, is often an optional part of compilation.

  • Some compilers are incapable of doing any significant optimization.

  • Optimization may

    • omit some code in your program

    • change the execution order of code in your program

      • P.S.: Sometimes, especially when synchronization between processes is required, the above results may create some bugs in your programs which can not be detected by just checking the source code.


Optimization vs reliability l.jpg

Optimization vs. Reliability

a:

memory

int a;

int foo()

{

a=1;

if(a>0)

a=3;

else

a=-1;

return a;

}

process 2

process 1

int a;

foo()

{

a=3;

}

optimization

If a is not a volatile variable, the optimization improve performance; otherwise, it introduces race condition problem.


Symbol table l.jpg

Symbol Table

  • The symbol table serves as a database for the compilation process.

  • The primary contents of the symbol table are

    • the type and attribute information of each user-defined name in the program.

      • P.S.: This information is placed in the symbol table by the lexical and syntax analyzers and is used by the semantic analyzer and the code generator.


The compilation process l.jpg

The Compilation Process


User program supporting code l.jpg

User Program Supporting Code

  • The machine language generated by a compiler can be executed directly on the hardware; however, it must nearly always be run along with some other code.

  • Most user programs also require programs form the OS.

  • Among the most common of these are programs for input and output.


Linking operation l.jpg

Linking Operation

  • Before the machine language programs produced by a compiler can be executed, the required programs from the OS must be found and linked to the user program.

  • The linking operation connects the user program to the system programs by placing the addresses of the entry points of the system programs in the calls to them in the user program.


Combine a user program and all supporting programs together l.jpg

Combine a User Program and All Supporting Programs Together

address space of a process

main()

{

printf()

}

main:

call add_of_printf

0x40ffffff

printf:

main:

call

linking

compilation

loading

0x40ffffff


Linking operation75 l.jpg

Linking Operation

  • Load module (executable image): the user and system code together

  • Linking and loading (linking): the process of collecting system program and linking them to user programs

    • Accomplished by a systems program called a linker


Libraries l.jpg

Libraries

  • In addition to systems programs, user programs must often be linked to previously compiled user programs that reside in libraries.

  • The linker not only links a given program to system programs, it may also link it to other user programs.


Von neumann bottleneck l.jpg

Von Neumann Bottleneck

  • Connection speed between a computer’s memory and its processor determines the speed of a computer

  • Program instructions often can be executed a lot faster than the above connection speed; the connection speed thus results in a bottleneck

  • Known as von Neumann bottleneck; it is the primary limiting factor in the speed of computers


Interpreter l.jpg

Interpreter

  • Programs are interpreted by another program called an interpreter, with no translation whatever.

  • The interpreter program acts as a software simulation of a machine whose fetch-execute cycle deals with high-level language program statements rather than machine instructions.

  • This software simulation obviously provides a virtual machine for the language.


Advantages of interpretation l.jpg

Advantages of Interpretation

  • Allowing easy implementation of many source-level debugging operations, because all run-time error messages can refer to source-level unit.

    • For example, if an array is found to be out of rang, the error message can easily indicate the source line and the name of the array.


Disadvantages of interpretation 1 l.jpg

Disadvantages of Interpretation (1)

  • Slower execution (10 to 100 times slower than compiled programs)

    • The decoding of the high-level language statements are far more complex than machine language instruction.

    • Regardless of how many times a statement is executed, it must be decoded every time.

    • Therefore, statement decoding, rather than the connection between the processor and memory, is the bottleneck of a pure interpreter.


Disadvantages of interpretation 2 l.jpg

Disadvantages of Interpretation (2)

  • Often requires more space.

    • In addition to the source program, the symbol table must be present during interpretation

    • The source program may be stored in a form designed for easy access and modification rather than one that provides for minimal size


Popularity of interpretation l.jpg

Popularity of Interpretation

  • Some simple early languages of the 1960s (APL, SNOBOL, and LISP) were purely interpreted.

  • By the 1980s, the approach was rarely used on high-level languages.

  • In recent years, pure interpretation has made a significant comeback with some Web scripting languages, such as JavaScript and PHP, which are now widely used.


Pure interpretation process l.jpg

Pure Interpretation Process


Hybrid implementation systems l.jpg

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 l.jpg

Examples

  • Perl programs

    • are partially compiled to detect errors before interpretation to simplify the intepreter.

  • Initial implementations of Java

    • initial implementations of Java were all hybrid

    • its 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)

    • There are now systems that translate Java byte code into machine code for faster execution.


Hybrid implementation process l.jpg

Hybrid Implementation Process


Just in time jit implementation systems l.jpg

Just-in-Time (JIT) Implementation Systems

  • Initially translate programs to an intermediate language

  • Then during execution, it compiles intermediate language methods into machine code when they are called

  • Machine code version is kept for subsequent calls

  • JIT systems are widely used for Java programs

  • .NET languages are implemented with a JIT system


Preprocessors l.jpg

Preprocessors

  • A preprocessor is a program that processes a program immediately before the program is compiled.


Preprocessor instructions l.jpg

Preprocessor Instructions

  • Preprocessor instructions are embedded in programs.

  • Preprocessor instructions are commonly used to specify that code from another file is to be included.

    • For example, the following C preprocessor instruction #include myLib.c, causes the preprocessor to copy the contents of myLib.c into the program at the position of the #include.


More preprocessor instructions l.jpg

More Preprocessor instructions

  • Other preprocessor instructions are used to define symbols to represent expressions.

    • For example, one could use

      #define max(A, B) ((A) > (B) ? (A): (B))

      to determine the largest of two given expressions.


Programming environments l.jpg

Programming Environments

  • The collection of tools used in software development

  • This collection may consist of only

    • a file system

    • a text editor

    • a linker

    • a compiler

  • Or a programming environment may include a large collection of integrated tools, each accessed through a uniform user interface.


Programming environment examples l.jpg

Programming Environment Examples

  • UNIX

    • Provides a wide array of powerful support tools for software production and maintenance in a variety of languages.

    • Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME) that run on top of UNIX

  • Borland JBuilder

    • An integrated development environment for Java

  • Microsoft Visual Studio.NET

    • A large and elaborate collection of software development tools, all used through a windowed interface.

    • Used to program in C#, Visual BASIC.NET, Jscript, J#, or C++


Summary l.jpg

Summary

  • The study of programming languages is valuable for a number of reasons:

    • Increase our capacity to use different constructs

    • Enable us to choose languages more intelligently

    • Makes learning new languages easier

  • Most important criteria for evaluating programming languages include:

    • Readability, writability, reliability, cost

  • Major influences on language design have been machine architecture and software development methodologies

  • The major methods of implementing programming languages are:

    • compilation,

    • pure interpretation,

    • hybrid implementation


  • Login