cs 199 computers unplugged · cs 199 computers unplugged course notes1 week 4: natural and...

32
CS 199 Computers Unplugged Course Notes 1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer http://www.cs.swan.ac.uk/csetzer/index.html http://www.cs.swan.ac.uk/csetzer/lectures/ computersUnplugged/10/index.html November 5, 2010 1 Substantially based on Stephen Anderson: How many languages are there in the world. Available from http://www.lsadc.org/info/pdf files/howmany.pdf CS 199 1/ 30

Upload: others

Post on 11-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

CS 199 Computers UnpluggedCourse Notes1

Week 4: Natural and Programming LanguagesLecture 2: Programming Languages

Anton Setzerhttp://www.cs.swan.ac.uk/∼csetzer/index.html

http://www.cs.swan.ac.uk/∼csetzer/lectures/computersUnplugged/10/index.html

November 5, 2010

1Substantially based on Stephen Anderson: How many languages are there in theworld. Available from http://www.lsadc.org/info/pdf files/howmany.pdf

CS 199 1/ 30

Page 2: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

How Many Programming Languages are there in thisWorld?

I Number of languages linked from at HOPL:I Same problems as for natural languages:

I Families of languages.I Dialects.I Different versions.I Different compilers for the same language execute differently.

CS 199 2/ 30

Page 3: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

What is a Programming Language?

I The Free Dictionary http://www.thefreedictionary.com:I An artificial language used to write instructions that can be translated

into machine language and then executed by a computer.

I Wikipedia http://en.wikipedia.org/wiki/Programming languageI A programming language is an artificial language designed to express

computations that can be performed by a machine, particularly acomputer

CS 199 3/ 30

Page 4: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

What is a Programming Language?

I Britannica Onlinehttp://www.britannica.com/EBchecked/topic/130670/computer-programming-language

I Computer programming language, any of various languages forexpressing a set of detailed instructions for a digital computer.

I Webopediahttp://www.webopedia.com/TERM/P/programming language.html

I A vocabulary and set of grammatical rules for instructing a computerto perform specific tasks

CS 199 4/ 30

Page 5: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

What is a Programming Language?

I My definition:I A

::::::::::::::programming

::::::::::language is a set of descriptions such that each

description can be used to instruct a computer or other mechanicaldevice to perform a specific task.

CS 199 5/ 30

Page 6: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

What is a Language?

I An::::::::::alphabet is a finite set.

I A:::::::formal

:::::::::::language is a set of strings over a given alphabet.

CS 199 6/ 30

Page 7: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

What is a Programming Language?

I Is mp3 a programming language?I Analogue computer languages.

I Not formal languages.

I Is English a programming language?

CS 199 7/ 30

Page 8: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Adjustment Mechanism of a Mechanical Watch – AnAnalogue Programming Language

CS 199 7a/ 30

Page 9: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Vynil Record – Analogue Programming Language

CS 199 7b/ 30

Page 10: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Antikythera Mechanism

CS 199 8/ 30

Page 11: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Antikythera Mechanism

CS 199 9/ 30

Page 12: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Antikythera Mechanism (around 150 - 100 BCE)

I From http://en.wikipedia.org/wiki/Computer programming:I The Antikythera mechanism from ancient Greece was a calculator

utilizing gears of various sizes and configuration to determine itsoperation, which tracked the metonic cycle still used in lunar-to-solarcalendars, and which is consistent for calculating the dates of theOlympiads.

I From Mark Wonnacott: Analogue Computers: The First DeclarativeProgramming.http://ragzouken.com/compsci/languages.pdf

I The first machine computable delcarative program is within the earliestmechanical computer, the Antikythera mechanism (c. 70 BC).Changing the date with the mechanism’s hand-crank turned a complexarrangement of gears to compute astronomical positions. Differentgearing rations between connected gears dictate the relationshipsbetween them and ultimately between the date and calculatedastronomical positions. These relationships are invariantly satisfied bythe turning of the gears, making the gears a form of declarativeprogram.

CS 199 10/ 30

Page 13: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Al-Jazari Musical Robots – A Digital ProgrammingLanguage

CS 199 11/ 30

Page 14: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

History of Programming Languages

I Wikipedia, http://en.wikipedia.org/wiki/Al-JazariI l-Jazari created a musical automaton, which was a boat with four

automatic musicians that floated on a lake to entertain guests at royaldrinking parties. Professor Noel Sharkey has argued that it is quitelikely that it was an early programmable automata and has produced apossible reconstruction of the mechanism; it has a programmable drummachine with pegs (cams) that bump into little levers that operated thepercussion. The drummer could be made to play different rhythms anddifferent drum patterns if the pegs were moved around. According toCharles B. Fowler, the automata were a ”robot band” which performed”more than fifty facial and body actions during each musical selection.”

CS 199 12/ 30

Page 15: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Jacquard Loom (Invented 1801)

Jacquard Loom, invented by Joseqph Marie Jacquard 1801

CS 199 13/ 30

Page 16: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Babbage’s Analytical Engine (1834)

CS 199 14/ 30

Page 17: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Babbage’s Analytical Engine – First Turing CompleteLanguage

I It’s Turing complete.I More in CS-236 Lanugage and Computation.

I Any computable function can be computed in principle usingBabbage’s Analytical Engine.

I The language for Babbage’s Analytical Engine is probably the firstTuring-Complete Programming Language.

CS 199 15/ 30

Page 18: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Ada Lovelace - The first Computer Programmer

CS 199 16/ 30

Page 19: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Hello World Program

CS 199 17/ 30

Page 20: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

99 Bottles of Beer

CS 199 18/ 30

Page 21: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Popular Languages

I Java

I C

I C++

I Pascal

CS 199 19/ 30

Page 22: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Scripting Languages

I Perl

I Python

CS 199 20/ 30

Page 23: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Easy to Use Languages

I BASIC

I Visual Basic

CS 199 21/ 30

Page 24: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Functional Programming Languages

I Haskell

I SML

I Coq (dependently typed)

CS 199 22/ 30

Page 25: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Logic Programming

I Prolog

CS 199 23/ 30

Page 26: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Markup Languages/Spreadsheets

I HTML

I Excel

CS 199 24/ 30

Page 27: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Misc

I Database LanguagesI SQL

I Graphical LanguagesI LabVIEW

CS 199 25/ 30

Page 28: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Historically Famous Languages

I Babbage’s Analytical Language

I ENIAC

I FORTRAN

I LISP

I Cobol

I Simula

CS 199 26/ 30

Page 29: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Assembler

CS 199 27/ 30

Page 30: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Theoretical Languages

I Turing Machine

I CSP

CS 199 28/ 30

Page 31: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Extreme Languages

I SheerPower.I Aimed at having the fastest compilation.I What does this mean?

I Brainfuck.I Aimed at having thesmallest compiler.I What does this mean?

I MalbolgeI Aimed at having the most incomprehensible language.

CS 199 29/ 30

Page 32: CS 199 Computers Unplugged · CS 199 Computers Unplugged Course Notes1 Week 4: Natural and Programming Languages Lecture 2: Programming Languages Anton Setzer ... I A programming

Esoteric Languages

I Cow.

I LOLCODE.

I Piet.

I Whitespace.

CS 199 30/ 30