CS 4337 Midterm

Ace your homework & exams now with Quizwiz!

How are boolean results represented in racket

#f, #t

Racket How do I declare a Non Lambda Function

(define (function_name, [args]) (<operations on args>))

Who is John Backus? (2)

-directed the team that invented and implemented FORTRAN, the first widely used high-level programming language --The inventor of the Backus-Naur Form, a notation used to define formal language syntax.

(4.3) What are the two goals of the parser

1. Find All Syntax Errors in the given input program 2. Generate a parse tree for that program

What are the 5 main programming domains

1. Scientific Applications 2. Business applications 3. Artificial Intelligence 4. Systems Programming 5. Web Software

(3.2) Define Language:

A Language is characterized by the set of all valid statements (i.e. strings) in that language. The cardinality of this set is potentially infinite

(1.7) Define Von Neumann bottleneck

Bottleneck that results from the fact that instructions often can be executed faster than they can be moved to the processor for execution, from memory. Often makes memory speed be the limiting factor in a computers speed.

(1.7) Define Hybrid Implementation

Compromise between compilers and pure interpreters; they translate high-level language programs to an intermediate language designed to allow easy interpretation.

(1.7) Define Load Module/Executable Image

Defined User code, combined with code provided by the OS in order to ensure proper compilation.

Backus Naur Form was created to?

Describe the syntax of Algol 58

True or False Parse Tree shape is affected by derivation technique used (Left or Right)

False

(1.3) Define Generality and Well Definedness

Generality: How applicable a language is to a wide array of applications Well Definedness: the completeness and precision of the language's official defining document

Describe how a Top Down Parser would work

Given a sentential form, xAα , the parser must choose the correct A-rule to get the next sentential form in the leftmost derivation, using only the first token produced by A.

Left Most Deriviation vs Right Most Deriviation

Left Derivation: Derivation technique where always chose the leftmost nonterminal for expansion Right Derivation: Derivation technique where we chose the rightmost non terminal for expansion.

Who created CFG

Noam Chomsky

(1.3) Define Portability

Portability is the ease with which programs can be moved from one implementation to another, and is most strongly influenced by the degree of standardization of the language. Some languages are not standardized at all, making it difficult to move programs. Standardization is a time-consuming and difficult process;.

How do we prove ambiguity

Proof By contradicition: Draw two parse trees and for a single string to show ambiguity

What does the cons Operator Do

Returns a dotted pair, when used with two non list arguments, else it appends the first item to the list in the second item.

What does the cdr operator do

Returns the entire list without the first argument or the second argument in a dotted pair.

What does the car operator do

Returns the first element of the list or dotted pair

(3.1) Define Semantics

Semantics: the meaning of the expressions, statements, and program units

(3.2) Define these terms: Sentence Language Lexeme Token

Sentence: is a string of characters over some alphabet Langugae: is a set of sentences Lexeme: is the lowest level syntactic unit of a language, i.e (myVar, if etc) Token: Category of Lexemes (i.e Identifier, Verb, noun etc)

(1.7) Define Preprocessors

Special Programs designed to process a source code program before it is compiled, preprocessor instructions are often embedded within the code files, (such as import statements). Most common use of preprocessors is to include code from other files.

(1.3) Unix shell commands such as grep are seen as violations of

Syntax Design Characteristic

(3.1) Define Syntax

Syntax: the form or structure of the expressions, statements, and program units

True or False Most Language Parse from left to right

True

(15) cond statment

if <bool_1> true expr 1 is run and so on... else statement is optional and associated expression will only run if <bool_1...n> is undefined.

When is production left recursive

A grammar is Left recursive if the leftmost variable on the RHS is the same as the variable on the LHS

(1.3) Explain the Reliability Language Evaluation Criterion

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

(1.7) Define the compiler implementation

A program is translated into machine language and is directly executed on the computer.

When is a production right recursive

A recursive grammar is said to be right recursive if the rightmost variable of RHS is same as variable of LHS.

(15) When conditional Format

<expr1> Is executed if bool is true (similar to if without else statement)

(15) If conditional Format

<expr1> executes if bool is true <expr2> executes if bool is false All 3 statements must be present. (like a if with an else statement)

In Racket Functions that return Boolean Values have

? at the end.

*****REVIEW SECTION 1.4.2*******

*****REVIEW SECTION 1.4.2*******

General Information About Psuedocode (3)

