




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
COMP 524: Programming Language Concepts. 02: Programming Languages. A Brief History of Modern Computing. Early computers required rewiring.
Typology: Study notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















COMP 524: Programming Language Concepts Björn B. Brandenburg The University of North Carolina at Chapel Hill Based in part on slides and notes by S. Olivier, A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010
Early computers required rewiring. ➡ (^) For example, ENIAC (Electronic Numerical Integrator and Computer, 1946) programed with patch cords. ➡ (^) Reprogramming took weeks. ➡ (^) Used to compute artillery tables. 2 Magnetic core memory. Each core is one bit. Source: Wikimedia Commons Credit: H.J. Sommer III, Professor of Mechanical Engineering, Penn State University Von Neumann: stored program computers. ➡ (^) Innovation: program is data. ➡ (^) Program stored in core memory. ➡ (^) Allowed for “rapid” reprogramming. Early programming. ➡ (^) Programmers wrote bare machine code. ➡ (^) Essentially, strings of zeros and ones. ➡ (^) Created with punchcards.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Assembly Code 4 Idea: use the computer to simplify programming! ➡ (^) Possible since programs are data. ➡ (^) Computer transforms human- readable input into machine code. First step: direct mapping. ➡ (^) Use mnemonic abbreviations for instructions. ‣ (^) One abbreviations for each instruction. ‣ (^) Also encode operands. ➡ (^) Computer assembles real program by mapping each line to its machine code equivalent , thus creating a new program. ➡ (^) Assemblers are still in use today.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Assembly Code 5 Idea: use the computer to simplify programming! ➡ (^) Possible since programs are data. ➡ (^) Computer transforms human- readable input into machine code. First step: direct mapping. ➡ (^) Use mnemonic abbreviations for instructions. ‣ (^) One abbreviations for each instruction. ‣ (^) Also encode operands. ➡ (^) Computer assembles real program by mapping each line to its machine code equivalent , thus creating a new program. ➡ (^) Assemblers are still in use today. Machine Code Instructions Operands Example : Intel x86-32 machine code and assembly language of javac program.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 High-Level Language
7
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Early High-Level Languages FORTRAN ➡ (^) John Backus (IBM), 1954. ➡ (^) Formula Translating System ➡ (^) For numerical computing. ➡ (^) Focus: efficiency. LISP ➡ (^) John McCarthy (MIT), 1958. ➡ (^) List Processor. ➡ (^) For symbolic computing. ➡ (^) Focus: abstraction. 8 ALGOL ➡ (^) John Backus (IBM), Friedrich Bauer (TU Munich), etal. , 1958. ➡ (^) Algorithmic Language ➡ (^) For specification of algorithms. ➡ (^) Focus: clear and elegant design. COBOL ➡ (^) Grace Hopper (US Navy), 1959. ➡ (^) Common Business-Oriented Language. ➡ (^) For data processing in businesses. ➡ (^) Focus: english-like syntax.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Definition What is a Programming Language? ➡ (^) Java? ➡ (^) HTML? ➡ (^) Javascript? ➡ (^) LaTeX? 10 Yes. No. Yes. Yes. A programming language is a formal language that is both ➡ (^) universal (any computable function can be defined) ➡ (^) implementable (on existing hardware platforms). Illustration source: Wikimedia Commons Turing-complete : can simulate any Turing machine. (of course, real hardware has space constraints)
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Practical Languages 11 To be of practical interest, a language should also: “Naturally” express algorithms. ➡ (^) With respect to its intended problem domain. ➡ (^) This is often achieved by mimicking existing notation or adopting core concepts (e.g., function definitions, predicates). ➡ (^) In essence, a language must appeal to its intended users to be successful. Be efficiently implementable. ➡ (^) Acceptable definitions of “efficient” vary by problem domain. ➡ (^) For example, in high-performance computing, there is typically no “ efficient enough .” ➡ (^) In contrast, in work on artificial intelligence, efficiency was often only a secondary concern in the past. Design Tradeoff “do what I mean” “do exactly what I say”
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Programming Language Spectrum 13 “do what I mean” “do exactly what I say” Declarative Languages Imperative Languages focus on what the computer should do focus on how the computer should do it Procedural / Von Neumann (Ex: Fortran, Pascal, C) Object-Oriented (Ex: Smalltalk, Eiffel, C++, Java) Functional (Ex: LISP/Scheme, ML, Haskell) Logic and constraint-based (Ex: Prolog) Dataflow (Ex: Id, Val) Scripting (Ex: Shell, TCL, Perl, Python)
Direct evolution from assembly (and thus how computers work internally): a program is a sequential computation that directly manipulates simple typed data (memory locations); abstraction is achieved by calling subroutines as service providers.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Programming Language Spectrum 14 “do what I mean” “do exactly what I say” Declarative Languages Imperative Languages focus on what the computer should do focus on how the computer should do it Procedural / Von Neumann (Ex: Fortran, Pascal, C) Object-Oriented (Ex: Smalltalk, Eiffel, C++, Java) Functional (Ex: LISP/Scheme, ML, Haskell) Logic and constraint-based (Ex: Prolog) Dataflow (Ex: Id, Val) Scripting (Ex: Shell, TCL, Perl, Python)
Human-inspired model: problems are solved by a team of objects that collaborate by sending messages to each other. Objects represent “ subcontractors ” that do one job (possibly with the help of other “experts”) and encapsulate all related state. The benefit of object-orientation is twofold: that large, complex problems can be decomposed in a “ natural ” way; and message passing can be compiled into efficient procedural code.
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Programming Language Spectrum 16 “do what I mean” “do exactly what I say” Declarative Languages Imperative Languages focus on what the computer should do focus on how the computer should do it Procedural / Von Neumann (Ex: Fortran, Pascal, C) Object-Oriented (Ex: Smalltalk, Eiffel, C++, Java) Functional (Ex: LISP/Scheme, ML, Haskell) Logic and constraint-based (Ex: Prolog) Dataflow (Ex: Id, Val) Scripting (Ex: Shell, TCL, Perl, Python)
Inspired by propositional logic. Program is defined in terms of facts (the “knowledge base”), rules (implications, “if X then also Y”), and a goal (query, “is Y true?”, “what makes Y true?”). The computer’s job is to construct a proof based on the given axioms (facts + rules).
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Programming Language Spectrum 17 “do what I mean” “do exactly what I say” Declarative Languages Imperative Languages focus on what the computer should do focus on how the computer should do it Procedural / Von Neumann (Ex: Fortran, Pascal, C) Object-Oriented (Ex: Smalltalk, Eiffel, C++, Java) Functional (Ex: LISP/Scheme, ML, Haskell) Logic and constraint-based (Ex: Prolog) Dataflow (Ex: Id, Val) Scripting (Ex: Shell, TCL, Perl, Python)
Similar to gate networks (hardware). Tokens (units of data) are streamed through a network of primitive functional units. “Unix pipes + loops + multiple inputs / outputs.”
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Programming Language Spectrum 19 Declarative Languages Imperative Languages focus on what the computer should do focus on how the computer should do it Procedural / Von Neumann (Ex: Fortran, Pascal, C) Object-Oriented (Ex: Smalltalk, Eiffel, C++, Java) Functional (Ex: LISP/Scheme, ML, Haskell) Logic and constraint-based (Ex: Prolog) Dataflow (Ex: Id, Val) Scripting (Ex: Shell, TCL, Perl, Python)
UNC Chapel HillUNC Chapel Hill Brandenburg — Spring 2010 Design Considerations Communicate ideas. ➡ (^) Programs are read more often than written. ➡ (^) Maintenance costs. Exactly specify algorithms. ➡ (^) Succinct and precise. ➡ (^) No ambiguity. Create useful programs. ➡ (^) Development must be economically viable. 20 What are the primary use cases? Readability Writability Expressivity Reliability