1/92
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is a programming language?
Programmers use programming languages to instruct computers to do things.
Syntax
The structure of programs (tokens, keywords, statements)
Semantics
The expected behavior of a given syntactical construct.
Meaning of a language
- Describes the effects of executing the code
- Difficult to provide a comprehensive description of meaning in al contexts
Programming language
a notation for communicating to a computer what we want it to do
What did John von Neumann propose?
proposed that computers should be permanently hardwired with a small set of general-purpose operations.
Opcode
the first 4 bits of a line of code
indicates the type of operation to be performed
Next 12 bits contain code for the instructions operands.
Assembly language
a set of mnemonic symbols for instruction codes and memory locations
Assembler
a program that translates the symbolic assembly language code to binary machine code
Loader
a program that loads the machine code into computer memory
FORTRAN
FORmula TRANslation language
- developed by John Backus in the early 1950s
- Reflected the architecture of a particular type of machine
- lacked the structured control statements and data structures of later high-level language
ALGOL
ALGOrighmic Language released in 1960.
- Provided a standard notation for computer scientists to publish algorithms in journals.
- Included structured control statements for sequencing (begin-end blocks), loops (for loop), and selection (if and if-else statements)
- Supported different numeric types
- Introduced the array structure
- Supported procedures, including recursive procedures
- Achieved machine independence with the requirement for an ALGOL compiler with each type of hardware
Compiler
Translates programming language statements into machine code
ALGOL was the first language to receive a formal specification or definition
Pascal
language for teaching programming in the 1970s
Descended form ALGOL
Ada
For embedded applications of U.S Dept of Defense
Lambda Calculus
Computational model developed by mathematician Alonzo Church
Based on the theory of recursive functions.
Lisp
Programming language that uses the functional model of computation
What are the two types of programming abstractions?
Data abstraction
Control Abstraction
Data Abstractions
simplify the behavior and attributes of data for humans
Examples: numbers, character strings, search trees
Control Abstractions
simplify properties of the transfer of control
Examples: loops, conditional statements, procedure calls
Basic Abstractions
Collect the most localized machine information
Ex: Memory, registers, variables.
Structured Abstractions
Collect intermediate information about the structure of a program
Ex: Array’s, linked lists, structs, interface.
Unit Abstractions
Collect large-scale information in a program
Ex: Global variables, Packages, libraries
Basic data abstraction
Hides internal representation of common data values.
Values are also called "primitive' or "atomic" because the programmer cannot normally access the component parts or bits of the internal representation
Variables
Use of symbolic names to hide computer memory locations containing data values
Data types
names given to kinds of data values
Declaration
The process of giving a variable a name and a data type
Data Structure
collects related data values into a single unit
Hides component parts but can be constructed from parts, and parts can be accessed and modified
Array
a sequence of individually indexed items with the same data type
Information Hiding
defining new data types (data and operations) that hide information
Unit abstraction
often associated with the concept of an abstract data type
a set of data values and the operations on those values
Interface
a set of operations available to the user
Implementation
Internal representation of data values and operations
Unit abstraction also provides ___________________
Reusability
Typically __________ are entered into a __________ and become the basis for library mechanisms
components, library
Application programming interface (API)
gives information about the resource's components
Basic control abstractions
statements that combine a few machine instructions into an abstract statement that is easier to understand
Syntactic Sugar
A mechanism that allows you to replace a complex notation with a simpler shorthand notation
Ex: x += 10 instead of x = x+10
Branch Instructions
Instructions that support selection and iteration to memory locations other than the next one
Iterator
an object associated with a collection (such as array, list, set, or tree)
Procedure (or subprogram or subroutine)
groups a sequence of actions into a single action that can be called or invoked from other points in the program
Procedure Declaration
names a procedure and associates it with the actions to be performed
invocation (or procedure activation)
the act of calling the procedure
Parameters
values that can change from call to call
Arguments (or actual parameters)
values supplied by the caller for the parameters
Runtime environment
The system implementation of the program
- Stores information about the condition of the program and the way procedures operate
Function
closely related to a procedure
- returns a value or result to its caller
- can be written to a correspond more closely to mathematical abstractions
Recursion
a mechanism that further exploits the abstraction mechanism.
Higher-order Functions
functions that can accept other functions as arguments and return functions as values
map functions
expects another function and a collection as arguments
applies the argument functions to each element in the argument collection and returns a list of results
Unit
a stand-alone collection of procedures providing logically related services to other parts of a program
Allows a program to be understood as a whole without needing to know the details of the services provided by the unit
Threads
other programs executing outside the Java system
Task
mechanism in Ada for parallel execution
Imperative Language
a language with three properties
-Sequential execution of instructions
-Use of variables representing memory locations
-Use of assignment to change the values of variables
Paradigm
Pattern
von Neumann Bottleneck
requirement that a program be described as a sequence of instructions
Functional Paradigm
Based on the abstract notion of a function in lambda calculus
Logic Paradigm
Based on symbolic logic
Object-oriented paradigm
Reusable code that operates in a way to mimic behaviors of real-world objects
Language Syntax
similar to the grammar of a natural language
Grammar
formal definition of the language's syntax
Lexical structure
structure of the language's words
similar to spelling in natural languages
Tokens
the language's words
includes keywords, identifiers, symbols for operations, special punctuation symbols, etc.
Are there any generally accepted formal methods for describing semantics
No.
Translator
a program that accepts other programs and either directly executes them or transforms them into a form suitable for execution
What are the two major types of translators
Interpreter and Compiler
Interpreter
Executes a program directly
Compiler
Produces an equivalent program in a form suitable for execution
Compilation requires at least two steps...
Source program - input to the compiler
Target program - output from the compiler
What must a target program be?
- Translated by an assembler into an object program
- Linked with other object programs
- Loaded into appropriate memory locations
Target language may be ____ _____
byte code
Byte code
a form of low-level code
Virtual machine
written differently for different hardware architectures
Efficiency of execution
primary design criterion
- Early FORTRAN code more or less directly mapped to machine code, minimizing the amount of translation required by the compiler
Writability
the quality of a language that enables a programmer to use it to express computation clearly, correctly, concisely, and quickly
Efficiency
usually thought of as efficiency of the target code
Programmer efficiency
how quickly and easily can a person read and write in the programming language?
Expressiveness
how easy is it to express complex processes and structures?
Regularity
refers to how well the features of a language are integrated
Languages that satisfy the criterion of regularity are said to adhere to the _________________
principle of least astonishment
Regularity can be subdivided into three concepts
- Generality
- Orthogonal design
- Uniformity
Generality
achieved by avoiding special cases in the availability or use of constructs and by combining closely related constructs into a single more general one
Orthogonal design
constructs can be combined in any meaningful way, with no unexpected restrictions or behaviors
Uniformity
a design in which similar things look similar and have similar meanings while different things look different
Can classify a feature or construct as irregular if it lacks one of these three qualities
Value Semantics
Values are copied during assignment
Reference semantics
Two references to the same object
Security
is the program going to make the computer crash?
Semantically safe
languages that prevent a programmer from compiling or executing any statements or expressions that violate the language definition
Extensible language
a language that allows the user to add features to it
Macro
specifies the syntax of a piece of code that expands to other standard code when compiled
Availability
a lot of people coding it
Portability
easy to move between cpus
What is a pure function?
They only operate on their input parameters
Functional programming
Provides a uniform view of programs as functions
Treat functions as data
Provides prevention of side effects.