Download presentation
1
CSCE 314 Programming Languages
John Keyser Spring 2016
2
About the course (syllabus overview)
Instructor John Keyser Office Hours Generally, MW 2:00-3:00 Today: 1:30-2:30 Monday 1/25: cancelled TA Mengyuan Chao Peer Teachers Other section (taught by Dylan Shell)
3
Course stuff Prerequisite: Textbooks Course webpage Piazza CSCE 221
Hutton: Programming in Haskell Arnold, Gosling, Holmes: The Java Programming Language Course webpage Will be up soon (today?) Piazza Will be used for class discussions Get a head start – sign up now...
4
Grades Exams (60%): Assignments (40%):
Midterm: 25% (just before Spring Break) Final: 35% (at time assigned) Final will be comprehensive, but weighted toward later material Expect exams to be open book (details will come later) Assignments (40%): Turn in via CSNet Late penalty: 10% first day, 20% second day, 100% thereafter
5
Collaboration Work should be your own The rest should be common sense…
Make sure you acknowledge any outside help
6
Understanding programming languages!
So, what’s the point of this course? Understanding programming languages!
7
The Big Picture Haskell sum [] = 0 sum (x:xs) = x + sum xs ??????????????????????? C a = 13 if (a>3) c=10 ASSEMBLY mov rdx, 7 mov eax, 3 jmp eax
8
Purpose of Programming Languages
To help PEOPLE communicate ideas To the computer To other people To their future selves Programming languages are designed to help people express ideas precisely and concisely. The more “natural” the language is the better people can express ideas Different languages do this in different ways
9
Abstraction Haskell, Prolog sum[1..100] More Abstract Scheme, Java mynum.add(5) C i++; Assembly Language iadd Less Abstract Machine Language
10
History of programming languages
1940s: connecting wires to represent 0s and 1s 1950s: assemblers, FORTRAN, COBOL, LISP 1960s: ALGOL, BCPL(-> B -> C), SIMULA 1970s: Prolog, FP, ML, Miranda 1980s: Eiffel, C++ 1990s: Haskell, Java, Python 2000s: D, C#, Spec#, F#, X10, Fortress, Scala, Ruby 2010s: Agda, Coq, … The evolution has been and is toward higher levels of abstraction
11
Defining a Programming Language
Syntax: Defines the set of valid programs Usually defined with the help of grammars and other conditions if-statement ::= if cond-expr then stmt else stmt | if cond-expr then stmt cond-expr ::= . . . stmt ::= . . . Semantics: Defines the meaning of programs Defined, e.g., as the effect of individual language constructs to the values of program variables if cond then true-part else false-part If cond evaluates to true, the meaning is that of true-part; if cond evaluates to false, the meaning is that of false-part.
12
Implementing a Programming Language
Task is to undo abstraction. From the source: int i; i = 2; i = i + 7; to assembly (this is actually Java bytecode): iconst_2 // Put integer 2 on stack istore_1 // Store the top stack value at location 1 iload_1 // Put the value at location 1 on stack bipush 7 // Put the value 7 on the stack iadd // Add two top stack values together istore_1 // The sum, on top of stack, stored at location 1 to machine language:
13
Implementing a Programming Language – How to Undo the Abstraction
Source program Optimizer I/O Type checker Code generator Machine code Lexer Parser Machine Bytecode JIT Interpreter Virtual machine I/O I/O
14
Compiling and Interpreting (1)
Typically compiled languages: C, C++, Eiffel, FORTRAN Java, C# (compiled to bytecode) Typically interpreted languages: Python, Perl, Prolog, LISP Both compiled and interpreted: Haskell, ML, Scheme
15
Compiling and Interpreting (2)
Borderline between interpretation and compilation not clear (not that important either) Same goes with machine code vs. byte code. Examples of modern compiling/interpreting/executing scenarios: C and C++ can be compiled to LLVM bytecode Java compiled to bytecode, bytecode interpreted by JVM, unless it is first JITted to native code, which can then be run on a virtual machine such as VMWare
16
Our Goal: To Understand Programming Languages!
How languages are designed - how they help people express ideas Language constructs Abstraction mechanisms Efficiency considerations How languages work – how they become the code that runs Parsing Internal program representation Type checking Interpretation Formal verification – how we know that code will work
17
Learn ideas through examples
Functional language: Haskell Object-oriented language: Java These languages are the means, not the goals
18
Next time More in-depth look at the “flowchart” of programs being processed Begin looking at Haskell, a functional programming language
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.