click below
click below
Normal Size Small Size show me how
ProgLang Finals
REVIEWER
Term | Definition |
---|---|
programming languages | facilitate the expression and communication of ideas. Language designers have a basic vocabulary about language structure, meaning, and pragmatic concerns that helps them understand how languages work. |
Principles of Language Design | Syntax, Names and Types, Semantics |
Syntax | a language describes what constitutes a structurally correct program. |
Names and Types | The vocabulary of a programming language includes a carefully designed set of rules for naming entities-variables, functions, classes, parameters, etc. |
Names of entities also have other properties during the life of a program, such as: | scope, visibility, and binding |
simple types | integers, decimal numbers, characters, and boolean values |
Structured types | include character strings, lists, trees, and hash tables |
complex types | functions and classes |
Semantics | meaning of a program is defined by this principle. That is, when a program is run, the effect of each statement on the values of the variables in the program |
paradigm | a pattern of thought that guides a collection of related activities |
paradigm | a standard, perspective, or set of ideas. |
paradigm | a way of looking at something. |
programming paradigm | a pattern of problem-solving thought that underlies a particular genre of programs and languages |
Four distinct and fundamental programming paradigms have evolved over the last few decades: | Imperative programming, Object -oriented programming, Functional programming, Logic programming |
Imperative Programming | the oldest paradigm and in this model both the program and its variables are stored together, and the program contains a series of commands that perform calculations, assign values to variables, retrieve input, produce output, or redirect control |
Imperative Programming | describe the details of HOW the results are to be obtained, in terms of the underlying machine model |
Imperative Programming | change the program's state through assignment statements, loops, and control structures like conditionals. |
Imperative programming in C | writing code with explicit instructions on what the computer should do, using loops, conditionals, and direct manipulation of variables |
Imperative programming in Java | uses explicit instructions to manipulate variables and control flow through loops and conditionals. |
Key Characteristics of Imperative Programming | Sequential Execution, State Changes, Explicit Control Structures |
Sequential Execution: | Both examples show a sequence of steps to perform the calculation. |
State Changes | The sum variable's state changes in each iteration of the loop. |
Explicit Control Structures | Both use a for loop to control the flow of the program. |
Object-Oriented Programming | a programming paradigm centered around the concept of "objects.“ |
Objects | represent real-world entities or abstract concepts, encapsulating both data (attributes or properties) and behaviors (methods or functions) related to them. |
Functional Programming | models a computational problem as a collection of mathematical functions, each with an input and a result spaces. |
Functional Programming | emphasizes the use of pure functions, higher-order functions, and immutable data structures. |
Logical Programming | allows a program to model a problem by declaring what outcome the program should accomplish, rather than how it should be accomplished. |
Logical Programming | Sometimes these languages are called rule-based languages, since the program's declarations look more like a set of rules, or constraints on the problem, rather than a sequence of commands to be carried out. |
Syntax | the form of a program, a programming language is a precise description of all its grammatically correct programs. can be described by a set of rules, just as it is for natural languages. |
Semantics | meaning of a program or expressions. |
Language | A group of words that can be combined and the rules for combining those words. |
Sentence | A legal statement in the language. |
Lexeme | The lowest level syntactic unit in the language. |
Token | A language category for the lexemes. |
lexical syntax | defines the rules for basic symbols including identifiers, literals (e.g., integer and floating point), operators, and punctuation. |
concrete syntax | refers to the actual representation of its programs using lexical symbols as its alphabet. |
abstract syntax | carries only the essential program information, without concern for syntactic idiosyncrasies like punctuation or parentheses. |
Grammar | syntax of a language can be largely specified using a formalism |
Grammar | written in a language-description-language, or metalanguage, and its purpose is to define all the legal strings of characters that can form a syntactically valid program. |
Context-free grammar (CFG) | a type of formal grammar used to describe the syntax of programming languages, natural languages, and other formal languages. |
Backus-Naur Form (BNF) Grammar | adapted from Chomsky's theory by John Backus and Peter Naur to express a formal syntactic definition for the programming language Algol |
year 1960 | BNF was adapted from Chomsky's theory |
Backus-Naur Form (BNF) Grammar | sometimes used as a synonym for context-free grammar. |
production | a rule for rewriting that can be applied to a string of symbols called a sentential form |
production is interpreted as follows: | the nonterminal A can be replaced by w in a sentential form |
symbol A | often called the left-hand side |
string w | called the right-hand side of the production |