Shared Flashcard Set

Details

Programming Languages Midterm 2
Q
59
Computer Science
Undergraduate 3
05/13/2009

Additional Computer Science Flashcards

 


 

Cards

Term
Why was Algol developed?
Definition
  • Some computer scientists thought that a SINGLE, UNIVERSAL, MACHINE-INDEPENDENT PROGRAMMING language would be useful
  • Tired of rewriting all their programs whenever they got a new computer
  • would like a language suitable for discussing algorithms, such as in CS journals
Term
*Algol-60's report was notable for several reasons. You should be familiar with at least two of these.
Definition
  • The Algol-60 report is a paradigm of brevity and clarity
  • The original algol-60 report was 15 PAGES LONG
  • used BNF for the syntax--clear, precise, unambiguous english-language description for the semantics
  • remains the "gold standard" against which to compare programming language descriptions
Term
What are the three levels of the Algol language? How are they related? Disagreement over what issue led to this decision?
Definition
  1. The reference language
  2. the publication language
  3. hardware representation

They were different in lexical conventions but had similar syntax; disagreement over the use of a period of a comma to represent a decimal place led to this decision

Term
What are some differences between FORTRAN 4 and Algol-60 in terms of available control structures?
Definition
If, for-loop, switch -- but now more general, less constrained
Term
What are some differences between FORTRAN 4 and Algol-60 in terms of arrays?
Definition
  • Algol has n-dimensional arrays, and FORTRAN only has arrays up to 3 dimensions
  • Another difference is in their lower bounds -- the lower bound of FORTRAN IV's arrays is always 1, while Algol-60 allows an array's lower bound to be an integer other than 1
  • FORTRAN IV restricted the allowable expressions for array indices/ subscripts to one of 5 specific forms, while Algol-60 permits any integer expression to serve as an array index/subscript
Term
What are some differences between FORTRAN IV and Algol-60 in terms of parameter passing mechanisms?
Definition

*choice of parameter-passing modes;


*provided 2 parameter-passing modes, (if none is specified, the default is used, and one can specify an alternate means if desired;)


*the default is pass-by-name

*you can explicitly request pass-by-value

Term
What are some differences between FORTRAN IV and Algol-60 in terms of types and typing?
Definition
Algol-60 is strongly typed.
Term
*What aspects of Algol lead to programmers using fewer goto-statements? How did this help contribute to development of structured programming?
Definition
~ nesting in algol was an aspect in algol that lead to programmers using fewer goto-statements
Term
*What does it mean for a programming language feature to be considered "baroque"? why was Algol's for-loop considered to be baroque?
Definition
~ algol’s for loops were considered baroque because in trying to oversimplify how loops work , they instead created for loops which were overcomplicated and confusing when first looked at (many possibilities)
Term
*What are the parameter-passing mechanisms in Algol?
Definition
~ the default option of parameter passing in algol was pass-by-name, but you could explicitly request pass-by-value
Term
*What is the difference between a block and a compound statement in Algol-60?
Definition
  • ~a compound statement uses the begin and end of keywords and allows a sequence of statements for where only one would exist (begin … end in a for loop)

 

  • ~a block uses begin … end as well but the difference is that blocks contain declarations while compound statements do not

 

Term
*What is the dangling else problem? How does Algol address this problem?
Definition
  • a dangling else problem is where you are uncertain as to where an else attaches to.
    • algol addressed this problem by requiring a begin … end for every consequent if
Term

*What is a Regular Expression (RE)?

 

What can these be used for?

Definition

~ a regular expression is used to describe tokens of programming languages

 

    ~ regular expressions can be used to identify a certain string of interest

Term
*What is meant by the alphabet of a RE? be able to read/understand the notation {a | b} for describing a language;
Definition
  •   ~ a finite set of symbols; ex: S = {cat} – in this case, cat is the alphabet
Term

*What is a Context-Free Grammar (CFG)?

 

*What can these be used for?

 

