1 / 48

Advanced Programming

Università di Pisa. Advanced Programming. Giuseppe Attardi Dipartimento di Informatica Università di Pisa. Language is an instrument of human reason, not merely a medium for the expression of thought. G. Boole, An Investigation of the Laws of Thought, 1854 . Instructors. Giuseppe Attardi

chenoa
Download Presentation

Advanced Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Università di Pisa Advanced Programming Giuseppe Attardi DipartimentodiInformatica Universitàdi Pisa

  2. Language is an instrument of human reason,not merely a medium for the expression of thought.G. Boole, An Investigation of the Laws of Thought, 1854

  3. Instructors Giuseppe Attardi Office: 292 Mail: attardi@di.unipi.it Haoyuan Li Office: 373 Mail: li@di.unipi.it

  4. Introduction • Programming in the 21 century • Software as complex as ever • Command line interface not enough • Data must be structured in a DB • Single computer not enough • Software development is a group activity

  5. Requirements • Cannot start from scratch • Reusable components are needed • OS + libraries not enough

  6. Elements of a Solution • Software Framework • Component Model • Execution Environment

  7. More Complex Software • Object-Oriented Programming allows ever larger applications to be built • Require increased high-level application and system oversight • Multi-tier applications development increases the choices on how to build applications • A new Software Architect Role is needed

  8. Software Architect • Creating, defining or choosing an application framework • Creating the component design • Structure a complex application into pieces • Understand the interactions and dependencies among components • Select the platform based on cost/performance criteria • Organize and supervise the “construction site”

  9. Application Framework • A software framework used to implement the standard structure of an application for a specific development environment

  10. Software Framework • A collection of common code providing generic functionality that can be selectively overridden or specialized by user code providing specific functionality • Frameworks, like software libraries, provide reusable abstractions of code wrapped in a well-defined API

  11. Framework Features • Inversion of control • unlike in libraries, the overall program's flow of control is not dictated by the caller, but by the framework • Hollywood Principle: Don’t call us, we’ll call you • Default behavior • Extensibility: usually by selective overriding • Non-modifiable framework code

  12. OO Software Framework • Object-oriented programming frameworks consists in a set of abstract classes • An application can be built simply inheriting from pre-existing classes in the framework • Instantiation of a framework consists of composing and subclassing the existing classes

  13. Examples of Frameworks • GUI • MFC • Gnome • Qt • General • Spring • Web • ASP.Net • GWT • Rails

  14. Benefits of Frameworks • Drives solution • Dictates how to fill-in-the-blanks • Helps solving recurring problems • Designed for reuse • High value, since reduces cost of development

  15. Framework Design • Intellectual Challenging Task • Requires a deep understanding of the problem domain • Requires mastering of software patterns, OO methods and polymorphism in particular

  16. Course Objectives • Understand programming language technology: • Execution Models • Run-time • Analyze programming metaphors: • Objects • Components • Pattern • Learn advanced programming techniques • Understand their limits ad how to overcome them

  17. Course Objectives • Explain how high level programming concepts and metaphors map into executable systems and which are their costs and limitations • Acquaint with modern principles, techniques, and best practices of advanced software construction • Introduce techniques of programming at higher abstraction levels, in particular generative programming, component programming and web computing • Present state-of-the-art frameworks incorporating these techniques

  18. Syllabus

  19. Programming Language Foundations • Syntax, Parsing, Abstract Syntax Tree, Parser Generators • Names, Scope, Binding • Parameter Passing • Static and Dynamic Allocaltion: Stack, Heap • Types, Inheritance, Polymorphism, Overloading • Delegates, Closures • Exception Handling

  20. Run-time Systems • Virtual Execution Environment • Memory Management • Thread Management • Exception Handling • Security • Debugging Support • AOT and JIT Compilation • Dynamic Link/Load • Reflection • Verification • Language Interoperability

  21. Advanced Techniques • Generic Programming • C++ templates • C# Generics • Java Generics • Generative Programming • Metaprogramming • Reflection • Template • Aspect Oriented Programming • Generators

  22. Interoperability • Process level: interprocess communication • Language level: CORBA/IDL • Object level: DCOM

  23. Component Based Programming • COM • JavaBeans • .NET (Assembly, Reflection, Interfaces, Attributes) • OSGi

  24. Web Programming • Web Services, SOA • Web Frameworks • Web 2.0

  25. Web Services • XML, XML-Schema • SOAP, RPC, Rest • WSDL • UDDI

  26. Web Frameworks and Applications • Asp.Net • ADO.Net • J2EE • Java Server Faces • AJAX: XHR, YUI, GWT • Mashup and Service Oriented Architecture

  27. Scripting Languages • Perl • Python • JavaScript • PHP

  28. Text Books Programming Language Pragmatics, third ed., Michael L. Scott, Morgan-Kaufmann, 2009. Generative Programming: Methods, Tools, and Applications, Krzysztof Czarnecki, Ulrich Eisenecker, Addison-Wesley, 2000. Object Thinking , David West, Microsoft Press, 2004.

  29. Assessment • Mid Term Paper: early November, one week homework • Term Paper: at the end of the course, one month homework

  30. Run-time Environments

  31. Run-Time Environments • Java Virtual Machine • .NET Common Language Runtime • Provide a virtual execution environment • Exposes a structure organized into elements • Not a simple abstraction of physical resources

  32. Controlling execution • Avoid damages • Install/uninstall is a nightmare • Component software?

  33. Benefits • Programmers • Use of library and tools • Shorter integration time • Higher productivity • Tool Developers • Avoid the need to care about infrastructure and interoperability • Administrators and Users • Benefit from packages solutions • Independence from processors or OS

  34. Common Language Infrastructure • Exposes all items in a unified type system • Packages elements in self-describing units • Loads and resolves interdependencies at runtime • Exposes information that allows verifying the type-safety • Execution Engine enforces politics • Metadata available at runtime enables dynamic and extensible solutions

  35. Question • Is it feasible to build a runtime common to all programming languages?

  36. More in detail • Prolog • How to implement logic variable? • Can one use the Warren-Abstract-Machine? • PHP 3 • Why assignment has unusual behavior? • LISP • How to handle multiple-values?

  37. Prolog example append(X, Y, Z) :- append(NIL, Y, Y) :- append([A . X], Y, [A . Z] ) :- append(X, Y, Z). :- append([a . b . c], [d . e], R) R = [a . b . c . d . e]

  38. Prolog backtrack :- append(X, Y, [a . b]) :- append(X, NIL, [a . b]) X = NIL Y = [a . b] X = [a] Y = [b] X = [a . b] Y = NIL

  39. PHP Assignement $str = ‘Ciao.’; $str2 = $str; $str{strlen($str) – 1} = ‘!’; echo $str2; • $var = $othervar • Performs copy of the value of $othervar • $var = &$othervar • Assignment by reference

  40. Control • Can we implement tail-recursion in C? • How to handle synchronization? • Function pointers? • How to invoke an arbitrary function given a list of arguments?

  41. General Function Invoker invoke(fun, argn, arglist) { if (n==0) return f(); else if (n==1) return f(arg[0]); else return fun(arg[0], arg[1], .. , arg[n-1]); }

  42. Basic Data Types • Strings in C, Pascal and C++ are different • Array in row or column order?

  43. Language Interoperability • C# and Cobol bark at each other

  44. C# dog using System; public class Dog { public virtual void RollOver () { Console.WriteLine("Scratch my tummy."); Bark(); } public virtual void Bark () { Console.WriteLine("WOOF WOOF (C#)"); } }

  45. Cobol BigDog 000010 CLASS-ID. BigDog INHERITS Dog. 000020 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 REPOSITORY. 000060 CLASS Dog. 000070 OBJECT. 000080 PROCEDURE DIVISION. 000090 METHOD-ID. Bark OVERRIDE. 000160 PROCEDURE DIVISION. DISPLAY "WOOF WOOF (COBOL)". 000210 END METHOD Bark. 000220 END OBJECT. 000230 END CLASS BigDog.

  46. Barfing dogs public class Demo{ public static void Main() { Dog d = new Dog(); BigDog b = new BigDog(); d.RollOver(); b.RollOver(); }}

  47. Final Term Paper • Aims at exercising ability to conceive and implement full solutions to a nontrivial problem • Examples: • ASP Code generator with regular expression matcher • Implement a DSL for handling persistent object containers • SOAP protocol and SOAP server • Code generator for searching an object DB • Xpath and XSLT Intrepreter • Language for generating network protocols • AJAX Framework

  48. Home Work • Develop a simple implementation of primitives: • void* malloc(size_t size) • void free(void*) • Discuss the limits of the solution

More Related