Concurrent Programming in Erlang

Book cover

J. Armstrong, R. Virding, C. Wikström, M. Williams

2:nd Edition
Prentice Hall, 1996, ISBN 0-13-508301-X

Erlang is a concurrent functional programming language designed for programming large industrial real-time systems. Erlang is dynamically typed and has a pattern matching syntax. Functions are defined using recursion equations. Erlang provides explicit concurrency, has asynchronous message passing and is relatively free from side effects.

Distributed Erlang programs can run transparently on cross-platform multi-vendor systems. The language has primitives for detecting run-time errors and for dynamic code replacement (i.e. changes to code can be made in a running real-time system, without stopping system).

Erlang has real-time GC, modules and a foreign language interface.

Erlang was developed at the Ellemtel Telecommunication Systems Laboratories and is used within Ericsson for product development and prototyping.


Part I. Programming.

Chapter 1   An Erlang Tutorial
	1.1 Sequential Programming
	1.2 Data Types
	1.3 Pattern Matching
	1.4 Built-In Functions
	1.5 Concurrency

Chapter 2   Sequential Programming
	2.1 Terms
	2.2 Pattern Matching
	2.3 Expression Evaluation
	2.4 The Module System
	2.5 Function Definition
	2.6 Primitives
	2.7 Arithmetic Expressions
	2.8 Scope of Variables

Chapter 3   Programming with Lists
	3.1 List Processing BIFs
	3.2 Some Common List Processing Functions
	3.3 Examples
	3.4 Common Patterns of Recursion on Lists
	3.5 Functional Arguments

Chapter 4   Programming with Tuples
	4.1 Tuple Processing BIFs
	4.2 Multiple Return Values
	4.3 Encrypting PIN Codes
	4.4 Dictionaries
	4.5 Unbalanced Binary Trees
	4.6 Balanced Binary Trees

Chapter 5   Concurrent Programming
	5.1 Process Creation
	5.2 Inter-Process Communication
	5.3 Timeouts
	5.4 Registered Processes
	5.5 Client--Server Model
	5.6 Process Scheduling, Real Time and Priorities
	5.7 Process Groups
Basic concurrent programming techniques. Creating and monitoring processes. Sending messages between process. Monitoring processes. The client-server model is introduced. Primitives for real-time programming.
Chapter 6   Distributed Programming
	6.1 Motivation
	6.2 Distributed mechanisms
	6.3 Registered Processes
	6.4 Connections
	6.5 A Banking Example
The language primitives have the same properties in a distributed system as in a single node system.
Chapter 7   Error Handling
	7.1 Catch and Throw
	7.2 Process Termination
	7.3 Linked Processes
	7.4 Run-Time Failure
	7.5 Changing the Default Signal Reception Action
	7.6 Undefined Functions and Unregistered Names
	7.7 Catch versus Trapping Exits
Basic error handling mechanisms. Catch and throw. Detecting process termination.
Chapter 8   Programming Robust Applications
	8.1 Guarding against Bad Data
	8.2 Robust Server Processes
	8.3 Isolating Computations
	8.4 Keeping Processes Alive
	8.5 Discussion
Basic programming techniques for programming fault-tolerant applications.
Chapter 9   Miscellaneous Items
	9.1 Last Call Optimisation
	9.2 References
	9.3 Code Replacement
	9.4 Ports
	9.5 Binaries
	9.6 Process Dictionary
	9.7 The Net Kernel
	9.8 Hashing
	9.8 Efficiency
Changing code in a running system without stopping the system. Interfacing to foreign languages.

Part II. Applications

The applications part of the book is a set of case studies. Here we build on the programming techniques of Part I to construct complete programs. Many of the studies are based on real-world applications.

Chapter 9   Databases
	9.1 The Access Functions
	9.2 Simple Database
	9.3 A Multi-Level Database
	9.4 Transaction Management
	9.5 External Databases
Simple database programs, with transactions, roll-back, fault-tolerance, etc..
Chapter 10    Distributed Programming Techniques
	10.1  Remote Procedure Calls (RPC)
	10.2  Multicalls
	10.3  Broadcasting
	10.4  Global Registration
	10.5  Promises
	10.6  Mulitcasting to Process Groups
	10.7  Negotiation Techniques
	10.8  Adaptive Load Distribution
	10.9  Relay Techniques
	10.10 Parallel Evaluation for Speed 
	10.11 Discussion
RPC, the ability to evaluate a function transparently an a remote node.
Promises, an asyncrounous RPC.

Erlang provides simpler primitives for RPC, global name servers, error detection etc. than many operating systems.


Chapter 11   Distributed Data
	11.1 Shared Data
	11.2 Partial Replication
	11.3 Transactions
Many applications may wish to have some common data structures available for access and modification by several processes on several nodes. This chapter describes various techniques for sharing data between physically separated nodes.

Chapter 12   Operating Systems
	12.1 Overview of the Standard Erlang OS
	12.2 System Startup
	12.3 Code Management
	12.4 The Input/Output System
	12.5 The Standard Shell
An overview of the standard Erlang operating system.

Chapter 13   Real-Time Control
	13.1 A Lift Control System
	13.2 A Satellite Control System
Two real-time (process control) applications.

Chapter 14   Telephony
	14.1 Typical Aspects of Switching System Software
	14.2 POTS
	14.3 Robustness
	14.4 SDL
A telephony application. This is sub-set of a much larger program which used to control an Ericsson PABX in a real-world application.
	
Chapter 15   An ASN.1 Compiler
	15.1 Background
	15.2 About ASN.1
	15.3 BER -- Basic Encoding Rules
	15.4 Implementation
	15.5 ASN.1 Applications
A cross compiler from ASN.1 (The CCITT specified data transport definition language) to Erlang. This again is from a real-world application.
Chapter 16   Graphics
	16.1 The User Interface
	16.2 Basic Graphics Primitives
	16.3 A Pocket Calculator
	16.4 A Prompter
	16.5 A TV Simulation
Building a graphic user interface in Erlang. This shows how Erlang can be interfaced to the X-windows system to build an advanced GUI.
Chapter 17   Object-Oriented Programming
	17.1 Basic Concepts
	17.2 Mapping to Erlang
	17.3 An Object-Oriented Interface
	17.4 Object-Oriented Programming
	17.5 Object-Oriented Design
Discusses the relation between Erlang and Object-Orientated programming.