Professional Documents
Culture Documents
What
calcula-ons?
Built
in
primi-ves
Crea-ng
our
own
methods
of
calcula-ng
Impera(ve
knowledge
how
to
methods
or
recipes
Declara(ve
knowledge
The
square
root
of
a
number
x is
a
number
y such
that
y*y = x
Can
you
use
this
to
nd
the
square
root
of
a
par(cular
instance
of
x?
Impera(ve
knowledge
Here
is
a
recipe
for
deducing
a
square
root
of
a
number
x
aFributed
to
Heron
of
Alexandria
in
the
rst
century
AD
Start
with
a
guess,
called
g!
If
g*g is
close
enough
to
x,
stop
and
say
that
g is
the
answer
Otherwise
make
a
new
guess,
by
averaging
g and
x/g !
Using
this
new
guess,
repeat
the
process
un(l
we
get
close
enough
An
example
Find
the
square
root
of
25
g
g*g
x/g
(g + x/g)
Program
counter
Crea%ng
recipes
Each
programming
language
provides
a
set
of
primi%ve
opera%ons
Each
programming
language
provides
mechanisms
for
combining
primi%ves
to
form
more
complex,
but
legal,
expressions
Each
programming
language
provides
mechanisms
for
deducing
meanings
or
values
associated
with
computa%ons
or
expressions
Aspects
of
languages
Primi%ve
constructs
Aspects
of
languages
Sta%c
seman%cs
which
syntac%cally
valid
strings
have
a
meaning
English
I
are
big
has
form
<noun>
<intransi%ve
verb>
<noun>,
so
syntac%cally
valid,
but
is
not
valid
English
because
I
is
singular,
are
is
plural
Programming
language
for
example,
<literal>
<operator>
<literal>
is
a
valid
syntac%c
form,
but
2.3/abc is
a
sta%c
seman%c
error!
Aspects
of
languages
Seman%cs
what
is
the
meaning
associated
with
a
syntac%cally
correct
string
of
symbols
with
no
sta%c
seman%c
errors
full or formal
Syntax - which string of characters and symbols are well formed (whether string is legal)
Syntac%c errors
in languages like python that are interpreted , the program(rather the interpreter) will walk through executing the
code and will catch static semantic errors on the fly
Our
goal
Learn
the
syntax
and
seman%cs
of
a
programming
language
Learn
how
to
use
those
elements
to
translate
recipes
for
solving
a
problem
into
a
form
that
the
computer
can
use
to
do
the
work
for
us
Computa%onal
modes
of
thought
enable
us
to
use
a
suite
of
methods
to
solve
problems