CSC 533: Organization of Programming Languages
Spring 2010

Test 2 Review

TEST 1 MATERIAL Programming paradigms imperative programming: program is a sequence of state assignments/functions efficient since variables/assignments correspond to underlying arch. object-based programming: program is a collection of interacting objects natural approach to design, modular (allows for reuse) object-oriented programming: OBP + inheritance + dynamic binding IS_A relationship enables generic functions/methods, polymorphism Imparative programming in C C design goals high-level abstractions, support for systems programming, efficient C language features: high-level functions & control, but low-level access functions, pass-by-value, control structures, arrays, structs, pointers preprocessor directives: #define (for constants), #typedef (for types) memory management: stack-dynamic by default can allocate heap-dynamic using malloc & free; no garbage collection top-down design (a.k.a. iterative refinement) focus on the sequence of tasks, design a function for each if a task is too complex, further refine into subtasks (& sub-functions) Object-based/oriented programming in C++ 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 can allocate heap-dynamic using new & delete; no garbage collection classes with dynamic data require copy constructors & destructors separate compilation, templated classes & functions OOB/OOP in C++ class, fields & member functions, public vs. private, ... inheritance, protected, abstract classes, scope resolution operator (::) functions bound statically by default, but can get dynamic via "virtual" multiple inheritance allowed (use :: to disambiguate), no interfaces Object-oriented programming in Java Java design goals simple, OO, network savvy, robust, secure, architecture neutral, portable, interpreted, high-performance, multi-threaded, dynamic Java language features: based 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 execution model: compile into byte code, then interpret with JVM OOP in Java: "pure" OO language class, fields & methods, extends, abstract classes, interfaces, super dynamic binding is automatic, implemented via method reference no multiple inheritance, but can implement multiple interfaces Java vs. JavaScript JavaScript designed to be an embedded, Web-scripting language retains basic syntax of Java, but very different characteristics memory & types bound dynamically, non-typed functions OOB with primitive support for classes security limitations due to client-side execution model