Programming Languages Exam 1

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

What are the three fundamental features of an object-oriented programming language?

Data abstraction (information hiding), inheritance, and dynamic method binding.

What programming language has dominated business applications over the past 50 years?

COBOL

What does a linker do?

Combines the object module of a program and the library functions called in that program into an executable file; resolves all external references; and adjusts relative reference in all object modules relative to the first object module.

What are the three general methods of implementing a programming language?

Compilation, pure interpretation, and hybrid implementation.

What are the lexical elements of a programming language?

a. Character set - set of all characters allowed in the text of a program. b. Lexemes - rules for grouping characters into words. c. Use of reserved words and keywords. d. Way blanks and line termination characters are handled. e. How comments are written.

What programming language has dominated artificial intelligence over the past 50 years?

LISP

Which produces faster program execution: a compiler or pure interpreter?

A compiler produces faster program execution due to the fact that pure interpreters have to decode high-level language statements which are far more complex than machine language instructions.

What is the difference between a language interpreter and a compiler?

An interpreter executes the program immediately without translation and a compiler just translates the code to machine code.

In what language is most of UNIX written?

C

What programming language has dominated scientific computing over the past 50 years?

FORTRAN

What construct of a programming language provides process abstraction?

Functions/classes provide abstraction.

What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture?

Imperative/procedural languages.

What are the advantages in implementing a language with a pure interpreter?

Portability and error detection is easier.

What language was the first to support the three fundamental features of object-oriented programming?

Smalltalk.

What role does the symbol table play in a compiler?

The symbol table contains all the identifiers and attributes in the program.

How can knowledge of programming language characteristics benefit the whole computing community?

They can help programmers efficiently write programs to solve problems in a particular application domain. They can transfer the characteristics to properly implement them in other languages.

You work in a company that wants to use only one programming language to implement all its programming applications. What is the most appropriate language in each of the following situations?

a. All applications have a lot of floating-point arithmetic computations and require only arrays as the major data structure - FORTRAN b. All applications are used to compute payrolls and also to generate reports - COBOL c. Some applications have a lot of floating-point arithmetic computations and require only arrays as the major data structure, but others are used to compute payrolls and also to generate reports - C# d. All applications are used for game playing with symbolic manipulations of data represented as linked lists - LISP e. All applications are used for the operation of the computer - C f. All applications are embedded in HTML documents, and are interpreted on the server before the document is sent to a requesting browser - PHP, Lua, Python, VB.net g. All applications are embedded in HTML documents and are interpreted by a browser that displays the document - JavaScript h. All applications are common Gateway Interface (CGI) programs for the World Wide Web - Perl

How can the awareness of a wider variety of programming language features reduce the limitations that the control structures, data structures, and abstractions of a programming language can impose on a programmer?

a. By choosing a programming language with the best features to solve a particular problem. b. By simulating features from one language in those that do not have them. Example: the string and fixed decimal basic data types of PL/1 can also be simulated in C/C++.

Provide the three major methods (each with an example) of implementing programming languages.

a. Compiler interpretation - a high level program is translated into a machine language program, which can be executed directly on the computer. Ex: C/C++, Pascal, and COBOL. b. Pure interpretation - a program called the interpreter takes as input the high-level language program and its input data; it executes the statements of this program on the computer and produces the result(s) of the program. Ex: JavaScript c. Hybrid implementation - the high-level language program is translated into an intermediate language designed to allow easy interpretation. The intermediate code is then executed using an interpreter. Ex: Perl, Lisp, and initial Java.

Provide the characteristics of the following high-level programming language categories:

a. Imperative languages: i. Variables are used to represent memory locations. ii. Assignment statements are used to store values in memory locations. iii. Use of iteration as a major form of repetition. iv. An algorithm is specified in great detail and the specific order of execution of the instructions/statements must be included. b. Functional (applicative) languages: i. Computation is mostly done by applying functions to arguments. ii. Variables (symbols) do not necessarily represent memory locations and can be bound to values (atoms or lists) by special forms or when a function is called. iii. Recursion is the primary means of repetition. c. Logic programming languages: i. Use of logical statements (facts and rules) to describe a program. ii. Programming in logic is nonprocedural because there is no way to specify in a program exactly how a result can be computed. The rules are specified in no particular order. iii. Computation is performed by deriving new facts from existing ones using an inference mechanism (resolution) and the rules. d. Object-oriented programming languages: i. Data abstraction and information hiding: a programmer may create a class and hide from its clients the implementation of that class (information hiding) and a client of a class need not know how a class is implemented in order to use its functionality. The description of class functionality is independent of its implementation. ii. Inheritance: the definition of one class (derived class) can be derived from that of another class (base class). iii. Dynamic binding of the methods to the messages (function calls): a function call is bound to a function at execution time.

