180 likes | 411 Views
CS C362 Programming Languages & Compiler Construction. Today’s Agenda. Course Perspectives Computing vs. Programming Programs Programming Languages Course Scope & Administrivia Coverage Projects / Tutorials. Course Perspectives. Computing vs. Programming
E N D
CS C362Programming Languages & Compiler Construction Sundar B., BITS, Pilani. TA C252
Sundar B., BITS, Pilani. TA C252 Today’s Agenda Course Perspectives Computing vs. Programming Programs Programming Languages Course Scope & Administrivia Coverage Projects / Tutorials
Sundar B., BITS, Pilani. TA C252 Course Perspectives Computing vs. Programming Programs capture “high level” computational behavior. (Contrast with a circuit) Programming – therefore – is an activity that deals with “high level” computational abstractions
Sundar B., BITS, Pilani. TA C252 Course Perspectives [2] Computers vs. Programs They have independent existence. Algorithms since Euclid (??? B.C.) Difference between algorithm & program? Programs pre-date (at least digital) computers Church’s lambda calculus (1930’s) Church-Turing equivalence
Sundar B., BITS, Pilani. TA C252 Programs [Course Perspectives] What is a program? Compare: Plan, Recipe, and Program. Plan: e.g. New Year Plans (stop postponing things, reduce TV time) e.g. Five Year Plans (generate 10 million jobs, increase tax revenue) Question: How is the plan implemented?
Sundar B., BITS, Pilani. TA C252 Programs [2] [Course Perspectives] Recipe: E.g. Bisibela Bath: 1 cup rice, 1/3 cup dhal, 1 tablespoon coriander powder, 1 teaspoon chilli powder and a little turmeric; mix everything and add salt to taste; boil until the mixture is soft. Question: teaspoon vs. tablespoon? Whose taste? How soft? Question: What will be the result?
Sundar B., BITS, Pilani. TA C252 Programs [3] [Course Perspectives] Plans are not (necessarily) feasible: No notion of execution or - as often - arbitrary notions of execution. Recipes are (often) feasible, but (as often) are ambiguous do not have predictable results are not (necessarily) repeatable: across time or persons.
Sundar B., BITS, Pilani. TA C252 Programs [4] [Course Perspectives] Programs are specifications of solutions to problems. They are unambiguous. are formal (i.e., they are – at least, ought to be – constructed systematically out of basic steps) are executable (by a machine) have predictable and repeatable results. Claim A: “executable by machine” implies “repeatable and predictable”. (No Schrodinger’s cats!) Proof: By hand waving :-)
Sundar B., BITS, Pilani. TA C252 Programs [5] [Course Perspectives] Definition: A program is a formal, unambiguous, and machine-executable specification of a solution to a problem.
Sundar B., BITS, Pilani. TA C252 Programs [6] [Course Perspectives] Claim B: “executable by machine” “formal and unambiguous”. Proof: By hand waving :-) Question: Does “formal and unambiguous” imply “executable by machine”? Answer: [Not so obvious but yes]
Sundar B., BITS, Pilani. TA C252 Programs [7] [Course Perspectives] Claim C: “formal and unambiguous” “executable by machine”. (Reasonable) Assumption: “basic steps are realizable in finite time using finite space”. This assumption is often referred to as “Turing-computablity” (i.e. executability by a Turing machine).
Sundar B., BITS, Pilani. TA C252 Programs [8] [Course Perspectives] Alternative (equivalent) definitions of a Program: A formal and unambiguous specification of a solution to a problem. A machine-executable specification of a solution to a problem. We will often use these definitions interchangeably: It is a matter of perspective!
Sundar B., BITS, Pilani. TA C252 Programming Languages [Course Perspectives] Programs are formal specifications Programming languages provide “the building blocks and the glues” to construct those specifications. Sizes and shapes of the building blocks as well as the nature of the glues vary from language to language. But the (usual) goal – in language design – is “Turing computability”. The unusual languages are often domain-specific e.g. SQL, JSP/ASP, MS Excel macros
Sundar B., BITS, Pilani. TA C252 Prog. Languages [2] [Course Perspectives] Church Turing Hypothesis: Anything “computable” is Turing-computable Turing Machine (TM) characteristics: States (control memory) State Transitions (instruction execution) Read/Write (Input/Output) Left/Right (Sequential Access)
Sundar B., BITS, Pilani. TA C252 Prog. Languages [3] [Course Perspectives] Random Access Machine (RAM) is equivalent to TM: Random access can be simulated by a counting/address tape Instruction execution is nothing but state transition So, by Church-Turing hypothesis Anything “computable” is RAM-computable
Sundar B., BITS, Pilani. TA C252 Prog. Languages [4] [Course Perspectives] Any common Instruction Set Architecture (say, x86 ISA) is an abstract form of RAM So, by Church-Turing hypothesis Anything “computable” is x86-ISA-computable A programming language (say C) is just an abstract form of ISA: Loops/conditionals can be simulated using jumps. All data values can be converted into binary forms. So, by Church-Turing hypothesis Anything “computable” is C-computable
Sundar B., BITS, Pilani. TA C252 Prog. Languages [5] [Course Perspectives] There is more to languages (than just building blocks and glues): The building blocks and glues have (often deep) conceptual foundations They are not (at least ought not to be) kitchen sinks – they have an internal structure by themselves. The product(s) that are made out of them are live (assuming programs do run!)
Sundar B., BITS, Pilani. TA C252 Course Scope • Course coverage will include: • Select Features of (widely used) languages • Brief insights into Programming (Lang.) Paradigms • Theoretical Foundations • Implementation of features (Compilers)