Early Programming Languages Introductory Presentation
Total Page:16
File Type:pdf, Size:1020Kb
1 /22 Early Programming Languages Introductory presentation History of Programming Languages seminar Riku Saikkonen [email protected].fi 15 September 2009 Beginnings: machine and assembly language 2 /22 Beginnings: machine and assembly language Beginnings: machine and assembly language 3 /22 The first computer programmers • Charles Babbage and Lady Ada Lovelace, 1837–43 • programmed for Charles Babbage’s Analytical Engine (which was never built) • e.g., a program for calculating Bernoulli numbers • programmed using three sets of punch cards, for operators, targets and numeric values • some other early programmers: • A. Turing: Universal Machine, 1936 • J. Eckert and J. Mauchly: first sample program for eniac, 1943 • J. von Neumann: a sorting program for edvac, 1945 • many other early machines were not general-purpose or did not support conditional branches • e.g., H. Aiken 1937 Mark i; J. Atanasoff 1937 abc; K. Zuse 1936–41 z1, z2, z3; J. Eckert 1945–48 ibm ssec Beginnings: machine and assembly language 4 /22 Stored program computers • most early computer-like designs had separate memories for code and data • the eniac (1943–46; Eckert, Mauchly et. al.) was highly parallel, but had little memory: 20 registers, each with its own programmable alu • programmed by rewiring, which took 1–2 days • John von Neumann designed the first stored program instruction sets for the edvac (1944–45; Eckert, Mauchly, von Neumann et. al.) • first version: serial computer, three 32-bit registers, 8192 32-bit words of memory • each word was either a two’s complement number (lsb = 0) or an instruction (lsb = 1, opcode, variant, address) • instructions: add, subtract, multiply, jump, load, . Beginnings: machine and assembly language 5 /22 A few early steps in machine languages • the first design for the edvac instructions used fixed registers, with only a few variations possible, and one memory address per instruction • von Neumann’s second design had two source addresses (registers) in most instructions, and a fixed target (the accumulator) • three-address codes: C. Mooers 1945, J. Mauchly 1946 • flags for terminating loops: C. Mooers 1946 (edvac branched by modifying the target address of a jump instruction) Beginnings: machine and assembly language 6 /22 Example code for the second design for EDVAC John von Neumann’s merge-sorting program (excerpt) SWITCH RST 1 LALPHA1 RST 1 LALPHA2 RST 1 ALPHA SUB YKEY,XKEY SEL LALPHA1,LALPHA2 STO SWITCH JMP SWITCH (Notation by Knuth 1970 – von Neumann’s notation was much less symbolic.) Beginnings: machine and assembly language 7 /22 Assemblers • in the beginning, assembly language was usually converted into binary by hand • in 1945, von Neumann proposed a special typewriter for edvac with special keys that produce parts of the instructions (e.g., opcodes) • other similar shortcuts also existed • the first assembler program: M. Wilkes, D. Wheeler, S. Gill 1949, for edsac Beginnings: machine and assembly language 8 /22 Subroutines and linkers • first subroutines: C. Babbage 1837–43, G. Hopper 1944 • “open subroutines”: copy into program instead of calling a fixed copy • subroutines that return: H. Goldstine, J. von Neumann 1946–47; also A. Turing 1945 • arguments and return addresses were written into the code of the subroutine before calling • coroutines: M. Conway 1958 • many of the early machines had some kind of linker software for relocating subroutine code in memory The first high-level languages 9 /22 The first high-level languages The first high-level languages 10 /22 Beginnings of high-level languages • first goal: a more natural syntax for arithmetic expressions (compared to assembler instructions) • the first high-level programming language was possibly K. Zuse’s Plankalkül, 1948–49 • first compiler: H. Rutishauser 1952 (for a special-purpose language) • this work, along with Fortran, eventually led to the first version of Algol (1959) • included loops: “for k = 1 (1) 10” • next, Fortran, J. Backus 1954–59 The first high-level languages 11 /22 Interpreters • the Universal Turing Machine, 1936 • first actual interpreters: J. Mauchly 1946 • J. Laning, W. Zierler 1952–53: an mathematical language for Whirlwind • “c=0.0053(a-y)/2ay” • first widely used: J. Backus: ibm 701 Speedcoding system (1953) for floating-point arithmetic • assembly-like: “523 SUBAB 100 200 300 TRPL 500” • ipl interpretive system for list processing: A. Newell, J. Shaw, H. Simon 1956 • also assembly-like • many others also existed in 1953–55 • these and other non-machine-code languages were called automatic programming systems in the 1950s The first high-level languages 12 /22 Fortran • John Backus 1954–59 • at ibm with a team: R. Nelson, H. Herrick, L. Haibt, R. Nutt, I. Ziller, S. Best, D. Sayre, R. Goldberg, P. Sheridan • a Fortran compiler for ibm 704 • along with the language, Backus had to design a parser • this later led to Backus–Naur form (bnf, 1959) • emphasis on efficiency and ease of use • pioneered many compiler optimizations • only global variables, no recursion • later, Backus did not really like Fortran and designed a functional programming language (fp, 1977) • Fortran is one of the few early languages that is still widely used (and even developed) The first high-level languages 13 /22 Quotes on Fortran John Backus on creating Fortran (Shasha, Lazere 1995) “Everybody was seeing how expensive programming was. It cost millions to rent machines and yet the cost of programming was as big or bigger.” “It [Fortran] would just mean getting programming done a lot faster. I had no idea that it would be used on other machines. There were hardly any other machines.” John Backus on effect of Fortran (Backus 1981) “. the fact that [languages like Fortran and its successors] have dominated our thinking for twenty years is unfortunate. It is unfortunate because their long-standing familiarity will make it hard for us to understand and adopt new programming styles which one day will offer far greater intellectual and computational power.” The first high-level languages 14 /22 Lisp • John McCarthy wanted a language for experimenting with artificial intelligence • first attempt: flpl added list-processing concepts to Fortran (H. Gelernter, N. Rochester, around 1958) • but McCarthy needed recursion (not in Fortran or flpl) • so McCarthy invented Lisp (1958), with a team at mit • influence from ipl (Newell, Shaw, Simon 1956) • key concept: list processing (instead of working with numbers as in assembly and Fortran) • first language with recursion and garbage collection • applications: symbolic logical inference, automated theorem-proving, other artificial-intelligence experiments The first high-level languages 15 /22 A quote on Lisp John McCarthy (Shasha, Lazere 1995) “If Fortran had allowed recursion, I would have gone ahead using flpl. I even explored the question of how one might add recursion to Fortran. But it was much too kludgy.” The first high-level languages 16 /22 Algol • designed by a committee of computer scientists, first at Zürich in 1958 • people from Germany and the US (including J. Backus) • algol 58, algol 60, algol 68 • local variables and block structure (Fortran did not have them) • recursion (suggested by McCarthy in 1960 from his work on Lisp) • simple “recursive” syntax • predecessor of most current imperative languages (e.g., Pascal and C) The first high-level languages 17 /22 Fortran example Sample code in Fortran i 10 DO 11 I=1,10 11 A(I) = I*N(I) 12 B(2*J,K+2,L) = A(3) 13 STOP The first high-level languages 18 /22 Algol example Code in algol 60 (Sammet 1969) procedure problem (a, b); value a, b; integer a, b, k; for k := 2*(a/2)+1 step 2 until b do begin e := if prime(k) then sqrt(3*k+sin(k)) else sqrt(4*k+cos(k)); if prime(k) then putlist(k, e, ’prime’) else putlist(k, e, ’nonprime’) end end The first high-level languages 19 /22 Lisp example Code in Lisp 1.5 (Sammet 1969) DEFINE (( (REVERSE (LAMBDA (X) (COND ((NULL X) NIL) (T (APPEND (REVERSE (CDR X)) (LIST (CAR X)) )) ))) )) An overview and references 20 /22 An overview and references An overview and references 21 /22 A historical overview of programming languages http://www.levenez.com/lang/lang.pdf (Éric Lévénez 1999–2009) An overview and references 22 /22 References • J. Backus: The History Fortran i, ii and iii. In History of Programming Languages I. acm 1981. • J. Backus: The ibm 701 Speedcoding System. Journal of the ACM 1(1). acm 1954. • H. Goldstine: The Computer from Pascal to von Neumann. Princeton University Press 1972. • D. Knuth: The Art of Computer Programming, vol. 1. 3rd ed., Addison-Wesley 1997. • D. Knuth: Von Neumann’s First Computer Program. Computing Surveys 2(4). acm 1970. • J. Pulkkinen: Sudenluusta supertietokoneeseen: Laskemisen kulttuurihistoriaa. Art House 2004. • J. Sammet: Programming Languages: History and Fundamentals. Prentice-Hall 1969. • D. Shasha, C. Lazere: Out of Their Minds: The Lives and Discoveries of 15 Great Computer Scientists. Copernicus 1995..