Provide one or more examples of each of the above programming language categories:

a. Imperative languages: C/C++, Pascal, PL/1, COBOL, FORTRAN b. Function (applicative)) languages: Lisp, Scheme, Meta Language, and Miranda c. Logic Programming languages: Prolog d. Objected-oriented programming language: Smalltalk (C++, Java, Python combine imperative and object-oriented features)

What are the major types of statements (with their meanings) of an imperative language?

a. Input statements - information is inputted into the program. b. Output statements - information is outputted to the monitor. c. Assignment statements - values are assigned to variable names in memory. d. Two-way selection structures - action following a decision occurs for both true and false. e. One-way selection structures - action following a decision occurs only for true or only for false. f. Counter-control iteration structure - index value is incremented by an integer value (doesn't exist in C/C++ but can be done through for and while loops). g. Logically controlled iteration - action returns to previous condition if only true or only false. h. Multiple-way controlled selection structure - If true/false, action occurs and program ends. If the opposite, another condition is tested and the process repeats

Provide the major components of a compiler with a brief description of their functions.

a. Lexical analyzer (scanner) - reads a source program character by character; groups those characters into words (lexemes) and classifies those words into tokens and comments. b. Syntax analyzer (parser) - takes as input the lexemes produced by the lexical analyzer; and groups the lexemes into the syntactic structures of the program. In some cases, it also generates the parse tree of each syntactic structure. c. Intermediate code generator (semantic analyzer) - takes as input the parse trees of the syntactic structures produced by the syntax analyzer. The semantic analyzer checks for errors such as type errors on the syntactic structures, and the intermediate code generator generates the intermediate (sometimes assembly language) codes that correspond to the syntactic structures. d. Code generator - takes as input the intermediate codes produced by the intermediate code generate and translates the intermediate codes into machine language.

What are the three things that characterize a programming language?

a. Lexical elements. b. Syntax. c. Semantics.

Provide a description of the functions of the linker and loader.

a. Linker - combines the object module of a program and the library functions called in that program into an executable file; resolves all external references; and adjusts relative reference in all object modules relative to the first object module. b. Loader - system program that allocates memory locations of an executable file, loads the executable file in memory, and initializes the registers for the program to be executed.

Provide two special-purpose languages with their characteristics.

a. Report Program Generator (RPG) - introduced by IBM in 1960s to generate reports. Has fixed coding structure with formats for: i. Input specification (files and data). ii. Switch specification (boolean). iii. Calculation and process. iv. Output specification. b. SIMULA - language for system description and simulation with the concept of class. i. A system in this case is viewed as a collection of independent entities (objects) interacting with each other. ii. Systems are simulated by examining the life cycles of the entities of a system.

What are the major characteristics of each of the following program domains: scientific and business applications.

a. Scientific: i. Simple data structures needed, most common ones are arrays and matrices. ii. Problems require large numbers of floating-point arithmetic computations. iii. Most common control structures are counting loops and selections. b. Business: i. Production of elaborate reports. ii. Need of precise ways for describing and storing character data (strings) and decimal numbers. iii. Ability to specify decimal arithmetic operations.

What are the most commonly used languages in each of the above programming domains?

a. Scientific: FORTRAN b. Business: COBOL

Provide the two types of semantics (each with a brief description) of a programming language.

a. Static semantics - properties of a compiler can determine without considering any execution. Ex: make sure a variable is present in the scope of a function. b. Dynamic semantics - depend on a particular execution. Ex: when an array index is out of range.

What are the six reasons for studying the concepts of programming languages?

a. To increase the capacity to express ideas and build appreciation for valuable language features and encourage programmers to use them. b. To improve the background for choosing appropriate languages to help programmers pick the most appropriate language for a new project. c. To increase the ability to learn new languages. It is easy to learn how concepts apply to a new language when you have a thorough understanding of them. d. To gain a better understanding of the significance of implementation. Proper understanding of features aids in the debugging of a certain language. e. To better utilize languages already known. A language can become widely accepted when the people picking the languages are familiar with their concepts.


Set pelajaran terkait

Midterm Environmental Sampling and Analysis

View Set

Mastering Assignment 7 - Exercise 8

View Set

Unit 8: Random Variables and Probability Distributions.

View Set

Chapter 10- Elder Abuse and Neglect

View Set

Macro: Chapter 14: MONETARY POLICY

View Set

Chapter 20- Muscular System and Pathologies

View Set