CS3723: Concepts in Programming Languages - Skills and Concepts Covered, Study notes of Programming Languages

The skills and concepts covered in the cs3723 course on concepts in programming languages. Topics include language syntax, lambda calculus, functional programming, type inference, tail recursion, object-oriented programming, and more. Students will learn how to define languages using bnf, understand lambda calculus and functional programming, translate between languages, and explore advanced topics such as memory management and implementing functions.

Typology: Study notes

Pre 2010

Uploaded on 07/31/2009

koofers-user-wa8
koofers-user-wa8 🇺🇸

10 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
cs3723 1
Review
Concepts in Programming
Languages
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download CS3723: Concepts in Programming Languages - Skills and Concepts Covered and more Study notes Programming Languages in PDF only on Docsity!

Review

Concepts in Programming

Languages

What we have learned

 Skills  Language syntax (context-free grammar, parse tree, and AST)  Lambda calculus (apply beta reduction)  Functional programming (recursion in Scheme and ML)  Type inference (from Scheme to ML or C)  Tail recursion, loops, and continuation passing (methods of programming)  Object-oriented programming (from ML datatype/abstype to C++ classes)  Knowledge (concepts)  Language semantics (expressing power, interpretation vs. compilation, higher-order functions, functions as first-class objects)  Types, type checking and type inference; Polymorphism  Memory management (blocks, functions, classes and inheritance)  Continuation and exceptions  Abstractions, object-oriented abstractions,  C++ and Java language design and implementations  Advanced topics  What if we modify a language by adding …

Skills

Lambda Calculus

 Higher order functions to the extreme

 Use functions to express everything
 Key: understand function abstractions and
function applications

 Exercise: apply beta reductions

 λ x. (λ y. y x) (λ z. x z)
 (λ x. (λ y. y x) (λ z. x z) ) (λ y. y z)
 (λ y. (λ x. λ y. x (x y)) (λ g. g y)) 5

Skills---

Blocks and Memory Management

 Key: understand the algorithm (get pass the syntax barrier)  Function definitions can be nested inside one another, but a function block is not entered untilled the function is invoked by a caller  Exercise: list the order of events for the following code; then draw the runtime stack snapshot. 1: let 2: fun mk_x(x) = 3: let fun add1(y) = x + y 4: in 5: let val x = 7 in add1(5) end 6: end 7: fun apply(f,x) = f(x) 8: in 9: apply(mk_x,10)- 10:end;

Concepts:

Languages and Functions

 Why high-level programming languages?  Productivity, portability, maintenability, machine efficiency  What can programming languages express?  Data and algorithms  Partial recursive functions  Programming paradigms  Can you define what they are and give examples?  Functional, imperative, object-oriented  What is a high-order function? What does “functions are first- class objects” mean?  In what ways can prog. languages be implemented? Give examples? What is the trade-off? What are the implementation phases  Compilation vs. interpretation  Lexical analysis, Syntax analysis, semantic analysis, interpretation/code generation+optimziation

Concepts --- Types

 What is a type? What is it used for?

 Types are classification of values  Different types of values have different layout/interpretation

 Type declaration and equivalence

 Name vs. structure type equivalence

 What is a type system

 How to determine types of variables and expressions?  Compile-time vs. runtime type checking  Type checking vs. type inference  Compile-time vs. runtime type checking  Type safety of languages

 Polymorphism

 Parametric, ad-hoc and subtype polymorphism

Concepts--

Implementing Functions

 How many ways can parameter values be passed?  Pass by value vs. pass by reference  What is a function closure? What is it used for?  The value of a function <code, env>  Used to setup environment for function calls  Why is implementing higher-order functions hard?  When a function returns other functions, the activation records needs to be saved  Activation record in the heap  OO languages  What is tail recursion? Why is it equivalent to loops?  Tail recursion: do not need to return  What is a continuation? What is continuation passing  Continuation: the rest of computation after function exit

Concepts: Exceptions

 Why are exceptions considered dynamic jumps?  Static jumps: goto, loop, conditionals, …  Exception:  Jump out of one or many levels of nested blocks  Until reaching some program point to continue  Pass information to the continuation point  What is required from a language to support expections?  Type (exception) declaration  Raise an exception  Handle an exception  Are exceptions part of the type system?  Raising of exceptions not part of type system  Handling of exceptions need to agree with type system

Object-oriented Abstractions

 OO abstractions are types

 Have constructors and can be used to build objects  Grouping of relevant data and functions  Access control: private, protected, public, friend, package

 Encapsulation

 Separate interface from implementation details

 Subtype polymorphism

 Values of subtypes can be used to substitute base type values

 Dynamically-bound functions

 Function pointers stored inside class objects  Virtual function are looked up at runtime

 Implementation inheritance

 Derived classes can redefine virtual functions of base classes

Object-oriented languages

 C++/Java classes vs. ML datatype + scoping
(nested functions)

 ML can simulate most features of C++/Java except  Inheritance and extensibility  Java/C++ encapsulation  ML function closure  Java/C++ namespaces ML structures/signatures  Java/C++ virtual methodsfunction pointers as values  Java/C++ subtyping  union types and pattern matching

 Implementation of classes C++ vs. Java

 Layout of class objects and Java interfaces  Managing class member functions  Design philosophies of the two languages