Programming Erlang: Software for a Concurrent World / Edition 2

Programming Erlang: Software for a Concurrent World / Edition 2

by Joe Armstrong

ISBN-10: 193778553X

ISBN-13: 9781937785536

Pub. Date: 09/22/2013

Publisher: Pragmatic Programmers, LLC, The

A multi-user game, web site, cloud application, or networked database can have thousands of users all interacting at the same time. You need a powerful, industrial-strength tool to handle the really hard problems inherent in parallel, concurrent environments. You need Erlang. In this second edition of the bestselling Programming Erlang, you'll learn how to

…  See more details below


A multi-user game, web site, cloud application, or networked database can have thousands of users all interacting at the same time. You need a powerful, industrial-strength tool to handle the really hard problems inherent in parallel, concurrent environments. You need Erlang. In this second edition of the bestselling Programming Erlang, you'll learn how to write parallel programs that scale effortlessly on multicore systems.

Using Erlang, you'll be surprised at how easy it becomes to deal with parallel problems, and how much faster and more efficiently your programs run. That's because Erlang uses sets of parallel processes-not a single sequential process, as found in most programming languages.

Joe Armstrong, creator of Erlang, introduces this powerful language in small steps, giving you a complete overview of Erlang and how to use it in common scenarios. You'll start with sequential programming, move to parallel programming and handling errors in parallel programs, and learn to work confidently with distributed programming and the standard Erlang/Open Telecom Platform (OTP) frameworks.

You need no previous knowledge of functional or parallel programming. The chapters are packed with hands-on, real-world tutorial examples and insider tips and advice, and finish with exercises for both beginning and advanced users.

The second edition has been extensively rewritten. New to this edition are seven chapters covering the latest Erlang features: maps, the type system and the Dialyzer, WebSockets, programming idioms, and a new stand-alone execution environment. You'll write programs that dynamically detect and correct errors, and that can be upgraded without stopping the system. There's also coverage of rebar (the de facto Erlang build system), and information on how to share and use Erlang projects on github, illustrated with examples from cowboy and bitcask.

Erlang will change your view of the world, and of how you program.

What You Need

The Erlang/OTP system. Download it from

Read More

Product Details

Pragmatic Programmers, LLC, The
Publication date:
Edition description:
Second Edition
Sales rank:
Product dimensions:
7.40(w) x 9.20(h) x 1.30(d)

Table of Contents