Definition
  • ~ a finite set of VARIABLES (also nonterminals or synctactic categories; each of these represents a language
  • this can be used to describe features that have a recursive structure
Term
*What is a variable or nonterminal?
Definition
~ a variable is also called a non-terminal and represents a language (EX: S -> 0A1 --- in this case, S is the variable)
Term
What is a terminal?
Definition

(EX: S -> 0A1)

 

~ a terminal are the primitive symbols that represent the language (0 is a terminal in ex above)

Term
what is a start symbol?
Definition
~ a start symbol is the first variable/nonterminal you begin at
Term

*Given a CFG G, what does L(G) mean?

Definition
~ the set of strings of terminals which can be derived from the starting symbol S.
Term
*What is the relationship between CFG's and BNF's?
Definition

    -->the languages describable by BNF are exactly the Chomsky Type 2, context-free languages;

 
Term

*When is a grammar said to be ambiguous? How can you prove that a grammar is ambiguous?

Definition
~a grammer is said to be ambiguous when there exists more than one derivation tree for a specific string, you can then prove that a grammar is ambiguous by creating a derivation tree of a specific string and checking to see if that may result in more than one derivation tree
Term

*What is a leftmost derivation? What is a rightmost derivation?

Definition
~ the leftmost derivation is what is most to the left of a parse tree, the rightmost is what is most to the right. Also, as you perform your derivation, you either work from the left to the right or from the right to the left depending upon whether you want to do rightmost or leftmost derivation *
Term

*Why was PL/I developed?

 

why is called a classic example of the "Swiss Army Knife" approach to language design?

why was it not more successful?

why did some consider PL/I to be a "fatal disease"?

 

how (one might argue) did it help lead to the development of Pascal?

Definition
  • PL/I was developed because programmers had hoped there would be something for everyone in the language
  • It was considered the "swiss army" knife of all programming languages because of all the languages attached to it
  • It was considered a "fatal disease" because all the languages that became a part of PL/I all in all, made PL/I the union of all the languages that encompassed it, rather than the intersection
Term
*What was the idea behind extensible languages?
Definition
~ The idea behind extensible languages was that a language could be created where the programmer was capable of adding to that language to suit their needs
Term
*What did Wirth feel would be necessary for a new language to have a chance of competing with FORTRAN? What was his approach when designing Pascal?
Definition

~ Wirth wanted non-numeric data to be handled

    ~ wanted to maintain maintain the compile-time and run-time efficiency of FORTRAN

    ~his approach was to start with Algol-60, eliminate all ill-conceived or expensive features, and expand the data structuring capabilities

 

Term
*The Pascal design had explicitly stated goals; what were these goals? Did it meet them?
Definition

    1. The language should be suitable for teaching programming in a systematic way.

    2. The implementation of the language should be reliable and efficient at compile-time and run-time on available compilers.

    ~ the goals were met and the language had a paper and became an international standard in 1982.

Term
*Why was the spread of Pascal helped by the development in 1973 of a portable Pascal system including a compiler (written in Pascal and generating P-code) and a P-code interpreter written in Pascal?
Definition
    ~ This was helped by that development because it encouraged the use of Pascal on microcomputers in the late 70s and early 80s.
Term

*How can enumeration types improve security and efficiency?

 

what are some of the benefits of enumerated types?

 

should be comfortable with the declaration, operations, and use of enumeration types in Pascal; you may need to read, write code using these types.

Definition

~improved security because: you can find inappropriate-use errors earlier

    ~ efficient because: you know how "HOW MANY, compute the minimum number of bits to assign consecutive integer codes; (DayOfWeek only needs 3 bits to represent its 7 different values ...)"

Term
*How does Pascal address the dangling else problem?
Definition

    ~ pascal addressed the problem by making an else go with the preceding if

 -->by assuming that each else is paired with the nearest unmatched then.

Term
*Why is Pascal's set type considered (in the words of MacLennan) "almost an ideal data type"? What are some of its benefits?
Definition
    ~ in the words of MacLennon: it is high level and application-oriented, the benefits are that is is very efficient
Term
*What is the elegance principle of programming languages? should be able to give example(s) of features within Pascal that can be said to follow this principle;
Definition
    ~ confine your attention to designs that look good because they are good (the set type illustrates this)
Term
*What are some ways in which Pascal generalizes Algol arrays? ...restricts them? what two fundamental design decisions in Pascal led to problems with array bounds, in practice?
Definition
  ~ the allowable index types, element types
Term

 

*How do Pascal's and Algol's for-loops compare? what additional iteration control structures does Pascal include?

Definition

    ~ pascal for loop syntax: for {name} := <expression> {to | downto} <expression> do <statement>

    ~ one example of an algol-60 for loop: for <name> := <expression> step <expression> until <expression> do ( ...block ...)
Term
*What are the parameter-passing mechanisms in Pascal?
Definition
    ~ pascal can have pass by reference or value
Term

*From what area of research/work did Prolog arise?

Definition
~Artifical intelligence?
Term
*theorem-proving based on what is the foundation of Prolog? (resolution)
Definition
     ~ horn clauses (?)
Term
*What is a Prolog fact? rule/predicate? query? should be able to write/read all three of these, and be able to reason about them as Prolog would;
Definition

   ~ a prolog fact is a set of rules in which something is true

      ~a query can use these facts of predicates

      ~a predicate is pretty much prolog’s equivalent of an if statement

Term
*What is a Horn Clause? what does it mean? what does a Horn Clause look like in Prolog?
Definition

    -->rules are Horn Clauses  

        Horn Clause: in logic:            

                     c : consequent - an atomic formula in predicate logic

        h's: antecedents

        c <- h1 ^ h2 ^ h3 ^ ... hn

        in prolog it looks like c :- h1, h2, h3, ... hn.

Term
*What part of a Horn Clause is its consequent, goal, or head?
Definition
--> Conseqent is a Goal or a Head
Term
*What part of a Horn Clause is its antecedents, subgoals, or tail?
Definition
--> Antecedents are Subgoals or a Tail
Term
*What is a Horn Clause (in Prolog) with no tail also called?
Definition

-->a Horn clause with NO TAIL is a fact;

Term
*What is a Horn Clause (in Prolog) with a tail also called?
Definition

--> Horn clause with a Tail is a Prolog rule;

Term
*How does Prolog (including SWI-Prolog) tell that something is a variable?
Definition
--> it begins with a capital letter
Term
*What is an auxiliary variable in Prolog?
Definition

  -->a varaible that is ONLY on the RHS of the :-

        is an AUXILIARY VARIABLE; it is bound

        in the course of proving, BUT its

        binding is not reported to the user;

Term
*What is the scope of a variable in Prolog?
Definition

the scope of a variable is one rule;

        and Prolog does not mind binding two different variables

        to the same value...

Term

 

*What goes in a Prolog knowledge base? How do you load that knowledge base in SWI-Prolog?

Definition
    ~rules and predicates go into a prolog knowledge base, and can be loaded by [‘rules.pl’].
Term
*How can you express a list in Prolog?
Definition
 ~ a list in prolog can be expressed as the head and the tail, and so a list can be expressed as [HEAD|TAIL], [ ] is also a null list, and a list can also be a set: [a, b, c, d]
Term
*How does one write a recursive predicate/rule in Prolog?
Definition
~ callme(X,Y) :- callme(X,Y), send(Y).
Term
*How do you typically "repeat" in Prolog?
Definition
~ Recusion
Term
*What is a cut? What are its semantics and side-effects? Why is it useful?
Definition
  ~     ! -- cut 
Term
*What are the 3 main common uses of cut, according to Clocksin and Mellish?
Definition

~to tell the Prolog system that it has picked the "correct" rule for a particular goal;

~to tell the Prolog system to fail a particular goal immediately, without trying for alternative solutions;

~when we want to terminate the generation of alternative solutions through backtracking;

Term
Regardless of the language, What are the essential features of "proper" recursion?
Definition
~ A function that calls itself with a means to an end down the road .
Term
*How are Boolean operators (and, or, not) written?
Definition

~ not can be written as \+ ( ), not()

~ and is written as commas in prolog

~ or is the predicate on the next line after a “.” of the previous predicate.

Term
*What does = mean in Prolog? What does == mean?
Definition
= means some variable X is bound to what is on the right side; == means equivalence of the left and right; prolog will check to see if this turns out to be true.
Term
*How does one handle lists in Prolog? What are Prolog's alternatives to Scheme's car and cdr?
Definition
     ~ []
     ~ [H|T]
Term

*What does the protocol predicate cause to happen, in a SWI-Prolog session?

Definition

~ the procol predicate causes prolog to log anything typed and outputted into the file specified (protocol(“file_output”).)

Term
*How is the is operator used with arithmetic expressions? what is its effect?
Definition

~ this is used with the variable on the left side, is in the middle, and the rest on the right side. The effect is that the right side is evaluated and is then what X becomes, whereas using the equal sign will not evaluate X if it were arithemetic

Term

 

*You should be able to name at least one programming language which has significant support for programming in that paradigm (keeping in mind that some languages have support for multiple such paradigms)

Definition
*this language, designed to help in describing algorithms, was developed by committee between 1958-1960, and was very influential in future language development, since Pascal, C, and Ada (amongst others) are considered to be derivatives of it.
Term
*What are some of the concepts that it introduced?
Definition
*there have been a number of programming languages designed for teaching; which, with a compiler written in itself by 1970, also had goals of reliability, efficiency, and simplicity.
Supporting users have an ad free experience!