- Language used in the 1940s and 50s o primitive computers that could only read machine code -Extremely difficult to read and write -Was error prone -Inserting/deleting an instruction, made all succeeding code invalid.

General Information About Plankulul (6)

-Created by Conrad Zuse in 1945 -The simplest data type in Plankalkül was the single bit. -Integer and floating-point numeric types were built from the bit type. -Although the language had no explicit goto, it did include an iterative statement similar to the Ada for. -Plankalkül included a selection statement, but it did not allow an else clause. -Used mathematical expressions showing the current relationships between program variables.

General Infromation about LISP Programming language (3)

-First functional programming language -Provided language features for list processing, which was heavily used in AI -repetition was specified using recursion, instead of loops

General Information about the IBM 704 and Fortran (7)

-IBM 704 was the first computer to have dedicated hardware to have both indexing and floating point instructions In its hardware. Ending Interpretive overhead costs. -Fortran 0: Document during implementation phase that described all inital features of fortran -Fortran 1: First release of fortran, allowed for input/output formatting, variable names, if and loop statements, subroutines, -Fortran 1: Did not support proper typing systems, variables whose names started with specific letters were ints, everything else float -Fortran 1 was primarily based on 704 instructions -Fortran 2: Brought support for indepedent subroutine compilation -Fortrasn 1 and onwards prevented any memory allocation for variables to occur at runtime

General Information about Perl

-Scripting language created by Larry Wall -Originally used as a utility in UNIX for processesing text files, but has other uses.

Describe axiomatic Semantics (2)

1. Based On Mathamatical Logic 2. Specifies what can be proven by the program

(4.2) What is a Lexical Analyzer (4)

1. Can be described as a pattern matcher for strings, 2. can be seen as the front end of the parser. 3. Basically Identifies substrings of the source problem that belong together. Usually Called as a function by the parser when it needs to extract the next token.

Describe Denotational Semantics (2)

1. Denotational semantics is the most rigorous and most widely known formal method for describing the meaning of programs 2. based on recursive function theory

What are the 6 reasons people study concepts of programming languages

1. Increased capacity to express ideas. 2. Improved background for choosing appropriate languages. 3. Increased ability to learn new languages. 4. Better understanding of the significance of implementation. 5. Better use of languages that are already known. 6. Overall advancement of computing.

(1.7) Describe the compiler implementation process

1. Lexical Analyzar translates source code into lexical units 2. Syntax analyzer converts lexical units into parse trees 3. Intermediate code generator converts the code into assembly language (or assembly like), while semantic analyzer checks for errors 3.5: Optimization (if present) is done on intermediate code 4. Code Generator translates intermediate code into machine code

Problems With Operational Semantics (2)

1. The individual steps in the execution of machine language and the resulting changes to the state of the machine are too small and too numerous 2. The storage of a real computer is too large and complex □ There are usually several levels of memory devices, as well as connections to enumerable other computers and memory devices through networks

3 Properties of Extended BNF Forms

1. [<expression>] denote optional parts 0 or 1 occurances 2. {<expression>} denote repitions 0 to many occurances 3. (<operator> | <operator>) <expression> denote alternate parts i.e (+\-) <expression>)

(1.3) Describe the Restricted Aliasing Characteristic

Aliasing is defined as having two or more distinct names in a program that can be used to access the same memory cell. It is a dangerous feature in a programming language, and can be prohibited by the design of a language. In some languages, aliasing is used to overcome deficiencies in the language's data abstraction facilities, while in others it is prohibited to increase reliability.

Explain the define Keyword in Racket

Allows us to define a value to a variable, construct or function. Can also override existing values, (define + *) will make all + operator multiply their operands.

Polish Notation

Arithmatic Notation, for compilers to read, when you reach an operator it is done on the previous two values which should be operands

(1.2) Explain how programming languages are used in Artifical Intelligence

Artificial intelligence (AI) is a broad area of computer applications characterized by the use of symbolic rather than numeric computations. The first widely used programming language for AI applications was the functional language Lisp, which appeared in 1959. During the early 1970s, an alternative approach to AI applications appeared—logic programming using the Prolog language. More recently, some AI applications have been written in systems languages such as Python.

Explain how Studying concepts programming languages help programmers achieve an "Increased ability to learn new languages."

Computer programming is still a young discipline, and design methodologies, software development tools, and programming languages are still in a state of continuous evolution. Learning a new programming language can be difficult, but once an understanding of the fundamental concepts of languages is acquired, it is easier to see how these concepts are incorporated into the design of the language being learned. Practicing programmers need to know the vocabulary and fundamental concepts of programming languages so they can read and understand programming language descriptions and evaluations, as well as promotional literature for languages and compilers.

