Topic I � Introduction and Motivation

Total Page:16

File Type:pdf, Size:1020Kb

Topic I � Introduction and Motivation � Topic I � Introduction and motivation References: � Chapter 1of Concepts in programm ing languages by J. C. Mitchell. CUP, 2003. � Chapter 1of Programming languag es: Design and implementation(3 RD EDITION) by T.W. Pr tt !" M. #.$elkowit'. Prentice Hall, )***. � Chapter 1of Programming languag e pragmatics (2ND EDITION) by M. L. ,cott. El-e.ier, 2006. � 5 Goals Critic l thinking bout 1rogr 3mi!2 la!20 ge-. ? What is 1rogr 33i!2 l !20 ge45 Study 1rogr 3mi!2 la!20 ge-. � 6e f 3iliar &ith ba-ic l !20 2e concepts. � 71preciate tr de8off- i! l !20 ge design. Tr ce history, 1preci te evolution !" di.er-ity of ideas. 6e 1re1 red for !e& 1ro2r 33i!2 methods, paradigms. � 6 Why study programming languages? � To i31ro.e the ability to "e.elop effecti.e lgorithms. � To i31ro.e the 0-e of f 3ili r l !20 2es. � To incre -e the .oc b0lary of 0-ef0l pro2r 33i!2 con-truct-. � To llo& better choice of 1rogr 33i!2 l !20 2e. � To 3 %e it e -ier to lear! !e& l !20 ge. � To 3 %e it e -ier to "e-ig! ne& l !20 2e. � To -im0late 0-ef0l feat0re- in l !20 ge- that l c% them. � To 3 %e better 0-e of l !20 2e technology &here.er it 11ear-. � 7 What makes a good language? Clarity, -i31licity, !" 0!ity. Ortho2onality. N turalne-- for the 11lication. ,011ort of bstraction. E -e of pro2r 3 .eri9c tion. Progr 33i!2 e!.iro!3ent-. Portability of 1rogr 3-. � 8 Co-t of 0-e. � Co-t of e:ec0tio!. � Co-t of 1rogr 3 tr !-l tion. � Co-t of 1rogr 3 creatio!, te-ti!2, !" 0-e. � Co-t of 1rogr 3 mai!te! !ce. � 9 What makes a language successful? � E:1re--ive 1o&er. � E -e of 0-e for the !o.ice. � E -e of imple3ent tio!. � O1en -o0rce. � E:cellent co31iler-. � Eco!omic-, 1 tron 2e, !" inertia. � 10 Influences Co31uter c 1abilitie-. 71plic tio!-. Progr 33i!2 method-. I31lementatio! 3etho"-. Theoretic l -t0"ies. ,t !"ar"is tion. � 11 Applications domains Era Application Major languages Other languages )*/0- 60-i!e-- CO6O+ 7--e3bler ,cie!ti9c ;ORTR7N 7+<O+, 67,IC, 7P+ ,y-te3 7--e3bler JO#I7+, ;orth AI +I,P ,NO6O+ To" y 60-i!e-- CO6O+, ,=+, -1re "-heet C, P+>I, ?<+- ,cie!ti9c ;ORTR7N, C, C@@ 67,IC, P -c l M 1le, M the3 tic ,y-te3 6CP+, C, C@@ P -c l, 7" , 67,IC, MODU+7 AI +I,P, Prolo2 P0bli-hi!2 TEA, Po-tcri1t, &ord 1roce--i!2 Proce-- UNIA -hell, TC+, Perl M r.el, E-terel Ne& 1 r "i23- ,3 llt l%, ,M+, ( -%ell, J . Eifell, CB, ,c l Pytho!, R0by � 12 5 Why are there -o 3 !y l !20 ge-5 � E.olution. � ,1ecial 10rpo-e-. � Per-onal 1reference. � 13 ��Motivating application in l !20 ge de-i2!�� 7 -1eci9c 1ur1o-e pro.ide- focus for l !20 2e "esig!er-C it hel1- to -et criteri for 3 %in2 "e-i2! deci-io!-. 7 -1eci9c, 3otivati!2 1plic tio! lso help- to -ol.e one of the har"est 1roblems i! 1ro2r 3min2 la!20 2e de-ig!D deci"in2 &hich feat0res to lea.e out. � 14 Examples: <oo" l !20 2es de-i2!ed &ith -peci9c 10r1ose i! mind. � +I,PD -y3bolic co310tation, 0tomate" re -oni!2 � ;PD f0!ction l pro2r 3min2, algebraic la&- � 6CP+D co31iler &ritin2 � ,i30l D -i30lation � CD -y-te3- 1rogr 33i!2 � MLD theore3 1ro.i!2 � ,3 llt lkD Dy!aboo% � Clu, ,M+ Mo"ulesD 3o"0lar pro2r 3min2 � C++D object orientatio! � J . D I!ternet 11lic tio!- � 15 Program execution model <ood l !20 ge de-ig! 1resent- abstract machine. � ;ORTR7ND ;l t regi-ter 3 chineC 3emory rr !2e" - linear rr y � +I,PD co!- cell-, re "8e. l-1ri!t loop � 7lgol familyD -t c% of activatio! recor"-C he 1 -tor ge � 6CP+, CD 0!derlyin2 3 chine @ bstr ction- � ,i30l D Object references � ;P, MLD f0!ction- re b -ic co!trol -tr0ct0re � ,3 llt lkD object- !" method-, comm0!icati!2 by 3e-- ge- � J . D J . .irt0al 3 chine � 16 ��Cl --i9c tio! of 1ro2r 3mi!2 la!20 2e-�� I31erati.e 1roced0ral C,7"a,Pascal,Algol,FORTRAN,... object orie!te" cala, C#,J . , malltal!, "MU$A,... -criptin2 Perl, Pytho!, P(P, . Decl rati.e f0!ctio! l ( -%ell, ,M+, +i-1, ,che3e, . logic Prolo2 "at Fo& I", #al con-tr int8b -ed -1re "-heet- template-b -e" A,+T � 17 Theoretical foundations Examples: � ;or3 l-l !20 2e theory. � 7uto3 t theory. � 7lgorithmic-. � λ8calc0l0-. � ,e3 ntic-. � ;or3 l .erific tio!. � Ty1e theory. � Co31le:ity theory. � +ogic. � 18 Standardisation Proprietary -t !" r"-. Co!-e!-0- -t !"ar"-. � 7N,I. � IEEE. � 6,I. � I,O. � 19 Language standardisation Co!-iderD int i; i = (1 && 2) + 3 ; ? I- it .ali" C code? If -o, &hatG- the .alue of i5 ? (o& "o &e !-&er -0ch H0estio!-45 % Re " the reference 3 !0al. % Try it !" -ee4 % Re " the 7N,I C ,t !"ar". � 20 Language8standards issues Timeliness. Whe! "o &e -t !"ar"ise l !20 ge5 Conformance& What does it 3e ! for 1ro2r 3 to dhere to -t !"ar" !" for co31iler to compile -t !" r"5 Ambiguity and freedom to optimise — Machine dependence — Undefined behaviour O'solescence& Whe! "oes -t !" r" ge !" ho& "oe- it 2et 3odi9ed5 Deprecated features � 21 Language standards PL/1 ? What does the followin2 9 + 8/3 3e !5 − 11.666... 5 − O.erFo& 5 − 1.666... 5 � 22 DEC(p,q) 3e !- p "igit- &ith q fter the deci3 l point. Ty1e rule- for DECIM7+ i! P+>)D DEC(p1,q1) + DEC(p2,q2) => DEC(MIN(1+MAX(p1-q1,p2-q2)+MAX(q1,q2),15),MAX(q1,q2)) DEC(p1,q1) / DEC(p2,q2) => DEC(15,15-((p1-q1)+q2)) � 23 ;or 9 + 8/3 &e h .eD DEC(1,0) + DEC(1,0)/DEC(1,0) => DEC(1,0) + DEC(15,15-((1-0)+0)) => DEC(1,0) + DEC(15,14) => DEC(MIN(1+MAX(1- ,15-14)+MAX(0,14),15),MAX(0,1!)) => DEC(15,14) ,o the calc0lation i- - follo&- 9 + 8/3 = 9 + 2.66666666666666 = 11.66666666666666 - "#ER%&"' = 1.66666666666666 - "#ER%&"' (is*+,-( � 24 istory 1()1–)5: E:1eri3ent l 0-e of e:1res-ion compiler-. 1()+*+0: FORTRAN, CO6O+, $" P, Algol 60. 1(+1–+5: 7P+ !ot tion, 7l2ol 60 (re.i-ed), ,NO6OL, CPL. 1(++*-0: 7PL, ,NO6O+ ?, ;ORTR7N //, 67,IC, "M#$A, 7lgol /I, 7lgol8W, 6CPL. 1(-1–-5: Pascal, P+>) (,t !" rd), C, ,che3e, Prolog. 1(-+*.0: malltal!, 7" , ;ORTR7N J7, ML. � 25 1(.1–.5: ,3 llt lk8I0, Prolog, 7" I3. 1(.+*(0: C@@, M$, ( -%ell. 1((1–(5: 7" *5, TCL, Perl. 1((+*/,,0: J .a. /,,,*,5: CB, Pytho!, R0by, cala. � 26 Language groups M0lti-1ur1o-e la!20 2e- � ,c la, CB, J . , C@@, C � ( -%ell, ,M+, Scheme, LI,P � Perl, Python, R0by ,1ecial810rpo-e l !20 2es � UNIA -hell � ,=+ � +7TEA � 27 Things to think a!out What 3 %es 2oo" l !20 ge5 The role of 1. 3oti. ti!2 11lication-, 2. 1rogr 3 e:ecution, 3. theoretic l fo0!"ation- i! l !20 ge "esign. + !20 ge -t !" rdi- tion. � 28.
Recommended publications
  • Latest Results from the Procedure Calling Test, Ackermann's Function
    Latest results from the procedure calling test, Ackermann’s function B A WICHMANN National Physical Laboratory, Teddington, Middlesex Division of Information Technology and Computing March 1982 Abstract Ackermann’s function has been used to measure the procedure calling over- head in languages which support recursion. Two papers have been written on this which are reproduced1 in this report. Results from further measurements are in- cluded in this report together with comments on the data obtained and codings of the test in Ada and Basic. 1 INTRODUCTION In spite of the two publications on the use of Ackermann’s Function [1, 2] as a mea- sure of the procedure-calling efficiency of programming languages, there is still some interest in the topic. It is an easy test to perform and the large number of results ob- tained means that an implementation can be compared with many other systems. The purpose of this report is to provide a listing of all the results obtained to date and to show their relationship. Few modern languages do not provide recursion and hence the test is appropriate for measuring the overheads of procedure calls in most cases. Ackermann’s function is a small recursive function listed on page 2 of [1] in Al- gol 60. Although of no particular interest in itself, the function does perform other operations common to much systems programming (testing for zero, incrementing and decrementing integers). The function has two parameters M and N, the test being for (3, N) with N in the range 1 to 6. Like all tests, the interpretation of the results is not without difficulty.
    [Show full text]
  • Cs 98 Algol W Implementat Ion by H. Bauer S. Becker S
    CS 98 ALGOL W IMPLEMENTAT ION BY H. BAUER S. BECKER S. GRAHAM TECHNICAL REPORT NO. CS 98 MAY 20, 1968 COMPUTER SC IENCE DEPARTMENT School of Humanities and Sciences STANFORD UNIVERS llTY ALGOL W IMPLEMENTATION* -- H, Bauer S. Becker S. Graham * This research is supported in part by the National Science Foundation under grants GP-4053 and ~~-6844. -ALGOL -W IMPLEMENTATION Table -.of Contents ,, 1, Introduction . ..~.........*0.~.**.e.....*.....".....* XI. General Organization . ..os.*..e.~*....~****.*..*.. 3 lX1. Overall Design . ..*.0~....~..~e~eo~o.e...e.....*~~.... 4 A. Principal Design Considerations . ..*......** 4 B. Run-Time Program and Data Segmentation ., ,,,... 6 C. Pass One . ..~D..O......~e~~.*~.*~.....~.. 7 D. Pass Two . ..*..eOC~O.4....*~~..~...~..~~....~ 8 1. Description of Principles and -=. Main Tasks .*0*.*.......0~,00*..*..* 8 2. Parsing Algorithm . ...*......**.* 8 3* Error Recovery .0....~..~.~.~.,~,~~~, 9 4. Register Analysis . ..*.......*.... 11 L- 5* Tables *.....@.,..*......e..*.*.y...* 13 6. Output ,.......*..*0..00..0*~~..~... 13 E. Pass Three . ..0......*....e...e..e.e........*, 16 L l-v. Compiler Details . ..~..~~~...~~~~.~~.....~..~... 17 A. Run-Time Organization ..~*0**~..*~...~...*~..., 17 1. Program and Data Segmentation ,,.,., 17 2. Addressing Conventions . ..*.9..*..** 20 30 Block Marks and Procedure Marks ,.., 20 4. Array Indexing Conventions . ..I.# 22 5. Base Address Table and Lirikage to System Routines . ..****..o....*.. 23 6. Special Constants and Error Codes ,. 24 Register Usage ..OI.OI.O,,..O..L,..~ 27 ;3** Record Allocation and Storage Reclamation .0.0.~.~*0*~0..~~~.**, 27 B. Pass We r....oc.o....o....o..~.*..~*.,.,.....* 33 1. Table Formats Internal to Pass One . ..0...*ee..o...Q....*.~.* 3c 2. The Output String Representing an ALGOL W Program l .
    [Show full text]
  • 50 Years of Pascal Niklaus Wirth the Programming Language Pascal Has Won World-Wide Recognition
    50 Years of Pascal Niklaus Wirth The programming language Pascal has won world-wide recognition. In celebration of its 50th birthday I shall remark briefly today about its origin, spread, and further development. Background In the early 1960's, the languages Fortran (John Backus, IBM) for scientific, and Cobol (Jean Sammet, IBM and DoD) for commercial applications dominated. Programs were written on paper, then punched on cards, and one waited for a day for the results. Programming languages were recognized as essential aids and accelerators of the hard process of programming. In 1960, an international committee published the language Algol 60. It was the first time that a language was defined by concisely formulated constructs and by a precise, formal syntax. Already two years later it was recognized that a few corrections and improvements were needed. Mainly, however, the range of applications should be widened, because Algol 60 was intended for scientific calculations (numerical mathematics) only. Under the auspices of IFIP a Working Group (WG 2.1) was established to tackle this project. The group consisted of about 40 members with almost the same number of opinions and views about what a successor of Algol should look like. There ensued many discussions, and on occasions the debates ended even violently. Early in 1964 I became a member, and soon was requested to prepare a concrete proposal. Two factions had developed in the committee. One of them aimed at a second, after Algol 60, milestone, a language with radically new, untested concepts and pervasive flexibility. The other faction remained more modest and focused on realistic improvements of known concepts.
    [Show full text]
  • 5. the Implementation of Algol W
    5. THE IMPLEMENTATION OF ALGOL W The two preceding chapters outline the data and control structures which appear with minor variations in most implementations of Algol-like languages, and they suggest how mechanisms for providing debugging facilities can be superimposed upon such structures. By emphasizing the generality of certain ideas, however, those chapters obscure the many crucial and often nontrivial problems of detail which must be solved for a particular language and implementation. This and subsequent chapters describe the internal structure of an implemented debugging system, which is based upon the Algol W language and the IBM System/360, IBM System/370, or ICL System 4 hardware. Various design problems are pinpointed and their solutions are described. Some of these are of general interest; others are specific to Algol W or the System/360 and are mentioned primarily to suggest the kinds of difficulties other designers should anticipate. This chapter sketches the underlying implementation of Algol W. It illustrates the application of some of the ideas in Chapter 3 and provides information necessary for understanding subsequent chapters. It also attempts to demonstrate that many features of the Algol W language and System/360 hardware naturally lead to design decisions which, as subsequent chapters show, simplify the implementation of useful debugging aids. The treatment of detail is intentionally selective; very cursory attention is given to those features of the compiler and object code which either are quite standard or are unrelated to the provision of debugging tools. A more thorough, although rather obsolete, description of the compiler is available elsewhere [Bauer 68].
    [Show full text]
  • An Interview with Tony Hoare ACM 1980 A.M. Turing Award Recipient
    1 An Interview with 2 Tony Hoare 3 ACM 1980 A.M. Turing Award Recipient 4 (Interviewer: Cliff Jones, Newcastle University) 5 At Tony’s home in Cambridge 6 November 24, 2015 7 8 9 10 CJ = Cliff Jones (Interviewer) 11 12 TH = Tony Hoare, 1980 A.M. Turing Award Recipient 13 14 CJ: This is a video interview of Tony Hoare for the ACM Turing Award Winners project. 15 Tony received the award in 1980. My name is Cliff Jones and my aim is to suggest 16 an order that might help the audience understand Tony’s long, varied, and influential 17 career. The date today is November 24th, 2015, and we’re sitting in Tony and Jill’s 18 house in Cambridge, UK. 19 20 Tony, I wonder if we could just start by clarifying your name. Initials ‘C. A. R.’, but 21 always ‘Tony’. 22 23 TH: My original name with which I was baptised was Charles Antony Richard Hoare. 24 And originally my parents called me ‘Charles Antony’, but they abbreviated that 25 quite quickly to ‘Antony’. My family always called me ‘Antony’, but when I went to 26 school, I think I moved informally to ‘Tony’. And I didn’t move officially to ‘Tony’ 27 until I retired and I thought ‘Sir Tony’ would sound better than ‘Sir Antony’. 28 29 CJ: Right. If you agree, I’d like to structure the discussion around the year 1980 when 30 you got the Turing Award. I think it would be useful for the audience to understand 31 just how much you’ve done since that award.
    [Show full text]
  • Comparative Programming Languages
    Comparative Programming Languages hussein suleman uct csc304s 2003 Course Structure 15 lectures 2 assignments 1 x 2-week programming assignment 1 x 1-week “written” tutorial open-book final (1/2 paper) 1 Course Topics overview of paradigms evolution of languages assignment and expressions types, variables, binding and scope pointers and memory management control structures, subprograms runtime execution exceptions concurrency visual languages scripting languages Overview of Paradigms and PL Issues 2 Why study programming languages? Understand differences and similarities. Understand concepts and structures independently of languages. Learn reasons for design decisions in particular languages. Develop the ability to choose appropriate languages and paradigms for particular tasks. Develop the ability to design languages. Common paradigms paradigm n. pattern, model - Dorling Kindersley Dictionary Procedural a.k.a. Imperative imperative = peremptory, urgent, necessary peremptory = imperious, dictatorial, precluding opposition imperious = dominating, dictatorial Object-oriented Declarative a.k.a. Logic Functional 3 Examples Language Paradigm C C++ Java Clean Prolog Assembly Language Visual C++ HTML C# Javascript (Programming) Languages Languages are used to standardise communication. What makes it a programming language? Is HTML a programming language? Javascript? SQL? 3 traditional concepts: sequence selection iteration 4 Issues in comparing languages Simplicity Orthogonality Control structures Data types and type checking Syntax Abstractions
    [Show full text]
  • Wirth Abstract an Entire Potpourri of Ideas Is Listed from the Past Decades of Computer Science and Computer Technology
    1 Zürich, 2. 2. 2005 / 15. 6. 2005 Good Ideas, Through the Looking Glass Niklaus Wirth Abstract An entire potpourri of ideas is listed from the past decades of Computer Science and Computer Technology. Widely acclaimed at their time, many have lost in splendor and brilliance under today’s critical scrutiny. We try to find reasons. Some of the ideas are almost forgotten. But we believe that they are worth recalling, not the least because one must try to learn from the past, be it for the sake of progress, intellectual stimulation, or fun. Contents 1. Introduction 2. Hardware Technology 3. Computer Architecture 3.1. Representation of numbers 3.2. Data addressing 3.3. Expression Stacks 3.4. Variable length data 3.5. Storing return addresses in the code 3.6. Virtual Addressing 3.7. Memory protection and user classes 3.8. Complex Instruction Sets 3.9. Register windows 4. Programming Language Features 4.1. Notation and Syntax 4.2. The GO TO statement 4.3. Switches 4.4. Algol’s complicated for statement 4.5. Own variables 4.6. Algol’s name parameter 4.7. Incomplete parameter specifications 4.8. Loopholes 5. Miscellaneus techniques 5.1. Syntax analysis 5.2. Extensible languages 5.3. Nested procedures and Dijkstra’s display 5.4. Tree-structured symbol tables 5.5. Using wrong tools 5.6. Wizards 6. Programming paradigms 6.1. Functional programming 6.2. Logic programming 2 6.3. Object-oriented programming 7. Concluding remarks 1. Introduction The history of Computing has been driven by many good and original ideas.
    [Show full text]
  • Wirth Transcript Final
    A. M. Turing Award Oral History Interview with Niklaus Wirth by Elena Trichina ETH, Zürich, Switzerland March 13, 2018 Trichina: My name is Elena Trichina. It is my honor to interview Professor Niklaus Wirth for the Turing Award Winners Project of the Association for Computing Machinery, the ACM. The Turing Award, sometimes referred to as “the Nobel Prize of computing,” is given annually for major contributions of lasting importance in computing. Professor Wirth received his award in 1984 in recognition of his outstanding work in developing a sequence of programming languages – Euler, Algol-W, Pascal, Modula. The hallmarks of Wirth’s languages are their simplicity, economy of design, and high-level engineering. We will talk about it and many other things later today in the interview that takes place on the 13th of March, 2018, in the Swiss Federal Institute of Technology. So we start. Ready? Guten Tag, Niklaus. Gruetzi. Wirth: Добрый ден, Елена Василевна Здравствуи [Good morning, Elena. Hello. – ed.] Trichina: Well, although your command of Russian is sufficient, my command of Swiss German is a little bit rudimentary. Shall we continue in one of the languages where we both feel comfortable? What would it be? French? English? Wirth: Oh, I think English is better for me. Yes, yes. Trichina: Okay. It’s probably better for the audience. [laughs] Wirth: Okay. True. Trichina: Okay. We continue in English. Here in front of me there is a list of the most important days in your life. You were born in February 1934 in Winterthur, which is a sort of middle-size industrial town in Switzerland.
    [Show full text]
  • Presentation (PDF)
    Back to the future – the history of programming languages Robert Stroud! Adelard LLP! ! [email protected]! 1! Abstract • What can we learn from the history of programming languages? ! • Are we still seeing technical innovation after 50-60 years of evolution or is there nothing new under the sun? ! • What can the past tell us about the future? ! • In this talk, I will review some of the key arguments and debates that have informed the development of programming language and speculate about current and future trends.! 2! Overview of talk • My first programming language! • A brief history of programming languages! • Technical debates! • What does the future hold?! 3! “Real Programmers don't eat quiche”! !Anon, c.1984! MY FIRST PROGRAMMING LANGUAGE 4! Real Programmers • Real Programmers don’t write application programs - they program right down on the bare metal. Applications programming is for the dullards who can’t do system programming.! • Real Programmers don’t document. Documentation is for simpletons who can’t read listings or the object code from the dump.! • Real Programmers don't write in PASCAL, or BLISS, or ADA, or any of those pinko computer science languages. Strong typing is for people with weak memories.! 6! My first programming language (1974) • FORTRAN, written on punched cards, running on an IBM 1130 in the sub-basement of Claremont Tower! 7! My first computer (1974) • IBM 1130, with up to 32K memory (3.6µs), 1MB disk.! • Fortran compiler ran in 8K! • Card reader could read up to 400 cards/minute! • Printer ran at 120 characters,
    [Show full text]
  • Programming Languages and Their Trustworthy Implementation
    Programming languages and their trustworthy implementation Xavier Leroy INRIA Paris Van Wijngaarden award, 2016-11-05 A brief history of programming languages and their compilation It's all zeros and ones, right? 10111000 00000001 00000000 00000000 00000000 10111010 00000010 00000000 00000000 00000000 00111001 11011010 01111111 00000110 00001111 10101111 11000010 01000010 11101011 11110110 11000011 (x86 machine code for the factorial function) Machine code is. That doesn't make it a usable language. Antiquity (1950): assembly language A textual representation of machine code, with mnemonic names for instructions, symbolic names for code and data labels, and comments for humans to read. Example (Factorial in x86 assembly language) ; Input: argument N in register EBX ; Output: factorial N in register EAX Factorial: mov eax, 1 ; initial result = 1 mov edx, 2 ; loop index = 2 L1: cmp edx, ebx ; while loop <= N ... jg L2 imul eax, edx ; multiply result by index inc edx ; increment index jmp L1 ; end while L2: ret ; end Factorial function The Renaissance: arithmetic expressions (FORTRAN 1957) Express mathematical formulas the way we write them on paper. p −b ± b2 − 4ac x ; x = 1 2 2a In assembly: In FORTRAN: mul t1, b, b sub x1, d, b D = SQRT(B*B - 4*A*C) mul t2, a, c div x1, x1, t3 X1 = (-B + D) / (2*A) mul t2, t2, 4 neg x2, b X2 = (-B - D) / (2*A) sub t1, t1, t2 sub x2, x2, d sqrt d, t1 div x2, x2, t3 mul t3, a, 2 A historical parallel with mathematics Brahmagupta, 628: Whatever is the square-root of the rupas multiplied by the square [and] increased by the square of half the unknown, diminish that by half the unknown [and] divide [the remainder] by its square.
    [Show full text]
  • Algol and Pascal
    � Topic IV � Block-structured procedural languages Algol and Pascal References: � Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. � Chapters 10(§2) and 11(§1)of Programming languag es: Design and implementation(3 RD EDITION) by T.W. P !tt !"# M. $.%el&o'it(. P entice )all, *+++. � 74 Chapter 5of Programming languag es: Concepts & constructs by R.,ethi (2ND EDITION). -#di.on-Wesley, *++6. Chapter 7of Understanding program ming languages by M 0en-- i. Wiley, *++/. � 75 �� �� ��Parameters�� The e ! e t'o conce1t. that 23.t be cle! ly #isti"4ui.he#5 � - formal parameter i. ! #ecl! ation that !11ea . i" the #ecla !tio" of the .3bp o4 am. (The comput!tion in the body of the .ub1ro4 !2 i. ' itten in ter2. of fo mal 1! !mete ..) � -" actual parameter i. ! 6al3e that the c!lli"4 1 o4 !2 .en#. to the .3bp o4 !m. Example: Named 1! !mete !..ociatio".. No 2!lly the !ct3!l 1! !2eter. in ! .3b1 o4 !2 c!ll ! e 73.t listed !"# the matchi"4 'ith the formal 1! !meter. is do"e by � 76 1ositio"5 procedure Proc(First: Integer; Second: Character); Proc(24,’h’); I" -#! it i. 1os.ible to 3.e named association i" the c!ll: Proc(Second => ’h’, First => 24); ? What about in ML9 Can it be .i2ul!ted9 Thi. i. commo"ly 3.ed togethe 'ith default parameters5 procedure Proc(First: Integer := 0; Second: Character := ’*’); Proc(Second => ’o’); � 77 �� �� ��Parameter passing�� The '!y that !ct3al 1! !2eter. ! e e6al3ate# !"# 1!..e# to 1 oced3re.
    [Show full text]
  • Programming Languages and Their Trustworthy Implementation
    Programming languages and their trustworthy implementation Xavier Leroy INRIA Paris Van Wijngaarden award, 2016-11-05 A brief history of programming languages and their compilation It's all zeros and ones, right? 10111000 00000001 00000000 00000000 00000000 10111010 00000010 00000000 00000000 00000000 00111001 11011010 01111111 00000110 00001111 10101111 11000010 01000010 11101011 11110110 11000011 (x86 machine code for the factorial function) Machine code is. That doesn't make it a usable language. Antiquity (1950): assembly language A textual representation of machine code, with mnemonic names for instructions, symbolic names for code and data labels, and comments for humans to read. Example (Factorial in x86 assembly language) ; Input: argument N in register EBX ; Output: factorial N in register EAX Factorial: mov eax, 1 ; initial result = 1 mov edx, 2 ; loop index = 2 L1: cmp edx, ebx ; while loop <= N ... jg L2 imul eax, edx ; multiply result by index inc edx ; increment index jmp L1 ; end while L2: ret ; end Factorial function The Renaissance: arithmetic expressions (FORTRAN 1957) Express mathematical formulas the way we write them on paper. p −b ± b2 − 4ac x ; x = 1 2 2a In assembly: In FORTRAN: mul t1, b, b sub x1, d, b D = SQRT(B*B - 4*A*C) mul t2, a, c div x1, x1, t3 X1 = (-B + D) / (2*A) mul t2, t2, 4 neg x2, b X2 = (-B - D) / (2*A) sub t1, t1, t2 sub x2, x2, d sqrt d, t1 div x2, x2, t3 mul t3, a, 2 A historical parallel with mathematics Brahmagupta, 628: Whatever is the square-root of the rupas multiplied by the square [and] increased by the square of half the unknown, diminish that by half the unknown [and] divide [the remainder] by its square.
    [Show full text]