You are on page 1of 6

Creaung reclpes"

Lach programmlng language provldes a seL of


prlmluve operauons
Lach programmlng language provldes
mechanlsms for comblnlng prlmluves Lo form
more complex, buL legal, expresslons
Lach programmlng language provldes
mechanlsms for deduclng meanlngs or values
assoclaLed wlLh compuLauons or expresslons
AspecLs of languages
rlmluve consLrucLs
rogrammlng language - numbers, sLrlngs, slmple
operaLors
Lngllsh - words
SynLax - whlch sLrlngs of characLers and symbols
are well-formed
rogrammlng language - we'll geL Lo speclcs shorLly,
buL for example 3.2 + 3.2 ls a valld yLhon
expresslon
Lngllsh - caL dog boy" ls noL synLacucally valld, as noL
ln form of accepLable senLence
AspecLs of languages
SLauc semanucs - whlch synLacucally valld
sLrlngs have a meanlng
Lngllsh - l are blg" has form <noun> <lnLransluve
verb> <noun>, so synLacucally valld, buL ls noL
valld Lngllsh because l" ls slngular, are" ls plural
rogrammlng language - for example, <llLeral>
<operaLor> <llLeral> ls a valld synLacuc form, buL
2.3/abc ls a sLauc semanuc error
AspecLs of languages
Semanucs - whaL ls Lhe meanlng assoclaLed
wlLh a synLacucally correcL sLrlng of symbols
wlLh no sLauc semanuc errors
Lngllsh - can be amblguous
l cannoL pralse Lhls sLudenL Loo hlghly"
rogrammlng languages - always has exacLly one
meanlng
8uL meanlng (or value) may noL be whaL programmer
lnLended
Where can Lhlngs go wrong?
SynLacuc errors
Common buL easlly caughL by compuLer
SLauc semanuc errors
Some languages check carefully before runnlng,
oLhers check whlle lnLerpreung Lhe program
lf noL caughL, behavlor of program unpredlcLable
rograms don'L have semanuc errors, buL
meanlng may noL be whaL was lnLended
Crashes (sLops runnlng)
8uns forever
roduces an answer, buL noL programmer's lnLenL
Cur goal
Learn Lhe synLax and semanucs of a
programmlng language
Learn how Lo use Lhose elemenLs Lo LranslaLe
reclpes" for solvlng a problem lnLo a form
LhaL Lhe compuLer can use Lo do Lhe work for
us
CompuLauonal modes of LhoughL enable us Lo
use a sulLe of meLhods Lo solve problems

You might also like