Course material
|
Programming Paradigms
procedural/imperative programming (e.g., C)
basic concept: machine state (memory cells/variables)
program by specifying a sequence of statements that alter the state
object-based programming (e.g., C++, scripting languages)
basic concept: abstract data types
program by specifying complex types that interact via message passing
object-oriented programming (e.g., C++, Java)
basic concept: abstract data types + inheritance + dynamic (late) method binding
program by defining hierarchies of interacting objects
functional programming (e.g., LISP, Clojure)
basic concept: functional transformation
program by defining and applying transformations to data
General Language Issues
language evaluation criteria: readability, writability, reliability, ...
syntax & semantics
BNF grammar, parse trees, ambiguity, EBNF, precedence & associativity
operational, axiomatic, & denotational semantics
variables & binding
variable attributes, type/address/value binding, scope & lifetime
static vs. dynamic binding, stack-based memory management, activation records
data types
primitive types: integer, floating-point, boolean, character, ...
pointer: indirect addressing, dynamic memory management
heap fragmentation & compaction, garbage collection vs. reference counts
complex types: string, enumeration, subrange, array/vector, record/struct
subprograms
parameters: by-value, by-result, by-value-result, by-reference, by-name
overloading functions/operators, templates
abstract data types - requires encapsulation + info hiding
C++ & Java classes, public vs. private vs. protected
object-oriented programming - requires inheritance + dynamic (late) method binding
inheritance, overriding/overloading methods, public vs. protected fields
polymorphism, IS_A relationship
in Java: extends, super, abstract class, interface, no multiple inheritance
in C++: ':', '::', virtual, abstract class, multiple inheritance
C -> C++ -> Java -> Beyond
C design goals: high-level abstractions, support for systems programming
C language features: high-level functions & control, but low-level access
pass-by-value, arrays & structs, pointers, preprocessor directives
memory management: stack-dynamic by default, malloc & free
C++ design goals: support OO, retain C performance, gentle path to OO
C++ language features: added OO to C + numerous reliability features
pass-by-value and -reference, constants, new & delete, bool, string
memory management: stack-dynamic by default, new & delete, copy constr.
Java design goals: simple, OO, network savvy, robust, secure, interpreted,
portable, architecture neutral, high-performance, multi-threaded, dynamic
Java language features: basied on C++ but simpler & more secure
pass-by-value only, Boolean, String library, name resolution at link time
memory management: stack-dynamic primitives, heap-dynamic objects
automatic garbage collection provided (mix of Mark & Sweep, Partition & Copy)
Other languages: R, Ruby, Go, Kotlin, Swift, Rust
Clojure
LISP design goals: simple & orthogonal, symbolic, dynamic lists, transparent memory
Clojure design goals: modern LISP, faster, add modern features (incl. Java compatability)
language features: function definitions and calls are lists
execution model: compiled into Java Byte Code, then interpreted using JVM
control: if, cond, recursion (w/ tail-recursion optimization), ...
modularity: functions, can implement OO classes & interfaces
many useful primitive functions, can easily compose into new functions
pass-by-value (with structure sharing), static scoping
memory management: heap-dynamic, utilizes structure sharing
automatic garbage collection (from Java)
weakly typed; types associated with values, not variables
structuring data
lists, vectors, sets, maps
can model trees by nesting lists
non-functional features
I/O (print, println, ...), sequencing (do),
destructive assignment (def, set!), environment definition (let)
advanced features
first class functions, fn expressions, higher order (apply, map, filter)
lazy sequences, delay/force, streams
closures, OOP via defprotocol & deftype
Concurrency
levels of concurrency: machine instruction, statement, subprogram, program
synchronization
cooperation (e.g., producer/consumer) vs. coordination (e.g., mutual exclusion)
mechansims: semaphores, monitors, message passing
concurrency in Java
Thread class, run method, synchronized, start/wait/notify/join methods
Amdahl's Law
|