Introducing Elixir Getting Started in Functional Programming [St. Laurent & Eisenberg 2014-09-25].Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Introducing Elixir Getting Started in Functional Programming [St. Laurent & Eisenberg 2014-09-25].Pdf Introducing Elixir Introducing Elixir Introducing Elixir is an excellent language if you want to learn about functional programming, and with this hands-on introduction, you’ll discover just how powerful and fun Elixir can be. This language combines the robust functional programming of Erlang with a syntax similar to Ruby, and includes powerful features for metaprogramming. This book shows you how to write simple Elixir programs by teaching one skill at a time. Once you pick up pattern matching, process-oriented programming, and other concepts, you’ll understand why Elixir makes it easier to build concurrent and resilient programs that scale up and down with ease. ■ Get comfortable with IEx, Elixir’s command-line interface ■ Discover atoms, pattern matching, and guards: the foundations of your program structure ■ Delve into the heart of Elixir with recursion, strings, lists, and higher-order functions ■ Create processes, send messages among them, and apply pattern matching to incoming messages ■ Store and manipulate structured data with Erlang Term Storage and the Mnesia database ■ Build resilient applications with Erlang’s Open Telecom Platform Introducing ■ Define macros with Elixir’s metaprogramming tools St. Laurent & Eisenberg Laurent St. Simon St. Laurent is a Strategic Content Director at O’Reilly Media, Inc., focusing primarily on web-related topics. He is co-chair of O’Reilly’s Fluent and OSCON conferences. Simon has written or co-written books, including Introducing Erlang, Learning Rails 3, and XML Pocket Reference, Third Edition (all O’Reilly). J. David Eisenberg is a programmer and instructor in San Jose, California, with a talent for teaching and explaining. He’s developed courses for CSS, JavaScript, CGI, and XML, and teaches Computer Information Technology courses at Evergreen Valley College. David has written books including SVG Essentials, Études for Erlang (both O’Reilly), and Let’s Read Hiragana (Eisenberg Consulting). Elixir GETTING STARTED IN FUNCTIONAL PROGRAMMING PROGRAMMING LANGUAGES Twitter: @oreillymedia facebook.com/oreilly US $24.99 CAN $26.99 ISBN: 978-1-449-36999-6 Simon St. Laurent & J. David Eisenberg www.it-ebooks.info Introducing Elixir Introducing Elixir Introducing Elixir is an excellent language if you want to learn about functional programming, and with this hands-on introduction, you’ll discover just how powerful and fun Elixir can be. This language combines the robust functional programming of Erlang with a syntax similar to Ruby, and includes powerful features for metaprogramming. This book shows you how to write simple Elixir programs by teaching one skill at a time. Once you pick up pattern matching, process-oriented programming, and other concepts, you’ll understand why Elixir makes it easier to build concurrent and resilient programs that scale up and down with ease. ■ Get comfortable with IEx, Elixir’s command-line interface ■ Discover atoms, pattern matching, and guards: the foundations of your program structure ■ Delve into the heart of Elixir with recursion, strings, lists, and higher-order functions ■ Create processes, send messages among them, and apply pattern matching to incoming messages ■ Store and manipulate structured data with Erlang Term Storage and the Mnesia database ■ Build resilient applications with Erlang’s Open Telecom Platform Introducing ■ Define macros with Elixir’s metaprogramming tools St. Laurent & Eisenberg Laurent St. Simon St. Laurent is a Strategic Content Director at O’Reilly Media, Inc., focusing primarily on web-related topics. He is co-chair of O’Reilly’s Fluent and OSCON conferences. Simon has written or co-written books, including Introducing Erlang, Learning Rails 3, and XML Pocket Reference, Third Edition (all O’Reilly). J. David Eisenberg is a programmer and instructor in San Jose, California, with a talent for teaching and explaining. He’s developed courses for CSS, JavaScript, CGI, and XML, and teaches Computer Information Technology courses at Evergreen Valley College. David has written books including SVG Essentials, Études for Erlang (both O’Reilly), and Let’s Read Hiragana (Eisenberg Consulting). Elixir GETTING STARTED IN FUNCTIONAL PROGRAMMING PROGRAMMING LANGUAGES Twitter: @oreillymedia facebook.com/oreilly US $24.99 CAN $26.99 ISBN: 978-1-449-36999-6 Simon St. Laurent & J. David Eisenberg www.it-ebooks.info Introducing Elixir Simon St. Laurent and J. David Eisenberg www.it-ebooks.info Introducing Elixir by Simon St. Laurent and J. David Eisenberg Copyright © 2014 Simon St. Laurent and J. David Eisenberg. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editors: Simon St. Laurent and Meghan Blanchette Cover Designer: Karen Montgomery Production Editor: Melanie Yarbrough Interior Designer: David Futato Proofreader: Amanda Kersey Illustrator: Rebecca Demarest Indexer: J. David Eisenberg September 2014: First Edition Revision History for the First Edition: 2014-09-10: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449369996 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Introducing Elixir, the cover image of a four-horned antelope, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While the publisher and the authors have used good faith efforts to ensure that the information and in‐ structions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. ISBN: 978-1-449-36999-6 [LSI] www.it-ebooks.info Table of Contents Preface. vii 1. Getting Comfortable. 1 Installation 1 Installing Erlang 1 Installing Elixir 2 Firing It Up 2 First Steps 2 Moving Through Text and History 3 Moving Through Files 3 Doing Something 4 Calling Functions 5 Numbers in Elixir 6 Working with Variables in the Shell 8 2. Functions and Modules. 11 Fun with fn 11 And the & 13 Defining Modules 13 From Module to Free-Floating Function 16 Splitting Code Across Modules 17 Combining Functions with the Pipe Operator 18 Importing Functions 19 Default Values for Arguments 20 Documenting Code 21 Documenting Functions 22 Documenting Modules 23 iii www.it-ebooks.info 3. Atoms, Tuples, and Pattern Matching. 25 Atoms 25 Pattern Matching with Atoms 25 Atomic Booleans 27 Guards 28 Underscoring That You Don’t Care 31 Adding Structure: Tuples 33 Pattern Matching with Tuples 33 Processing Tuples 34 4. Logic and Recursion. 37 Logic Inside of Functions 37 Evaluating Cases 37 Adjusting to Conditions 40 If, or else 41 Variable Assignment in case and if Constructs 42 The Gentlest Side Effect: IO.puts 43 Simple Recursion 44 Counting Down 45 Counting Up 46 Recursing with Return Values 47 5. Communicating with Humans. 51 Strings 51 Multiline Strings 53 Unicode 54 Character Lists 54 String Sigils 55 Asking Users for Information 56 Gathering Characters 56 Reading Lines of Text 58 6. Lists. 61 List Basics 61 Splitting Lists into Heads and Tails 63 Processing List Content 64 Creating Lists with Heads and Tails 66 Mixing Lists and Tuples 68 Building a List of Lists 68 7. Name-Value Pairs. 73 Keyword Lists 73 iv | Table of Contents www.it-ebooks.info Lists of Tuples with Multiple Keys 75 Hash Dictionaries 76 From Lists to Maps 77 Creating Maps 77 Updating Maps 78 Reading Maps 78 From Maps to Structs 78 Setting Up Structs 79 Creating and Reading Structs 79 Pattern Matching Against Structs 80 Using Structs in Functions 80 Adding Behavior to Structs 82 Adding to Existing Protocols 84 8. Higher-Order Functions and List Comprehensions. 87 Simple Higher-Order Functions 87 Creating New Lists with Higher-Order Functions 89 Reporting on a List 90 Running List Values Through a Function 90 Filtering List Values 91 Beyond List Comprehensions 92 Testing Lists 92 Splitting Lists 93 Folding Lists 94 9. Playing with Processes. 97 The Shell Is a Process 97 Spawning Processes from Modules 99 Lightweight Processes 102 Registering a Process 102 When Processes Break 104 Processes Talking Amongst Themselves 105 Watching Your Processes 107 Watching Messages Among Processes 109 Breaking Things and Linking Processes 110 10. Exceptions, Errors, and Debugging. 119 Flavors of Errors 119 Rescuing Code from Runtime Errors as They Happen 120 Logging Progress and Failure 122 Tracing Messages 123 Watching Function Calls 125 Table of Contents | v www.it-ebooks.info Writing Unit Tests 126 11. Storing Structured Data. 131 Records: Structured Data Before structs 131 Setting Up Records 132 Creating and Reading Records 133 Using Records in Functions 134 Storing Data in Erlang Term Storage 136 Creating and Populating a Table 138 Simple Queries 142 Overwriting Values 143 ETS Tables and Processes 144 Next Steps 146 Storing Records in Mnesia 146 Starting up Mnesia 146 Creating Tables 147 Reading Data 151 12. Getting Started with OTP. 153 Creating Services with gen_server 154 A Simple Supervisor 159 Packaging an Application with Mix 162 13. Using Macros to Extend Elixir. 167 Functions versus Macros 167 A Simple Macro 168 Creating New Logic 170 Creating Functions Programatically 171 When (Not) to Use Macros 173 Sharing the Gospel of Elixir 173 A.
Recommended publications
  • Mnesia Database Management System (MNESIA)
    Mnesia Database Management System (MNESIA) version 4.4 Typeset in LATEX from SGML source using the DocBuilder-0.9.8.5 Document System. Contents 1 Mnesia User’s Guide 1 1.1 Introduction.......................................... 1 1.1.1AboutMnesia..................................... 1 1.1.2TheMnesiaDataBaseManagementSystem(DBMS)............... 2 1.2 GettingStartedwithMnesia................................. 4 1.2.1StartingMnesiaforthefirsttime.......................... 4 1.2.2AnIntroductoryExample.............................. 5 1.3 BuildingAMnesiaDatabase................................. 14 1.3.1DefiningaSchema.................................. 15 1.3.2TheDataModel................................... 16 1.3.3StartingMnesia.................................... 16 1.3.4CreatingNewTables................................. 19 1.4 TransactionsandOtherAccessContexts.......................... 21 1.4.1TransactionProperties................................ 22 1.4.2Locking........................................ 23 1.4.3DirtyOperations................................... 27 1.4.4RecordNamesversusTableNames......................... 28 1.4.5ActivityConceptandVariousAccessContexts................... 30 1.4.6Nestedtransactions.................................. 32 1.4.7PatternMatching................................... 33 1.4.8Iteration........................................ 35 1.5 MiscellaneousMnesiaFeatures................................ 36 1.5.1Indexing........................................ 37 1.5.2DistributionandFaultTolerance.........................
    [Show full text]
  • Implementing Erlang/OTP on Intel Galileo
    DEGREE PROJECT, IN INFORMATION TECHNOLOGY, FIRST LEVEL STOCKHOLM, SWEDEN 2015-06-22 Implementing Erlang/OTP on Intel Galileo Paul Coada, Erkut Kaya KTH ROYAL INSTITUTE OF TECHNOLOGY INFORMATION AND COMMUNICATION TECHNOLOGY Abstract The Intel Galileo, inspired by the well-known Arduino board, is a development board with many possibilities because of its strength. The Galileo is has an Intel processor capable of running GNU/Linux and can be connected to the internet, which opens up the possibility to be controlled remotely. The programming language that comes with the Intel Galileo is the same as for the Arduino development boards, and is therefore very limited and does not utilize the Galileo’s entire strength. Our aim with this project is to integrate a more suitable programming language; a language that can make better use of the relatively powerful processor to control the components of the board. The programming language of choice is Erlang, and the reason is obvious. Erlang can be described as a process-oriented programming language based on the functional programming paradigm and its power in concurrency. The result of the project was the successful integration of a complete version of GNU/Linux on the board and the cross-compilation of Erlang/OTP onto the board. Having Erlang running on the system opens up many possibilities for future work, amongst all: creating Erlang programs for the Intel Galileo, integrating an effective API, and measuring the pros and cons of using Erlang on an Intel Galileo. Keywords Embedded, Arduino, multiprogramming, concurrency, Internet of Things, cross-compilation, API Sammanfattning Intel Galileo är ett utvecklingskort som bygger på Arduinos succé.
    [Show full text]
  • Erlang – a Platform for Developing Distributed Software Systems
    Erlang – a platform for developing distributed software systems Lars-Ake˚ Fredlund 1 / 55 Problems of distributed systems ■ Distributed programming is hard ■ Challenges for concurrency: ◆ process coordination and communication 2 / 55 Problems of distributed systems ■ Distributed programming is hard ■ Challenges for concurrency: ◆ process coordination and communication ■ And challenges for distributed software: ◆ heterogeneous systems ◆ security, reliability (lack of control) ◆ performance 2 / 55 Distributed Programming Today Todays contrasts: ■ Vision – easy programming of distributed systems ■ The nightmare/reality – Web services, XML, Apache, SOAP, WSDL, . ■ Why are Web services a nightmare? Too many standards, too many tools, too many layers, too complex! ■ Erlang is an Industrially proven solution for developing and maintaining demanding distributed applications ■ Good qualities of Erlang as a distributed systems platform: Complexity encapsulated in a programming language, good performance, efficient data formats, debuggable, not complex 3 / 55 Erlang as a component platform: a summary ■ Processes are the components 4 / 55 Erlang as a component platform: a summary ■ Processes are the components ■ Components (processes) communicate by binary asynchronous message passing 4 / 55 Erlang as a component platform: a summary ■ Processes are the components ■ Components (processes) communicate by binary asynchronous message passing ■ Component communication does not depend on whether components are located in the same node, or physically remote
    [Show full text]
  • The Implementation and Use of a Generic Dataflow Behaviour in Erlang
    The Implementation and Use of a Generic Dataflow Behaviour in Erlang Christopher Meiklejohn Peter Van Roy Basho Technologies, Inc. Universite´ catholique de Louvain Bellevue, WA, United States Louvain-la-Neuve, Belgium [email protected] [email protected] Abstract concurrent programming: developers author code that adheres to a 2 We propose a new “generic” abstraction for Erlang/OTP that aids in specific “behaviour” and these abstractions then provide a com- the implementation of dataflow programming languages and mod- mon way to supervise, manage, and reason about processing con- els on the Erlang VM. This abstraction simplifies the implemen- current messages to a single actor. tation of “processing elements” in dataflow languages by provid- We propose a new Erlang/OTP “generic” abstraction for dataflow ing a simple callback interface in the style of the gen server and programming on the Erlang VM called gen flow. This abstraction gen fsm abstractions. We motivate the use of this new abstraction allows for the arbitrary composition of stateful actors into larger by examining the implementation of a distributed dataflow pro- dataflow computations. This abstraction is sufficiently generic to gramming variant called Lasp. aid in the implementation of an arbitrary dataflow language in Erlang/OTP: we motivate the use of gen flow through the im- Categories and Subject Descriptors D.1.3 [Programming Tech- plementation of a deterministic distributed dataflow variant called niques]: Concurrent Programming; E.1 [Data Structures]: Dis- Lasp. [14, 15] tributed data structures This paper contains the following contributions: Keywords Dataflow Programming, Erlang, Concurrent Program- • gen flow abstraction: We propose gen flow, a new abstrac- ming tion in the style of the “generic” abstractions provided by Er- lang/OTP for building dataflow “processing elements.” 1.
    [Show full text]
  • Making Reliable Distributed Systems in the Presence of Sodware Errors Final Version (With Corrections) — Last Update 20 November 2003
    Making reliable distributed systems in the presence of sodware errors Final version (with corrections) — last update 20 November 2003 Joe Armstrong A Dissertation submitted to the Royal Institute of Technology in partial fulfilment of the requirements for the degree of Doctor of Technology The Royal Institute of Technology Stockholm, Sweden December 2003 Department of Microelectronics and Information Technology ii TRITA–IMIT–LECS AVH 03:09 ISSN 1651–4076 ISRN KTH/IMIT/LECS/AVH-03/09–SE and SICS Dissertation Series 34 ISSN 1101–1335 ISRN SICS–D–34–SE c Joe Armstrong, 2003 Printed by Universitetsservice US-AB 2003 iii To Helen, Thomas and Claire iv Abstract he work described in this thesis is the result of a research program T started in 1981 to find better ways of programming Telecom applica- tions. These applications are large programs which despite careful testing will probably contain many errors when the program is put into service. We assume that such programs do contain errors, and investigate methods for building reliable systems despite such errors. The research has resulted in the development of a new programming language (called Erlang), together with a design methodology, and set of libraries for building robust systems (called OTP). At the time of writing the technology described here is used in a number of major Ericsson, and Nortel products. A number of small companies have also been formed which exploit the technology. The central problem addressed by this thesis is the problem of con- structing reliable systems from programs which may themselves contain errors. Constructing such systems imposes a number of requirements on any programming language that is to be used for the construction.
    [Show full text]
  • The Implementation and Use of a Generic Dataflow Behaviour in Erlang
    The Implementation and Use of a Generic Dataflow Behaviour in Erlang Christopher Meiklejohn Peter Van Roy Basho Technologies, Inc. Universite´ catholique de Louvain Bellevue, WA, United States Louvain-la-Neuve, Belgium [email protected] [email protected] Abstract concurrent programming: developers author code that adheres to a 2 We propose a new “generic” abstraction for Erlang/OTP that aids in specific “behaviour” and these abstractions then provide a com- the implementation of dataflow programming languages and mod- mon way to supervise, manage, and reason about processing con- els on the Erlang VM. This abstraction simplifies the implemen- current messages to a single actor. tation of “processing elements” in dataflow languages by provid- We propose a new Erlang/OTP “generic” abstraction for dataflow ing a simple callback interface in the style of the gen server and programming on the Erlang VM called gen flow. This abstraction gen fsm abstractions. We motivate the use of this new abstraction allows for the arbitrary composition of stateful actors into larger by examining the implementation of a distributed dataflow pro- dataflow computations. This abstraction is sufficiently generic to gramming variant called Lasp. aid in the implementation of an arbitrary dataflow language in Erlang/OTP: we motivate the use of gen flow through the im- Categories and Subject Descriptors D.1.3 [Programming Tech- plementation of a deterministic distributed dataflow variant called niques]: Concurrent Programming; E.1 [Data Structures]: Dis- Lasp. [14, 15] tributed data structures This paper contains the following contributions: Keywords Dataflow Programming, Erlang, Concurrent Program- • gen flow abstraction: We propose gen flow, a new abstrac- ming tion in the style of the “generic” abstractions provided by Er- lang/OTP for building dataflow “processing elements.” 1.
    [Show full text]
  • Getting Started with Erlang
    Getting Started with Erlang version 5.2 Typeset in LATEX from SGML source using the DOCBUILDER 3.2.2 Document System. Contents 1 Getting Started with Erlang 1 1.1 GettingStartedwithErlang................................. 1 1.1.1Introduction...................................... 1 1.1.2WorkingwithErlang................................. 2 1.1.3TheErlangShell................................... 5 1.1.4 Compiling . 13 1.1.5DebuggingwithPman................................ 16 1.1.6DistributedErlang.................................. 18 1.1.7Configuration..................................... 22 List of Figures 23 List of Tables 25 Bibliography 27 Getting Started with Erlang iii iv Getting Started with Erlang Chapter 1 Getting Started with Erlang 1.1 Getting Started with Erlang 1.1.1 Introduction This chapter describes the most common tasks users perform in Erlang/OTP and is intended for readers who are running Erlang/OTP for the first time. It also contains references to more detailed information. This manual assumes that you have another source of information about how the language Erlang works. The first chapter of the book Concurrent Programming in ERLANG,[Concurrent Programming in ERLANG [1]], is available online in PDF1 format. This manual will describe how to ¯ compile and run Erlang programs ¯ work with the Erlang shell, this is the most central part of the development environment ¯ use the basic tools, Debugger and Pman This manual will also describe differences in development environment on the Unix and Windows platforms. Manual conventions The following conventions are used to describe commands, which are entered from the keyboard in the Erlang shell, or on the Emacs command line: window-based ¯ to enter the command C-c: Press the Control key and the letter c simultaneously. C-c is equivalent to ^c.
    [Show full text]
  • Go Big - Scaling Erlang
    Informatix Solutions GO BIG - SCALING ERLANG Richard Croucher Page 1 © - Informatix Solutions, 2014 Version 1.0 Informatix Background and Biases – Richard Croucher Solutions • Platform architect • Chief Architect at Sun Microsystems where I helped create the dotcom deployment standard and designed and deployed a 1024 server cluster • Principle DevOPs Architect at Microsoft for all its Internet properties . Adding 4000 servers a month. Established the dynamic computing working group to create design patterns for Cloud computing • Primary focus over the last decade has been High Frequency Trading systems for Banks - pushing technology to extremes • Involved with several Cloud startups • Code in multiple languages • Transitioned through Assembler, Pascal, C, C++, Java , C# and Erlang • Love new technology and finding novel ways to use existing technologies • Degrees in Physics, Electronics and Materials Science • Elected Fellow of the British Computer Society and Fellow of STAC Research • See www.informatix-sol.com Page 2 © - Informatix Solutions, 2014 Version 1.0 Informatix My Erlang journey Solutions Wow! Erlang is great Page 3 © - Informatix Solutions, 2014 Version 1.0 Informatix My Erlang journey Solutions OTP has all I need Wow! Erlang is great Page 4 © - Informatix Solutions, 2014 Version 1.0 Informatix My Erlang journey Solutions c("tcp-test"). tcp-test.erl:4: bad module declaration Immutable variables take some getting used to OTP has Where’s ‘while’ all I OTP is so hard need Limited atoms Slow maths chatty Wow! OOM Erlang is great Page 5 © - Informatix Solutions, 2014 Version 1.0 Informatix My Erlang journey Solutions c("tcp-test"). tcp-test.erl:4: bad module declaration Immutable variables take some getting used to OTP has Where’s ‘while’ all I OTP is so hard need Limited atoms Slow maths chatty Wow! OOM Erlang is great Page 6 © - Informatix Solutions, 2014 Version 1.0 Informatix My Erlang journey Solutions c("tcp-test").
    [Show full text]
  • Elixir in Action
    SECOND EDITION Saša Juric´ Sample Chapter MANNING Elixir in Action by Saša Jurić Chapter 1 Copyright 2019 Manning Publications brief contents 1 ■ First steps 1 2 ■ Building blocks 16 3 ■ Control flow 63 4 ■ Data abstractions 102 5 ■ Concurrency primitives 129 6 ■ Generic server processes 159 7 ■ Building a concurrent system 179 8 ■ Fault-tolerance basics 201 9 ■ Isolating error effects 224 10 ■ Beyond GenServer 251 11 ■ Working with components 277 12 ■ Building a distributed system 305 13 ■ Running the system 334 v First steps This chapter covers 1 ¡ Overview of Erlang ¡ Benefits of Elixir This is the beginning of your journey into the world of Elixir and Erlang, two effi- cient and useful technologies that can significantly simplify the development of large, scalable systems. Chances are, you’re reading this book to learn about Elixir. But because Elixir is built on top of Erlang and depends heavily on it, you should first learn a bit about what Erlang is and the benefits it offers. So let’s take a brief, high-level look at Erlang. 1.1 About Erlang Erlang is a development platform for building scalable and reliable systems that constantly provide service with little or no downtime. This is a bold statement, but it’s exactly what Erlang was made for. Conceived in the mid-1980s by Ericsson, a Swedish telecom giant, Erlang was driven by the needs of the company’s own tele- com systems, where properties like reliability, responsiveness, scalability, and con- stant availability were imperative. A telephone network should always operate 1 2 CHAPTER 1 First steps regardless of the number of simultaneous calls, unexpected bugs, or hardware and software upgrades taking place.
    [Show full text]
  • Programming Languages for Distributed Applications
    Invited paper for New Generation Computing 1 Programming Languages for Distributed Applications Seif Haridi, Peter Van Roy,† Per Brand,‡ and Christian Schulte§ June 14, 1998 Abstract Much progress has been made in distributed computing in the areas of distribution structure, open computing, fault tolerance, and security. Yet, writing distributed applications remains diffi- cult because the programmer has to manage models of these areas explicitly. A major challenge is to integrate the four models into a coherent development platform. Such a platform should make it possible to cleanly separate an application’s functionality from the other four concerns. Concurrent constraint programming, an evolution of concurrent logic programming, has both the expressiveness and the formal foundation needed to attempt this integration. As a first step, we have designed and built a platform that separates an application’s functionality from its distri- bution structure. We have prototyped several collaborative tools with this platform, including a shared graphic editor whose design is presented in detail. The platform efficiently implements Distributed Oz, which extends the Oz language with constructs to express the distribution struc- ture and with basic primitives for open computing, failure detection and handling, and resource control. Oz appears to the programmer as a concurrent object-oriented language with dataflow synchronization. Oz is based on a higher-order, state-aware, concurrent constraint computation model. 1 Introduction Our society is becoming densely interconnected through computer networks. Transferring informa- tion around the world has become trivial. The Internet, built on top of the TCP/IP protocol family, has doubled in number of hosts every year since 1981, giving more than 20 million in 1997.
    [Show full text]
  • Improving the Scalability of the Erlang Distributed Actor Platform
    P. Trinder, N. Chechina, N. Papaspyrou, K. Sagonas, S. Thompson, et al. • Scaling Reliably • 2017 Scaling Reliably: Improving the Scalability of the Erlang Distributed Actor Platform Phil Trinder,Natalia Chechina,Nikolaos Papaspyrou, Konstantinos Sagonas,Simon Thompson,Stephen Adams,Stavros Aronis, Robert Baker,Eva Bihari,Olivier Boudeville,Francesco Cesarini, Maurizio Di Stefano,Sverker Eriksson,Viktoria Fordos,Amir Ghaffari, Aggelos Giantsios,Rockard Green,Csaba Hoch,David Klaftenegger, Huiqing Li,Kenneth Lundin,Kenneth MacKenzie,Katerina Roukounaki, Yiannis Tsiouris,Kjell Winblad RELEASE EU FP7 STREP (287510) project www.release-project.eu/ April 25, 2017 Abstract Distributed actor languages are an effective means of constructing scalable reliable systems, and the Erlang programming language has a well-established and influential model. While the Erlang model conceptually provides reliable scalability, it has some inherent scalability limits and these force developers to depart from the model at scale. This article establishes the scalability limits of Erlang systems, and reports the work of the EU RELEASE project to improve the scalability and understandability of the Erlang reliable distributed actor model. We systematically study the scalability limits of Erlang, and then address the issues at the virtual machine, language and tool levels. More specifically: (1) We have evolved the Erlang virtual machine so that it can work effectively in large scale single-host multicore and NUMA architectures. We have made important changes and architectural improvements to the widely used Erlang/OTP release. (2) We have designed and implemented Scalable Distributed (SD) Erlang libraries to address language-level scalability issues, and provided and validated a set of semantics for the new language constructs.
    [Show full text]
  • Introducing Concurrent Functional Programming in the Telecommunications Industry
    Introducing Concurrent Functional Programming in the Telecommunications Industry Bjarne Dacker Computer Science Laboratory, Ericsson Utvecklings AB, Box 1505, 12525 Sweden Key words: Functional programming, Concurrent programming, Technology dissemination Abstract: This paper gives an overview of the concurrent functional programming language and its development, dissemination, and use. Erlang was developed at Ericsson and is used for several large and important telecom systems. It is also available externally, both supported and through open source. Erlang provides a highly relevant case-study of technology diffusion since its development touches upon many relevant topics such as applied research in the industrial environment and spread of technology through open source. 1. INTRODUCTION Telecommunications systems place very difficult demands on the underlying programming and computer technology, such as large number of concurrent activities, systems distributed over several computers, large and complex software systems, software maintenance (reconfiguration, etc.) while the system is in operation, fault tolerance to hardware failures and software errors, etc. The concurrent junctional programming language Erlang [3, 5] was developed as a software technology to meet these requirements and to facilitate the design of telecommunications systems. Section 2 gives a short The original version of this chapter was revised: The copyright line was incorrect. This has been corrected. The Erratum to this chapter is available at DOI: 10.1007/978-0-387-35404-0_19 M. A. Ardis et al. (eds.), Diusing Software Product and Process Innovations © IFIP International Federation for Information Processing 2001 242 Bjarne Dacker overview over Erlang and the subsequent sections describe how Erlang was developed and experiences from its spread both inside and outside Ericsson.
    [Show full text]