Engineering Agent-Oriented Technologies and Programming Languages for Computer Programming and Software Development
Total Page:16
File Type:pdf, Size:1020Kb
ALMA MATER STUDIORUM — UNIVERSITA` DI BOLOGNA DEIS - Department of Electronics, Computer Science and Systems PhD Course in Electronics, Computer Science and Telecommunications Cycle XXV Concourse Sector: 09/H1 Disciplinary Sector: ING-INF/05 ENGINEERING AGENT-ORIENTED TECHNOLOGIES AND PROGRAMMING LANGUAGES FOR COMPUTER PROGRAMMING AND SOFTWARE DEVELOPMENT Candidate Dott. ANDREA SANTI Ph.D Coordinator: Supervisor: Chiar.mo Prof. Ing. ALESSANDRO VANELLI Chiar.mo Prof. Ing. ALESSANDRO RICCI CORALLI Tutor: Chiar.mo Prof. Ing. ANTONIO NATALI FINAL EXAMINATION YEAR 2013 Contents Abstract vii 1 Introduction 1 1.1 Contributions . .4 1.2 Outline of the Dissertation . .6 I Setting The Stage 9 2 Background on the Actor Model 11 2.1 Overview of The Actor Model . 11 2.2 Programming Abstractions . 14 2.2.1 Request-Reply Messaging Pattern . 14 2.2.2 Local Synchronization Constraints . 15 2.2.3 Continuations and Promises . 17 2.3 Actor-Oriented Programming: The Next Big Thing is Already Here . 18 2.4 Main Shortcomings and Limitations . 19 3 Background on Programming Multi-Agent Systems 21 3.1 Introduction . 21 3.2 Programming the Agent Dimension . 24 3.2.1 The Belief Desire Intention Agent Model . 24 3.2.2 Agent-Oriented Programming Languages and Frameworks . 26 3.3 Programming the Environment Dimension . 30 3.3.1 Programming the Environment Taking the AI Perspective . 34 3.3.2 Programming the Environment Taking a Software Engineering Per- spective . 36 3.4 Programming the Organization and Interaction Dimensions . 43 3.4.1 Programming the Interaction Dimension . 44 3.4.2 Programming the Organization Dimension . 46 3.5 Concluding Remarks . 50 II Engineering Agent-Oriented Technologies for Programming Multi- Agent Systems 53 4 The JaCa Platform 55 4.1 An Effective Action and Perception Model for BDI-based APLs Working with Endogenous Environments . 55 iii 4.1.1 The Action Model . 56 4.1.2 The Perception Model . 58 4.2 Programming Multi-Agent Systems in JaCa . 60 4.2.1 Programming the Agents . 62 4.2.2 Programming the Environment . 65 4.2.3 The Multi-Agent Program in the Overall . 68 4.3 JaCa Programming: Focus on Further Features . 69 4.3.1 Integrating Direct Communication and Mediated Interaction . 69 4.3.2 Distributed and Open Systems Programming . 73 4.3.3 Wrapping Existing Libraries and External Resources . 74 4.4 JaCa-Android: Programming Smart Mobile Applications in JaCa . 76 4.4.1 The JaCa-Android Platform . 77 4.4.2 A Concrete Case Study . 80 4.5 JaCa-WS: Programming Applications based on the Service-Oriented Architec- ture and Web Services in JaCa . 84 4.5.1 The JaCa-WS Platform . 84 4.5.2 A Concrete Case Study . 86 4.6 JaCa-Web: Programming Rich Internet Applications in JaCa . 92 4.6.1 The JaCa-Web Platform . 94 4.6.2 A Concrete Case Study . 95 4.7 Concluding Remarks . 99 5 The JaCaMo Platform 103 5.1 The JaCaMo Approach . 103 5.1.1 Overview of the JaCaMo Programming Meta-Model . 105 5.1.2 Synergies Among the JaCaMo Programming Dimensions . 106 5.2 Impact on Multi-Agent System Programming: The JaCaMo Programming Model and Platform . 108 5.2.1 The Building-A-House Example . 111 5.3 Using JaCaMo for Real World Applications . 116 5.3.1 Engineering Smart Co-Working Spaces . 116 5.3.2 An Agent-Based Machine-To-Machine Management Infrastructure . 119 5.4 Concluding Remarks . 121 6 AOP: Shifting from the Development of Intelligent Software Systems to General Purpose Computing 123 III The simpAL Project 127 7 The simpAL Programming Language and Ecosystem 129 7.1 simpAL Overview . 129 iv 7.1.1 Background Metaphor: Human-Inspiered Computing . 130 7.1.2 The Agent Model and Control Architecture . 132 7.1.3 A Computational Model for Artifacts . 135 7.2 The simpAL Programming Language . 136 7.2.1 Programming the Agents . 138 7.2.2 Programming the Environment . 150 7.2.3 Programming the Organization . 152 7.3 Focus on Main Features . 155 7.3.1 Integrating Autonomous and Event-Driven Behaviors . 155 7.3.2 Typing Support . 164 7.3.3 Polymorphism . 171 7.3.4 Distributed Runtime Infrastructure . 172 7.4 Concrete Case Studies . 173 7.4.1 A Reactive File Searcher . 173 7.4.2 Implementation of the Ricart-Agrawala’s algorithm . 178 7.5 The simpAL Integrated Development Environment . 183 7.5.1 IDE Requirements . 183 7.5.2 IDE Overview . 184 7.6 Remarks on Performance . 187 7.7 Final Remarks . 190 7.7.1 Comparison with State-of-the-Art Agent-Oriented Programming Ap- proaches . 190 7.7.2 Current Limitations . 191 IV Conclusion 193 8 Conclusion and Future Work 195 V Appendix 199 A EBNF Grammar of the simpAL Language 201 B Additional Sources 207 B.1 Reactive File Searcher Script . 207 B.2 Sources of the Test Programs . 209 Bibliography 220 v vi Abstract Mainstream hardware is becoming parallel, heterogeneous, and distributed on every desk, every home and in every pocket. As a consequence, in the last years software is having a fundamental and epochal turn toward concurrency, decentralization, distribution, interaction which is pushed by the evolution of hardware architectures and the growing of network availability. This is having a strong impact on everyday programming: concurrent and distributed programming – which are challenging – are no longer a matter of specific application domains, but are be- coming more and more issues to take into the account in mainstream programming and related languages. This calls for introducing further abstraction layers on top of those provided by classical mainstream programming paradigms, to tackle more effectively the new complexities that de- velopers have to face in everyday programming. Given the big tide on concurrency and the well-known difficulties and problems that af- fect multi-threaded programming, a convergence it is recognizable in the mainstream toward the adoption of the actor model and actor-related approaches as a mean to unite object-oriented programming and concurrency. Nevertheless, we argue that the actor paradigm can only be con- sidered a good starting point to provide a more comprehensive response to such a fundamental and radical change in software development. Accordingly, the main objective of this thesis is to propose Agent-Oriented Programming (AOP) as a high-level general purpose programming paradigm, natural evolution of actors and finally objects, introducing a further level of human-inspired concepts for programming soft- ware systems, meant to simplify the design and programming of concurrent, distributed, reactive and interactive programs. To this end, in the dissertation first we construct the required background by studying the state-of-the-art of both actor-oriented and agent-oriented programming, and then we focus on the engineering of integrated programming technologies for developing agent-based systems in their classical application domains: artificial intelligence (AI) and distributed artificial intelli- gence (DAI). Then, we shift the perspective moving from the development of intelligent software systems, toward general purpose computing and software development. Using the knowledge and expert- ise maturated during the phase of background construction, we introduce a general-purpose pro- gramming language, named simpAL, which founds its roots on general principles and practices of software development, and at the same time provides an agent-oriented level of abstraction for the engineering of general purpose software systems. Practical experience with relevant case studies suggests that the proposed programming approach is effective for tackling some of the main complexities that modern software development introduces. Keywords: concurrent programming, distributed programming, event-driven programming, programming languages, agents, actors. vii viii 1 Introduction The fundamental turn of software toward concurrency, decentralization, distribution, interaction that we are witnessing in recent years – pushed by the evolution of hardware architectures (e.g., multi-core, many-core, mobile platforms) and network availability – is having a strong impact on everyday programming. Mainstream hardware is becoming parallel, heterogeneous, and distributed on every desk, every home and in every pocket. 2011 in particular was special: it’s when we completed the transition to parallel computing in all mainstream form factors, with the arrival of multi-core tablets and smart-phones. These changes are permanent, and so will permanently affect the way we have to write programs. There is no going back [Suta]. As stated by Herb Sutter, “The free lunch is over. Now welcome to the jungle.” [Sutb, Suta]1: concurrent and distributed programming – which are challenging – are no more a matter of only specific application domains (e.g., high-performance computing), but are more and more issues to take into the account in mainstream programming and related languages. This caused a big tide on concurrency, and the consequent development of libraries, frameworks and fine-grained mechanisms on top of existing languages specifically tailored to harness the power of multi- core, many-core and cloud-core architectures in our programs, sometimes also hiding concur- rency, parallelism and decentralization as much as possible (e.g., automatic parallelization). So, most of the research nowadays is focused on how to get a performance boost from the exploit- ation of such powerful hardware, while sticking with current well-established paradigms—i.e., Object-Oriented Programming (OOP) in particular. This is evident by briefly analyzing the contributions appeared in the last years in the main tracks of reference research conferences on programming languages such as OOPSLA/SPLASH [LD12, LF11]. Besides this important viewpoint, we argue that the free lunch is over is also a matter of con- ceptual modeling and abstraction, not only performance, that is to think about introducing and experimenting in everyday programming novel programming paradigms, modeling and imple- menting in a more natural and effective way than mainstream approaches concurrent, reactive, adaptive and distributed software systems.