Who is Ada Lovelace?

Created the first programming language, to be used with Charles Babbage's analytical engine.

Who is John Von Neumann?

Creator of the von Neumann computer architecture, which is still the prevalent architecture today in most computer.

(3) Generator approach for describing syntax

Defined as a device that generates sentences of a language, one can determine if a language is sytactically correct by comparing it to the structure of the generator

(3) Recongnizer approach to describe a language

Defined as a recognization device that reads input strings over language alphabet, and decides whether the input string should belong to the language.

Who is Donald Knuth?

Designed the original LR algorithm (canonical LR) for LR parsers and attribute grammars

(15) How would you describe a racket Expression

Everything in Racket is an expression and are represented by lists.

(1.3) Describe the Exception Handeling Characteristic

Exception handling is the ability of a program to intercept run-time errors and take corrective measures, which is essential for reliability. Ada, C++, Java, and C# have extensive capabilities for exception handling, but not C.

(1.3) Describe the Expressivity Characteristic

Expressivity in a language can refer to several characteristics. In APL, there are powerful operators that allow a great deal of computation to be accomplished with a small program. In C, the notation count++ is more convenient and shorter than count = count + 1. In Ada, the and then Boolean operator is a convenient way to specify short-circuit evaluation of a Boolean expression. In Java, the for statement makes writing counting loops easier than with the use of while. These characteristics increase the writability of a language.

(1.4) What is the fetch-execute cycle? And what does it do?

For Each instruction to be executed it 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. Algorithm in image

(15). The first argument in a list is assumed to be a _____ how do we bypass this assumption

Function, use a tick mark.

(15) What does it mean in racket when functions are "First Class citizens"

Functions can be passed as other arguments into functions, and can be stored in variables or data structures.

Describe Story around ambiguity between if else then statment

If then statement was originally ambigious to solve this parsers only accepted code where an else clause matches to the nearest unmatched then clause, and code could not contain if statement without an else clause between a then clause and its matching else.

General Information about Java (2)

Imperative Object Orientated Programing language based on C++ but was much safer, smaller and simpler. -Removed many excess and unsafe features from C++, to provide for better reliability

Who is Charles Babbage

In 1842, he designed an analytical engine that performed general calculations automatically.

(1.7) Define Byte code

In Java source code is compiled down to byte code which is then interpretated.

Explain how Studying concepts programming languages help programmers achieve an "Overall advancement of computing"

Many people believe that the most popular programming languages are not always the best available. For example the programmers and software development managers of the early 1960s, who did not understand the conceptual design of ALGOL 60 and did not appreciate the benefits of block structure, recursion, and well-structured control statements. If those who choose languages were well informed, better languages would eventually squeeze out poorer ones.

(1.3) Define optimization

Optimization is the collection of techniques that compilers may use to decrease the size and/or increase the execution speed of the code they produce. It is influenced by the environment in which the compiler is used, such as a laboratory for beginning programming students or a production environment where compiled programs are executed many times after development. Little or no optimization should be done in a laboratory, while in a production environment it is better to pay the extra cost to optimize the code.

General Information about Prolog

Logic Programming language whose primary components are are a method for specifying predicate calculus propositions and an implementation of a restricted form of resolution.

(1.3) Describe the Orthogonality Characteristic

Orthogonality in a programming language allows a small set of primitive constructs to be combined in a small number of ways to build control and data structures. For example, if a language has four primitive data types and two type operators, a large number of data structures can be defined. A lack of orthogonality leads to exceptions to the rules of the language, such as if pointers are not allowed to point to arrays, many useful user-defined data structures cannot be defined. Orthogonity is closely related to simplicity, with fewer exceptions meaning a higher degree of regularity in the design, making the language easier to learn, read, and understand.

Describe these axiomatic semantics terms Precondition: Postcondition: Weakest Precondition:

Precondition: An assertion before a statement states the relationships and constraints among variables that are true at that point in execution Postcondition: An assertion following a statement Weakest Precondition: least restrictive precondition that will guarantee the postcondition

Explain how Studying concepts programming languages help programmers have "Improved background for choosing appropriate languages"

