Wikipendium

History Compendium
Log in
This is an old version of the compendium, written Oct. 14, 2014, 6:11 a.m. Changes made in this revision were made by ilsegv. View rendered version.
Previous version Next version

TDT4165: Programming Languages

# Definitions Syntax : The set of rules that defines the combinations of symbols that are recogized as sentences. Semantics : Defines what programs do when executed. Syntactic sugar : Adds a shorthand in the syntax, but does not create a new semantic. Compiling : Source code is used to produce a executable binary which can be run on the target machine. Interpreting : The program reads the source code when run. Lexical analyzer : Reads characters and turns them into tokens ('i''f' to 'if'). Parser : Reads tokens and outputs a syntax tree. ## Linguistic abstraction Abstraction and addition to a language, by using already existing concepts of the language _Example:_ use `proc` to define `fun` # Programming paradigms Object oriented : Objects encapsulate data and methods. Objects send messages and execute operations on receiving messages. Imperative : The program consists of a sequence of statements which update the state of variables. Usually close to the underlying hardware. Declarative : The program specifies what needs to be done and let the language decide how it is done. Functional : Programs consist of functions that compute values based on input. Lazy execution : Expressions are not evaluated until they are needed. Concurrent : Programs are able to do several operations at the same time. Logic programming : A program is a set of logical assertions and can be used to find out if a query is true. ## Declarative programming - stateless - indepent - deterministic In other words, every time you run a declarative program with the same input (or just a declarative component) it will give you the same result (i.e. output). ### Observal declarativity A component can be seen as declarative if the definition is, even though the implementation is not _Example:_ A database with a declarative interface. ## Higher-order programming Use procedure values in programs. (E.g. pass procedures as arguments to other procedures) __Closure__ = procedure value. Four basic operations underlie all techniques in higher order programming ### Procedural abstraction Any statement can be put into a procedure. ### Genericity The ability to pass procedure values as arguments to a procedure call. ### Instatiation The ability to return procedure values as results from a procedure call. ### Embedding Put procedure values in data structures # EBNF Extended Backus-Naur Form is at metalanguage. It is used to write the grammar of other languages. The rules of grammar of a language can be expressed like this: $$ \langle c \rangle ::= \epsilon | a \langle c \rangle a | $$ EBNF consists of terminals and variables. The slides use V for variables and S for symbols. ## Chomsky's hierarchy of languages ### Unconstrained languages All grammar is of the form $$ a ::= b $$
where $a,b \in (V \unioncup S)$.
### Context-sensitive languages All rules are of the form $$ avb ::= ayb $$
where $v \in V$ and $a,b,y \in (V \unioncup S)$.
### Context-free languages Generated by context-free grammar. This means that every production rule is of the form $$ A \rightarrow a' $$ where A is a variable and a' a sequence of variables and terminals. ### Regular languages A regular language is generated by regular grammar. $$ v ::= s v' $$ $$ v ::= s $$ $$ v ::= \epsilon $$ $$ s \in S; v, v' \in V $$ # Oz ## Functions and procedures ## Higher order functions ## Dataflow ## Records ## Concurrency ## Lazy evaluation ## Streams ## Explicit state ## Encapsulation ## Inheritance ## Pattern Matching ## Declarativity ## Non-determinism
  • Contact
  • Twitter
  • Statistics
  • Report a bug
  • Wikipendium cc-by-sa
Wikipendium is ad-free and costs nothing to use. Please help keep Wikipendium alive by donating today!