Programming Languages - Chapter 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Expressivity

1. A set of relatively convenient ways of specifying operations 2. Strength and number of operators and predefined functions

What makes a language successful?

1. Easy to learn (BASIC, Pascal, LOGO, Scheme, Python) 2. Easy to express things, easy to use once fluent, "powerful" (C, Common Lisp, APL, Algol-68) 3. Easy to implement (BASIC, Forth) 4. Possible to compile to very good (fast/small) code (Fortran) 5. Backing of a powerful sponsor (COBOL, PL/1, Ada, Visual Basic) 6. Wide dissemination at minimal cost (Pascal, Java)

Why are there so many programming languages?

1. evolution -- we've learned better ways of doing things over time 2. socio-economic factors: proprietary interests, commercial advantage 3. orientation toward special purposes 4. orientation toward special hardware 5. diverse ideas about what is pleasant to use

What are the phases of compilation?

1. lexical analysis: converts characters in the source program into lexical units 2. syntax analysis: transforms lexical units into a parse tree which represents the syntactic structure of program 3. semantics analysis: type checking and intermediate code generation 4.code generation: machine code is generated

Programming Methodologies Influences

1950s/1960s: Simple applications; worry about machine efficiency Late 1960s: People efficiency became important; readability, better control structures structured programming top-down design Late 1970s: Process-oriented to data-oriented - data abstraction Middle 1980s: Object-oriented programming - Data abstraction + inheritance + polymorphism

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 Examples: Java Byte Code Phases: 1. Lexical Analysis: produces lexical units 2. Syntax analysis: produces parse trees 3. Intermediate code generation: produces Intermediate code 4. Interpreter w/ data: produces results

Simplicity

A manageable set of features and constructs - Minimal feature multiplicity - Minimal operator overloading

Orthgonality

A relatively small set of primitive constructs can be combined in a relatively small number of ways Every possible combination is legal & meaningful

What is a virtual machine?

A virtual machine is a simulation of a computer whose machine language is not the language of the computer on which the simulation is running.

Why do we have programming languages?

A way of expressing algorithms Abstraction of a virtual machine

What is the Von Neumann bottleneck? Why is it the primary limiting factor in the speed of computers?

Basis for Imperative languages Bottleneck: the connection speed between the CPU and the memory Connection speed between a computer's memory and its processor determines the speed of a computer Program instructions often can be executed much faster than the speed of the connection; the connection speed thus results in a bottleneck The primary limiting factor in the speed of computers

Implementation Methods

Compilation Pure Interpretation Hybrid Implementation

What are the two main influences on language design?

Computer Architecture: Von Neumann Programming Methodologies: New software development methodologies (e.g., objectoriented software development) led to new programming paradigms and by extension, new programming languages

What are the categories of languages?

Imperative - Central features are variables, assignment statements, and iteration - map directly to hardware Include object oriented languages, scripting, visual languages Includes C, Java, Perl, Python, Lua, C++ Functional - Main means of making computations is by applying functions to given parameters Examples: Lisp, Scheme, Racket, Haskell, Ocaml Logic - Rule-based (rules are specified in no particular order) Examples: prolog Markup/programming hybrid - Markup languages extended to support some programming Examples: JSTL, XSLT

What is the von neumann architecture?

Imperative languages are most dominant because of von Neumann computers - Memory is separate from CPU - Data and programs both stored in memory - Instructions and data are piped from memory to CPU - Basis for imperative languages

Just-in-Time Implementation Systems

Initially translate programs to an intermediate language • Then compile the intermediate language of the subprograms into machine code when they are called

Exception handling

Intercept run-time errors and take corrective measures

Pure Interpretation

No translation • Easier implementation of programs (run-time errors can easily and immediately be displayed) - But errors are not found until actually executed • Slower execution (10 to 100 times slower than compiled programs) • Often requires more space

Writability

Overall Simplicity: A manageable set of features and constructs Minimal feature multiplicity Minimal operator overloading Orthogonality: A relatively small set of primitive constructs can be combined in a relatively small number of ways Every possible combination is legal & meaningful Support for abstraction: the ability to define constructs which allows the details to be ignored. Expressivity: A set of relatively convenient ways of specifying operations Strength and number of operators and predefined functions

Aliasing

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

Language Design Trade-Offs

Reliability vs. cost of execution Ex: Java checking for references to arrays to be type checked Writability (flexibility) vs. reliability Ex: C & C++ pointers are powerful and very flexible but are the source of many programming errors Readability vs. writability Ex: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 poor readability

What are the domains of programming languages? What features do each of the them need? What is an example of a type of language for each domain?

Scientific Applications: (1) Large numbers of floating point computations; use of (2) arrays Example: Fortran Business Applications: Produce reports, use (1) decimal numbers and (2) characters Example: COBOL Artificial Intelligence: Manipulate symbols rather than numbers; use of linked lists Example:LISP Systems Programming: (1) Efficiency because of continuous use, (2) low-level access, (3) use of pointers Example: C Web Software: Eclectic collection of languages: 1. markup (e.g., XHTML), 2. scripting (e.g., PHP), 3. general-purpose (e.g., Java)

Readability

Simplicity and orthogonality Control statements Data types and structures Syntax considerations

Syntax considerations

Special words and methods of forming compound statements • if {...} vs. if ... endif - Form and meaning: self-descriptive constructs, meaningful keywords

Type checking

Testing for type errors, whether compile-time or run-time Preventing a bit-pattern representing one type of data from being interpreted as a different type of data

Support for abstraction

The ability to define and use complex structures or operations in ways that allow details to be ignored

Generality

The applicability to a wide range of applications

Well-definedness

The completeness and precision of the language's official definition

Portability

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

Chapter 1 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, and hybrid implementation

Cost

Training programmers to use the language Writing programs* (closeness to particular applications) Compiling programs Executing programs (speed, space, etc.) Language implementation system: availability and cost of compilers, IDE (hopefully they are free) Reliability*: poor reliability leads to high costs Maintaining programs*

Compilation

Translate high-level program (source language) into machine code (machine language) Slow translation, fast execution -- 1. lexical analysis: converts characters in the source program into lexical units 2. syntax analysis: transforms lexical units into a parse tree which represents the syntactic structure of program 3. semantics analysis: type checking and intermediate code generation 4.code generation: machine code is generated

Reliability

Type checking Exception Handling Aliasing Readability and Writability

Language Evaluation Criteria

Writability: the ease with which a language can be used to create programs Readability: the ease with which programs can be read and understood Reliability: programs conform to specifications (i.e., perform to their specifications) under all conditions Cost: the ultimate total cost

What is the fetch-execute-cycle on the 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


Set pelajaran terkait

Skeletal system - Connective Tissues and Joints

View Set

Chapter 8: Gene Expression - The Flow of Information from DNA to RNA to Protein

View Set

Army Health System Support to Detainee Operations ATP 4-02.46

View Set

Computer Google Forms Study Guide

View Set

R53 — Portfolio Risk and Return: Part II

View Set

Chapter 21: Genomes and Their Evolution

View Set