introduction to programming and algorithms...
TRANSCRIPT
1Introduction
Uwe R. Zimmer - The Australian National University
Introduction to Programming and Algorithms 2015
Introduction
Uwe R. Zimmer - The Australian National University
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 34 of 793 (chapter 1: “Introduction” up to page 99)
References
[ Church1932 ] Church, Alonzo A set of postulates for the foundation of logic Annals of Mathematics, Ser-ies 1932 vol. 2 ( 33 ) pp. 346-366
[ Church1936 ] Church, Alonzo An unsolvable problem of elementary number theory American Journal of Mathematics 1936 vol. 58 ( 2 ) pp. 345-363
[ Gödel1931 ] Gödel, Kurt Über formal unentscheidbare Sätze der Principia
Mathematica und verwandter Systeme I (“On Formally Undecidable Propositions of Principia Mathematica and Related Systems”) Monatshefte für Mathematik und Physik 1931
[ Neumann1945 ] von Neumann, John The First Draft Report on the EDVAC Technical report 1945 pp. 1-51
[ Rice1953 ] Rice, Henry Gordon Classes of Recursively Enumerable Sets and Their Decision Problems
Transactions of the Amer-ican Mathematical Society 1953 vol. 74 ( 2 ) pp. 358-366
[ Thompson2011 ] Thompson, Simon Haskell - The craft of functional programming Addison Wesley, third edition 2011
[ Turing1937 ] Turing, Alan On computable numbers, with an application to the Entscheidungsproblem Proceedings of the Lon-don Mathematical So-ciety 1937 vol. 2 ( 42 )
“Textbook” for the course
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 35 of 793 (chapter 1: “Introduction” up to page 99)
Why are we doing this? – Your course in context
• A science built on logic, yet speaking in metaphors?
• What are computers?
• What are programming languages and how do they relate to computers?
• The experience of programming …
• Things which will not work …
• Things which work …
Outline
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 36 of 793 (chapter 1: “Introduction” up to page 99)
The language of Computer Science
Metaphors and Anthropomorphic Language
While computer science is based on logic, physics and psychology, its technical terms can be colourful and confusing to outsiders:
Bus, window, word, language, desktop, fi le, open, kill, bootstrapping, memory, library, drive, driver, virus, mouse, web, machine, assembler, surfi ng, backbone, handshake, tunnel, gates,
port, cookie, slave, buffers, intelligent control, running, …
“Computing” and “404” themselves are also used as metaphors in other areas or disciplines, like the cognitive sciences.
Deus ex machina? or:
Glorifi ed collection of switches?
© Róbert Oláh, 2007
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 37 of 793 (chapter 1: “Introduction” up to page 99)
Computer Science
What is Computer Science about?
Some forms of hardware “Computers“ and all their components
Any form of “software”“Programs” ranging from a heating controller switch to
“running” the International Space Station
TheoryKnowing what works (and what does not) and what works effi ciently and reliably
Related disciplines:
Mathematics (mostly discrete), Philosophy, Logic, Physics, Psychology, Design, Engineering (mostly electronics), …
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 38 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition
Algorithm
Abstract, yet fi nite and formal description of a method to achieve an in-tended output or effect, dependent on a range of possible input values.
• … can introduce a fi nite number of internal states.
• … can be deterministic or non-deterministic.
• … can be sequential or concurrent.
Origins of the word:
• Abū ‘Abdallāh Muhammad ibn Māsā Al-Khwārizmī ( )(9th century Persian mathematician – wrote in Arabic).
• Algoritmi de numero Indorum (12th century Latin translation of an original Arabic script).
• Algorithme (17th century French term denoting the decimal number system).
• Algorithm (19th century English term – current meaning formed in the early 20th century).
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 39 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition
Algorithm
Abstract, yet fi nite and formal description of a method to achieve an in-tended output or effect, dependent on a range of possible input values.
• … can introduce a fi nite number of internal states.
• … can be deterministic or non-deterministic.
• … can be sequential or concurrent.
Origins of the word:
• Abū ‘Abdallāh Muhammad ibn Māsā Al-Khwārizmī ( )(9th century Persian mathematician – wrote in Arabic).
• Algoritmi de numero Indorum (12th century Latin translation of an original Arabic script).
• Algorithme (17th century French term denoting the decimal number system).
• Algorithm (19th century English term – current meaning formed in the early 20th century).
… meaning it can store and hold information.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 40 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition
Algorithm
Abstract, yet fi nite and formal description of a method to achieve an in-tended output or effect, dependent on a range of possible input values.
• … can introduce a fi nite number of internal states.
• … can be deterministic or non-deterministic.
• … can be sequential or concurrent.
Origins of the word:
• Abū ‘Abdallāh Muhammad ibn Māsā Al-Khwārizmī ( )(9th century Persian mathematician – wrote in Arabic).
• Algoritmi de numero Indorum (12th century Latin translation of an original Arabic script).
• Algorithme (17th century French term denoting the decimal number system).
• Algorithm (19th century English term – current meaning formed in the early 20th century).
… it can e.g. contain instructions like
“try each of those in any order until you fi nd one which …”.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 41 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition
Algorithm
Abstract, yet fi nite and formal description of a method to achieve an in-tended output or effect, dependent on a range of possible input values.
• … can introduce a fi nite number of internal states.
• … can be deterministic or non-deterministic.
• … can be sequential or concurrent.
Origins of the word:
• Abū ‘Abdallāh Muhammad ibn Māsā Al-Khwārizmī ( )(9th century Persian mathematician – wrote in Arabic).
• Algoritmi de numero Indorum (12th century Latin translation of an original Arabic script).
• Algorithme (17th century French term denoting the decimal number system).
• Algorithm (19th century English term – current meaning formed in the early 20th century).
)
… it can e.g. contain instructions like “distribute those calculations
over eight CPU cores and then wait for all of them to fi nish”.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 42 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition
Algorithm
Abstract, yet fi nite and formal description of a method to achieve an in-tended output or effect, dependent on a range of possible input values.
• … can introduce a fi nite number of internal states.
• … can be deterministic or non-deterministic.
• … can be sequential or concurrent.
Origins of the word:
• Abū ‘Abdallāh Muhammad ibn Māsā Al-Khwārizmī ( )(9th century Persian mathematician – wrote in Arabic).
• Algoritmi de numero Indorum (12th century Latin translation of an original Arabic script).
• Algorithme (17th century French term denoting the decimal number system).
• Algorithm (19th century English term – current meaning formed in the early 20th century).
The term “Algorithm” is used slightly
differently by different communities.
)
“Degree of formalism” can vary widely.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 43 of 793 (chapter 1: “Introduction” up to page 99)
Controllable Switches & Ratiosas transistors, relays, vacuum tubes, valves, etc.
Building blocks
pter 1: “Introduction” up to page 99)
Difference Engine
Charles Babbage 1822
First transistor
John Bardeen and Walter Brattain 1947
Strandbeest
Theo Jansen 1990Antikythera Mechanism
Greek 150-100 BC
Credit: Wikipedia
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 44 of 793 (chapter 1: “Introduction” up to page 99)
Controllable Switches & Ratiosas transistors, relays, vacuum tubes, valves, etc.
Building blocks
pter 1: “Introduction” up to page 99)
DDDDDDDDDDDDDDDDDiiiiiiiiifffffffffffffffffffffeeeeeeerrrrreeeeeennnnnncccce Engine
Charle gCCCCCCCCChhhhhhhhhaarrrrlllleeeeessss BBBBBabbbbbbbaage 1822
FFirrsst trannnnnnnsssssssssssssssiiiiiiiiiiiiiiiissssssssssssssssssttttttttttttttor
hn Bardeen and Walter Brattain 1947arrrrdddddddddddeeeeeeeeeeeeeennnnnnnnnnnnnn aaaaaaaaaaannnnnnnnnnnnnnnnddddddddddddddd WWWWWWWWWWWWWWWWaaaaaaaaaaaaaaaalllllllllllllltttttttttttttteeeeeeeeeeeeeeerrrrrrrrrr BBBBBBBBBBBBBBBBBBBrrrrrrrrrrrraaaaaaaaaaaaaaatttttttttttttttttttttttttttttttttaaaaaaaaaaaaaiiiiiiiiiiiiinnnnnnnnnnnnn 111111111111111119999999999999999944444444444444477777777777
tSSSSSttttttttttttrrrrrrrrrrrrrrrraaaaaaaaaaaaaaannnnnnnnnnnnnndddddddddbbbbbeeeeeeeesssss990TThhheeeooooo JJJJJJJJJJJJJJJJJJaaaaaaaaaaaaaaaaaaaaaannnnnnnsssseeeeeennnn 1111 Antikythera MAAAAAAnnnnnntttttttiiikkkkkkkkkkyyyyyyyyyyytttttthhhhhhhhhheeeeeeeeeeeerrrrrrraaaaaa MMMMMMMMMMMMMeeeeeeeeccccccccccchhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnniiiiiiiiiiiiisssssssssssssmmmmmmmmmmmmmmmm
Greek 150-100 BC
Credit: Wikipedia
JooooooooooooooooooooooooohhJJJ
Analogue Computers
Digital Computers
ys, vac s, etc.
11
2
3
8
99
100
SYNC
CV1
CV2
PW CV1
PW CV2
1
2
3
45
7
8
9
100
CV2
1
2
3
45
7
8
9
100
PW
2
3
45
7
8
PW CV2
A-11STANDTT G MOD.
A114
XIn
YIn
YIn
X*YOut
X*Y
1
2
3
45
7
8
9
100
1
2
33
45
77
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
1004
5
Orig.In
Out
F/2F/2
F/4
F/8
F/16
A-115 DIV.VVAudio Divider
100
3
45
7Out
A-131 VCA
3
Audio Out
A-1
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
2
3
45
7
8
Frq.CV1
CV2
CV3
Audio In
Audio Out
CV2
CVC 3
Lev.
A-120 VCF1LOW PASS FILPP TERLL
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
1004
5
Lev.Audio In
ClippingCVpppp
Audio Out
ClippinglLep
vel
CCC V
SCV
Sym
A-116 WPVC VC WaWavefoveformrm PrProcessorocessor
Symm.CV
y
Notch
FilterOutputs
High
Band
A-121 VCF2
1
2
3
1
2
3
1
2
3
1
2
3
Gate
Retrig.
ut
ut
utse
A-1ENVE
TiRa
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
100
1
2
3
45
7
8
9
1004
5
7
8
9
In1Input 1
Input 2
Input 3
Input 4
Output
In2
In3
In4
Out
A-138 MIXERlin expp
7
8
9
7
8
9
7
8
9
7
8
9
1
7
8
9
n1
n2
n3
n4
Out
R
Reset InReset In
RRangangeeFFrequ.
2
3
45
7
8
9
1004
5
A
D
A-140 ADSRENVELOPE GEN.
TTimeiRange
AL S&HA148
+
+
Reset InReset In
RRangangeeFFrequ.
/64 8
In
Out
In
Out
Range
HL
M
5
1 9
100
DU
Control
CoControntroll
Time
I/O1
I/O2
I/O2
O/I
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 45 of 793 (chapter 1: “Introduction” up to page 99)
---222222
0000000000000000000 VVCVCVCVVCVCVCVVCVCVVCVVCVCVVCVCVVCVCVVCVCVCVCOOOOOOOOOOOOOOOOOOODDAAAAAAAAAARRRRRRD VCO RRRRINNNNNNNNNNNG
-1
0+1
+2
7
65 Tune
Range XIn
Y
Ratios - building blocks for analogue computers
Analogue ComputersIn signal processing and control – and especially in sound & graphics
100000 1000pO/IO/IO/IO/I papagagagBackground: Doepfer A-100 analogue synthesizer system
111
22222 888888
9 1
2
333
222222 8888
3 773333 7COREAC (Cornell Electronic Analog Computer)Al Jackson, ca. 1954
1
2
7
8
9
100
1
2
3
45
7
8
9
100444444444
55
Audio In1
AAAAAAAAAAAA didiudiudiudiudiudiudiudiudiudiudi IIo Io Io Io Io Io Io Io Io Io Innnnnnnnnn 222222222222
In1
IIIInInInInInInInInInInIn22222222222222
A-A-AAAAAAA 1313131313131313133111111111 VCVCVCVCVCVCVCVCVCCAAAAAAAAAEXEXEXEXEXEXPPPPPP.PP VCVCVCVCVCVCAAAAAA
111
2222
33333
111
2222
33333
11
2222
33333
1
2
Audio In1
AAAAAAAAAAAA didiudiudiudiudiudiudiudiudiudiudi IIo Io Io Io Io Io Io Io Io Io Innnnnnnnnn 222222222222
A-A-AAAAAAA 1111111LILILILILILINNNENENENEEEEEEEENEEENNNEENNNNNN AAA
FFFFFFFFCCCCCV2
QQQQCQCQCQCQCQCQCQCCCCCCCCQCQCCCQQCQCQQ V1V1V1VV1V1V1V1V1V1V1
1
2 8
9
100
1
2
3
4 65
7
8
9
100
FCV2
4 64 64 64 64 64 64 64 64 64 655
RRRReReReReReReReReReReRessssssss.s.s.s.
A-A-AAAAAAA 121212121212121212111111111 VCVCVCVCVCVCVCVCVCCF2F2F2F2F2F2F2F2F2MMMMMMMMMMMMUMMMUMMMMUMMUMUMUMULLLLLLTITITITITITIMOMOMOMOMOMODEDEDEDEDEDE FFFFFFILILILILILILLLLLLLLLL TETETETETETERRRRRRLLLLLLLLL
1
2
3
45
7
8
9
1004
5
GainCV1
CV2 CV2
CV
CV2
AudioIn
FCV1
1
2
3
4 65
7
8
9
100
AudioLevel
oo
4 65
Frequ.33 7
In233
Res. Audio In 2 In2 Audio In 2Q Rest i A CCC3 7l CC t )COREAC ll ElCCCC C (CC(CCC
1111111 9999999
100
DDDDDDDDDDOEPFERDOEPFER
X YOOuOuOuOuOuOuOuOuOuOuOutttttttttttt
1
2
33333333
4
77777777
8
9
100
Out F/F/F/F/16161616
DOEPFER
1
2
33333333
4
77777777
8
9
100
Audio Out SySySySyyyymmmm
DOEPFER
1
2
33333333
4
111100000000
OutOutOutOutputputputputppp OOOO
DOEPFERRRRRRRRRRRRR
1
2
3
45
1110000000
1
2
3
45
111100000000
1
2
3
45
111100000000
1
2
3
45
1111100000011111000000 5555
IIIInput 1
Input 2
Input 3
Input 4
III
III
III
O
A-138 MIXXXXXXXXXEEEEEEEEEElin exp
1
2
3
45
7
8
9
101010100000
Frequ.
A-145 LFO
1
2
3
45
7
8
9
101010100000
Frequ.
A-145 LFOCLOCK DIV.VV
A160
Trig.
/8
In
/16
/2
/4
In
Res.
CLK SEQU.A161
5
2
6
3
4
1
MULTIPLESLLA180
Reset In F Reset In F
2
3
4Outputp OOO
H
LM
HHHHHHHH
LLLLLLLMM /3/32/32/32/32/32 7777777
444555555555
OO tOut tput OOOOJohn Whitney’s “Catalog”, 1961, Electronical, mechanical, and optical analogue components
g
OOuOuOuOuOuOuuuutttttututOuutttOuuututttOOOuOuOuOuuuuOOuuuuuuuuutuOuOuOuuuOuOuttuOuutOOuOuOOuutOuO tpppp
uOuutuOuOuOuOOOOuOuOuOuuutuututtutOOOuOuOuOOuuuttOuOuOOuuuttOOuOuutuututuOuOuuuuOuOOuuuu p
OutpInInIIIInInInInInIInInInIInInInI vers
11111
2222222222222222222222222222
77777777777777
888888888888888888888888888888888
999999999999999999999999999999999999999999
1010000110010110101101010010001110000001101100110001010000000000000000000000000000000000
11111111111111
222222222222222222222222222222222222222222
33333333333333333333333
44444444444444444444444444444444555555555555555555555555555555
7777777777777777777777777777
8888888888888888888888888888888888888888
99999999999999999999999999999999999999
10101000101001010101010100011011010000000000110100010110000100000000000000000000000000000000000
11111111111111111111111111
2222222222222222222222222222
3333333333333333333333333333333333333333333
44444444444444444444444444444444444444444444444555555555555555555555555
77777777777777777777777777777777777777777777
888888888888888888888888888888888
999999999999999999999999999999
1101000101010101000101001110010001000100010001011000101001101000010010000000000000000
OutOuOOuOuOuOuOuOuOutOutOutuOutOutOutOutOutOutOutOOOOOOOOuOuttOutOutOututOOuOOOuuOuuOututtOOOOutuuttputputputputpputputputputpputputupupupuupuupppppppppupppppppppppppp
OutOutOuOOutOutOuOutOutOutOuOutOuOutOutOuOutOutOutOOOuOutOutOutOOutOutOutOutuOutttOutOOuOutOutOOutOuOutOutOOutOOOuOuutOOuOuOututOuuOutOutOOOOuuOuttOuOuO putputputputputputputputpuputputputputputputputputpuutpuutputpututputtp tttputupututputttputputttttpuutputtuputup
OutputIIIIIIIInInnververververssse
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
1111111111111111111111111111111
22222222222222222222222222222222 88888888888888888888888888888888888
999999999999999999999999999999
0101010101100100010010111101000010001110010000010001001001100001100001011110101000100000000000000000000000000000 555555555555555555555555555555555555555
CoCoCoCoCoCoCoCoCoCoCoCooooCoCoCoCoCoCCCCCoCoCoCoCoCCCCoCCCooCooooCCooCoCoooCooCCoooCCooCooooCCCCCConntnntntntntnntnnnntrnttrtrtrtrtntntnntnnnn rnntntttrtrnttntntnnnttntnttrrntrn rrtt oooooooooooooooooooooooooooooooooooooooooooooooooollllllllllllllllllllllllll
11111111111111
222222222222222222222222222222222
3333333333333333333333333333333333333
44444444444444444444444444444444555555555555555555555555555555555555555555
777777777777777777777777777777777
888888888888888888888888888888888888888888
9999999999999999999999999999999999999999999
1111100000000000010000101000000000000000000000000000000000000000000000
222222222222222222222222
3333333333333333333333333333333333333333333333
4444444444444444444444444444444444444444444444444444444444444455555555555555555555555555555555555555555
777777777777777777777777777777777777777777777777
8
DeDeDeDeDeDeDeDeDDDeDDDeDDeDeDeDeDeDeDeDeDeDeDeDDeDeDeDeDeeDeDDDeDeDeDeDeDDDDeDDeDeDeeDeDeDeDeDeeeDDDDDeDDDDDDeDDDDeDDDDeDeeeeDDeDeDDeeDeDeeDDeDDDDDeDeDDDD llll.ll.l.l.l.l.l.l.llll..lllllll.l..InInInnnnIIIInnInnIInInInInInnInnIInIInInnnnInnnnnnnnnnnInnIInnnnnnnnnnn
OuOOOuOOOOOOuOuOOOOuOOOOuOOO ttttttttttttttttttttttttttttttttt LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLeneenenenenneenenenenenneeneneeeeeeeneneneneneenenenenennnneeennennnneeeneeennnnneneeneeneneneneneneneeneneeeeneneeneneneneeeennneeeeeeee .................
Outputp
H
pp
CCCoCoCoCoCoo tnttntntrr.r.
HHHH MMMMMM
ADSADSADSADSSRRRR1 9
10000110 555555
CCC tt llll H M55 of545544 793793 ntroduction” up to pagee 99)e 9)99)troduction” up to pageHHHHLLLLL
MMMMntroduction” up to pageoduodu(chapter 1: “InnCoCoCoCoCoCoContrntrntrntrntrntroooooontrolllllll( h tterter
OutpOutputAnalogue Synthesizer, 2010
(Doepfer modules with several sequencers)
AE
Audio Out
1 9
100
1
2
3
45
0
Res
DOE
Low QCV2100
4 65
QCV2
A-1777777
2
3
4
AL SLE
1 99999
Audio O7
8
99999999999
10101010010101
Res.
EPFEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
Low QCV2
111
22222222222222222
333333333333333
4 6
7
8
9
101010011111000000000000
QCV2
DDDDDODODODODODODDOOODOOODDODDDODDDODODDODODODDODDDDODODODODDOOOOOOOOOOOOOOOOOOOOOOOOOOOEPEPEPEPPPPPEPPEPEPEPEPEPEPEPPPPEPEPEPEPEPEPEEPEEPEPEPEPEPEPPEEPEEPEPEPPEPEEPEPEPEPEPEPEEPEEPEPPEPEPEEPEPEEPPEEEPEEEPEEPPEPEPEPEEPEPPPPPFFFFFFEFEFFFFFFFFFFEFFFFFFEFFFEFFEFEFFFFFEFFFFFFFEFEFFFFFFEFFFEFFFFEEEEEFEEFEFFERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
GateTTTTTTTTTTTTTTTTTTTTTTTimmmmmimmimmmmmmmmmmmmmimimimmmiiii eeeeeeeeee
7777777777770000000000000000000000000000000 SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
5
777
8
EWWW WWWWWWWWWW LILILLILILILIL MIMMMMMMMMMMMMMMMMM TETEETETETETETEEETETETETTETTETEETETETETETETETTETEEETTTEETETTERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRA-A-AAAAA-A-A-A-A-A-A-A-AAAAAA-AA-AA-A-A-A-A-AA-AAA-A-A-A-AA--A-A-A-A-A-A-A-A-A--AAA-A-A-A-A-A-A-AA-A-A-AAAAA-A-AA-AAAAA-AA-A-AA-AAAA 16166661616616161616161666666666666666616661616166162222222222222222222222222222222222 TTTTTTTTDTDTDTDTDTTTTTDTDTTTDTDTDDTDTTTDDTTDDTDTTDTDDDTDTDTTDTTDTDDTDDDDDEEEELELLLLLLLLELLELLLLEELLELELELELLELELELLELELELLLLELEEEEE
DUDUDUDDDDDUDUDUUUDUDUDDUDUDUDDDUDDUDUDDDDDDDDDDUDDDDDDDDDDDDDDDDDDDUDDDDUDDUDUUD AALAALALALALLALALAALLLAALAAAAALLALALALALAAAAAALALLLLLALAALLALLALLALLALALALAAALL TTTTRTTRTRTRRRRRTRRTRRTRTRTRTTTTTTRTTRTTTTTTRTTTRTRTRTTRTRTTTRTTTTTRTRTTTTTTTTTTTTTTTTRT IGIGGGIGIGIIGIGIGIGGGGGGGGGGGGGGGGGEGEGEGEGEGEGEGEGEGEGEGEEEERRRRRRRRRRRRRRRRRRRRRR RRRR RRRR RRRRR RRRRRRRRRRRRR DDDDEDDDEDEDEEEEEEEDDEDDDEDEDEEEDEDEDEDDDEDEDDDDDDDDEDDEDDDDDEDDDDDDEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEDDDD LAAALALLALALLALAALALALLALLLLLLLLLLLLLALLLLLLLLLL YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYAAAAAAAAAAA
2
3333333
4444444445555555555555
77777777777777777777777
888888888888
DeDeDeDDeDeDeDeDeDeDeDeDeDeDeDeDDeDeDDDeeDeDDeDDeDeDeeellllllllllllll.l.l.l.IIInInInnnnIInIIIIIInInnnIInnInnnnIInIInInnnnnnnnnnnnnnnnnIInIIInIIIInnIIIInnnnIInnnn
DUDUDUDUDDUDUDUDUDUDUDUDUDUDUUUDUDUUUDDUDUUDDUUUUDUUUUUUUUUUDUDUDUDDUDDDUALAAAALAAALALALLAAAALLAAAAAALALALAAALAAAAAALALAAAALAAAAAAALALAAAALLLAAALAALALAA VCVCVCVCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSA1A1A1A1A1A1A1A1A1A1AAA11111AA11AA1111A1111AA11AA1111A11A1505050505050505050500000
CCCCVCVCVCVCVCVCVCVCVCVCVCV
11
Retrig.1000010 1000
44445
OOOOuOuO tttt LLLLLeeen.I/O/OI/OI/O/OOO1111113333
g333333 777
e .
1111 999999
1010000101010
1111 99999
100000
Programmable “System on a chip”, 2011(Cypress, product brochure)
DODODODODODODODODODODODODODOOOEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPFEFEFEFEFEFEFEFEEFEFEFFEEFEFEFEFEFERRRRRRRRRRRRRRRRRRRRRR
1111
222222222
33
DDDDDDODODODODODODODODODODODDDDODODDODODO
3 7
1
2
7
8
9
100
DOE
Mixed signalsystems
222222222222 888888888
4
1
2
3
4
7
8
9
100
3
45
7
CV
O/I
Specialpurpose
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 46 of 793 (chapter 1: “Introduction” up to page 99)
Logic - the basic building blocks for digital computers
Constructing logic gates – for instance NAND in CMOS:
NANDAB
Q
A
B
Q
PMOS
NMOS
A B & Q0 0 & 10 1 & 11 0 & 11 1 & 0
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 47 of 793 (chapter 1: “Introduction” up to page 99)
Logic - the basic building blocks for digital computers
Constructing logic gates – for instance NAND in CMOS:
… and subsequently all other logic gates:
NAND
NAND NAND
A Q
NAND
NAND
NAND
Q
Q
AB
A
B
NAND
NAND
NAND
NANDNAND
NAND
NAND
NAND
A
B
Q
NOTA Q
OR QA
B
QA
BAND
XORA
BQ
NANDAB
Q
A
B
Q
PMOS
NMOS
A B & Q0 0 & 10 1 & 11 0 & 11 1 & 0
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 48 of 793 (chapter 1: “Introduction” up to page 99)
Logic - the basic building blocks for digital computers
Half adder: Full adder:
Ripple carry adder:
A XOR
ANDB
S
C
Ai
XOR
AND
Bi
XOR
AND
OR
Si
Ci-1 Ci
A0
XOR
AND
B0
S0
XOR
AND
XOR
AND
OR
S1
A1 B1
XOR
AND
XOR
AND
OR
A2 B2
S2
C
No, you did not end up in the wrong course!
… hang in there …
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 49 of 793 (chapter 1: “Introduction” up to page 99)
Logic - the basic building blocks for digital computers
Basic Flip-Flops
Q
Q
D Q
Q
NAND Q
NAND Q
NAND
NAND
NAND
NAND
NAND
NAND
D
C
Q
Q
C
S
R
S
R
NAND
NAND
Q
Q
NAND
NAND
NAND
NAND
NAND
NAND
NOT
S
R
J
K
C
J
K
Q
Q
S
R
S
R
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 50 of 793 (chapter 1: “Introduction” up to page 99)
Logic - the basic building blocks for digital computers
Q
Q
D Q
Q
S
R
J
K
Q
Q
S
R
S
R
J
K
Q
Q
S
R
DC
T Q
Q
J
K
Q
Q
S
R
TC
T Q
Q
D Q
Q
XORTC
J Q
Q
D Q
QCK
AND
OR
AND
J
K
S
R
S
R
T S
R
T S
R
T S
R
T S
R
T S
R
T S
R
T S
R
T S
R
1
C
S0 S1 S2 S3 S4 S5 S6 S7
R
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
JK- and D- Flip-Flops as universal Flip-Flops
Counting register:
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 51 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition: Processor
Hardware origins18th century machines
L’Ecrivain1770
Programmable, yet not a computer in today’s
defi nition (not Turing complete)
L’Ecrivain (1770)Pierre Jaquet-Droz, Henri-Louis Jaquet-Droz & Jean-Frédéric Lescho
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 52 of 793 (chapter 1: “Introduction” up to page 99)
Defi nition: Processor
Digital ComputersHardware origins
• Patents by Konrad Zuse (Germany), 1936.
• First digital computer: Z1 (Germany), 1937: Re-lays, programmable via punch tape, clock: 1 Hz, 64 words memory à 22-bit, 2 registers, fl oating point unit, weight: 1 t.
• First freely programmable (Turing complete) relays computer: Z3 (Germany), 1941: 5.3 Hz
• Atanasoff Berry Computer (US) 1942: Vacuum tubes, (not Turing complete).
• Colossus Mark 1 (UK) 1944: Vacuum tubes (not Turing complete).
• “First Draft of a Report on the EDVAC” (Electronic Discrete Variable Automatic Computer) by John von Neumann (US), 1945: Infl uential article about core elements of a computer:Arithmetic unit, control unit (Sequencer), memory (holding data and program), and I/O.
• First high level programming language: Plankalkül (“Plan Calculus”) by Konrad Zuse, 1945.
• ENIAC (Electronic Numerical Integrator And Computer) (US) 1946: programed by plugboard,First Turing complete vacuum tubes based computer, clock: 100 kHz, weight: 27 t on 167 m2.
Konrad Zuse with Z1, © Dr. Horst Zuse (replica of the 1937 computer)
ENIAC 1946, Glen Beck (background), Betty Jennings (foreground)
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 53 of 793 (chapter 1: “Introduction” up to page 99)
Computer Architectures
Harvard Architecture
• Control unitConcurrently addresses program and data memory and fetches next instruction.Controls next ALU operations and determines the next instruction (based on ALU status).
• Arithmetic Logic Unit (ALU)Fetches data from memory.Executes arithmetic/logic operation.Writes data to memory.
• Input/Output
• Program memory
• Data memory
Prog
ram
mem
ory
Control unit
Arithmetic Logic Unit
Dat
a m
emor
y
Control Status
Add
ress
Inpu
t/O
utpu
t
Dat
aA
ddre
ssIn
stru
ctio
ns
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 54 of 793 (chapter 1: “Introduction” up to page 99)
Computer Architectures
von Neumann Architecture
• Control unitSequentially addresses program and data memory and fetches next instruction.Controls next ALU operations and determines the next instruction (based on ALU status).
• Arithmetic Logic Unit (ALU)Fetches data from memory.Executes arithmetic/logic operation.Writes data to memory.
• Input/Output
• MemoryProgram and data is not distinguished
Programs can change themselves.
Mem
ory
Control unit
Arithmetic Logic Unit
Control Status
Add
ress
Inpu
t/O
utpu
t
Dat
aIn
stru
ctio
ns
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 55 of 793 (chapter 1: “Introduction” up to page 99)
Computer Architectures
A simple processor (CPU)
• Decoder/SequencerCan be a machine in itself which breaks CPU instructions into concurrent micro code.
• Execution Unit / Arithmetic-Logic-Unit (ALU)A collection of transformational logic.
• Memory
• RegistersInstruction pointer, stack pointer,general purpose and specialized registers.
• FlagsIndicating the states of the latest calculations.
• Code/Data managementFetching, Caching, Storing.
ALU
Mem
ory
SequencerDecoder
Code management
Registers
IP
SP
Flags
Data management
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 56 of 793 (chapter 1: “Introduction” up to page 99)
Computer Architectures
A simple processor (CPU)
• Decoder/SequencerCan be a machine in itself which breaks CPU instructions into concurrent micro code.
• Execution Unit / Arithmetic-Logic-Unit (ALU)A collection of transformational logic.
• Memory
• RegistersInstruction pointer, stack pointer,general purpose and specialized registers.
• FlagsIndicating the states of the latest calculations.
• Code/Data managementFetching, Caching, Storing.
ALU
Mem
ory
SequencerDecoder
Code management
Registers
IP
SP
Flags
Data management
Mem
ory
MRegisters
IP
SP
Flags… all this can be build out of NAND gates, which are based
on the controllable switch technology of the time!
56 f 793 ( h 1 “I d i ” 99)
Indicating the states of the Indicating the states of thelatest calculations.
• Code/Data managementFetching, Caching, Storing.
In later courses you will learn about pipelines,
multi-cores, hyper-threads, vector machines,
virtual memory, and a whole lot more …
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 57 of 793 (chapter 1: “Introduction” up to page 99)
Hardware
Where are all the computers?
• ~ 98% of all CPUs are found in embedded devices.
• Modern cars exceed 100 CPUs per vehicle.
• ~ 7.3 billion mobile phones worldwide (2014) > 1 per person.
• ~ 2% of all CPUs are found in laptops and desktops.
• High performances are achieved by special purpose GPUs
• ~ 1-2 billion laptop and desktop computers worldwide.
• The majority of CPUs are 8-bit and programmed in C or Assembler.… my key-ring torch has a CPU.
How many CPUs does your laptop sport?
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 58 of 793 (chapter 1: “Introduction” up to page 99)
Programming processors
Machine codeMemory address
Memory contents
Hexadecimal Binary Hexadecimal
00001000 01001000 11100111 48 E7
00001002 00000010 00000000 20 00
00001004 00110100 00000000 34 00
00001006 00000100 01000010 04 42
00001008 00000000 00000001 00 01
0000100A 01000010 10000001 42 81
0000100C 00110010 00011000 32 18
0000100E 11010010 01011000 D2 58
00001010 01010001 11001010 51 CA
00001012 11111111 11111100 FF FC
00001014 10000010 11000000 82 C0
00001016 01001100 11011111 4C DF
00001018 00000000 00000100 00 04
... or: what the world looks like if you are a computer.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 59 of 793 (chapter 1: “Introduction” up to page 99)
Programming processors
Assembler
LabelMemory address
Memory contentsAssembler instruction
Symbolic Hexadecimal Binary Hexadecimal Instruction Parameters
00001000 01001000 11100111 48 E7 MoveM.L D2, -(A7)
00001002 00000010 00000000 20 00
00001004 00110100 00000000 34 00 Move.W D0, D2
00001006 00000100 01000010 04 42 SubI #0001, D2
00001008 00000000 00000001 00 01
0000100A 01000010 10000001 42 81 CLR.L D1
0000100C 00110010 00011000 32 18 Move.W (A0)+, D1
Loop: 0000100E 11010010 01011000 D2 58 Add.W (A0)+, D1
00001010 01010001 11001010 51 CA DBra D2, Loop
00001012 11111111 11111100 FF FC
00001014 10000010 11000000 82 C0 DivU D0, D1
00001016 01001100 11011111 4C DF MoveM.L (A7)+, D2
00001018 00000000 00000100 00 04
A little more human friendly.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 60 of 793 (chapter 1: “Introduction” up to page 99)
Programming processors
Semantic
LabelMemory address
Memory contentsAssembler instruction
Comments
Symbolic Hexadecimal Binary Hexadecimal Instruction Parameters Semantic
00001000 01001000 11100111 48 E7 MoveM.L D2, -(A7) Input: D0 discrete values which are stored beginning at memory address (A0).
Output: Discrete arithmetic mean in D1.
Method: D0 values are accumulated in D1 and divided by the number of values.
Side effects: none.
00001002 00000010 00000000 20 00
00001004 00110100 00000000 34 00 Move.W D0, D2
00001006 00000100 01000010 04 42 SubI #0001, D2
00001008 00000000 00000001 00 01
0000100A 01000010 10000001 42 81 CLR.L D1
0000100C 00110010 00011000 32 18 Move.W (A0)+, D1
Loop: 0000100E 11010010 01011000 D2 58 Add.W (A0)+, D1
00001010 01010001 11001010 51 CA DBra D2, Loop
00001012 11111111 11111100 FF FC
00001014 10000010 11000000 82 C0 DivU D0, D1
00001016 01001100 11011111 4C DF MoveM.L (A7)+, D2
00001018 00000000 00000100 00 04
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 61 of 793 (chapter 1: “Introduction” up to page 99)
Programming processors
Machine level programming
Observations: Dependent on the specifi c CPU model.
Error prone.
Harder to handle complex problems.
The machine dictates the language in which the programmer “thinks”.
Full control.
Need for more problem oriented languages.
Need for more abstract and safer languages.
P.S. How much control are you willing to or need to sacrifi ce for abstraction?
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 62 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran (‘57), Cobol (‘59), Basic (‘64), C (‘71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 63 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran (‘57), Cobol (‘59), Basic (‘64), C (‘71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)
73)Imperative means (informally) that the
program is a sequence of instructions.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 64 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran (‘57), Cobol (‘59), Basic (‘64), C (‘71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)
S
, Algol68, Pascal (‘70)
SmallTalk (‘69)
Functional programming means (informally) that
the program is a set of functions transforming input to output
without storing any information
(much like a mathematical function).
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 65 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran (‘57), Cobol (‘59), Basic (‘64), C (‘71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)
( )
page 65 of 793 (chapter 1: “Introduction” up to page 99)
('72)
Message passing based (object oriented) programs are (informally)
a set of “objects” which store information
locally and send each other messages.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 66 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran (‘57), Cobol (‘59), Basic (‘64), C (‘71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)page 66 of 793 (chapter 1: “Introduction” up to page 99)
Logic based programs are (informally)
a set of “rules” or logic equations.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 67 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Early languagesMachine code inspired (imperative, extended macro assemblers):
Fortran ('57), Cobol (‘59), Basic ('64), C ('71)Based on lambda calculus (functional programming):
Lisp ('58), ML ('73)Structured and strongly typed (imperative):
Algol (‘58), Algol60, Algol68, Pascal (‘70)Based on message passing (object oriented):
Simula (‘67), SmallTalk (‘69)Based on declarative, fi rst order logic:
Prolog ('72)2)
l68 Pascal ( 70)l68, Pascal ( 70)
Talk (‘69)
While those languages provided a
basis for most languages today, none
of those over 40 year old editions are
capable to handle large scale problems
or modern hardware by themselves.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 68 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Find the right language
Ekkehard Floegel, I J G Inc (Bluec), 1983
Use the fi rst language you learned
for everything else in your career?Use the first language you learnedddd
Choose what promises to be “easy”?Ch
Choose what seems popular?s popular?
Follow the hype?Ask a fanboy?
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 69 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Find the right language
Ekkehard Floegel, I J G Inc (Bluec), 1983
Use the fi rst language you learned
for everything else in your career?Use the first language you learnedddd
Choose what promises to be “easy”?Ch
Choose what seems popular?s popular?
Follow the hype?Ask a fanboy?
Choose the best tool for the job.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 70 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Paradigms
• Control fl ow: Imperative ↔ Declarative
• Declarative: Functional ↔ Logic ↔ Finite State Machines
• Allocations and bindings: Static ↔ Dynamic
• Time: Event-driven ↔ Discrete ↔ Synchronous ↔ Continuous
• Focus: Control fl ow-oriented ↔ Data fl ow-oriented
• Degree of concurrency: Sequential ↔ Concurrent ↔ Distributed
• Structure: Modular ↔ Generics ↔ Templates ↔ Object-Oriented ↔ Aspect-Oriented ↔ Agent-Oriented
• Determinism: Deterministic ↔ Non-deterministic
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 71 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Paradigms
• Control fl ow: Imperative ↔ Declarative
• Declarative: Functional ↔ Logic ↔ Finite State Machines
• Allocations and bindings: Static ↔ Dynamic
• Time: Event-driven ↔ Discrete ↔ Synchronous ↔ Continuous
• Focus: Control fl ow-oriented ↔ Data fl ow-oriented
• Degree of concurrency: Sequential ↔ Concurrent ↔ Distributed
• Structure: Modular ↔ Generics ↔ Templates ↔ Object-Oriented ↔ Aspect-Oriented ↔ Agent-Oriented
• Determinism: Deterministic ↔ Non-deterministic
m
nous ↔ Continuous
State Machines
mic
nous ↔ C ti
You do not need to understand all those paradigms right here
…
this page is just to show that there
are many, many ways to program.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 72 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Languages which could be considered infl uential:
… conceptual foundations:
m-Calculus/Lisp – Simula/Smalltalk – Algol – Prolog
… other major infl uences:
ML/Haskell – Eiffel – Ada – C – Java
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 73 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
… by counting how many other languages they infl uenced.
According to this method:
Haskell, Lisp, Smalltalk and C
have inspired the most other languages
… don’t take this method too seriously.
A#
Aldor
A+
K
ABC
Python
Ada
A#.NET
C#
C++
Eiffel
Java PL/SQL
Ruby
Seed7
Spark
VHDL
AgentSheets Etoys
Scratch
Alef
Go
Limbo
Rust
Algol58
Algol60
ABCAlgol
Algol68
AlgolW
B
BCPL
C
CPL
Modula
Modula-2
Modula-3
Oberon
Pascal
Simula
Bash
Bourneshell
Mary
S3
AmbientTalkECMAScript
APL
J
Mathematica
MATLAB
Nial
PPL
Q
ARS
A++
AS/400
WindowsPowerShell
AWK
AMPL
Korn
Lua
Perl
Tcl
Basic
AutoHotkey
AutoItCOMAL
GRASS
VisualBasic
VisualBasic.NET
Xojo
BlitzBasic
MonkeyX
Boomerang
XSLT
BitC
C--
Cshell
D
JavaScript
LPC
Objective-C
PHP
Pike
ProcessingVerilog
C*
Dataparallel-C
F#
Kotlin
Nemerle
Vala
C99
Falcon
Caml
Clojure
Elixir
CLU
Argus
Sather
Cobol
ABAP
PL/I
CoffeeScript
LiveScript
COMIT
Snobol
CommonLisp
CadenceSKILL
Dylan
EmacsLisp
EuLisp
ISLISP
Julia
Moose
R
SubL
Comtran
ConcurrentEuclid
Turing+
Cool
OCaml
CoolMUDColdC
Coq
Agda
COWSEL
POP-2
C
Joins
DScript
MiniD
Qore
DBaseClipper
Harbour
DCL
Goo
Lasso
Lisaac
Racket
Scala
Emerald
Singularity
Croquet_Project Tweak
Euclid
Mesa
Turing
F
Fortran
F*
FACT
Factor
Cat
Concat
FL
FLOW-MATIC
Forth
PostScript
Rebol
RPL
MUMPS
PACT
Ratfor
FP
FPr
GemstoneGemFire
JavaPlatform
GenericJava
Groovy
GScript
Gosu
GW-Basic
MSXBasic
QBasic
QuickBasic
XHarbour
Haskell
Bluespec
C++11
Cayenne
Clean
Concepts
Curry
Elm
Epigram
Escher
Frege
GenericsinJava
Isabelle
LanguageIntegratedQuery
Mercury
Perl6
Qi
Quark
Timber
mega
HyperTalk
LiveCode
IBM_Basic
IBM_RPG
IBMRPGII
Icon Unicon
Io
Fancy
Ioke
Luna
RestrictedIo
IPL
Lisp
ISWIM
Lucid
Miranda
ML
SASL
NumPy
SuperCollider
BeanShell
J_Sharp
ActionScript
Dart
JScript.NET
Node.js
Objective-J
QML
TypeScript
Joe-E
Caja
Join-pattern
Join-calculus
JOSS
CALFOCAL
TELCOMP
JOVIAL
Coral_66
SYMPL
Joy
TrithV
Joyce
SuperPascal
Karel
GvRKarel++
KRC
KRL
KM
LESS
Sass
Liberty_Basic
JustBasic
StacklessPython
CLIPS
Logo
MDL
Nu
OPS5
POP-11
Shen
Smalltalk
Boxer
KTurtle
NetLogo
GameMonkey
Squirrel
Lustre
Pure_Data
SISAL
Mizar_system
HOLLight
OMDoc
Cyclone
Erlang
Felix
Opa
Zonnon
Modula-2+
MOO
VilniusBasic
MUF
CachéObjectScript
PSL
Newsqueak
NewtonScript
Oaklisp
Oberon-2
ComponentPascal
ObjectOberon
ObjectPascal
FreePascal
ObjectREXX
NetRexx
TOM
ATS
Occam
Ease
Orwell
Oz
Alice
Pascal-P
Oxygene
Hack
Pizza
Rexx
SP/k
Plankalkül
Superplan
PolyphonicC#
Prolog
Datalog
KL0
KL1
Strand
VisualProlog
Boo
Cobra
Pure
QB64
Qt
Scheme
Rc
Inferno
JSONRed
Mirah
Potion
Reia
Stylus
Tritium
Ceylon
Fantom
Hop
Kernel
S
Sed
Chomski
SelfAgora
Cel
Squeak
SETL
ProSet
Slim
ShortCode
pascal
SAC
SK8
AppleScript
CommonLispObjectSystem
Logtalk
SpeC#
Speedcoding
SQL
CQL
SOQL
StandardML
StandardMLofNewJersey
Mythryl
StarLogo
STOS_Basic
AMOS
T
Tea
Object-OrientedTuring
TUTORTenCORE
USE
UCBLogo
VBScript
SystemVerilog
Basic4ppc
Gambas
XPath
XForms
XMLSchema
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 74 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languagesImperative,
Fortran family:(or: “scripting formula languages”)
Fortran, Cobol, Basic, PL/I…
Cobol
ABAP
PL/I
Basic
AutoHotkey
AutoIt
COMAL
GRASS
VisualBasic
VisualBasic.NET
Xojo
BlitzBasic
MonkeyX
GW-Basic
MSXBasic
QBasic
QuickBasic
IBM_Basic
Liberty_Basic
JustBasic
VilniusBasic
QB64
STOS_Basic
AMOS
Basic4ppc
Gambas
Fortran
Algol58
C
MUMPS
PACT
Ratfor
AS/400
B
Rexx
SP/k
JOSS
Speedcoding
Comtran
FACTFLOW-MATIC
F
Modula-2
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 75 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languagesImperative, C family:
(or: “curly-brace languages”)
BCPL, B, C, C++, D, Objective-C, Java, C#, …
BCPL
BC
AMPL
AWK
BitC
C--
C#
Cshell
C++
D
Go
Java
JavaScript
Limbo
LPC
Objective-C
Perl
PHP
Pike
Processing
Rust
Seed7
Verilog
F#
Kotlin
MonkeyX
Nemerle
Vala
Ada
C99
FalconLua
DScript
MiniD
Qore
NuObjective-J
TOM
BeanShell
Clojure
ECMAScript
Groovy
J_Sharp
Python
Scala
Algol60
CPL
Algol68
Fortran
Speedcoding
Cω
Eiffel
Haskell
Modula-3
ObjectPascal
ML
Simula
C++11
Ruby
Smalltalk
Emerald
GenericJava
Mesa
Pascal
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 76 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Imperative, Algol family:(or: “begin-end languages”)
Algol 60, Algol 68, Pascal, Modula, Modula-2,
Oberon, Object-Pascal, Ada, …
Ada
A#.NET
C#
C++
Eiffel
Java
PL/SQL
Ruby
Seed7
Spark
VHDL
Algol58
Algol60
ABCAlgol
Algol68AlgolW
B
BCPL
C
CPL
Modula
Modula-2Modula-3
Oberon
PascalSimula
Bash
Bourneshell
Mary
Python
S3
ComponentPascal
FreePascal
Pascal-P
Oberon-2
ObjectPascal
Oxygene
Go
Zonnon
ObjectOberon
Fortran
Lua
Modula-2+
Caml
CLU
PlankalkülSpeedcoding
Mesa
ShortCode
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 77 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Imperative, Algol family:(or: “begin-end languages”)
Algol 60, Algol 68, Pascal, Modula, Modula-2,
Oberon, Object-Pascal, Ada, …
Ada
A#.NET
C#
C++
Eiffel
Java
PL/SQL
Ruby
Seed7
Spark
VHDL
Algol58
Algol60
ABCAlgol
Algol68AlgolW
B
BCPL
C
CPL
Modula
Modula-2Modula-3
Oberon
PascalSimula
Bash
Bourneshell
Mary
Python
S3
ComponentPascal
FreePascal
Pascal-P
Oberon-2
ObjectPascal
Oxygene
Go
Zonnon
ObjectOberon
Fortran
Lua
Modula-2+
Caml
CLU
PlankalkülSpeedcoding
Mesa
ShortCode
© 2015 Uwe R. Zimmer, The Australian National Universityy
dula-2+
© 2015 Uwe R Zimmer The Australian National University
d
© 2015 Uwe R Zimmer The Australian National University
Mod
© 2015 Uwe R Zimmer The Australian National University
d
Note: Infl uence does not imply popularity:
Algol 60 is one of the most infl uential
languages, yet it will be hard to fi nd a compiler for it today.
Caml Mesa
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 78 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Functional (m-Calculus) languages:
Lisp, Common-Lisp, ML, OCaml,
Scheme, Haskell, …
F#
F*
LiveScript
Haskell
Agda
Bluespec
C#
C++11
Cayenne
Clean
Clojure
CoffeeScriptConcepts
Curry
Elm
Epigram
Escher
Frege
GenericsinJava
Isabelle
Java
LanguageIntegratedQuery
Mercury
Perl6
Python
Qi
Quark
Scala
Timber
VisualBasic.NET
Ωmega
Lisp
CLIPS
CLU
COWSEL
Dylan
Falcon
Forth
Io
Ioke JavaScript
Julia
Logo
Lua
Mathematica
MDL
ML
Nu
OPS5
Perl
POP-11
POP-2
R
Racket
Rebol
Ruby
Shen
Smalltalk
Tcl
CommonLisp
CadenceSKILL
EmacsLisp
EuLisp
ISLISP
Moose
SubL
C++
Cyclone
Erlang
Felix
Miranda
Opa
Scheme Hop
Kernel
S
OCaml
ATSRust
OccamEase
StandardML
StandardMLofNewJersey
Mythryl
Caml
ISWIM
Orwell
SASL
IPL
KRC
CommonLispObjectSystem
Cool
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 79 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Logic languages:
Planner, Prolog, …Prolog
Datalog
Erlang
KL0
KL1
Mercury
Oz
Strand
VisualProlog
Planner
Haskell
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 80 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Scripting languages:
Perl, Ruby, Python, JavaScript, … JavaScript
ActionScript
CoffeeScript
DartJScript.NET
LiveScript
Node.js
Objective-J
QML
TypeScript
PerlECMAScript
Falcon
LPC
Perl6
PHP
Python
Qore
Ruby
WindowsPowerShell
Hack
D
Elixir
Fancy
Groovy
Ioke
MirahNu
Potion
Reia
Boo
Cobra
F#
Go
C
Java
Lisp
Scheme
Self
C++
Smalltalk
ABC
Algol68
Dylan
Haskell
Icon
Modula-3
Simula
Ada
CLU
Eiffel
AWK
Sed
AS/400
DCL
SQL
Tcl
VBScript
Cshell
Bourneshell
Bash
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 81 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Scripting languages:
Perl, Ruby, Python, JavaScript, … JavaScript
ActionScript
CoffeeScript
DartJScript.NET
LiveScript
Node.js
Objective-J
QML
TypeScript
PerlECMAScript
Falcon
LPC
Perl6
PHP
Python
Qore
Ruby
WindowsPowerShell
Hack
D
Elixir
Fancy
Groovy
Ioke
MirahNu
Potion
Reia
Boo
Cobra
F#
Go
C
Java
Lisp
Scheme
Self
C++
Smalltalk
ABC
Algol68
Dylan
Haskell
Icon
Modula-3
Simula
Ada
CLU
Eiffel
AWK
Sed
AS/400
DCL
SQL
Tcl
VBScript
Cshell
Bourneshell
Bash
Note: Popularity does not imply infl uence:
PHP is one of the most used languages today,
yet it is commonly considered too fl awed
to base any new language design on it.
ActionScriptActionScripActionScrip
LiveScript
TypeScriptTypeScript
Elixir
Fancy
Ioke
Nu
Potion
Reia
Boo
F#
Go
Java
Schem
Simula
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 82 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Infl uential languages
Learning an infl uential language may make it easier for you to learn other languages later.
(Keep in mind that this is only a statistical counting exercise
based on incomplete data.)
Infl uential does not imply quality or well designed concepts … there are also trends, hypes, habits and other social effects at play.
A#
Aldor
A+
K
ABC
Python
Ada
A#.NET
C#
C++
Eiffel
Java PL/SQL
Ruby
Seed7
Spark
VHDL
AgentSheets Etoys
Scratch
Alef
Go
Limbo
Rust
Algol58
Algol60
ABCAlgol
Algol68
AlgolW
B
BCPL
C
CPL
Modula
Modula-2
Modula-3
Oberon
Pascal
Simula
Bash
Bourneshell
Mary
S3
AmbientTalkECMAScript
APL
J
Mathematica
MATLAB
Nial
PPL
Q
ARS
A++
AS/400
WindowsPowerShell
AWK
AMPL
Korn
Lua
Perl
Tcl
Basic
AutoHotkey
AutoItCOMAL
GRASS
VisualBasic
VisualBasic.NET
Xojo
BlitzBasic
MonkeyX
Boomerang
XSLT
BitC
C--
Cshell
D
JavaScript
LPC
Objective-C
PHP
Pike
ProcessingVerilog
C*
Dataparallel-C
F#
Kotlin
Nemerle
Vala
C99
Falcon
Caml
Clojure
Elixir
CLU
Argus
Sather
Cobol
ABAP
PL/I
CoffeeScript
LiveScript
COMIT
Snobol
CommonLisp
CadenceSKILL
Dylan
EmacsLisp
EuLisp
ISLISP
Julia
Moose
R
SubL
Comtran
ConcurrentEuclid
Turing+
Cool
OCaml
CoolMUDColdC
Coq
Agda
COWSEL
POP-2
C
Joins
DScript
MiniD
Qore
DBaseClipper
Harbour
DCL
Goo
Lasso
Lisaac
Racket
Scala
Emerald
Singularity
Croquet_Project Tweak
Euclid
Mesa
Turing
F
Fortran
F*
FACT
Factor
Cat
Concat
FL
FLOW-MATIC
Forth
PostScript
Rebol
RPL
MUMPS
PACT
Ratfor
FP
FPr
GemstoneGemFire
JavaPlatform
GenericJava
Groovy
GScript
Gosu
GW-Basic
MSXBasic
QBasic
QuickBasic
XHarbour
Haskell
Bluespec
C++11
Cayenne
Clean
Concepts
Curry
Elm
Epigram
Escher
Frege
GenericsinJava
Isabelle
LanguageIntegratedQuery
Mercury
Perl6
Qi
Quark
Timber
mega
HyperTalk
LiveCode
IBM_Basic
IBM_RPG
IBMRPGII
Icon Unicon
Io
Fancy
Ioke
Luna
RestrictedIo
IPL
Lisp
ISWIM
Lucid
Miranda
ML
SASL
NumPy
SuperCollider
BeanShell
J_Sharp
ActionScript
Dart
JScript.NET
Node.js
Objective-J
QML
TypeScript
Joe-E
Caja
Join-pattern
Join-calculus
JOSS
CALFOCAL
TELCOMP
JOVIAL
Coral_66
SYMPL
Joy
TrithV
Joyce
SuperPascal
Karel
GvRKarel++
KRC
KRL
KM
LESS
Sass
Liberty_Basic
JustBasic
StacklessPython
CLIPS
Logo
MDL
Nu
OPS5
POP-11
Shen
Smalltalk
Boxer
KTurtle
NetLogo
GameMonkey
Squirrel
Lustre
Pure_Data
SISAL
Mizar_system
HOLLight
OMDoc
Cyclone
Erlang
Felix
Opa
Zonnon
Modula-2+
MOO
VilniusBasic
MUF
CachéObjectScript
PSL
Newsqueak
NewtonScript
Oaklisp
Oberon-2
ComponentPascal
ObjectOberon
ObjectPascal
FreePascal
ObjectREXX
NetRexx
TOM
ATS
Occam
Ease
Orwell
Oz
Alice
Pascal-P
Oxygene
Hack
Pizza
Rexx
SP/k
Plankalkül
Superplan
PolyphonicC#
Prolog
Datalog
KL0
KL1
Strand
VisualProlog
Boo
Cobra
Pure
QB64
Qt
Scheme
Rc
Inferno
JSONRed
Mirah
Potion
Reia
Stylus
Tritium
Ceylon
Fantom
Hop
Kernel
S
Sed
Chomski
SelfAgora
Cel
Squeak
SETL
ProSet
Slim
ShortCode
pascal
SAC
SK8
AppleScript
CommonLispObjectSystem
Logtalk
SpeC#
Speedcoding
SQL
CQL
SOQL
StandardML
StandardMLofNewJersey
Mythryl
StarLogo
STOS_Basic
AMOS
T
Tea
Object-OrientedTuring
TUTORTenCORE
USE
UCBLogo
VBScript
SystemVerilog
Basic4ppc
Gambas
XPath
XForms
XMLSchema
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 83 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Concrete languages
• Most languages offer a mixture of paradigms, yet a few are based on a small base of orthogonal primitives.
• Some are more universal than others, yet no language serves all purposes.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 84 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Concrete languages
• Most languages offer a mixture of paradigms, yet a few are based on a small base of orthogonal primitives.
• Some are more universal than others, yet no language serves all purposes. Orthogonal primitives means here:
For most problems there is exactly one way to do it.
or
“less freedom of choice, less keywords to learn”
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 85 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Concrete languages
• Most languages offer a mixture of paradigms, yet a few are based on a small base of orthogonal primitives.
• Some are more universal than others, yet no language serves all purposes.
Other, pragmatic questions to consider:
How good is the compiler (compilation speed, performance of the produced code)?
How comfortable is the “development environment”?
Does it work well on the platform(s) (computer system(s)) you need?
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 86 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
TranslationsPrograms need to be executed on an actual computer.
All programs need to be translated into machine code.
This happens sometimes in multiple stages (via intermediate languages and machines).
CompilerTranslates a higher level program as a whole into a lower level language.
InterpreterTranslates a higher level program into a lower level language while the higher level program progresses (slower but potentially more interactive).
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 87 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
TranslationsPrograms need to be executed on an actual computer.
All programs need to be translated into machine code.
This happens sometimes in multiple stages (via intermediate languages and machines).
CompilerTranslates a higher level program as a whole into a lower level language.
InterpreterTranslates a higher level program into a lower level language while the higher level program progresses (slower but potentially more interactive).ppotentially more interactive)
level language while otentially more interactive).l
potentially more interactive)
Makes the computer appear to “speak” the high level
language as the “words” are “translated” as you type.
e languages and machines).eYou task a “translator” to make
the computer understand your whole story in one go.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 88 of 793 (chapter 1: “Introduction” up to page 99)
Programming languages
Haskell
• Functional programming language (based on the m-calculus).
• Statically typed with polymorphism and operator overloading.
• Uses monads to provide side-effects and imperative sequences.
Pragmatic aspects:
• Offers compilers as well as interactive environments.
• Concise and compact syntax.
• Compiler detects many errors (while error messages can be confusing).
• Performs mostly better than many, yet slower than some languages (e.g. Ada, C++, …).
• Commonly used for: Verifi able systems, High integrity (non-real time) systems
• Not directly usable for: Real-time systems, High performance systems.
Used as the main language for the course.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 89 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
Human craft and correctness
Programming is a human activity (“The art of programming”).
A program can be well crafted and aesthetical.
A program can be maintainable or unreadable.
Programming is an expression in (temporal) logic:
A program can be correct or incorrect (against a specifi cation).
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 90 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
Human craft and correctness
Programming is a human activity (“The art of programming”).
A program can be well crafted and aesthetical.
A program can be maintainable or unreadable.
Programming is an expression in (temporal) logic:
A program can be correct or incorrect (against a specifi cation).
e Australian National University page 90 y
Programming Languages
ng is a human activity (“The art of programm
A program can be well crafted andd aest
A program can be maintainable or unre
ng is an expression in (temporal) logic:
ogram can be correct or t incorrect (against at
#inclu
de
<ma
th.h>
#inclu
de
<sys/
time.h
>
#inclu
de
<X11/
Xlib.h
>
#inclu
de
<X11/k
eysym.
h>
double
L ,o
,P
,
_=dt,T
,Z,D=1
,d,
s
[999],
E,h= 8
,I,
J
,K,w[9
99],M,
m,O
,n
[999],
j=33e-
3,i=
1E
3,r,t,
u,v ,
W,S=
74
.5,l=2
21,X=7
.26,
a,
B,A=32
.2,c,
F,H;
in
t N,q,
C, y,
p,U;
Win
dow z;
char
f[52]
; GC k
; main
(){ Di
splay*
e=
XOpen
Displa
y( 0);
z=Roo
tWindo
w(e,0)
; for
(XSetF
oregro
und(e,
k=XCre
ateGC
(e,z,0
,0),Bl
ackPix
el(e,0
))
; scan
f(“%lf
%lf%lf
”,y +n
,w+y,
y+s)+1
; y ++
); XSe
lectIn
put(e,
z= XCr
eateSi
mpleWi
ndow(e
,z,0,0
,400,4
00,
0,0,Wh
itePix
el(e,0
) ),Ke
yPress
Mask);
for(X
MapWin
dow(e,
z); ;
T=sin(
O)){ s
truct
timeva
l G={
0,dt*1
e6}
; K= c
os(j);
N=1e4
; M+=
H*_; Z
=D*K;
F+=_*P
; r=E*
K; W=c
os( O)
; m=K*
W; H=K
*T; O+
=D*_*F
/ K+d/
K*E*_;
B=
sin(j)
; a=B*
T*D-E*
W; XCl
earWin
dow(e,
z); t=
T*E+ D
*B*W;
j+=d*_
*D-_*F
*E; P=
W*E*B-
T*D; f
or (o+
=(I=D*
W+E
*T*B,E
*d/K *
B+v+B/
K*F*D)
*_; p<
y; ){
T=p[s]
+i; E=
c-p[w]
; D=n[
p]-L;
K=D*m-
B*T-H*
E; if(
p [n]+
w[ p]+
p[s
]== 0|
K <fab
s(W=T*
r-I*E
+D*P)
|fabs(
D=t *D
+Z *T-
a *E)>
K)N=1
e4; el
se{ q=
W/K *4
E2+2e2
; C= 2
E2+4e2
/ K
*D; N
-1E4&&
XDraw
Line(e
,z,k,
N ,U,q
,C); N
=q; U=
C; } +
+p; }
L+=_*
(X*t +
P*M+m*
l); T=
X*X+ l
*l+M *
M;
XDra
wStrin
g(e,z,
k ,20,
380,f,
17); D
=v/l*1
5; i+=
(B *l-
M*r -X
*Z)*_;
for(;
XPend
ing(e)
; u *=
CS!=N)
{
X
Event
z; XNe
xtEven
t(e ,&
z);
++*
((N=XL
ookupK
eysym
(
&z.xke
y,0))-
IT?
N
-LT? U
P-N?&
E:&
J
:& u:
&h); -
-*(
D
N -N?
N-DT ?
N==
R
T?&u:
& W:&h
:&J
); } m
=15*F/
l;
c+=(I=
M/ l,l
*H
+I*M+a
*X)*_;
H
=A*r+v
*X-F*l
+(
E=.1+X
*4.9/l
,t
=T*m/3
2-I*T/
24
)/S;
K=F*M+
(
h* 1e
4/l-(T
+
E*5*T
*E)/3e
2
)/S-X
*d-B*A
;
a=2.6
3 /l*d
;
X+=(
d*l-T/
S
*(.1
9*E +a
*.64
+J/1e3
)-M*
v +A*
Z)*_
; l +=
K *_
; W=d;
spri
ntf(f,
“%5d
%3d”
“%7d
”,p =l
/1.7,
(C=9E3
+
O*57.3
)%0550
,(int)
i); d+
=T*(.4
5-14/l
*
X-a*
130-J*
.14)*
_/125e
2+F*_*
v; P=(
T*(47
*I
-m* 52
+E*94
*D-t*.
38+u*.
21*E)
/1e2+W
*
179*v
)/2312
; sele
ct(p=0
,0,0,0
,&G);
v-=(
W*
F-T*(.
63*m-I
*.086+
m*E*19
-D*25-
.11*u
)/107
e2)*_;
D=cos
(o); E
=sin(o
); } }
f 793 ( h t 1 “I t d ti ” t 99)
from the: The International Obfuscated C Code Contest, 1998: (c) Landon Curt Noll, Jeremy Horn, Peter Seebach and Leonid A. Broukhis, 1999.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 91 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
Human craft and correctness
Programming is a human activity (“The art of programming”).
A program can be well crafted and aesthetical.
A program can be maintainable or unreadable.
Programming is an expression in (temporal) logic:
A program can be correct or incorrect (against a specifi cation).
e Australian National University page 91 y
Programming Languages
ng is a human activity (“The art of programm
A program can be well crafted and d aest
A program can be maintainable or unre
ng is an expression in (temporal) logic:
ogram can be correct ort incorrect (against at
#inclu
de
<ma
th.h>
#inclu
de
<sys/
time.h
>
#inclu
de
<X11/
Xlib.h
>
#inclu
de
<X11/k
eysym.
h>
double
L ,o
,P
,
_=dt,T
,Z,D=1
,d,
s
[999],
E,h= 8
,I,
J
,K,w[9
99],M,
m,O
,n
[999],
j=33e-
3,i=
1E
3,r,t,
u,v ,
W,S=
74
.5,l=2
21,X=7
.26,
a,
B,A=32
.2,c,
F,H;
in
t N,q,
C, y,
p,U;
Win
dow z;
char
f[52]
; GC k
; main
(){ Di
splay*
e=
XOpen
Displa
y( 0);
z=Roo
tWindo
w(e,0)
; for
(XSetF
oregro
und(e,
k=XCre
ateGC
(e,z,0
,0),Bl
ackPix
el(e,0
))
; scan
f(“%lf
%lf%lf
”,y +n
,w+y,
y+s)+1
; y ++
); XSe
lectIn
put(e,
z= XCr
eateSi
mpleWi
ndow(e
,z,0,0
,400,4
00,
0,0,Wh
itePix
el(e,0
) ),Ke
yPress
Mask);
for(X
MapWin
dow(e,
z); ;
T=sin(
O)){ s
truct
timeva
l G={
0,dt*1
e6}
; K= c
os(j);
N=1e4
; M+=
H*_; Z
=D*K;
F+=_*P
; r=E*
K; W=c
os( O)
; m=K*
W; H=K
*T; O+
=D*_*F
/ K+d/
K*E*_;
B=
sin(j)
; a=B*
T*D-E*
W; XCl
earWin
dow(e,
z); t=
T*E+ D
*B*W;
j+=d*_
*D-_*F
*E; P=
W*E*B-
T*D; f
or (o+
=(I=D*
W+E
*T*B,E
*d/K *
B+v+B/
K*F*D)
*_; p<
y; ){
T=p[s]
+i; E=
c-p[w]
; D=n[
p]-L;
K=D*m-
B*T-H*
E; if(
p [n]+
w[ p]+
p[s
]== 0|
K <fab
s(W=T*
r-I*E
+D*P)
|fabs(
D=t *D
+Z *T-
a *E)>
K)N=1
e4; el
se{ q=
W/K *4
E2+2e2
; C= 2
E2+4e2
/ K
*D; N
-1E4&&
XDraw
Line(e
,z,k,
N ,U,q
,C); N
=q; U=
C; } +
+p; }
L+=_*
(X*t +
P*M+m*
l); T=
X*X+ l
*l+M *
M;
XDra
wStrin
g(e,z,
k ,20,
380,f,
17); D
=v/l*1
5; i+=
(B *l-
M*r -X
*Z)*_;
for(;
XPend
ing(e)
; u *=
CS!=N)
{
X
Event
z; XNe
xtEven
t(e ,&
z);
++*
((N=XL
ookupK
eysym
(
&z.xke
y,0))-
IT?
N
-LT? U
P-N?&
E:&
J
:& u:
&h); -
-*(
D
N -N?
N-DT ?
N==
R
T?&u:
& W:&h
:&J
); } m
=15*F/
l;
c+=(I=
M/ l,l
*H
+I*M+a
*X)*_;
H
=A*r+v
*X-F*l
+(
E=.1+X
*4.9/l
,t
=T*m/3
2-I*T/
24
)/S;
K=F*M+
(
h* 1e
4/l-(T
+
E*5*T
*E)/3e
2
)/S-X
*d-B*A
;
a=2.6
3 /l*d
;
X+=(
d*l-T/
S
*(.1
9*E +a
*.64
+J/1e3
)-M*
v +A*
Z)*_
; l +=
K *_
; W=d;
spri
ntf(f,
“%5d
%3d”
“%7d
”,p =l
/1.7,
(C=9E3
+
O*57.3
)%0550
,(int)
i); d+
=T*(.4
5-14/l
*
X-a*
130-J*
.14)*
_/125e
2+F*_*
v; P=(
T*(47
*I
-m* 52
+E*94
*D-t*.
38+u*.
21*E)
/1e2+W
*
179*v
)/2312
; sele
ct(p=0
,0,0,0
,&G);
v-=(
W*
F-T*(.
63*m-I
*.086+
m*E*19
-D*25-
.11*u
)/107
e2)*_;
D=cos
(o); E
=sin(o
); } }
f 793 ( h t 1 “I t d ti ” t 99)
from the: The International Obfuscated C Code Contest, 1998: (c) Landon Curt Noll, Jeremy Horn, Peter Seebach and Leonid A. Broukhis, 1999.
g”).
Flight simulator code
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 92 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
Programming is …
… essentially easy – everybody can do it in a few easy tutorials?
… intrinsically hard – only the best and bravest will ever get it?
… a weird way to spend your day – lock yourself into a nerdy cellar?
Vote?
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 93 of 793 (chapter 1: “Introduction” up to page 99)
Programming Languages
Programming is …
… essentially easy – everybody can do it in a few easy tutorials?What the salesman of the latest trendy language wants to make you believe.
… intrinsically hard – only the best and bravest will ever get it?That’s what the “old boys” might tell you to keep you out of their feet.
… a weird way to spend your day – lock yourself into a nerdy cellar?Many Hollywood movies about programmers show some of those.
… or …
… a specialized, comparatively recent, professional activity, which requires plenty of care and focus (just like any advanced profession).
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 94 of 793 (chapter 1: “Introduction” up to page 99)
Some things will never work
Decision problems:
• Is a program syntactically correct?
• Is x a prime number?
• Will a program stop given a certain input?
Can one write programs which answer those questions for all cases?
Theory of programming
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 95 of 793 (chapter 1: “Introduction” up to page 99)
Some things will never work
Decision problems:
• Is a program syntactically correct?
• Is x a prime number?
• Will a program stop given a certain input?
Can one write programs which answer those questions for all cases?
The last one (the “Halting problem”) is a representative for a class of algorithmically not solvable decision problems.
Theory of programming
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 96 of 793 (chapter 1: “Introduction” up to page 99)
Undecidable problems
Kurt Gödel ('31): in loose, short translation and paraphrasing:
Any consistent theory can express true statements which cannot be proven within this theory.
Turing ('37): Implications from his article: “On Computable Numbers With an Application to the Entscheidungsproblem”:
No program can decide whether another arbitrary program will terminate on a given input.
Non-trivial properties of programs are algorithmically undecidable(Rice’s theorem '53), yet can often be proven for specifi c cases.
Theory of programming
by Vladymyr Lukash (Ukraine)
phrasing:
Kurt Gödel, ca. 1926, photographer unknown
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 97 of 793 (chapter 1: “Introduction” up to page 99)
Some programs work reliably
• Most fl ight computers.
• Car braking controllers.
• Banking systems.
• High speed trains, subway systems.
• Internet search engines.
• Professional audio/video equipment.…
Professional programing leads to many high integrity systems, some of which we often trust with our lives.
Programming
Boeing 787 cockpit (press release photo)
Midas Pro 6 console (press release photo)
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 98 of 793 (chapter 1: “Introduction” up to page 99)
Programming
What makes a professional programmer?or: How to migrate from “kinda works” to reliable?
• Is “fl uent” in all essential programming concepts and paradigms.
• Knows the right tools for the job and uses them.
• Knows what the available hardware is capable ofand takes this into consideration.
• Understands the translation into executable machine code and controls its essential parameters.
• Understands testing and verifi cation and applies them adequately.
• Finds the best suited abstractions and modularisations (requires experience).
• Knows how to analyse unexpected problems (“debugging”).
This course is the fi rst step.
Introduction
© 2015 Uwe R. Zimmer, The Australian National University page 99 of 793 (chapter 1: “Introduction” up to page 99)
Summary
Introduction
• Defi nitions• Algorithm.
• Computers• Basic hardware concepts.
• Basic forms and distribution.
• Programming languages• Why are they needed?
• Existing paradigms and relation to hardware.
• Things which work and things which won’t.• Impossible and reliable systems.