Professional programmers often lack formal education in computer science and have developed their programming skills independently or through in-house training programs, limiting instruction to one or two languages that are relevant to the current projects. This has resulted in many programmers using the language with which they are most familiar, even if it is poorly suited for the project at hand. If these programmers were familiar with a wider range of languages and language constructs, they would be better able to choose the language that best addresses the problem.

Explain how Studying concepts programming languages help programmers have " Increased capacity to express ideas."

Programmers are often constrained by the language in which they develop software, (i.e limiting the kinds of control structures, data structures, and abstractions they can use). Awareness of a wider variety of programming language features can reduce these limitations and increase the range of their software development thought processes by learning new language constructs.

Explain how Studying concepts programming languages help programmers have "Better use of languages that are already known"

Programming languages are large and complex, making it difficult for programmers to be familiar with and use all of the features. By studying the concepts of programming languages, programmers can learn about previously unknown and unused parts of the languages they already use and begin to use those features.

(1.7) Define Pure Interpretation Implementation

Pure interpretation is an implementation method that uses an interpreter to interpret programs. It has the advantage of allowing easy implementation of source-level debugging operations, but has the disadvantage of being 10-100 times slower than compiled systems due to the decoding of high-level language statements. It also requires more space as the symbol table must be present during interpretation. Additionally, the source program may be stored in a form designed for easy access and modification rather than one that provides minimal size.

(1.2) Explain how programming languages are used in Systems Programming

Requires efficiency because of continus use C: The language of systems programming, unix is made in C, windows is made in C, and since macos is made on the Darwin kernel, its also written in C. So at that point in time of life, now you don't have to reboot your PC Then the first OS came out that can have two programs running at the same time, one would be 'live', the other would be 'paused' - that OS is called Moltix, where as the operating system that was doing one thing at a time 'unix'. But people kept calling unix as moltix was hard to say and people were used to unix.

(1.3) Describe the Syntax design Characteristic (what are syntax designs that increase readbility)

Special Words: Special words are important for program appearance and readability. They are used to form compound statements, or statement groups, primarily in control constructs. Some languages have used matching pairs of special words or symbols to form groups, while C and its descendants use braces to specify compound statements. Fortran 95 and Ada (ISO/IEC, 2014) make this clearer by using a distinct closing syntax for each type of statement group. Another important issue is whether the special words of a language can be used as names for program variables. In Fortran 95, special words such as Do and End are legal variable names, so the appearance of these words in a program may or may not connote something special, leading to confusion. Form and Meaning: Form and meaning should follow directly from syntax, but this principle can be violated by two language constructs that are identical or similar in appearance but have different meanings depending on context. For example, the meaning of the reserved word static depends on the context of its appearance. If used on the definition of a variable inside a function, it means the variable is created at compile time. If used on the definition of a variable that is outside all functions, then it means the variable is visible only in the file in which its definition appears; Designing statements so that their appearance at least partially indicates their purpose is an obvious aid to readability.

Describe Operational Semantics

The Idea is to describe the meaning of a statement or program by specifying the effects of running it on a machine, the effects are viewed as a sequence of changes on its state

(1.2) Explain how programming languages are used in Web Software

The World Wide Web is supported by a variety of languages, ranging from markup languages such as HTML to general-purpose programming languages such as Java. Because of the need for dynamic Web content, computation capability is often provided by embedding programming code in an HTML document, often in the form of a scripting language such as JavaScript or PHP. There are also markuplike languages that have been extended to include constructs that control document processing.

(1.2) Explain how programming languages are used in Scientific Applications

The first digital computers, which appeared in the late 1940s and early 1950s, were used for scientific applications that used relatively simple data structures but required large numbers of floating-point arithmetic computations. The early high-level programming languages invented for scientific applications were designed to provide for those needs, such as Fortran, (efficiency was a primary focus for these languages since they competed with assembly). ALGOL 60 and most of its descendants were also intended to be used in this area, but no subsequent language is significantly better than Fortran, which explains why Fortran is still used.

(1.3) Explain the Readability Language Evaluation Criterion

The most important criteria for judging a programming language is the ease with which programs can be read and understood. Before 1970, software development was largely thought of in terms of writing code. In the 1970s, the software life-cycle concept was developed and maintenance was recognized as a major part of the cycle. This was an important transition from a focus on machine orientation to a focus on human orientation. Readability became an important measure of the quality of programs and programming languages.

(1.3) Describe the Simplicity Characteristic (how does feature multiplicity, and operator overloading affect simplicity)

