Download presentation
Presentation is loading. Please wait.
Published byMichelle MacKenzie Modified over 10 years ago
1
1 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Programming Languages Features Programming styles or paradigms Imperative Functional Declarative Modularity Procedural Object-oriented Aspect-oriented Reflective Component-based Design by Contract
2
2 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Programming Styles or Paradigms Imperative: how Most common languages (C, C++, Java…) Programmer provides explicit algorithm to solve a problem State (variable assignments), side effects Functional (e.g. LISP (next Seminar)) Everything is a function Computation = function evaluation Declarative: what AI background: Intelligent systems – Programmer states what needs to be done (not an explicit algorithm) – System searches for solution No explicit global state and side effects
3
3 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Programming Styles or Paradigms Declarative Logic (e.g. Prolog) Rule-based (CLIPS/Jess, Cisco ACLs) expert(pmeier, uberlin, graphtheory). expert(jsmith, ucla, netarch).... paper(title1, ptann, ulancs, netarch). paper(title2, mgerla, ucla, netarch). paper(title3, pkim, uskr, graphtheory).... reviewer(E, P) :- expert(E, I, T), paper(P, _, J, T), \+ I = J. ?- reviewer(X,Y). gprolog http://gnu-prolog.inria.fr/ not run program: query
4
4 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto More Programming Styles and Paradigms Deductive Message-passing Constraint High-order........
5
5 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Modularity Features Procedural Object-oriented Aspect-oriented Reflective Component-based Design by Contract
6
6 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Aspect-Oriented Programming (AOP) Separation of concerns Functional (application) concerns – Good encapsulation through classes (OO) Cross-cutting concerns – Repeat across different classes – Examples: logging, monitoring, debugging, security – Encapsulation through aspects Aspect construct: encapsulates cross-cutting concerns Facilitates changes and upgrades (e.g. security policies) No changes to functional classes
7
7 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Aspect-Oriented Programming (AOP) AspectJ Language Java extension Implementation within Eclipse software platform Weaving classes and aspects together through joint points, pointcuts and advices – joint points: points in the program where the aspect must interfere (typically method calls, access to class members, exception handler blocks) – pointcut: selects joint points that match certain criteria – advices: the aspect-related code that is executed before, after, or around (before+after) a joint point.
8
8 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto AOP Example: Logging class B method1(...) method2(...) class A method1(...) method2(...) aspect AutoLog{ pointcut loggableCalls(): before():loggableCalls(){ logger.entry(thisJointPoint.get...) } after():loggableCalls(){ logger.exit(thisJointPoint. get...) } jointpoint
9
9 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Component-Based Systems Classes (OO) Clear interface on exported features (how to use class) Imported features (what the class uses) not entirely clear from outside (class as a black-box) Components Both exported and imported features must be specified Like a hardware component described in a datasheet Software factories: assembling software like hardware Reusable components (Dynamic) composition mechanisms E.g. (Enterprise) JavaBeans, TinyOS nesC (sensor nets)
10
10 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Computational Reflection Reflection or introspection: think about oneself Self-Reference: Quine Computer program which prints its own source code (without reading it from a file or other external input) Self-replicating program Reflective system: information about itself (meta- information) accessible to the system itself Meta-info may be used to explain or change its behavior Two levels: Functional level or Base level Meta level: meta-information
11
11 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Quine Examples From http://www.nyx.net/~gthompso/quine.htm In C: char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} In Scheme: ((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x))))) More: http://www.madore.org/~david/computers/quine.html
12
12 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Computational Reflection Reflection tower (recursive): Meta level inspects base level Meta meta level inspects meta level, …, and so on Java reflection ( java.lang.reflect.*) Read classes and methods by name Discover class, object, and method properties Invoke methods or create objects whose class is discovered only at run time Not possible to create new classes, modify methods, etc.
13
13 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Design by Contract Contract = specification associated to a component Goals: quality assurance, reliability Eiffel language Contract specification as part of the language constructs contract Component A (Supplier) Component B (Client) Benefits and obligations
14
14 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Contract Example in Eiffel class DICTIONARY... put (x: ELEMENT; key: STRING) is require count < capacity not key.empty do... insertion algorithm... ensure has (x) item (key) = x count = old count + 1 invariant 0 <= count count <= capacity end Pre-conditions or obligations Post-conditions or benefits General class assertion
15
15 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Concurrency and Parallelism B A C time sequentialexecution BA A fork D C join CB parallel execution cobegin coend begin end
16
16 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Concurrency and Parallelism Granularity Processes (e.g. Unix fork) Threads (e.g. in Java) Concurrent blocks: fork, join, cobegin...coend Machine instructions: e.g. Very Long Instruction Word (VLIW), Data Flow machines
17
17 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Concurrency and Parallelism Chemical Programming: Gamma max 1 89 20 76 54 max(x,y): x >= y => x max 1 9 20 76 54 max 76
18
18 CS506 Seminar: Zehn Programmier-sprachen in einem Semester, Language Features, by L. Yamamoto Other Features and Concepts Iterators Persistence Operational Semantics Self-Documentation Proof-Carrying Code.....
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.