Unit 2 - Declarative
Unit 2 - Declarative
PROGRAMMING
PARADIGM
INTRODUCTION
◦Declarative programming is a programming paradigm that expresses the
logic of a computation without describing itscontrol flow.
◦This paradigmoften considers programs as theories of a formal logic,
and computations as deductions in that logic space.
◦Declarative programming is often defined as any style of programming
that is not imperative.
◦Common declarative languages include those of database query
languages (SQL), logic programming, functional programming, etc.
HISTORY
DECLARATIVE
FUNCTIONAL LOGIC
- Lambda calculus - First Order Logic
- Lisp - Prolog
OVERVIEW
◦A programthat describes what computation should be
performed and not how to compute it. Non-imperative,
non-procedural.
◦Any programming languagethat lacksside effects(example: a
function mightmodify a global variable or static variable,
modify one of its arguments, raise an exception,).
◦A languagewith a clear correspondence to mathematical
logic.
OVERVIEW – Logic Paradigm
◦Computing takes place overthe domainof all terms
defined over a “universal” alphabet.
◦Valuesare assigned to variables bymeans of
automatically generated substitutions, called most
general unifiers. These values may contain variables,
called logical variables.
◦Thecontrol is provided bya single mechanism: automatic
backtracking.
Declarative Semantics Vs Imperative Semantics
◦In declarative semantics the meaningof a given proposition
in a logic programming languagecan be concisely determined
from the statement itself.
◦In an imperative language, the semantics of a simple
assignment statement requires examination local declarations,
scoping rules of the language, typesof variables in the
assignment statement, depends on its run-time context.
SQL - StructuredQuery Language
◦SQL is the standardlanguageused to communicate with a
relational database.
◦ In WPF, XAML forms a user interface markup language to define UI elements, data binding,
eventing, and other features. Anythingthat is created or implemented in XAML can be
expressed using a more traditional .NET language suchas C# or Visual Basic .NET.
DEMO
SQL EXAMPLES – INSERT INTO
SQL in PYTHON