The overall simplicity of a programming language affects its readability. A language with a large number of basic constructs is more difficult to learn than one with a smaller number. Programmers who must use a large language often learn a subset of the language and ignore its other features. Readability problems occur when the program's author has learned a different subset from that which the reader is familiar. Feature Multiplicity: Language having more than one way to do a certain task, (i.e Java and adding 1 to a int var), reduces simplicity as the reader might not know a certain way to achieve a feature that the author has implemented Operator Overloading: Single operator (+,-, / etc) can have more than one meaning, reduces simplicity as the reader might be used to using a specific operator in a different way than what the authored intended it to be used in their program.

(1.3) Describe the Data Type Characteristic

The presence of adequate facilities for defining data types and data structures in a language is essential for readability. For example, in the original version of C numeric types where used to throw exceptions as booleans did not exist, an assignment such as "timeout = 1" would be unclear, but in a language with Boolean types, it would be "timeout = true" which is easier to understand.

(1.7) What is Linking and Loading aka just linking

The process of collecting system programs and linking them to user programs, this often done by a system of programs called a Linker.

(1.3) Define Cost

The total cost of a programming language is a function of many factors, such as the cost of training programmers, the writability of the language, the cost of writing programs in the language, and the cost of executing programs. Additionally, there is the cost of poor reliability, which can be very expensive in terms of lost future business or lawsuits over defective software systems. The cost of maintaining programs also depends on language characteristics, primarily readability.

(1.2) Explain how programming languages are used in Business Applications

The use of computers for business applications began in the 1950s, with COBOL (ISO/IEC, 2002) being the first successful high-level language. It is still the most commonly used language for these applications, with facilities for producing elaborate reports, describing and storing decimal numbers and character data, and specifying decimal arithmetic operations.

(1.4) How has Computer Architecture affected Programming Languages (What is Von Neuman Archetecture)

The von Neumann architecture has had a profound effect on language design, as most popular languages of the past 60 years have been designed around it. In a von Neumann computer, both data and programs are stored in the same memory, and instructions and data must be transmitted from memory to the CPU. Nearly all digital computers built since the 1940s have been based on the architecture.

(1.4) Describe how the von Neumann Architecture works

The von Neumann architecture of imperative languages is characterized by variables, assignment statements, and the iterative form of repetition. These features are piped from memory to the CPU and piped back to the memory cell represented by the left side of the assignment. Iteration (instead of recursion) 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 branch instruction.

Top Down Vs Bottom Up Parser

Top Down: Produces the Parse tree at the beginning of the root, used for grammars that have right recursion and expands node via leftmost derivation. Bottom Up: Produces the parse tree begenning at the leaves, used for grammars that have left recursion and expand node via rightmost derivation

(1.3) Describe the Type Checking Characteristic

Type checking is an important factor in language reliability, as run-time type checking is expensive and the earlier errors are detected, the less expensive it is to make repairs. Java requires checks of the types of nearly all variables and expressions at compile time, eliminating type errors at run time.

Explain how Studying concepts programming languages help programmers have "Better understanding of the significance of implementation."

When learning programming languages, it is important to understand the implementation issues that affect them. This knowledge can lead to an understanding of why languages are designed the way they are, as well as the ability to use a language more intelligently. Additionally, it allows us to visualize how a computer executes various language constructs and provide hints about the relative efficiency of alternative constructs. For example, programmers who know little about the complexity of the implementation of subprogram calls may not realize that a small subprogram that is frequently called can be a highly inefficient design choice. Also certain bugs can only be fixed if a programmer knows implementation details about a language.

(1.3) Explain the Writability Language Evaluation Criterion

Writeability is a measure of how easily a language can be used to create programs for a chosen problem domain. It is affected by the same language characteristics that affect readability. Writability must be considered in the context of the target problem domain, as it is not fair 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. For example, Visual BASIC (VB) and C are dramatically different for creating a program that has a graphical user interface (GUI), for which VB is ideal, and for writing systems programs, such as an operating system, for which C was designed.

Define Accumulator

extra numerical function argument that is incremented, decrements, or an extra list function argument that is incrementally built, i.e. "accumulated"

A Grammar is Ambigious if and only if

if it generates a single sentential form that has two or more distinct parse trees


Related study sets

Local Anesthesia and Vasoconstrictors

View Set

World's Biggest, Tallest, Longest, and Smallest

View Set

Review Questions - Module 6 - Wireless Networking

View Set

BUSMHR 2500 Chapter 4 Creativity and The Business Idea

View Set