Begin     1
Road Map     2
Begin Again     5
Acknowledgments     6
Getting Started     7
Overview     7
Installing Erlang     10
The Code in This Book     12
Starting the Shell     13
Simple Integer Arithmetic     14
Variables     16
Floating-Point Numbers     21
Atoms     22
Tuples     24
Lists     27
Strings     29
Pattern Matching Again     30
Sequential Programming     33
Modules     33
Back to Shopping     39
Functions with the Same Name and Different Arity     42
Funs     42
Simple List Processing     48
List Comprehensions     51
Arithmetic Expressions     54
Guards     55
Records     59
Case and if Expressions     62
Building Lists in Natural Order     63
Accumulators     64
Exceptions     67
Exceptions     67
Raising an Exception     68
Try...catch     69
Catch     72
Improving Error Messages     73
Programming Style with try...catch     73
Catching Every Possible Exception     74
Old- and New-Style Exception Handling     75
Stack Traces     75
Advanced Sequential Programming     77
BIFs     78
Binaries     78
The Bit Syntax     80
Miscellaneous Short Topics     89
Compiling and Running Your Program     109
Starting and Stopping the Erlang Shell     109
Modifying the Development Environment     110
Different Ways to Run Your Program     113
Automating Compilation with Makefiles     118
Command Editing in the Erlang Shell     121
Getting Out of Trouble     122
When Things Go Wrong     122
Getting Help     125
Tweaking the Environment     126
The Crash Dump     127
Concurrency     129
Concurrent Programming     133
The Concurrency Primitives     134
A Simple Example     135
Client-Server-An Introduction     136
How Long Does It Take to Create a Process?     140
Receive with a Timeout     142
Selective Receive     145
Registered Processes     146
How Do We Write a Concurrent Program?     148
A Word About Tail Recursion     148
Spawning with MFAs     149
Problems     150
Errors in Concurrent Programs     151
Linking Processes     151
An on_exit Handler     152
Remote Handling of Errors     154
The Details of Error Handling     154
Error Handling Primitives     162
Sets of Linked Processes     164
Monitors     164
A Keep-Alive Process     165
Distributed Programming     167
The Name Server     169
The Distribution Primitives     174
Libraries for Distributed Programming     177
The Cookie Protection System     178
Socket-Based Distribution     179
IRC Lite     183
Message Sequence Diagrams     185
The User Interface     186
Client-Side Software     187
Server-Side Software     191
Running the Application     195
The Chat Program Source Code     196
Exercises      203
Interfacing Techniques     205
Ports     206
Interfacing an External C Program     207
Open_port     213
Linked-in Drivers     214
Notes     218
Programming with Files     219
Organization of the Libraries     219
The Different Ways of Reading a File     220
The Different Ways of Writing to a File     228
Directory Operations     232
Finding Information About a File     233
Copying and Deleting Files     234
Bits and Pieces     234
A Find Utility     235
Programming with Sockets     239
Using TCP     240
Control Issues     249
Where Did That Connection Come From?     252
Error Handling with Sockets     253
UDP     254
Broadcasting to Multiple Machines     257
A SHOUTcast Server     259
Digging Deeper     266
ETS and DETS: Large Data Storage Mechanisms     267
Basic Operations on Tables     268
Types of Table     269
ETS Table Efficiency Considerations     270
Creating an ETS Table      271
Example Programs with ETS     273
DETS     278
What Haven't We Talked About?     281
Code Listings     282
OTP Introduction     285
The Road to the Generic Server     286
Getting Started with gen_server     295
The gen_server Callback Structure     299
Code and Templates     303
Digging Deeper     306
Mnesia: The Erlang Database     307
Database Queries     307
Adding and Removing Data in the Database     311
Mnesia Transactions     313
Storing Complex Data in Tables     317
Table Types and Location     319
Creating the Initial Database     322
The Table Viewer     323
Digging Deeper     323
Listings     325
Making a System with OTP     329
Generic Event Handling     330
The Error Logger     333
Alarm Management     340
The Application Servers     342
The Supervision Tree     345
Starting the System     348
The Application     352
File System Organization     354
The Application Monitor     355
Digging Deeper     355
How Did We Make That Prime?     357
Multicore Prelude     359
Programming Multicore CPUs     361
How to Make Programs Run Efficiently on a Multicore CPU     362
Parallelizing Sequential Code     366
Small Messages, Big Computations     369
Mapreduce and Indexing Our Disk     373
Growing Into the Future     383
Documenting Out Program     385
Erlang Type Notation     386
Tools That Use Types     389
Erlang on Microsoft Windows     391
Erlang     391
Fetch and Install MinGW     391
Fetch and Install MSYS     392
Install the MSYS Developer Toolkit (Optional)     392
Emacs     392
Resources     395
Online Documentation     395
Books and Theses     396
Link Collections     396
Blogs     396
Forums, Online Communities, and Social Sites     397
Conferences     397
Projects     397
Bibliography     398
A Socket Application     399
An Example      399
How lib_chan Works     402
The lib_chan Code     405
Miscellaneous     415
Analysis and Profiling Tools     415
Debugging     418
Tracing     427
Dynamic Code Loading     431
Module and Function Reference     435
Module: application     435
Module: base64     436
Module: beam_lib     437
Module: c     437
Module: calendar     439
Module: code     440
Module: dets     441
Module: dict     444
Module: digraph     445
Module: digraph_utils     446
Module: disk_log     447
Module: epp     448
Module: erl_eval     449
Module: erl_parse     449
Module: erl_pp     450
Module: erl_scan     450
Module: erl_tar     450
Module: erlang     451
Module: error_handler     460
Module: error_logger     460
Module: ets     461
Module: file     464
Module: file_sorter     466
Module: filelib     467
Module: filename      467
Module: gb_sets     468
Module: gb_trees     470
Module: gen_event     471
Module: gen_fsm     472
Module: gen_sctp     473
Module: gen_server     474
Module: gen_tcp     474
Module: gen_udp     475
Module: global     475
Module: inet     476
Module: init     477
Module: io     477
Module: io_lib     478
Module: lib     479
Module: lists     479
Module: math     483
Module: ms_transform     483
Module: net_adm     483
Module: net_kernel     484
Module: os     484
Module: proc_lib     485
Module: qlc     485
Module: queue     486
Module: random     487
Module: regexp     488
Module: rpc     488
Module: seq_trace     490
Module: sets     490
Module: shell     491
Module: slave     491
Module: sofs     492
Module: string     496
Module: supervisor     497
Module: sys     497
Module: timer     498
Module: win32reg     499
Module: zip     500
Module: zlib     500
Index     503

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >