cs a331 programming language conceptsssiewert/a331_doc/lectures/lecture-week-1.pdfjanuary 12, 2014...

8
January 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Upload: vudan

Post on 02-May-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

January 12, 2014 Sam Siewert

CS A331 Programming Language Concepts

Lecture 1 - Introduction

Page 2: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Sam Siewert UC Berkeley – National Research University, Philosophy/Physics University of Notre Dame, BS - Private, Aerospace/Mechanical Johnson Space Center, U. of Houston – UHCL Computer Engineering, National R&D Center, Mission Control Center U. of Colorado, Boulder, MS/PhD – Growing Research University, Gov’t Labs, Start-Ups, Computer Science

Interdisciplinary Teaching & Research – Aerospace/Mechanical, Computer Science, Computer Engineering

CU Boulder Senior Instructor, Adjunct Professor CTO, Architect, Developer/Engineer

Sam Siewert 2

1984-85

1985-89

1989-92

1992-today

Page 3: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Course Topics The course includes study of the theoretical foundations to design and implement modern programming languages, including syntax, type systems, semantics, and memory structures. Comparison of several programming languages in different paradigms such as procedural, functional, logic, and scripting languages. Programming assignments will be given in each language studied. Survey of Languages and Comparison – Linux – Used for C/C++, Assembly, Halide, R, and Lisp – Eclipse – Used for Java – Windows – Used for R, and Visual Studio C++

Syntax and Semantics – Code Generation from a Syntactic Specification – Interpretors

Sam Siewert 3

Page 4: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Sam Siewert 4

Administrivia Introductions – Instructor (Office Hours) -

http://www.cse.uaa.alaska.edu/~ssiewert/Schedule-Spring-2014.pdf – Students (Introductions)

UAA Blackboard – http://www.uaa.alaska.edu/classes/

Course Information – REQUIRED Text: Michael L. Scott, "Programming Language

Pragmatics, 3rd Ed.", Morgan Kaufman, 2009. – E-mail list (please sign up on sheet being passed around) – Lecture Notes and Labs on UAA Blackboard System (please do not read

more than one week ahead)

Personal Lab – You MUST Have VB Linux and/or use transformer.uaa.alaska.edu

Page 5: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Programming Langauge Concepts ALU and Machine Code Assembly Mnemonics for Machine Code – opcode, operands – E.g. sub r1, r1, r0

Machine (assembly) code generation for C statement – a = a – b; ldr r3, [fp, #-16] /* r3=a */

ldr r2, [fp, #-20] /* r2=b */

rsb r3, r2, r3 /* r3=r3-r2 */

str r3, [fp, #-16] /* r3=a (a=a-b) */

Basic Formula Translation to basic ASM block – FORTRAN – ALGOL

Sam Siewert 5

Page 6: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Syntax and Semantics Syntax – Informal - set of rules that defines the combinations of symbols that

are considered to be a correctly structured document or fragment in that language [Wikipedia – Syntax (programming languages)]

– Formal – Figure 1.3, pp 26-28: Parsing with a context-free grammar which is a set of potentially recursive rules that are used to form a parse tree (constructs including statements, expressions, subroutines, …)

Semantics – Informal - the field concerned with the rigorous mathematical study

of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language [Wikipedia - Semantics (computer science)]

– Formal – Code generation to implement the meaning of a program (construct), pp. 29-35

Sam Siewert 6

Page 7: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Programming Language Classification We will look at examples (shown in red) Declarative – Functional [Lisp, Scheme, ML, Haskell] – Dataflow [System Verilog, SystemC] – hardware system spec – Logic [Prolog] – Template-based [XSLT]

Imperative – Compiled for ALU [C, Ada, Pascal, Fortran, …] – Scripted [Perl, Python, R] – Object Oriented [Ada 95/2005, C++, Java]

http://rosettacode.org/wiki/Rosetta_Code

Sam Siewert 7

Page 8: CS A331 Programming Language Conceptsssiewert/a331_doc/lectures/Lecture-Week-1.pdfJanuary 12, 2014 Sam Siewert CS A331 Programming Language Concepts Lecture 1 - Introduction

Defining a Language Lex and Yacc – – http://flex.sourceforge.net/ – http://www.gnu.org/software/bison/

Lexical analysis Parsing Code Generation or Interpretation Specifying a Programming Language – Reference Implementation – An example compiler or interpreter – Denotational Semantics - http://www.cs.cmu.edu/~crary/819-f09/Scott71.pdf – Detailed Written Language Specifications – E.g. C99 - http://www.open-

std.org/jtc1/sc22/WG14/www/docs/n1256.pdf We will build an interpreter or simple lexer/parser/code-generator (compiler) – A reference Implementation Sam Siewert 8