Shared Flashcard Set

Details

Programming Languages Midterm 1
Midterm 1 definitions and stuff like that
52
Computer Science
Undergraduate 3
05/13/2009

Additional Computer Science Flashcards

 


 

Cards

Term
What were some of the factors that made programming early computers especially difficult?
Definition
  • Very little storage
    very little power
  • more complicated to programmer
    • increases chance of programmer errors
Term
What were the benefits of optimal coding? What were the drawbacks?
Definition
  • The address of the next instruction would come right after the previous
  • but it was a tedious and error-prone process
Term
What are the benefits of program design notations? How are they distinct from programming languages?
Definition
  • They would allow the programmer to design program layouts without being concerned about the details (such as optimal coding); others provided menumonics for machine operations
  • but these languages/notations were designed for programmers and not for processing of the computer
Term
What were the benefits of psuedo-code interpreters? What were the drawbacks?
Definition
  • Because they eliminated a great deal of lower level details, but they ran a magnitude slower than the real computer\
  • implemented a virtual computer
  • provided more suitable applications
  • eliminated many details from programming (automation principle)
  • regular rules, w/out exception, are easier to learn, use, describe and implement
  • but:
  • --magnitude slower than a real computer; additional cost due to floating-poing and indexing
Term
What factors made pseudo-code interpreters practical for a period of time? What were the drawbacks?
Definition
Although subroutines added a great deal of time to psuedo-code interpreters, it was acceptly small since floating point and indexing subroutines took time anyways
Term
What factors made psuedo-code interpreters practical for a period of time? What development made them impractical, and why?
Definition
  • Floating point hardware made interpreters unattractive because programs were no longer spending most of their time in floating-point subroutines
  • FORTRAN/Speedcoding
  • the factor of 10, or more, slower execution of interpreters became intolerable
Term
Why was “automatic coding” considered unfeasible in the early 1950s?
Definition
Programmers were mainly concerned about efficiency in their code, rather than readability/maintainability
Term
What factors led John Backus to develop Speedcoding and then FORTRAN? What was Speedcoding?
Definition
  • Backus recognized that it was more expensive to design and debug a program than to run it
    • this was around the time that people were using psuedo-code interpreted languages/interpreters
  • speedcoding was the first higher-level language created for an IBM computer; an interpreter focusing on the ease of use rather than efficiency of computer resources
    • since efficiency was on most programmers' mind, it was not accepted(?)
Term
What were the main goals of FORTRAN's developers? Was language design a big part of these goals?
Definition
  • to design an efficient language with conventional methemetical notation, comparable to a good programmer
  • language design wasn't a big part of those goals
Term
What factors helped FORTRAN to succeed despite the “indifference and skepticism” that met the release of its preliminary specification? What were FORTRAN's main contributions?
Definition
  • Exceptionally clear documentation, very sophisticated optimization techniques, and because FORTRAN delivered the efficiency that had been promised.
  • FORTRAN is considered the first widely used programming language supported across a variety of computer architectures
Term
What FORTRAN statement "is the workhorse of control flow"?
Definition
GOTO statements
Term
What is the overall structure of a FORTRAN program?
Definition
Main program
subprogram 1 (0 or more)
subprogram 2
subprogram n
Term
What functions do FORTRAN declarations perform? (hint: variable declaration in FORTRAN really only perform 2 of the 3 functions mentioned in MacLennan on pg. 42, but the wise programmer will make sure that the 3rd function is taken care of as well even if the declaration doesn't to it …!)
Definition

 1. They allocated an area of memory of a specified size


2. they attached a symbolic name to that area of memory. This is called binding a name to an area of memory


3. they initialized the contents of that memory area

Term
What are the three kinds of imperative statements in FORTRAN?
Definition
  • Computational statements
  • control-flow statements
  • input-output statements
Term
What were the four stages in the FORTRAN compilation process? What are the three phases in the compilation stage of the compilation process?
Definition
  • Linking
    • Address incorporated
  • Loading
    • placed into memory
  • Execution
    • control turned over to memory
  • Compilation stage
    • synctactic analysis
    • optimization
    • code synthesis
Term

What were FORTRAN control structures based on? What FORTRAN statement "is the workhorse of control flow"?

What was the only "high-level" control structure provided by FORTRAN? Why could it be provided?

Definition
  • Control structures were based on the IBM 704 branch instructions.
  • only high-level control structures provided was "do", because it was highly optimized.

 

Term

How can you write a leading-decision loop in FORTRAN?

 

A trailing decision loop?

Definition

100 IF (condition) GOTO 200

...statements for body of loop

GOTO 100

200 ...

and a trailing decision loop:

 

100 ... statement for body loop ...

...

Term
Why does MacLennan describe FORTRAN's GOTO as a “two-edged sword”? What principle first proposed by Edgay Dijkstra seems to explain why GOTO-based control structures are not ideal? You should be familiar with this principle.
Definition
  • it is possible to implement almost any control regime with it, those that are good, but also those that are bad.
  • he pretty much proposed that programs should move downwards in a consistent order (think no gotos)  – The Structure Principle
Term
Why can FORTRAN's Computes and Assigned GOTO's be easily confused?
Definition
Syntax is too familiar...
Term
Be able to give examples of interactions of features in FORTRAN that can lead to problems within programs …
Definition
  • Overwriting constants/literals
  • Lack of reserved words
  • no syntax errors
Term
You should be comfortable with both FORTRAN's arithemetic IF and logical IF
Definition

Arithmetic IF:

    IF (e) n1, n2, n3

  •        Less than 0, equal to zero, greater than 0

Logical IF:

If (e) statement

IF (X.EQ.A(I)) K = I - 1

Term

How are parameters usually passed in FORTRAN?

What are the benefits and drawbacks of this approach?

What is the alternative sometimes used in FORTRAN implementations?

 

Given appropriate fragments of code and the parameter-passing method, you should be able to determind the values that result within each fragment...

Definition
  • They are passed by pass by reference
  •  
    • efficient
    • but pass by reference can change the values of an input variable which may be changed by the subprogram
Term
What were the two kinds of data in FORTRAN (MacLennan calls them the two data structuring methods included in FORTRAN, p. 66)?
Definition
  • Scalars
  • Arrays
Term
What is meant when one says that FORTRAN arithmetic operators are overloaded?
Definition
  • It can be used with integers as well as reals
  • because different types of mathematical operations are completely different based on the type of number, it is necessary to overload several meanings to each arithmetic operation
Term
Why is FORTRAN's INTEGER type considered to be overworked?
Definition
it is required to do double duty; it represents both integers and character strings.
Term
What is the data constructor in FORTRAN's array? Why are these limitations in place?
Definition
Arrays. Static and limited to 3-dimensions because they have to be simple and efficient
Term

When are names bound to locations in a FORTRAN program?

 

Definition
These are performed by FORTRAN declarations
Term
When are names bound to types in a FORTRAN program?
Definition
names are bound to types also during declaration
Term
What is FORTRAN's optional variable declaration? What are its benefits and drawbacks?
Definition
  • optional variable declarations allows variables starting with a certain letter to be declared a certain type automatically 
    • drawbacks to this are that programmers may pick obscure names to represent certain variables
Term

What were FORTRAN's lexical conventions?

 

What were its fixed-format lexics?

Definition

one statement per card and columns dedicated to particular purposes...

 

fixed-format lexics:

Columns            Rows

1_5        Statement #

6            Continuation

07/01/72         Statement

73_80        Sequence number

 

 

Term

How are blanks treated in FORTRAN?

Benefits and drawbacks of this decision?

Definition

Blanks are ignored in FOTRAN

drawback: conflicting variable names if the programmer takes too much advantage of it

 

good: improvement over fixed fields

Term
Why is the lack of reserved words in FORTRAN considered to be a mistake?
Definition
Collides badly with the automatic declaration of variables …
Term
What are some major characteristics of "first-generation" languages such as FORTRAN?
Definition
  • Control Structures
    • non-nested
    • depends on goto
    • no recursion
  • Data structures
    • weak type system
  • name structures
    • disjoint scope
  • synctactic structures
    • linear arrangement
    • ignores blanks
Term
What operation is not available in pure functional programming?
Definition
Do, while, for loops; if statements.
Term

What common control structure is this also not available in pure functional programming?

 

What takes place of this control structure in pure functional programming?

Definition

Variables and iteration are not available;

 

recursion takes place of iteration

Term
What is means by the term referential transparency?
Definition
  • Pure functions
    • the property of a pure function is that its value depends only on the value of its arguments (and non-local constants)
Term
What is meant by a higher-order function?
Definition
Takes in functions and outputs functions
Term
In lecture (and posted) we discussed five qualities of functional programming languages and functional programs (as summarized by Louden) – what are they?
Definition
  • All procedures and functions all clearly distinguish incoming values (parameters) from outgoing values (results)
  • There are no variables or assignments -- vars are replaced by parameters
  • There are no loops--loops are replaced by recursive calls
  • The value of a function depends only on the value of its parameters and not in the order of evaluation or on the execution path that led to the call
  • functions are first-class values
Term
What are some benefits of functional programming (and of functional styles of programming, even with imperative languages)?
Definition
  • Clarity
  • Straightforward semantics
  • can be manipulated in arbitrary ways, without arbitrary restrictions
Term
Are lisp and scheme suitable only for pure functional programming? Are they used only for pure functional programming?
Definition
NO
Term
What led John McCarthy to start developing LISP?
Definition
  • Conditional expression that is short circuting
    • recursion
  • higher-order functions
  • anonymous functions
  • garbage collection

 

Term
What control structure did John McCarthy need for his work, develop, and suggest he included in Algol (as well as in Lisp?)
Definition
 He wanted to use this with what powerful concept for processing lists?
Term
Why was it important to McCarthy that the conditional expression be short circuting? What is meand by short-circuting in this context?
Definition
In recursion, if you hit your base case, you want to short circuit and go no further
Term
How did LISP's distinct notation come about? Why did it persist?
Definition
The abstract syntax tree; because programmers liked it
Term
What is the primary data constructor in LISP (pg. 314)
Definition
lists
Term
How are both data and programs represented in LISP?
Definition
Linked lists
Term
What is the relationship between linked lists and lisp LISTS?
Definition
lists used linked lists; the first element in a list is the first part of a linked list node, and the next is the next in a linked list?
Term
LISP was the first language to contain what type of expression (then added to Algol)?
Definition
Logical IF expression
Term
How is iteration accomplished in LISP?
Definition
recursion
Term
What is an anonymous function?
Definition
Lambda, which returns an unnamed function
Term
What is the difference between reference counts and garbage collection? What are the benefits and drawbacks?
Definition
Both are automatic memory reclamation
Term
What is meant by the term currying?
Definition
anonymous/higher-order functions
Supporting users have an ad free experience!